project fonts not being used
Unsolved
QML and Qt Quick
-
Hi all -
I'm trying to use some custom fonts for my UI. Here are the fonts in project view:
and my code for enabling a couple of them:FontLoader { id: rubikSemiBold source: "qrc:/fonts/Rubik/static/Rubik-SemiBold.ttf" onStatusChanged: if (rubikSemiBold.status == FontLoader.Ready) console.log('Loaded') } FontLoader { id: rubikItalic source: "qrc:/fonts/Rubik/static/Rubik-Italic.ttf" } ... NavSymbol { id: homeIcon iconFile: "qrc:/icons/Home.png" labelText: "Home" fontFam: rubikItalic.name } ... // my Navsymbol.qml file RowLayout { id: navSymbol property string iconFile: "qrc:/icons/blank.png" property string labelText: "to be replaced" property string fontFam: "unknown" Image { source: navSymbol.iconFile } Label { text: navSymbol.labelText font { family: fontFam pixelSize: navSymbol.fontSize } }
I'm not getting a runtime error, but the fonts aren't being used. Can someone see what I'm doing wrong?
Thanks...
-
@Markkyboy I don't have a qml.qrc file. The file the fonts are in is "resources.qrc:"
<RCC> <qresource prefix="/"> <file>fonts/Rubik/static/Rubik-Black.ttf</file> <file>fonts/Rubik/static/Rubik-BlackItalic.ttf</file> <file>fonts/Rubik/static/Rubik-Bold.ttf</file> <file>fonts/Rubik/static/Rubik-BoldItalic.ttf</file> <file>fonts/Rubik/static/Rubik-ExtraBold.ttf</file> <file>fonts/Rubik/static/Rubik-ExtraBoldItalic.ttf</file> <file>fonts/Rubik/static/Rubik-Italic.ttf</file> <file>fonts/Rubik/static/Rubik-Light.ttf</file> <file>fonts/Rubik/static/Rubik-LightItalic.ttf</file> <file>fonts/Rubik/static/Rubik-Medium.ttf</file> <file>fonts/Rubik/static/Rubik-MediumItalic.ttf</file> <file>fonts/Rubik/static/Rubik-Regular.ttf</file> <file>fonts/Rubik/static/Rubik-SemiBold.ttf</file> <file>fonts/Rubik/static/Rubik-SemiBoldItalic.ttf</file> </qresource> </RCC>
which is in CMakeLists.txt:
qt_add_executable( appnga_demo main.cpp icons.qrc resources.qrc ...
The FontLoader seems to be finding the fonts (I tried substituting a nonsense name, and got an error, but I get no error with the "good" names). Somehow, they're just not being used.