Loading custom fonts on iOS
-
wrote on 20 Dec 2013, 12:01 last edited by
Thank you very much! I will give it a try.
hint: if you want to use custom .plist file you can place one in your project directory and add following line to your .pro file
QMAKE_INFO_PLIST = MyApp.plist
Cheers
-
wrote on 2 Jan 2014, 22:42 last edited by
Hope it is going to be implemented in Qt 5.2.1;-)
-
wrote on 7 Jan 2014, 06:47 last edited by
Yeah, would be great :)
...but for now solution given by dbrian works like a charm, thanks for that.
P.S. i haven't used resource file, just plain ttf and it worked without using font loader, i've just listed all available font families by
@
QFontDatabase db;
foreach (const QString &family, db.families()) {
qDebug() << family;
}
@...and picked my custom font's family name
Cheers
-
wrote on 7 Jan 2014, 08:16 last edited by
Will give it a try in the evening
-
wrote on 8 Jan 2014, 02:15 last edited by
Tried it.
In the .pro file I added:
@
ios: {
fonts.files = ../../src/qml/fonts/SourceCodePro-Regular.ttf
fonts.path = .fonts
QMAKE_BUNDLE_DATA += fonts
}
@On the iOS device or simulator QFontDatabase db.families() contains an entry "Source Code Pro" and the .ttf file got copied to the corresponding application sandbox sub directory .fonts
But the console logs as you described
@
This plugin does not support application fonts
qrc:///qml/main.qml:12:5: QML FontLoader: Cannot load font: "qrc:///qml/fonts/SourceCodePro-Regular.ttf"
@main.qml lists
@
FontLoader { id: sourceCodeProFont; source: "fonts/SourceCodePro-Regular.ttf" }
@main.qml has been launched via qrc
@
view->setSource(QUrl("qrc:///qml/main.qml"));
@My Info.plist contains
@
<key>UIAppFonts</key>
<array>
<string>.fonts/SourceCodePro-Regular.ttf</string>
</array>
@Therefore, it seems as if one can not load a custom font!?
It would help to be able to have a .qml in the qrc system but define a file url as source of FontLoader instead of a qrc url in the .qml
-
wrote on 8 Jan 2014, 06:23 last edited by
Hi Jamil,
please try to remove FontLoader from qml completely, in my case that was a problem.If your font is present in QFontDatabase, just use font's family name while defining item in qml, i.e.:@
Text {
anchors.centerIn: ......
text: ......
color: "#ffffffff"
font.family: "Source Code Pro"
font.pointSize: 20
}
@Cheers
-
wrote on 23 Mar 2014, 13:51 last edited by
Just to precise something :There is no need to have a script for changing the plist file :
Add "QMAKE_INFO_PLIST = AppliInfo.plist" in the .pro in order to use your own plist file.
-
wrote on 24 Mar 2014, 05:59 last edited by
yup, see my post from 20 Dec
Cheers
-
wrote on 24 Mar 2014, 08:40 last edited by
Oops yes. Sorry ^^
-
wrote on 2 Apr 2014, 18:31 last edited by
For the sake of completeness, it seems like FontLoader is fully implemented for iOS as of the current "Qt 5.3 beta":http://blog.qt.digia.com/blog/2014/03/25/qt-5-3-beta-released/, so there are no more hacks required. ;)
Cheers,
Alex