Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
5.15.10
-
None
Description
Supporting a Qt-based project, I ran into a problem with font calls where code with explicit font names was being utilized on different platforms. Not all platforms have the same fonts installed and errors/warnings were returned.
Also, QFontDatabase::systemFont(QFontDatabase::FixedFont) on a platform with bad Qt configuration may result in an erroneous font being returned. (Note, I found a handful of QTBUG reports describing similar situation).
Unfortunately, the web is littered with works-for-me code. Finding a robust code solution to identify any fixed pitch font was quite difficult. Each offered solution involved using a string literal to identify the family, include the font as an app resource, or be dependent on Qt configuration.
My web searches lead me to the Character Map Example. Playing with that code, I was struck by the elegance of the QFontCombo control. It seemed that an easy solution for programmatically finding a fixed font already existed within the sources for this control.
Unfortunately, the filtering mechanism employed by QFontCombo relies on static functions declared only in qfontcombo.cpp and not exposed by qfontcombo.h (see qfontcombo.cpp:19 - writingSystemFromScript and qfontcombo.cpp:89 - writingSystemFromLocale).
Feature request is to move some of the font information/support mechanisms in the QFontCombo into QFontDatabase. For example, determining the current QFontDatabase::writingsystem from a user's locale should be an extension of font handling rather than a GUI control function.