qt qml chinese/russian fonts not working

1.7k views Asked by At

Im working on a QT/QML (4.7.4) application for a device which is running X11. Running on a linux desktop the chinese and russian fonts work fine, but when On the device it does not.

From all the researching and investigation Ive done Im not sure if this is a QML FontLoader issue or I should be fixing the X11 fonts?

Ive spent a couple days working on fc-cache and xset +fp and associated commands with no luck. Ive also tried using QFontDatabase::addApplicationFont() with no luck.

If I should be using FontLoader, do I have to tell every text item in the entire app when the font is different (when the user switched languages?) That could be a big task. I would rather fix this via X11 if possible.

If the answer is in X11, I need some help. I copied all the fonts from the Qt distro onto the device and ran the following commands (as well as added the chinese font for now since I just need to see one of them work to know I have a solution):

(This may not be complete as its been a couple days)

1. go into the directory that I copied the Qt fonts to and:
   A. mkfontscale .
   B. mkfontdir .
2. sudo xset +fp "/dir/to/qt/fonts/dir"
3. sudo xset fp rehash
4. xset q  (shows whats set)
5. sudo fc-cache -fv
6. export FC_DEBUG=1024  (shows debug info when app starting app or fc-list)

In my Qt application, I have:

int ret = fonts.addApplicationFont("/opt/project/lib/fonts/wqy-zenhei.ttc");
if (ret == -1)
   qDebug() << "ERROR - font didnt load";

I do not see the ERROR msg, so my font apparently is loaded correctly.

When I run my application, I do not see the font in the list (via both FC_DEBUG and fc-list).

Id appreciate any insight/help on resolving this issue. Thanks

1

There are 1 answers

0
theB On

Turns out I was doing things correctly as stated above. My qml was using the chinese (and other) fonts directly in the source code, but the other qml files were being translated. Once I select the language (we have a selection qml panel on startup), the fonts are there. Now I just have to solve the inital fonts not showing up.