cancel
Showing results for 
Search instead for 
Did you mean: 

Some unicode characters are not displayed correctly

I am using font Noto Sans Regular which contains glyphs for omega and subscript 2. My wildcard range is set to: a-z,A-Z,0-9,0x0040,0x00B0,0x00B2,0x03a9,0x2082. However the characters are displayed incorrectly:-

Unicode::strncpy(Buffer, "\u03A9", 10); // displays as O not Omega

Unicode::strncpy(Buffer, "\u2082", 10); // displays as 2 not subscript 2

Other unicode characters are displayed correctly:-

Unicode::strncpy(Buffer, "\u00B0", 10); // displays correctly as °

Unicode::strncpy(Buffer, "\u00B2", 10); // displays correctly as superscript 2

I noticed Designer generated file Font_NotoSans_Regular_14_1bpp_4.cpp, containing characters 0x2082, 0x2082, which I have included in the build.

6 REPLIES 6
Michael K
Senior III

I don't think Wildcard Range is the correct place to specify these characters. Try Wildcard Characters, and try pasting in the actual character (rather than typing out the hex).

Hi Michael, this was worse pasting the actual character in the wildcard characters instead. In the examples above, only superscript 2 was displayed correctly, degree mark became question mark, omega became O, subscript 2 became just 2.

I tried with different font (Calibri) which also includes all four of these characters, with the same result.

Any other suggestions to try please @Martin KJELDSEN​ ?

Martin KJELDSEN
Chief III

​I helped some guy on StackOverflow once with this (sub/superscripts) - See if there's anything you can use.

https://stackoverflow.com/questions/58874343/issues-with-subsript-superscript-characters-touchgfx

Thanks Martin and Michael.

It seems the problem related to defining the unicode characters inline in a string for the buffer using Unicode::strncpy(), e.g. Unicode::strncpy(Buffer, "\u03A9", 10) and using wildcard ranges or wildcard characters.

Using a unicode character array using Unicode::snprintf() and wildcard ranges as per the SO article worked fine.

As my text is just selecting some existing typed text, I've settled with changing the buffer using Unicode::snprintf(Buffer, 10, "%s", touchgfx::TypedText(T_SINGLEUSEIDxxx).getText()) similar to the generated base class constructor, as this works with different languages and is DRY. This works using wildcard characters pasting the actual character (rather than hex in wildcard range as I had started with).

Martin KJELDSEN
Chief III

Just make sure you're actually generating the glyphs by specifying them as specific unicodes or through ranges in the designer. Check your "generated" folder to see if the glyphs you need are actually available to TouchGFX.

e.g. generated/fonts/src/Font_verdana_10_4bpp_0.cpp