Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Not displaying Chinese characters
Forum Updated to NodeBB v4.3 + New Features

Not displaying Chinese characters

Scheduled Pinned Locked Moved Solved Mobile and Embedded
19 Posts 3 Posters 6.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vdevadass
    wrote on last edited by A Former User
    #1

    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.

    J.HilkJ 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      How exactly are you adding that font ?

      Did you deploy the needed fonts on your target ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vdevadass
        wrote on last edited by vdevadass
        #3

        I added this line in my code:
        QFontDatabase::addApplicationFont("NanumGothic");

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

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Did you check that it succeeded it ?

          addApplicationFont takes a file path as parameter not just a font name.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          V 1 Reply Last reply
          0
          • V vdevadass

            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.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

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


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            V 1 Reply Last reply
            0
            • SGaistS SGaist

              Did you check that it succeeded it ?

              addApplicationFont takes a file path as parameter not just a font name.

              V Offline
              V Offline
              vdevadass
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • J.HilkJ J.Hilk

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

                V Offline
                V Offline
                vdevadass
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vdevadass
                  wrote on last edited by
                  #8

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

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

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

                    How would your application support multiple languages ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vdevadass
                      wrote on last edited by vdevadass
                      #10

                      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)

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        Did you check the return values of your font setup code ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        0
                        • V Offline
                          V Offline
                          vdevadass
                          wrote on last edited by
                          #12

                          The application chooses DejaVuSans.

                          1 Reply Last reply
                          0
                          • SGaistS Offline
                            SGaistS Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            Hence my question, did you check the return value of addApplicationFont ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0
                            • V Offline
                              V Offline
                              vdevadass
                              wrote on last edited by
                              #14

                              The return of addApplicationFont() is 0 for /usr/lib/fonts/NanumGothic.ttf

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                And how are you selecting and setting that font in your application ?

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0
                                • V Offline
                                  V Offline
                                  vdevadass
                                  wrote on last edited by
                                  #16

                                  QFont font("/usr/lib/fonts/NanumGothic.ttf");
                                  font.setPointSize(FONT_SIZE);
                                  font.setBold(true);
                                  QApplication::setFont(font);

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    QFont doesn't have any constructor that takes a file path.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    2
                                    • V Offline
                                      V Offline
                                      vdevadass
                                      wrote on last edited by
                                      #18

                                      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

                                      1 Reply Last reply
                                      0
                                      • V Offline
                                        V Offline
                                        vdevadass
                                        wrote on last edited by
                                        #19

                                        Update, it seems that the fontconfig was choosing NanumBrush and NanumPen over NanumGothic, hence i was unable to see the Chinese characters previously.

                                        1 Reply Last reply
                                        1

                                        • Login

                                        • Login or register to search.
                                        • First post
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • Users
                                        • Groups
                                        • Search
                                        • Get Qt Extensions
                                        • Unsolved