1

From blackberry 10.2 I can use FontFaceRule like below to use custom fonts. But I need it to support from 10.0. Is there any way to do this? If not, is it atleast possible that I can check the sdk version in qml so that if the sdk version is > 10.2 it should import bb.cascades 1.2 and include fontface rule. My project is currently set to base sdk 10.0 so importing anything greater than 1.0 throws error.

TextStyleDefinition {
    id: myLabel
    base: SystemDefaults.TextStyles.BodyText
    fontWeight: FontWeight.Bold
    textAlign: TextAlign.Center
    fontSize: FontSize.PointValue
    color: Color.create("#FFFFFF")
    fontSizeValue: 12
    rules: [
        FontFaceRule {
            id: styleFontRule
            source: "asset:///fonts/Montserrat-Bold.ttf"
            fontFamily: "Montserrat-Bold"
        }
    ]
}

EDIT

attachedObjects: [
 FontLoader {
                id: fixedFont;   source: "asset:///fonts/Montserrat-Bold.ttf"
            },

TextStyleDefinition {
        id: myLabel
        base: SystemDefaults.TextStyles.BodyText
        fontWeight: FontWeight.Bold
        textAlign: TextAlign.Center
        fontSize: FontSize.PointValue
        color: Color.create("#FFFFFF")
        fontSizeValue: 12
        fontFamily: fixedFont.source
    }
}]
Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Francis F
  • 3,157
  • 3
  • 41
  • 79
  • Why don't you use FontLoader instead? – sam Dec 31 '14 at 06:48
  • I did try Fontloader as above, but it shows error:FontLoader is not a type. Any suggestions?? – Francis F Jan 03 '15 at 13:35
  • what do you mean by "not a type" error? FontLoader is not an element in blackberry? I usually use fixedFont.name for font.family in qml. Try to change fixedFont.source to fixedFont.name. – sam Jan 03 '15 at 13:42
  • I tried that, still same error. Am I doing anything wrong? I have currently imported import QtQuick 1.0 is there anything else that I need to import. – Francis F Jan 03 '15 at 14:10

0 Answers0