PathText QML Type

Defines a string in a specified font. More...

Import Statement: import QtQuick 2.2
Since: QtQuick 2.15

Properties

Detailed Description

This element defines the shape of a specified string in a specified font. The text's baseline will be translated to the x and y coordinates, and the outlines from the font will be added to the path accordingly.

 PathText {
     x: 0
     y: font.pixelSize
     font.family: "Arial"
     font.pixelSize: 100
     text: "Foobar"
 }

See also Path, QPainterPath::setFillRule, PathPolyline, PathQuad, PathCubic, PathArc, PathAngleArc, PathCurve, PathSvg, and PathMove.

Property Documentation

font.bold : bool

Sets whether the font weight is bold.


font.capitalization : enumeration

Sets the capitalization for the text.

  • Font.MixedCase - This is the normal text rendering option where no capitalization change is applied.
  • Font.AllUppercase - This alters the text to be rendered in all uppercase type.
  • Font.AllLowercase - This alters the text to be rendered in all lowercase type.
  • Font.SmallCaps - This alters the text to be rendered in small-caps type.
  • Font.Capitalize - This alters the text to be rendered with the first character of each word as an uppercase character.
 PathText { text: "Hello"; font.capitalization: Font.AllLowercase }

font.family : string

Sets the family name of the font.

The family name is case insensitive and may optionally include a foundry name, e.g. "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 will be set using the font matching algorithm.


font.italic : bool

Sets whether the font has an italic style.


font.kerning : bool

Enables or disables the kerning OpenType feature when shaping the text. Disabling this may improve performance when creating or changing the text, at the expense of some cosmetic features. The default value is true.

 PathText { text: "OATS FLAVOUR WAY"; font.kerning: false }

font.letterSpacing : real

Sets the letter spacing for the font.

Letter spacing changes the default spacing between individual letters in the font. A positive value increases the letter spacing by the corresponding pixels; a negative value decreases the spacing.


font.pixelSize : int

Sets the font size in pixels.

Using this function makes the font device dependent. Use pointSize to set the size of the font in a device independent manner.


font.pointSize : real

Sets the font size in points. The point size must be greater than zero.


font.preferShaping : bool

Sometimes, a font will apply complex rules to a set of characters in order to display them correctly. In some writing systems, such as Brahmic scripts, this is required in order for the text to be legible, but in e.g. Latin script, it is merely a cosmetic feature. Setting the preferShaping property to false will disable all such features when they are not required, which will improve performance in most cases.

The default value is true.

 PathText { text: "Some text"; font.preferShaping: false }

font.strikeout : bool

Sets whether the font has a strikeout style.


font.styleName : string

Sets the style name of the font.

The style name is case insensitive. If set, the font will be matched against style name instead of the font properties font.weight, font.bold and font.italic.


font.underline : bool

Sets whether the text is underlined.


font.weight : enumeration

Sets the font's weight.

The weight can be one of:

  • Font.Thin
  • Font.Light
  • Font.ExtraLight
  • Font.Normal - the default
  • Font.Medium
  • Font.DemiBold
  • Font.Bold
  • Font.ExtraBold
  • Font.Black
 PathText { text: "Hello"; font.weight: Font.DemiBold }

font.wordSpacing : real

Sets the word spacing for the font.

Word spacing changes the default spacing between individual words. A positive value increases the word spacing by a corresponding amount of pixels, while a negative value decreases the inter-word spacing accordingly.


text : string

The text for which this PathText should contain the outlines.


x : real

The horizontal position of the PathText's baseline.


y : real

The vertical position of the PathText's baseline.

Note: This property refers to the position of the baseline of the text, not the top of its bounding box. This may cause some confusion, e.g. when using the PathText with Qt Quick Shapes. See FontMetrics for information on how to get the ascent of a font, which can be used to translate the text into the expected position.