Chinese Fonts on the Raspberry Pi 3



  • I just finished my Chinese translations (not knowing if the translations are any good :D). My work PC now succesfully translates a sentence send by an arduino :D

    But I am also cross-compiling for a Raspberry Pi 3 which is my 'target device'. But the Raspberry only shows me [] [] [] [] [] [] -_-"

    The line of code which prints the characters is:

    monitors[index1]->model()->setData(monitors[index1]->model()->index(row[index1],column[index1]++),QChar(UTF)); // UTF holds a correct value
    

    if UTF is 32 for instance, I get a ' ' printed. But no chinese or thai :(

    I suppose I need to copy a font file from ubuntu 16.04 running host PC to Raspbian running Rpi 3. But I do not know which file in which folder needs to go to which folder on the Pi.

    I'll post this on the raspberry forum as well


  • Moderators

    @bask185 said in Chinese Fonts on the Raspberry Pi 3:

    32

    32 is still ASCII and means space.
    What font are you using on RPi?



  • I know that 32 is ascii and means space, that is why I used it as an example ;)

    I dug up on old E-mail and:
    /usr/share/fonts/truetype/dejavu

    these are the folders/font file of the RPI

    pi@raspberrypi:/usr/share/fonts/truetype/dejavu $ ls
    DejaVuSans-Bold.ttf                  DejaVuSansMono-Oblique.ttf
    DejaVuSans-BoldOblique.ttf           DejaVuSansMono.ttf
    DejaVuSans-ExtraLight.ttf            DejaVuSerif-Bold.ttf
    DejaVuSans-Oblique.ttf               DejaVuSerif-BoldItalic.ttf
    DejaVuSans.ttf                       DejaVuSerif-Italic.ttf
    DejaVuSansCondensed-Bold.ttf         DejaVuSerif.ttf
    DejaVuSansCondensed-BoldOblique.ttf  DejaVuSerifCondensed-Bold.ttf
    DejaVuSansCondensed-Oblique.ttf      DejaVuSerifCondensed-BoldItalic.ttf
    DejaVuSansCondensed.ttf              DejaVuSerifCondensed-Italic.ttf
    DejaVuSansMono-Bold.ttf              DejaVuSerifCondensed.ttf
    DejaVuSansMono-BoldOblique.ttf
    

    I


  • Moderators

    @bask185 You need to check whether any of these fonts support Chinese



  • My Ubuntu machine on which I cross-compile makes use of the ubuntu-font-family. So I copied that entire folder to the raspberry. And I changed a line in .bashrc to "export QT_QPA_FONDIR=/usr/share/fonts/truetype/ubuntu-font-family" (was dejavu before)

    I doubt that the export line does anything at all, I outcommented it, but there seems to be no difference.

    I don't how the cross-compiled executable picks which font. If I can somehow change a setting that it picks a font of my choise.......

    I asked the people from www.qtrpi.com if they can help me out, but I have not yet received an answer.


  • Moderators

    @bask185 I wouldn't copy the fonts from Ubuntu. You can check what font Raspbian uses and eventually install another one. What window manager or desktop environment do you use on RPi?



  • I use the PIXEL desktop which comes with Raspbian. However the app also works if I boot to the CLI without launching pixel.

    As far as I know the window manager is not working with my application, when I open a new window in the app there are no border lines and no - and x on top.

    I also do not know to check to see what font Raspian uses, or what the application is using. However, I have been figuring out that 'find' command and I went looking in the Qt5 folder on Rpi

    pi@raspberrypi:~/opt/qt5 $ find | grep .ttf
    ./qtdeclarative/tests/auto/quick/qquickfontloader_static/data/font.ttf
    ./qtdeclarative/tests/auto/quick/qquickfontloader/data/daniel.ttf
    ./qtdeclarative/tests/auto/quick/qquickfontloader/data/tarzeau_ocr_a.ttf
    ./qtdeclarative/tests/auto/quick/qquickfontloader/data/dummy.ttf
    ./qtdeclarative/tests/auto/qmltest/fontloader/tarzeau_ocr_a.ttf
    ./qtdeclarative/tests/auto/qmltest/fontloader/dummy.ttf
    ./qtdeclarative/tests/testapplications/elements/content/font/Vera.ttf
    ./qtdeclarative/examples/quick/text/fonts/content/fonts/tarzeau_ocr_a.ttf
    ./qtwebengine/src/3rdparty/chromium/ui/keyboard/resources/roboto_bold.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/gardiner_mod/GardinerModCat.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/gardiner_mod/GardinerModBug.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/skia/resources/fonts/Roboto2-Regular_NoEmbed.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/skia/resources/fonts/Em.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/skia/resources/fonts/Funkster.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/skia/resources/fonts/ReallyBigA.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/skia/resources/fonts/HangingS.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/skia/resources/fonts/Distortable.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/skia/resources/fonts/SpiderSymbol.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/webrtc/examples/objc/AppRTCDemo/ios/resources/Roboto-Regular.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/e207635780b42f898d58654b65098763e340f5c7.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/fcdcffbdf1c4c97c05308d7600e4c283eb47dbca.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/270b89df543a7e48e206a2d830c0e10e5265c630.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/3511ff5c1647150595846ac414c595cccac34f18.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/f22416c692720a7d46fadf4af99f4c9e094f00b9.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/37033cc5cf37bb223d7355153016b6ccece93b28.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/1c04a16f32a39c26c851b7fc014d2e8d298ba2b8.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/1a6f1687b7a221f9f2c834b0b360d3c8463b6daf.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/49c9f7485c1392fa09a1b801bc2ffea79275f22e.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/f518eb6f6b5eec2946c9fbbbde44e45d46f5e2ac.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/813c2f8e5512187fd982417a7fb4286728e6f4a8.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/375d6ae32a3cbe52fbf81a4e5777e3377675d5a3.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/1c2fb74c1b2aa173262734c1f616148f1648cfd6.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/757ebd573617a24aa9dfbf0b885c54875c6fe06b.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/8454d22037f892e76614e1645d066689a0200e61.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/a34a7b00f22ffb5fd7eef6933b81c7e71bc2cdfb.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/f499fbc23865022234775c43503bba2e63978fe1.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/43979b90b2dd929723cf4fe1715990bcb9c9a56b.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/a919b33197965846f21074b24e30250d67277bce.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/5a5daf5eb5a4db77a2baa3ad9c7a6ed6e0655fa8.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/ffa0f5d2d9025486d8469d8b1fdd983e7632499b.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/fbb6c84c9e1fe0c39e152fbe845e51fd81f6748e.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/0509e80afb379d16560e9e47bdd7d888bebdebc6.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/ef86fe710cfea877bbe0dbb6946a1f88d0661031.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/7ef276fc886ea502a03b9b0e5c8b547d5dc2b61c.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/07f054357ff8638bac3711b422a1e31180bba863.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/b9e2aaa0d75fcef6971ec3a96d806ba4a6b31fe2.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/d629e7fedc0b350222d7987345fe61613fa3929a.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/cc5f3d2d717fb6bd4dfae1c16d48a2cb8e12233b.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/051d92f8bc6ff724511b296c27623f824de256e9.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/7e14e7883ed152baa158b80e207b66114c823a8b.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/1c2c3fc37b2d4c3cb2ef726c6cdaaabd4b7f3eb9.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/706c5d7b625f207bc0d874c67237aad6f1e9cd6f.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/bb9473d2403488714043bcfb946c9f78b86ad627.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/a98e908e2ed21b22228ea59ebcc0f05034c86f2e.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/57a9d9f83020155cbb1d2be1f43d82388cbecc88.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/45855bc8d46332b39c4ab9e2ee1a26b1f896da6b.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/4cce528e99f600ed9c25a2b69e32eb94a03b4ae8.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/205edd09bd3d141cc9580f650109556cc28b22cb.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/fab39d60d758cb586db5a504f218442cd1395725.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/43ef465752be9af900745f72fe29cb853a1401a5.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/df768b9c257e0c9c35786c47cae15c46571d56be.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/641bd9db850193064d17575053ae2bf8ec149ddc.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/5028afb650b1bb718ed2131e872fbcce57828fff.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/8a9fea2a7384f2116e5b84a9b31f83be7850ce21.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/c4e48b0886ef460f532fb49f00047ec92c432ec0.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/226bc2deab3846f1a682085f70c67d0421014144.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/8099955657a54e9ee38a6ba1d6f950ce58e3cc25.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/298c9e1d955f10f6f72c6915c3c6ff9bf9695cec.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/191826b9643e3f124d865d617ae609db6a2ce203.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/6466d38c62e73a39202435a4f73bf5d6acbb73c0.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/8240789f6d12d4cfc4b5e8e6f246c3701bcf861f.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/6ff0fbead4462d9f229167b4e6839eceb8465058.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/bb0c53752e85c3d28973ebc913287b8987d3dfe8.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/7a37dc4d5bf018456aea291cee06daf004c0221c.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/harfbuzz-ng/fuzz/seed_corpus/56cfd0e18d07f41c38e9598545a6d369127fc6f9.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/sfntly/src/cpp/data/ext/Tuffy.ttf
    ./qtwebengine/src/3rdparty/chromium/third_party/sfntly/src/cpp/data/ext/AnonymousPro-Regular.ttf
    ./qtwebengine/src/3rdparty/chromium/tools/page_cycler/acid3/acid3.acidtests.org/font.ttf
    ./qtwebengine/src/3rdparty/chromium/chrome/app/theme/Roboto-Regular.ttf
    ./qtwebengine/src/3rdparty/chromium/chrome/app/theme/Roboto-Thin.ttf
    ./qtwebengine/src/3rdparty/chromium/chrome/app/theme/Roboto-Light.ttf
    ./qtwebengine/src/3rdparty/chromium/chrome/app/theme/Roboto-Medium.ttf
    ./qtwebengine/src/3rdparty/chromium/chrome/app/theme/Roboto-Bold.ttf
    ./qtwebengine/src/3rdparty/chromium/testing/libfuzzer/fuzzers/convert_woff2ttf_fuzzer.cc
    ./qtquickcontrols/src/extras/Styles/Flat/fonts/OpenSans-Semibold.ttf
    ./qtquickcontrols/src/extras/Styles/Flat/fonts/OpenSans-Light.ttf
    ./qtquickcontrols/src/extras/Styles/Flat/fonts/OpenSans-Regular.ttf
    ./qtquickcontrols/src/dialogs/qml/icons.ttf
    ./qtquickcontrols/examples/quickcontrols/extras/gallery/fonts/OpenSans-Regular.ttf
    ./qtquickcontrols/examples/quickcontrols/extras/dashboard/fonts/DejaVuSans.ttf
    ./qtquickcontrols2/examples/quickcontrols2/texteditor/fonts/fontello.ttf
    ./qtbase/tests/auto/gui/text/qrawfont/testfont_bold_italic.ttf
    ./qtbase/tests/auto/gui/text/qrawfont/testfont_os2_v1.ttf
    ./qtbase/tests/auto/gui/text/qfontmetrics/ucs4font.ttf
    ./qtbase/tests/auto/shared/resources/testfont_condensed.ttf
    ./qtbase/tests/auto/shared/resources/test.ttf
    ./qtbase/tests/auto/shared/resources/testfont.ttf
    ./qtbase/doc/global/template/style/icomoon.ttf
    

  • Moderators

    @bask185 Do you have this problem when running your app in PIXEL?



  • @jsulm said in Chinese Fonts on the Raspberry Pi 3:

    @bask185 Do you have this problem when running your app in PIXEL?

    Yes, and because of some slowness bug I have to boot to Pixel. When I boot to the CLI the app runs significantly slower for some reason.


  • Moderators

    @bask185 I guess if you boot to CLI you get framebuffer device without any hardware acceleration. In this case it is not a bug.



  • @jsulm That the cause of something might have a perfectly clear reason, does not mean that something isn't a bug persé. That slow running bug was one helluva annoying bug to me, whatever the reason may be.

    But how does this help me teach the Raspberry speak Chinese?


  • Moderators

    @bask185 said in Chinese Fonts on the Raspberry Pi 3:

    But how does this help me teach the Raspberry speak Chinese?

    It does not, I just wanted to say that framebuffer devices do not have hardware acceleration and this can be the reason for slow UI.



  • Well I narrowed down the folder out of which the application picks it's fonts. If I leave 1 font, she will pick that one. So I could modify the font in the application.

    /usr/local/qt5pi/lib/fonts
    

    I vaguely remembered I once had no texts at all, so I dug up some e-mails and I remembered I had to manually copy paste fonts into the folder. What I however don't know is how the app picks one of them. I know it does not pick the first on the list.

    www.qtrpi.com's FAQ had a step with which I had to add an export line to .basrc. I think that that line was supposed to copy ttf files to that folder. But that did not work for me.

    I already downloaded a chinese font, but now everything were squares.

    I now only have to find and copy a complete .ttf file in that folder, that ought to teach this Raspberry some Chinese...



  • Well I finally have me some Chinese characters, it was indeed copying a suitable .ttf to the fonts folder. I still dont have Thai though :D

    I just found a website with which you can open .ttf files so you can look for your unicodes/characters. I only wish I would have thought of this earlier.. like before I solved the file. I still don't know if Qt can work with 2 or more different font files.... all the plain text is kinda ugly now :D
    CharMap


  • Qt Champions 2016

    @bask185
    Hi
    Qt can use any font installed on the system.
    You can even use custom fonts not installed with
    QFontDatabase::addApplicationFont("qrc:///resources/Triforce.ttf");
    https://forum.qt.io/topic/57772/using-custom-fonts



  • Yeah I came across the QFontDatabase in my 'Quest' for the solution. But not long after, I knew which folder my app was using for fonts. At that point I only had to find a decent Chinese and Thai font.

    For me it does not really matter whether the app picks a font out of the resource folder or the "/usr/local/qt5pi/lib/" fonts folder. Well that is not true, it does matter because now I do not have to learn how QFontDatabase works and produce (redundant) lines of code :P + if I want to add a new .ttf, I merely have to download and move the file to the folder. If I would use the resource folder instead I would also have to add a line of code in the app to include that font.

    My project is almost done now. So I will update my report and clone the Pi's SD card. My superior was impressed ;)


  • Qt Champions 2016

    @bask185

    -. My superior was impressed ;)

    Super :)



  • @bask185 You may like Google Noto fonts https://www.google.com/get/noto/.


Log in to reply
 

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