Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.11.1
-
None
Description
In my QML application I use external font. The font contains several styles, each style in a separate file. All the files are in a resource.
QList<QString> fonts = { "Montserrat-Black.otf", "Montserrat-BlackItalic.otf", "Montserrat-Bold.otf", "Montserrat-BoldItalic.otf", "Montserrat-Medium.otf", "Montserrat-MediumItalic.otf", "Montserrat-Regular.otf", "Montserrat-Italic.otf", "Montserrat-Light.otf", "Montserrat-LightItalic.otf", "Montserrat-Thin.otf", "Montserrat-ThinItalic.otf" }; foreach(const QString &font, fonts) { if(QFontDatabase::addApplicationFont(":/fonts/" + font) == -1) qDebug() << "Error loading font: " + font; }
Font usage:
Button { text: qsTr("Sign In") font.weight: Font.Medium font.family: "Montserrat" } Button { text: qsTr("Sign In") font.pixelSize: 18 font.weight: Font.Normal font.family: "Montserrat" }
The result:
QML just ignores Font.Medium and display it as Font.Normal.
That how it looks in Sketch:
All the fonts are installed in Windows.
If I try to change the font weight in Designer, only Normal and Bold make sense. All other weights are displayed as Normal.
The Montserrat font could be found [here|http://example.com]
Attachments
Issue Links
- is required for
-
QTBUG-74860 Umbrella task for font selection issues
- In Progress
- relates to
-
QTBUG-46043 QFontDatabase makes bad font weight choices for Alright Sans family
- Closed
-
QTBUG-75641 Qml font weight and styleName not working (not rendered correctly)
- Reported
-
QTBUG-74857 Some fonts with weight greater than 870 can't be created using DirectWrite font engine
- Reported