Skip to main content
moredatalesscenter
Associate III
November 9, 2020
Question

Some unicode characters are not displayed correctly

  • November 9, 2020
  • 6 replies
  • 4396 views

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.

This topic has been closed for replies.

6 replies

Michael K
Senior III
November 9, 2020

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).

Embedded UI/UX Consulting: cadenza.design
moredatalesscenter
Associate III
November 9, 2020

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.

moredatalesscenter
Associate III
November 17, 2020

Any other suggestions to try please @Martin KJELDSEN​ ?

Martin KJELDSEN
Principal III
November 19, 2020

​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

moredatalesscenter
Associate III
November 19, 2020

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
Principal III
November 19, 2020

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