[Development] System-wide font preferences for monospace font

Jan Kundrát jkt at flaska.net
Thu May 9 14:09:36 CEST 2013


Hi,
it looks like Qt tries to respect the font settings of the underlying platform in many situations, but there's unfortunately no way (AFAIK) to get the user's preference for a monospace font. My use case is to fit well into the user's desktop when showing and writing plaintext e-mails.

I've dug through the Qt's sources and it appears that Qt4 contains some code for parsing the KDE's options (src/gui/kernel/qapplication_x11.cpp). It will read the "font" settings, but not the "fixed" settings. Furthermore, it looks like there's no support for various types of default fonts.

In Qt5, the situation looks a bit better, the qtbase:gui/kernel/qplatformtheme.h contains QPlatformTheme::Font enum with support for multiple fonts to be used in the application menus, labels etc. Unfortunately, the support for a "fixed font" is not there. and in addition to that, this feature does not appear to be visible to the user code as it's a private header.

I've added rather basic support for parsing the settings of KDE ($KDEHOME/share/config/kdeglobals) and Gnome (`gconftool-2 --get /desktop/gnome/interface/monospace_font_name`) font preferences in my application [1]. I think that this might be useful for other users of Qt as well, so I'd like to make it a part of Qt5. I've got a couple questions:

- Do you think this is worth it?
- How shall the user-facing API look like?
- Is the approach taken by my code reasonable (calling `gconftool-2` etc) from the Qt's perspective?
- This is for the dev branch, right?

With kind regards,
Jan

[1] http://quickgit.kde.org/?p=trojita.git&a=blobdiff&h=51a4e5c19de01a953d657b275beb52ce5f06c7b2&hp=d800a4976b690a64673e8dd4227ab3903b7b3cb1&hb=d97e9ac219837133203491bd860e3432cccd62e0&f=src%2FGui%2FUtil.cpp

-- 
Trojitá, a fast Qt IMAP e-mail client -- http://trojita.flaska.net/



More information about the Development mailing list