Skip to main content
Associate II
November 7, 2023
Solved

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

  • November 7, 2023
  • 9 replies
  • 6395 views

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

This topic has been closed for replies.
Best answer by Jix

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 

 

9 replies

Osman SOYKURT
ST Technical Moderator
November 7, 2023

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.

ST Software Developer | TouchGFX
JixAuthorBest answer
Associate II
November 9, 2023

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 

 

Osman SOYKURT
ST Technical Moderator
November 13, 2023

You're welcome :)

ST Software Developer | TouchGFX
ferro
Lead
November 13, 2023

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