Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
4.7.4, 5.0.0
-
None
Description
In the attached .qml, the 3rd state "source" attempts to change the FontLoader to use a url located font. Click anywhere to advance through the states.
- The first method, expected to read the source and change the name based on the loaded font, fails. (QML FontLoader: Cannot load font: "")
- The second method, setting the font name, succeeds - but when switching back to using name it fails. (QML FontLoader: Cannot load font: ""). It will succeed every time after this first failure.
- The third method, setting name: undefined, fails the first time (the font shows for a short moment) but succeeds every time after that.
There seems to be some weak behaviour in FontLoader determining what should be displayed.
// import QtQuick 2.0 Item { id: fontloaderelementtest height: 640; width: 360 property string testtext: "" property int statenum: 1 property int currentfont: 0 property variant availablefonts Component.onCompleted: { availablefonts = Qt.fontFamilies(); } Rectangle { anchors.fill: textitem; color: "lightsteelblue"; radius: 5 } FontLoader { id: fontloaderelement; name: availablefonts[currentfont] onStatusChanged: { console.log("State: ",statenum,"\nStatus: ",status,"\nFontname: ",name,"\nFontsource: ",source,"\nUsing font: ",availablefonts[currentfont]); switch(status) { case FontLoader.Null: loaderstatus.text = "Null"; break; case FontLoader.Ready: loaderstatus.text = "Ready"; break; case FontLoader.Loading: loaderstatus.text = "Loading"; break; case FontLoader.Error: loaderstatus.text = "Error"; break; default: loaderstatus.text = "No idea"; break; } } } Text { id: textitem; text: fontloaderelement.name; font: fontloaderelement.name horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter; height: 100; width: 250; anchors.centerIn: parent; } Text { id: loaderstatus; text: ""; font: fontloaderelement.name horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter; height: 50; width: parent.width; anchors.top: textitem.bottom; } MouseArea { anchors.fill: parent; onClicked: { advance(); } } states: [ // Use the first available font State { name: "start"; when: statenum == 1 }, // Use the second available font State { name: "changefont"; when: statenum == 2 PropertyChanges { target: fontloaderelementtest; currentfont: 1 } }, // Use a locally stored font State { name: "source"; when: statenum == 3 PropertyChanges { target: fontloaderelement; source: "NeonLights.ttf" } // 1. Don't change name property //PropertyChanges { target: fontloaderelement; source: "NeonLights.ttf"; name: "Neon Lights" } // 2. Changed within state, should reset //PropertyChanges { target: fontloaderelement; name: undefined; source: "NeonLights.ttf" } // 3. Unset name } ] function advance() { statenum = statenum == states.length ? 1 : statenum+1; } }
Attachments
Issue Links
- resulted in
-
QTBUG-65870 Make FontLoader's name property read-only in Qt 6
- Closed