font QML Basic Type

A font configuration. More...

A font type describing a font configuration. The available properties are:

When using the Monotype Spark font engine, the font configuration uses the font class mapping rules.

See also Text Rendering and Fonts, Qt.font(), and Basic Types for more information.

This basic type is provided by the QtQuick import.

Usage example

Text {
    font.family: "Helvetica";
    font.pixelSize: 24;
    font.bold: true

Constant font configurations

A constant font configuration is where all the font's subproperties can be resolved to a constant value by qmltocpp. Binding to a readonly property is therefore permitted. Examples:

readonly property int titlePixelSize: 40
readonly property font myFontConfig: Qt.font({ pixelSize: titlePixelSize })

Text {
    text: "hello world"
    font.pixelSize: titlePixelSize

Text {
    text: "hello world 2"
    font: myFontConfig

Text {
    text: "hello world 3"
    font.italic: true

Note: The static font engine supports only constant font configurations.

Font family

Sets the family name of the font. The default font familiy is set by MCU.Config.defaultFontFamily.

Static font engine

The family name is case insensitive and may include a foundry name. For example, "Helvetica [Cronyx]". If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen. If the family isn't available, a family is set using the font matching algorithm.

Spark font engine

The value of MCU.Config.defaultFontFamily QmlProject property is read when using the Fontmap file format. Otherwise, only the font.pixelSize font configuration is used.

Font bold

Sets whether the font weight is bold.

Font italic

Sets whether the font has an italic style.

Font pointSize

The pointSize property does not respect screen DPI as documented on the known issues or limitations page. Currently the set value is simply scaled to 1.5 times. It is recommented to use font.pixelSize instead.

Font pixelSize

Sets the font size in pixels.

Font unicodeCoverage

This property is supported in Qt.font() context only.

Note: The unicodeCoverage property has a different meaning, depending on the used font engine. See Text Rendering and Fonts for font engine-specific details.

The array may contain:

  • String literals containing glyphs to add, like "\u1722".
  • Unicode block enum values, like Font.UnicodeBlock_Kannada. For the list of supported enum values, see unicode block names.
  • A list of pairs indicating a unicode range, like [0x600, 0x61F].


Text {
    font: Qt.font({
        family: "DejaVu Sans",
        unicodeCoverage: [Font.UnicodeBlock_Kannada, "ᜠᜡ\u1722", [0x600, 0x61F]]
    text: CppSingleton.retrieveText()

In the earlier example, the glyphs for many extra unicode codepoints are prerendered for the font configuration used by the Text item. This information is compiled into the application binary. The codepoints in the "Kannada" Unicode block, the codepoint range 0x600 to 0x61F (inclusive), and the individual characters ᜠ, ᜡ, and U+1722 will be included.

Only a single glyph is generated per codepoint, even if the codepoint is contained in several ranges, blocks, or strings.

Font weight

Sets the font's weight. The following enums are supported:

  • Font.Thin
  • Font.ExtraLight
  • Font.Light
  • Font.Normal
  • Font.Medium
  • Font.DemiBold
  • Font.Bold
  • Font.ExtraBold
  • Font.Black

Font quality

The rendering quality of a font.

The font.quality property allows more fine-grained optimization, by providing hints to render low-quality glyphs.

The requested quality must be one of the predefined values:

  • Font.QualityVeryLow
  • Font.QualityVeryHigh


Text {
    font: Qt.font({ quality: Font.QualityVeryHigh })
    text: "..."

Note: The quality property can be set only in the Qt.font() function.

Note: This feature may not be supported by hardware on all reference boards. For more information, see Supported Features table.


By default, the font compiler generates glyphs for all used characters in all used font configurations. This may result in redundant glyphs being generated. For example:

Text {
    font: Qt.font({ quality: Font.QualityVeryHigh })
    text: "a"
Text {
    font: Qt.font({ quality: Font.QualityVeryLow })
    text: "b"

In the earlier example, glyphs for the "ab" characters are generated twice, one for VeryHigh and the other for VeryLow quality. This allows binding text property between existing Text items. You can disable this behavior by setting the MCU.Config.autoGenerateGlyphs to OFF.

To set the default font quality for an application, see the MCU.Config.defaultFontQuality QmlProject property.

Available under certain Qt licenses.
Find out more.