[Development] Question to fonts and styles
René J.V. Bertin
rjvbertin at gmail.com
Sat May 9 13:57:08 CEST 2015
On Saturday May 09 2015 13:26:49 Martin Koller wrote:
> I got a question from a kolourpaint user (KDE painting program) why he can not see
> the same fonts he finds in e.g. libreoffice.
I'm afraid the answer is that Qt's handling of not-so-common font styles and weights is incomplete, not to say flaky. This is especially noticeable with Qt 4.x on OS X, but I'm glad to see I'm not the only one who's noticed it on Linux too.
The code is evolving, though. I've been working on a patch to improve things, and it's been getting smaller from Qt 4.8.7 to 5.4 to 5.5 .
I'm not claiming that this patch will bring Qt on par with GTk though. The fundamental approach feels flawed to me, and I fear the code will always be trying to catch up with fonts no one ever thought of checking.
I cannot affirm that the situation is actually that much better with GTk, but it seems safe to say that given its heritage (the GIMP Toolkit...), flaky font handling was never acceptable.
> /usr/share/fonts/truetype/DejaVuSans-ExtraLight.ttf: DejaVu Sans,DejaVu Sans Light:style=ExtraLight
> /usr/share/fonts/truetype/DejaVuSansCondensed.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
> but in a QFontComboBox I only get "DejaVu Sans" and also "DejaVu Sans Mono", but I do not get
> the two above "DejaVu Sans Light" and "DejaVu Sans Condensed" both of which libreoffice shows.
> (This happens with Qt4.8.6 and with Qt5.4.1)
> Is this because the two mentioned above are just "styles" of "DejaVu Sans" ?
> Intersting is that fc-list also lists "DejaVu Sans Condensed" as family name, e.g.
> family: "DejaVu Sans"(s) "DejaVu Sans Condensed"(s)
> familylang: "en"(s) "en"(s)
> style: "Condensed"(s) "Book"(s)
> stylelang: "en"(s) "en"(s)
> fullname: "DejaVu Sans Condensed"(s)
> Shouldn't Qt list all fonts as different fonts which are listed with a unique family name ?
This actually depends on what's in the font files. Typically, Condensed/Narrow and Mono/Typewriter are a different (variant) family that can have as many weights/styles (bold, italic/slanted/oblique, medium/demibold/semibold, book/light, thin, black, heavy, etc) as the normal family. That is because the outlines are considered different, not just the result of a transformation. It's clearer with the Mono variant of course. But ultimately it depends on how this information is stored in the font files that you have installed. I'm sure everyone has seen cases where even the bold and italic weight/styles show up as different fonts ... and that is actually how foundries and font experts think of typefaces. The whole grouping into families, styles and weights is a convenience feature.
More information about the Development