Qt for embedded: 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.

  • Lifetime Qt Champion


    How exactly are you adding that font ?

    Did you deploy the needed fonts on your target ?

  • I added this line in my code:

    I added the fonts in /usr/lib/fonts and /usr/share/fonts.
    I'm working on Qt 4.8

  • Lifetime Qt Champion

    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.

  • @J.Hilk I'm not on android platform, rather on TI am335x-evm-, but I'm not sure about any issues between the two? If anyone can detail more on this, it would be helpful.

  • 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??

  • Lifetime Qt Champion

    What do you mean by "set the font manually" ?

    How would your application support multiple languages ?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.