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

Till Oliver Knoll till.oliver.knoll at gmail.com
Wed Oct 12 09:10:43 CEST 2011



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."

[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.

Cheers, Oliver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20111012/cf3dff75/attachment.html 


More information about the Qt-interest-old mailing list