[Interest] Selecting a font on Windows and Linux/Android using QtQuick

Cornelius Hald hald at icandy.de
Tue Nov 5 10:48:30 CET 2013


Hi,

in my QQuick 2.0 application I'm using some custom fonts that I load
using QFontDatabase::addApplicationFont().

The thing is that the same font file gets different font family names on
Windows and on Linux/Android. For example the font "Futura Cond Medium"
gets the following names:

Windows: "FuturaConMed"
Linux/Android: "Futura Cond"

So in my QML code I'm currently doing something like this:

Text {
  fontSize: 20
  font.family: backend.isLinux ? "Futura Cond" : "FuturaConMed"
}

Is there a better way to handle that? Shouldn't the font family be the
same across platforms?

Also it seems that there are differences with regards to different
styles of the same font family. If I load font files with "Futura Cond
Medium" and "Futura Cond Extra Bold" I get the following:

Windows: "FuturaConMed" and "FuturaConExtBol"
Linux/Android: Only "Futura Cond"

So my code to workaround looks like this:

Text {
  fontSize: 20
  font.family: backend.isLinux ? "Futura Cond" : "FuturaConExtBol"
  font.weight: backend.isLinux ? Font.Black : Font.Normal
}

What do you guys think? Did I miss something? Should this be reported as
a bug or is there a good reason for this behavior?

Thanks!
Conny





More information about the Interest mailing list