QML FontLoader not working

c++, fonts, qml, qt

Solution

I've had headaches with Qt/QML's font handling. Fonts with "various sub styles" seem to be the fundamental problem. When I absolutely needed to get at one particular problem font style in Qt, creating a custom version with fontforge of the font where the wanted style was renamed "normal" seemed to work.

Problem

I'm trying to use QML's built-in FontLoader element to load a custom font for our application without success. I've tried using both OTF and TTF fonts with identical results. The fonts are in the same directory as the project files. There is only one QML, the main one where this FontLoader lives. This is what it should look like: Here is my code: ``` import QtQuick 2.0 Rectangle { width: 360 height: 360 FontLoader { id: cFontLoader source: "./fontlol.ttf" } Text { id: testText anchors.centerIn: parent text: "Hello Fonts!" font.family: cFontLoader.name font.pointSize: 32 } } ```

Original source