On 10/11/2014 09:02, Rutledge Shawn wrote: > On 10 Nov 2014, at 08:30, Harri Pasanen <ha...@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.
On 10/11/2014 09:02, Rutledge Shawn wrote: > On 10 Nov 2014, at 08:30, Harri Pasanen <ha...@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. Well, in C++ I used QFontDatabase::addApplicationFontFromData(), in the hope that it would be available for use. But I suppose Qt.fontFamilies() does not merge with QFontDatabase::applicationFontFamilies()... I presume FontLoader uses QFontDatabase::addApplicationFontFromData() under the covers, but apparently something more needs to be done to make QML see it. Anyway, thanks for the pointers, at least I know it should be doable. Harri _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest