[Interest] QML and application fonts

Rutledge Shawn Shawn.Rutledge at theqtcompany.com
Mon Nov 10 09:02:24 CET 2014


On 10 Nov 2014, at 08:30, Harri Pasanen <harri at mpaja.com> wrote:

> Hi,
> 
> I've been playing with the font support in Qt.
> In C++ I'm able to define and select a custom application font with 
> font.setFamily("MyCoolFont"),
> but on the QML side something like
> 
> Text {
>     anchors.centerIn: parent
>     text: "Test font"
>     font.family: "MyCoolFont"
> }
> 
> seemingly does nothing.
> 
> Am I missing something, or is this just not implemented yet?

Yes it should work, as long as that’s an OS installed font.  If it isn’t installed, then you might want to use a FontLoader:

http://qt-project.org/doc/qt-5/qml-qtquick-fontloader.html

But if it works in C++ but not in QML, there might be a bug, so tell us more about what system you are using, and how and where the font is installed.

You can also try qtdeclarative/examples/quick/text/fonts/availableFonts.qml to see samples of all installed fonts, and see if the one you want is in the list.


More information about the Interest mailing list