getting QML to report on font used
-
Hi all -
I've been struggling with a font that I'm using through the resource system. I'm not getting any runtime errors, but my various attempts to use the font aren't showing up. Is there some QML magic that will allow me to report on the font being used, through the console.log() facility or something?
Thanks...
-
@mzimmers said in getting QML to report on font used:
I've been struggling with a font that I'm using through the resource system. I'm not getting any runtime errors, but my various attempts to use the font aren't showing up.
Can you please describe your various attempts?
Is there some QML magic that will allow me to report on the font being used, through the console.log() facility or something?
Something like this:
ApplicationWindow { id: window visible: true // ... Component.onCompleted: console.log(window.font) }
-
@JKSH said in getting QML to report on font used:
Component.onCompleted: console.log(window.font)
That's going to be helpful going forward; thanks.
To answer your question, I've:
- created a resource file and populated it with the fonts I want
- added the resource file to my CMakeLists.txt (which also includes:
set(CMAKE_AUTORCC ON)
- put this code in the QML file I'm trying to manipulate:
font.family: "Rubik" font.pixelSize: 24 font.weight: Font.Bold
I think I'm getting the font loaded, based on your telltale suggestion:
qml: QFont(Rubik,-1,24,5,700,0,0,0,0,0,0,0,0,0,0,1)
But my Font.Bold isn't "taking."
EDIT:
I also have this code in my main.qml:
FontLoader { id: rubikItalic source: "qrc:/fonts/Rubik/Rubik-Italic-VariableFont_wght.ttf" } FontLoader { id: rubik source: "qrc:/fonts/Rubik/Rubik-VariableFont_wght.ttf" }
In addition to the two variable .ttf files in this font, there are a number of static fonts, but for now I'm assuming that I don't need to load those.