Not displaying Chinese characters
-
Hi,
I'm currently working on dynamic translation on runtime using qm files. It works for English, French and Arabic, but for Chinese, the application doesn't not set any text, instead displays empty space.
I tried adding the NanumGothic using QFontDatabase::addApplicationFont(), in the code, but was unsuccessful.
Also in which specific folder where the application looks for fonts, by default?
NOTE: Qt is not installed on the embedded system, only libraries have been added to the embedded system.
-
Hi,
How exactly are you adding that font ?
Did you deploy the needed fonts on your target ?
-
Did you check that it succeeded it ?
addApplicationFont
takes a file path as parameter not just a font name. -
@vdevadass I run into something similar recently.
Any and all Hanzi/Kanji could not be displayed anymore.The reason was the following. The Qt version used was 5.7 and the OS was android 7 those 2 aparently dont mix well.
So I recompiled the project with 5.9 and the problem was fixed.
As you're using Qt 4 I would think this might be a possible culprit.
-
i gave the ttf file path, it did not work.
QFontDatabase::addApplicationFont( "/usr/lib/fonts/NanumGothic.ttf" );Is that file path relative to the exe or the qt libraries' location?
I should mention that Qt is not installed on the embedded device, only added libraries.
-
Hi
Update: if i set the font manually, i can see chinese but if i add it using addApplicationFont(), Qt does not pick it up. I want the application to support mulitple language in different font families automatically, any way to do this? And does this have something to do with fontconfig?? -
What do you mean by "set the font manually" ?
How would your application support multiple languages ?
-
Hi, sorry for the late reply.
i set NanumGothic as default font using setFont(). Hence, I think maybe my embedded qt doesnt know NanumGothic is present.i have another question, i copied the ttf files to the embedded devices, is that the proper way or is there way to install the font in the embedded device? ( i don't know what installing a font means, i saw it across the web, if you can explain it would be helpful)
-
Did you check the return values of your font setup code ?
-
Hence my question, did you check the return value of
addApplicationFont
? -
And how are you selecting and setting that font in your application ?
-
QFont doesn't have any constructor that takes a file path.
-
Hi,
The chinese characters are being displayed on the target, but i didn't change my code, this has me stumped, unable to figure out why it is being displayed out of the blue?!
Anyway thank you SGaist for all your help :) I will close this thread for now