[Qt-interest] QFont - Sans Serif and Monospace for all Plattforms

suzuki toshiya mpsuzuki at hiroshima-u.ac.jp
Wed Oct 12 09:29:46 CEST 2011


Hi,

Till Oliver Knoll wrote:
> 
> Am 12.10.2011 um 04:38 schrieb suzuki toshiya <mpsuzuki at hiroshima-u.ac.jp>:
> 
>> Hi Till,
>>
>> Thank you for clarification that "Monospace" for GNU/Linux is
>> not the family (it's a predefined alias of fontconfig, so
>> it is unavailable if Qt is configured not to use fontconfig).
> 
> Just to make sure: I actually didn't want to imply that setting "Monospace" as a font family was wrong on Linux only (forgive my sloppy drop of the GNU prefix here ;) It is "wrong" anywhere - from a Qt API point of view!
> 
> All I was repeating (Atlant mentioned it first) is that you're supposed to pass the enum value QFont::Monospace to setStyleHint.
> 
> But oops, I just noticed the Qt docs saying: "Qt does not support style hints on X11 since this information is not provided by the window system."

Yes. Nothing to say, the conventional (maybe some people call as
legacy) X11 core font protocol can get a list of fonts including
a keyword "fixed" or "sans serif" in their logical names, but if
one executes "xlsfonts | fgrep 'serif'", he will find that most
fonts lack these keywords. I think, except of the assumed resolution,
point size, and charset/encoding, X11 core font logical names are
not reliable source to check the font properties.

The case in fontconfig would be similar, it can list the fonts with
specified charset, specified weight, but it cannot list the fonts
with specified serif/sans serif, fixed/proportional pitch. Maybe it
would be related with the reason why fontconfig has a predefined alias
names like "Serif", "Sans Serif" and "Monospace".

> [Sorry for the HTML here]
> 
> So off course you can also try to set "monospace" as *family*, but that really depends then on the underlying font matching algorithm and also how the fonts are setup on a given system. Not to mention your need to also choose in addition between sans-/serif. That is definitelly not supported by the Qt API ( the docs make no mention about doing something like Monospace | Serif, for instance).
> 
> So the safest bet would probably be to ship the desired font with your application and make the Qt font system aware of the additional font path, or have the user configure the proper font of her choice in some config dialog.

Oops :-)

Regards,
mpsuzuki



More information about the Qt-interest-old mailing list