cancel
Showing results for 
Search instead for 
Did you mean: 

in touchgfx how to display chinese character with Wildcard and totally pure code

Jix
Associate II

I would like to ask for advice on how to modify text wildcards generated by pure code that cannot be displayed in Chinese. English is displayed normally.

My personal feeling is that the font does not support Chinese, but I don't know where to set it in pure code

{B(2[I~3(TMMLS(HO5N60$I.png

S]V{_(WN(1~38TRW_)@O8DH.png

TB0%O(EN42%C`L`EX2NY5XE.png

T~YZ9OPW@TJ[1M`08P8FMFV.png

J5}MZX}~~ML}I}Y~MJSQB2T.png

1 ACCEPTED SOLUTION

Accepted Solutions

Thank u for your advice. It  works. However, I plan to implement a combination display of Chinese and dynamic numbers in a TextAreaWithOneWildcard , like“第%d组”,But it seems that there is no such function, and I can only continuously convert values to adapt to the sprint function in C language, but it still shows failure 

 

View solution in original post

9 REPLIES 9
Osman SOYKURT
ST Employee

Hello @Jix ,

You'll necessarily need a font that supports Chinese characters like this one for example. Then in your Typography menu, you have to include the wildcard range like such: 0x4E00-0x9FFF

Also, you can't use the Chinese letters in your code directly without converting it into Unicode because your C++ code is encoded in UTF-8.
So if you want to make a text by pure code, you have to do something like this :

 

void Screen1View::fillText()
{
    const uint8_t* Mystring = (const uint8_t*)"鉴于对人类家庭所";
    Unicode::fromUTF8(Mystring, textArea1Buffer, TEXTAREA1_SIZE);
    textArea1.invalidate();
}

 


Let me know if you succeed in making it.

Osman SOYKURT
ST Software Developer | TouchGFX

Thank u for your advice. It  works. However, I plan to implement a combination display of Chinese and dynamic numbers in a TextAreaWithOneWildcard , like“第%d组”,But it seems that there is no such function, and I can only continuously convert values to adapt to the sprint function in C language, but it still shows failure 

 

Jix_0-1699502369874.png

Jix_1-1699502379006.png

By converting a char type string to const uint8_ t*  and function of  Unicode:: from UTF8 (); I succeeded!  the red characters in touchgfx design are the result  which are corresponding the code  sprintf(id_temp,"第%d组",2);

 

You're welcome 🙂

Osman SOYKURT
ST Software Developer | TouchGFX
ferro
Senior II

Hi,

I use u"" approach:

 

 

static constexpr char16_t const * const UnicodeRussian = u"цупыйц";
static constexpr char16_t const * const UnicodeChinese = u"本中 您将";
static constexpr char16_t const * const UnicodeArabic  = u"بطضغفحلظت";

 

ferro_0-1699893765076.png

 Now, all strings are Unicode and can be used with cast:

 

 

reinterpret_cast<touchgfx::Unicode::UnicodeChar const *>( UnicodeChinese )

 

 

ferro_0-1699892982647.png

 

"you have to include the wildcard range like such: 0x4E00-0x9FFF"

This is very helpful, thanks @Osman SOYKURT . I do not think I saw it mentioned anywhere in GFX documentation.

Ferro

Thank you for your help. By the way, do you know how to achieve button shake cancellation in touchgfx ? When I operate buttons on the LCD touch screen, I often experience repeated triggering situations . Obviously, a simple delay function does not work. And for ordinary buttons, it seems that there is no function to detect bouncing, but rather abstractbutton classes have this function.

Hello @Jix ,

I don't understand what you mean by button shake cancelation. Could you give an example?

Osman SOYKURT
ST Software Developer | TouchGFX

Such as a toggle button , usually, I flip once with just one click, but it doesn't seem to detect any bouncing functions - only the abstract button seems to be able to monitor bouncing. However, in practical operation, when I press a button on the touch screen and keep my hand pressed, the button will continue to be repeatedly clicked