Silex
Silex

Reputation: 2713

How to display Chinese characters on Linux embedded devices Qt

I have a software running on an embedded Linux written in Qt/QML. I am using a font family, let's call it SomeFontFamily.otf. This font family doesn't support Chinese characters, therefore when I want to display a Chinese text I am getting empty squares instead. If I run the same software on my desktop Linux I get the same result with Chinese text, but if I add a .font directory in my home folder with a font family that supports Chinese then it displays the characters. So I thought I can do the same on the embedded device and added a .font folder in my home directory with the right font, but unfortunately it didn't work. Then I have found this doc about Qt fonts on embedded devices. It says that I should put my font under lib/fonts directory because Qt will search there for it on embedded devices. I tried it, but unfortunately with no success. Anybody had a similar issue? Just for the record this is not translation related. I just want to be able to display Chinese characters in an english text.

Upvotes: 0

Views: 2576

Answers (3)

Silex
Silex

Reputation: 2713

My final solution was actually creating a wrapper class for QFont and adding QFont::insertSubstitution(...) in the constructor for my set font. Then expose it to QML and use it as a default font. It works like a charm.

As a side note: if you have bundled your fonts with a resource file (.qrc) you have to add those fonts with QFontDatabase::addApplicationFont.

Upvotes: 0

mohabouje
mohabouje

Reputation: 4050

I have fixed the problem with Arabic language by using my own FontConfig. You have to enable it using FontConfig & Font Qt Embedded

Upvotes: 1

nim
nim

Reputation: 2441

Embedded QT versions often lack features, disabled by people who want to cut on dependencies without checking what the dependencies are there for in the first place.

To get font substitution to work you need a build with fontconfig enabled. To get complex text support (anything that exercises more than latin glyphs) you need harfbuzz, the newer version (harfbuzz-ng) the better.

Upvotes: 2

Related Questions