How to set text dynamically in unreal engine - c++

I would like to set text and 2d images dynamically in Unreal Engine maybe using a placeholder like a Billboard Blueprint then using the Set Text Blueprint.
I am getting json from an external source -- amazon product information -- then want to update the UI Billboard with this json result which includes text and links to image files.
Does anyone know how to achieve this.

Create the string:
FString TestHUDString = FString(TEXT("Buy this crap!"));
FStrings can be set/modified during runtime just like you want it from a std::string
TestHUDString = "buy this other crap....";
And (for example) write it to the "screen":
Canvas->DrawText(BigFont, TestHUDString, 110.0f,110.0f);
You man need to convert your data to a c string or UTF-8 if you have Problems.
Theres also text components of objects if you want to create "in world" billboards for example.
Here the official documentation about using FStrings:
https://docs.unrealengine.com/latest/INT/Programming/UnrealArchitecture/StringHandling/FString/
This should help assuming that you know how to deserialize the json - wich is a different topic imho.

Related

Windows API To Access Font Tables (Kern, GPOS, etc)

Currently Apple provides functions to access data in font tables, like CTFontCopyTable. I'm using it to parse information (kerning, etc) out of a font when available. Is there any similar way of pulling the same data on Windows per font?
I can see a lot of documentation on the windows side when it comes to these font tables, but I can't seem to find a way to pull this data per font.
Here is how I'm pulling the data in osx:
CTFontRef lCTFont = CTFontCreateWithName((CFStringRef)lNSFontName, 800.0f, NULL);
CFDataRef lKernTable = CTFontCopyTable(lCTFont, kCTFontTableKern, kCTFontTableOptionNoOptions);
CFDataRef lGPOSTable = CTFontCopyTable(lCTFont, kCTFontTableGPOS, kCTFontTableOptionNoOptions);
GetFontData will get the raw table data, but as other suggestions advise, you will probably want to use the system-provided text layout methods rather than trying to roll your own.
You can use GetKerningPairs to get kerning data and GetCharacterPlacement to get GPOS data.
If your real intent is to simply render some text correctly though, you might want to use Uniscribe instead.

Automatic Advanced styling for QGIS

I have a PostGIS database containing roads, waterbodies. POI, parks, etc that I have styled in QGIS following the very useful posts: Guide to Advanced Labeling for OSM Roads and “Google Maps”-Style Road Maps in QGIS of Anita Grasser.
I'm a python programmer and I would like to recreate these styles automatically not by hand, is it possible? Could anyone show me any example?
Thank you very much in advance!
In QGIS You can get labeling in command line choose layer and type
layer = iface.activeLayer()
layer.labelling()
You will get instance of QgsAbstractVectorLayerLabeling
https://qgis.org/pyqgis/master/core/Abstract/QgsAbstractVectorLayerLabeling.html?highlight=qgsabstractvectorlayerlabeling
To go to symbol You need type
layer = iface.activeLayer()
layer.renderer()
You will get class QgsFeatureRenderer https://qgis.org/pyqgis/master/core/Feature/QgsFeatureRenderer.html?highlight=qgsfeaturerenderer#qgis.core.QgsFeatureRenderer.symbols
You can also set renderer by
renderer = QgsFeatureRenderer()
layer.setRenderer(renderer)

Grabbing Text from Sublime Text Regions

I'm new to creating Sublime Text 3 Plugins and I'm trying to understand the Plugin API that's offered. I want to be able to "grab" text I highlight with my mouse and move it somewhere else. Is there a way I can do this using the Sublime Text Plugin API?
So far, all I've done is be able to create a whole region:
allcontent = sublime.Region(0, self.view.size())
I've tried to grab all of the text in the region and put it into a lot file:
logfile = open("logfile.txt", "w")
logfile.write(allcontent)
But unsuccessfully of course as the log file is blank after it runs.
I've looked over google and there is not a lot of documentation, except for the unofficial documentation, in which I can't find a way to grab the text. Nor are there many tutorials on this.
Any help is greatly appreciated!
A Region just represents a region of text (i.e. from position 0 to position 10), and isn't tied to any specific view.
To get the underlying text from the view's buffer, you need to call the view.substr method with the region as a parameter.
import os
logpath = os.path.join(sublime.cache_path(), 'logfile.txt')
allcontent = self.view.substr(sublime.Region(0, self.view.size()))
with open(logpath, 'w') as logfile:
logfile.write(allcontent)
print('written buffer contents to', logpath)
To get the region represented by the first selection, you can use self.view.sel()[0] in place of sublime.Region(0, self.view.size()).

How to set color of text on Card object

How to set color to the card object?
There is some information about which are the support html tags, however i don´t know how to use it.
Card m_InstructionCard new Card(this);
String texto = getString(R.string.instruction_card_text);
m_InstructionCard.setText(Html.fromHtml(texto));
m_InstructionCard.setTimestamp(R.string.instruction_card_info);
m_InstructionCard.addImage(R.drawable.second_capture);
The function setText don´t support spanned.
Should I use style? There is some example of how do it?
As i can´t use card with resource xml, i don´t know how to do it.
The Card.setText method currently only supports unstyled Strings. Please file an enhancement request on our issue tracker if you would like to see other features.

How to load qt linguist dynamically changed label text

In my project i'm trying to use qt linguist. When i change the language from English to Turkish, it is working all constant label.
But some labels i m loading them dynamically according to scenario of use cases.
Whatever i do with qt linguist, it doest workthe texts of these label.
How can i get rid of this problem?
Any help will be apprecialted
Qt has a guide to internationalization, which includes the basic information: to wrap your string in a tr function call.
label->setText( tr( "Hello, World!" ) );
In addition to this, if you want the language to change on the fly, you'll need to identify when the context has changed, and update your labels appropriately. Unfortunately, I can't easily put my hands on the signal that indicates when to do so.