12-05-2012 07:23 AM
I want to Embed a "Custom font" TTF in QML and C++, I didn't find any references about How to embed and use it
I am using Native SDK for Cascades Beta4
12-05-2012 07:34 AM
It SHOULD be supported by adding it to the Qt Font database in C++ - after that it would be accessible as a standard font selection in both C++ & QML. However, if you search the forum you'll find the last thread this was asked on and it is apparently not supported by the platform currently.
12-05-2012 09:06 AM
The documentation is here:
However, as far as I know it will NOT work at the moment. The BB10 platform does not support adding custom fonts yet.
12-05-2012 01:52 PM
The BB10 platform does not support adding custom fonts yet.
It's more that Cascades doesn't support custom fonts rather than BB10. It will depend on what libraries you are using to render your app.
Look at bbutil.c from the HelloWorldDisplay example (NDK samples, not Cascades samples). This shows a more low-level form of text support, including loading fonts. (I tried to attach it to the message but ".c" and ".h" are missing fromt he accepted file extensions...)
Unfortunately the two approaches are mutually exclusive (Cascades and HelloWorldDisplay), well unless you want to punch holes through Cascades with foreign windows, which is horrible.
I'd say that if an app is totally dependent on custom fonts, Cascades is probably not the way to go. Actually I'm tempted to say that you should go for QtCreator/QtQuick as your development platform for now. Either that or you go down to the level of bbutil.c
12-06-2012 04:56 AM
Sorry, I should have said the BB10 platform doesn't support adding custom fonts to Qt yet.
I'm not sure even QtCreator/QtQuick will help here? They need to wrap the custom font rendering the native platform provides with the Qt classes. If Qt's font database isn't told about the additional font then you're not going to be able to use it in your app. Or has this already been done but is just not correctly integrated with Cascades?
12-06-2012 09:31 AM
If you use the font engine to render images and then display those, yes. Can you plug the font engine into the Qt system and use the fonts in QML, no - as I understand it you need to rebuild Qt itself for the platform to add a new font rendering engine.
12-06-2012 09:41 AM
To be honest Mark, I'm not totally sure.
As far as I know, you can port pretty much any QT app to BB 10 using the Native SDK with minimal changes. I assume that includes font handling, though QT does depend on its supporting platform libraries for font access.
What I've used myself is the bbutil.c. I wrapped it in a C++ class, and I use it to get string lengths in pixels (another thing missing from Cascades). It allows me to do intelligent word-wrap: I don't want single words, I want phrases to wrap, basically I want "10.30am (tomorrow)" to be on the same line, and the word-wrap you get with multiline labels doesn't handle that use-case. It does mean having my own screen_context and loading fonts from the file system tho, which is why I'm pretty sure you can load fonts, just not in Cascades.
12-06-2012 09:56 AM
I got my info on font sideloading for Qt not being supported on BB10 from the thread above, haven't tried it - Cascades is just using the standard QFontDatabase to provide font support, so if you can do it in standard Qt you'll be able to do it in Cascades too, C++ or QML should work fine.