2019-07-12 03:15 AM
When I run this code:
void Screen1View::startSession()
{
Unicode::fromUTF8((const uint8_t*) "Hello world!!", longTxtBuffer, LONGTXT_SIZE);
longTxt.invalidate();
}
it works as expected.
However, when I change it to:
void Screen1View::startSession()
{
Unicode::fromUTF8((const uint8_t*) "Hello World!!", longTxtBuffer, LONGTXT_SIZE);
longTxt.invalidate();
}
I'm seeing a ? instead of W in both simulator and target.
Is this a bug?
2019-07-12 04:16 AM
Hi Antoine,
I seems that you have pasted the same code snippet twice.
When TouchGFX displays a "?" instead of the desired character it is usually because the glyph for that unicode is not within the wildcard characters/ranges.
You can add these characters in the Designer under Texts -> Topographies
Regards
2019-07-12 04:23 AM
I modified the title of the post to "TextAreaWithWildcard displaying "?" now that we know what the issue is about. I hope you don't mind, @AMege.
/Martin
2019-07-16 08:44 AM
Hi Martin,
"I seems that you have pasted the same code snippet twice."
No, I did not, notice the capital W?
Thanks for your answer, I have now a better understanding how TouchGFX works with text and fonts and I have resolved the issue.
Next issue is how to have support for newlines in a text box...
2019-07-17 12:52 AM
Hi @AMege
Ah, yes I see, didn't catch that the first time i read it.
The text area where you have a wildcard which contains newlines, you need to remove the check "Auto-size" in the Designer and then expand the size of the text area.
Adding new lines are done as usual with \n
Unicode::fromUTF8((const uint8_t*) "Hello World!!\nNew line", textArea2Buffer, TEXTAREA2_SIZE);
textArea2.invalidate();
Running the application will yields "New line" written on a new line for a wildcard text (BTW, pressing F3 creates a screenshot of the simulator)
Here is a bit more documentation on how texts works in TouchGFX:
https://touchgfx.zendesk.com/hc/en-us/articles/207015345-Using-texts-and-fonts
/Anders
2019-07-18 08:52 AM
Removing Auto-size seemed a bit counter intuitive, but yes, that worked. Thanks!
2019-07-18 11:38 PM
That's because the "auto-size" calculation is done before the code is generated -> The Designer calculates the size of the text input and then sets up the high and width of the text widget.
The wildcard rendering is done at run time, and thus the needed size of the text widget is unknown.
/Anders
2019-08-05 05:43 AM
Yeah, it's a bit counter intuitive because for wildcards the width will be 0 if there's no initial value in the buffer and you have to resize it manually after manually updating the buffer.