font QML Value Type

a font value with the properties of QFont. The font type refers to a font value with the properties of QFont. More...

Detailed Description

Properties of type font default to the application's default font.

The most commonly used properties are:

If both pointSize and a pixelSize are specified, pixelSize will be used.

The following properties are also available:

Example:

     Text {
         font.family: "Helvetica"
         font.pointSize: 13
         font.bold: true
     }

As font is a structured value type, it can also be constructed with a JavaScript object:

     readonly property font myFont: ({
         family: "Helvetica",
         pointSize: 13,
         bold: true
     })

When integrating with C++, note that any QFont value passed into QML from C++ is automatically converted into a font value, and vice-versa.

This value type is provided by the QtQuick import.

Numerical values for font weights follow the CSS specification, where a weight of 100 is extremely light, and 900 is extremely bold. The following values are supported:

ConstantDescription
Font.Thin100
Font.ExtraLight200
Font.Light300
Font.Normal400
Font.Medium500
Font.DemiBold600
Font.Bold700
Font.ExtraBold800
Font.Black900

Capitalization supports the following values:

ConstantDescription
Font.MixedCaseNo capitalization change is applied.
Font.AllUppercaseAlters the text to be rendered in all uppercase type.
Font.AllLowercaseAlters the text to be rendered in all lowercase type.
Font.SmallCapsAlters the text to be rendered in small-caps type.
Font.CapitalizeAlters the text to be rendered with the first character of each word as an uppercase character.

Setting the hinting preference only has an effect when using the "NativeRendering" render type. The property supports the following values:

ConstantDescription
Font.PreferDefaultHintingUse the default hinting level for the target platform.
Font.PreferNoHintingIf possible, render text without hinting the outlines of the glyphs.
Font.PreferVerticalHintingIf possible, render text with no horizontal hinting, but align glyphs to the pixel grid in the vertical direction.
Font.PreferFullHintingIf possible, render text with hinting in both horizontal and vertical directions.

See also QML Value Types.