Search code examples
qtfontsmultilingualqtembedded

How to (properly) output multilingual text in Qt-Embedded?


My target system is:

  • linux 3.3.7,
  • Qt Embedded (open source edition) 4.8,
  • Droid fonts (taken from fonts-droid_20111207+git-1_all.deb Debian package and copied into /usr/lib/fonts directory),
  • Linux Framebuffer for main Qt GUI application,
  • everything is build by Buildroot package.

My test application is very simple: just one dialog box with a few static QLabel on it (one for Chinese, one for Arabic, one for Cyrillic, etc).

When I run it on my linux desktop, all labels are shown correctly. But when it runs on my target system some text disappears.

After some research, I'd found this difference in the behavior of Qt framework: QFontDatabase class reports that there is only 4 Droid font families on my desktop system:

Droid Sans [unknown]
Droid Sans [monotype]
Droid Sans Mono
Droid Serif

But the same QFontDatabase class reports that there are lots of separated font families on my target system:

Droid Arabic Naskh
Droid Sans
Droid Sans Armenian
Droid Sans Ethiopic
Droid Sans Fallback
Droid Sans Georgian
Droid Sans Hebrew
Droid Sans Japanese
Droid Sans Mono
Droid Sans Thai
Droid Serif

As the result, if I change "default" font family for my application (via -fn command line option or manually via calling setFont() inside my application) some text labels are shown but other are not (for example, when I use "Droid Sans Hebrew" font family, Korean text is missing but Hebrew/Arabic are ok).

So, my questions are: what is proper way to output multilingual text in a Qt Embedded application? Why did the "Droid Sans" family become separated? Is there any way to combine them together?

Thanks.


Solution

  • Well, looks like the solution is found at last.

    There is a bug in Qt Embedded Rendering Engine: for some reasons it uses "QPF2" Font Engine (QFontEngineQPF) for rendering text in "broken" scripts (Hebrew/Arabic/Thai/Korean in my case).

    To avoid/fix this issue, just need to run an application with QWS_NO_SHARE_FONTS=1 environment variable (and with -fn "Droid Sans" command line parameter as well).

    After that all text in all languages is displayed without any issue.