BB10: Cascades: Change Font Size for QML Controls


Now that I have my 5 BB10 apps submitted to AppWorld I can take a break and write up a few articles on things I discovered along the way. These will be concise and to the point, but I think documenting them will be worthwhile.

One thing I found out is that changing the font size for BlackBerry 10 Cascades controls involves a little more than just setting the size of text. Example after the jump.

References:

 

What Works

In order for Cascades to accept a point-value for text the textStyle.fontSize property must be set to FontSize.PointValue. If this is not set, the point value set using textStyle.fontSizeValue will be ignored (In the BB10 Gold SDK, anyway).

Here's a Label setup to allow arbitrary font-size:

Label {
    text: "Message Here"
    textStyle.fontSize: FontSize.PointValue
    textStyle.fontSizeValue: 20
    textStyle.fontWeight: FontWeight.Bold
}
 

What Doesn't Work

This will be the first thing that a lot of people try, but it won't work:

Label {
    text: "Message Here"
    textStyle.fontSizeValue: 20
    textStyle.fontWeight: FontWeight.Bold
}