font weights don't seem to change
Unsolved
QML and Qt Quick
-
Hi all -
This code:
Column { Text { font.family: 'roboto' font.pixelSize: 24 font.weight: Font.Normal text: "this is an example of roboto with Font.Normal." } Text { font.family: 'roboto' font.pixelSize: 24 font.weight: Font.Medium text: "this is an example of roboto with Font.Medium." } Text { font.family: 'roboto' font.pixelSize: 24 font.weight: Font.DemiBold text: "this is an example of roboto with Font.DemiBold." } Text { font.family: 'roboto' font.pixelSize: 24 font.weight: Font.Bold text: "this is an example of roboto with Font.Bold." } }
Produces this:
Only two weights seem to be visible. Any ideas what's going wrong?
Thanks...
5.14.2, BTW.
-
Seems to be relevant to available fonts and what they support. No idea how this is determined.
Column { id: fontcolumn anchors.right: parent.right //property string fontFam: 'roboto' property string fontFam: "Helvetica" Text { font.family: parent.fontFam font.pixelSize: 24 font.weight: Font.Normal text: "this is an example of roboto with Font.Normal." } Text { font.family: parent.fontFam font.pixelSize: 24 font.weight: Font.Medium text: "this is an example of roboto with Font.Medium." } Text { font.family: parent.fontFam font.pixelSize: 24 font.weight: Font.DemiBold text: "this is an example of roboto with Font.DemiBold." } Text { font.family: parent.fontFam font.pixelSize: 24 font.weight: Font.Bold text: "this is an example of roboto with Font.Bold." } } ListView { anchors.top: fontcolumn.bottom anchors.bottom: parent.bottom anchors.right: parent.right width: 200 model: Qt.fontFamilies() delegate: Item { height: 40; width: ListView.view.width Text { text: modelData; MouseArea { anchors.fill: parent onClicked: { fontcolumn.fontFam = modelData } } } } }
You will need to re-anchor these Items to see this correctly. It gives you a list of available fonts and selects them when you click on the font name in the list.
-
I suspect if you provided ttf font it might work better. No idea if the system fonts are ttf. Also, adding fonts in Windows is a pain as you have to install them I suppose you could hide a font in a qrc resource. But Windows does weird things with fonts I don't completely understand.