[Fontconfig] How to block glyph fallback in a QT application?
rs at mytum.de
Sun Jan 19 08:35:54 PST 2014
in case this is still of some concern to you, I have now had the
opportunity to try this with Qt 5.2.0:
Janusz S. Bien wrote:
> Quote/Cytat - "Janusz S. Bien" <jsbien at mimuw.edu.pl> (Mon 06 Jan 2014
> 04:58:44 PM CET):
>>> Gucharmap has an option to turn off fallback, and so does Pango, but for
>>> a Qt application you will need a Qt solution.
> For archive, I've found
> "QFont::NoFontMerging 0x8000 If the font selected for a certain
> writing system does not contain a character requested to draw, then Qt
> automatically chooses a similar looking font that contains the
> character. The NoFontMerging flag disables this feature. Please note
> that enabling this flag will not prevent Qt from automatically picking a
> suitable font when the selected font does not support the writing system
> of the text."
> "Add style strategy to QFont to turn off automatic font resolution
> The QFont::NoFontMerging flag turns off font merging within a single
> script item, but still allows automatically picking different fonts for
> each script item if the currently selected font does not support the
> script in question."
> I would appreciate very much your comments to the quoted passages: what
> is the meaning of "script" or "writing system" in this context? How the
If I understand  correctly, Qt splits every piece of text according
to its QFontDatabase::WritingSystem  value. This behavior cannot be
changed with QFont::NoFontMerging. Only the behavior later in the
rendering chain (if the selected font misses a glyph despite it being in
the correct "writing system") can be changed.
However, what I've found is that I cannot even reproduce the example in
, i. e. QTBUG-1732, although its follow-up bug (QTBUG-9816) is still
marked as "unresolved".
When I try this code:
QFont fn("DejaVu Sans");
str += testChar;
...Qt shows an empty box instead of \u3042 despite the character very
likely not being in any writing system supported by DejaVu Sans.
Only if I remove the call to setStyleStrategy from the code above, Qt
performs glyph fallback and renders the character with a fallback font.
Maybe something got changed in the implementation inbetween -- after all
there's this other bug that Akira dug up a couple of weeks ago which
suggested that the merging behavior was broken for some time in Qt 4.8
? Or it's a platform issue, and Qt behaves differently for
Anyway. Qt's "charactermap" example (in
qtbase/examples/widgets/widgets/charactermap/) seems to use
So I suppose that could work in the end.
Worringer Str 31 Duesseldorf 40211 DE home: <rs at mytum.de>
+49-179-2981632 icq 16845346 work: <rs at interface-ag.de>
More information about the Fontconfig