I am writing an app for which the client has provided a custom font. The font comes as four separate otf
files, one for regular, bold, italic and bold-italic. If I want to use only one of these four fonts in my class, I create the FontLoader
like so:
FontLoader { id: clientFontRegular; source: "qrc:/client/fonts/Font-Regular.otf" }
and then I can use it for any control on my page like so:
font.family: clientFontRegular.name
My problem is that I have multiple controls on my page, and I want to use regular for some, bold for some, italics for some others etc. To do this I've added FontLoader
objects for the other fonts as well, like so:
FontLoader { id: clientFontBold; source: "qrc:/client/fonts/Font-Bold.otf" }
FontLoader { id: clientFontItalic; source: "qrc:/client/fonts/Font-Italic.otf" }
FontLoader { id: clientFontBoldItalic; source: "qrc:/client/fonts/Font-BoldItalic.otf" }
But this does not work correctly. All four ids (clientFontRegular, clientFontBold, clientFontItalic and clientFontBoldItalic) can be used anywhere in the page (i.e. without crashing or ending up using the system font), but the font used no matter what is the bold font.
I know that all four of my otf
files are valid, because if I comment out all but the FontLoader for one file and use only that one, the custom font is rendered correctly. There just seems to be a problem with attempting to define multiple FontLoaders in one class (none of the FontLoader samples I've seen online use more than a single custom font).
Anybody know how to do this?