Defines a string in a specified font. 更多...
import 语句: | import QtQuick |
Since: | QtQuick 2.15 |
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" }
另请参阅 路径 , QPainterPath::setFillRule , PathPolyline , PathQuad , PathCubic , PathArc , PathAngleArc , PathCurve , PathSvg ,和 PathMove .
font.bold : bool |
Sets whether the font weight is bold.
font.capitalization : enumeration |
Sets the capitalization for the text.
常量 | 描述 |
---|---|
Font.MixedCase
|
no capitalization change is applied |
Font.AllUppercase
|
alters the text to be rendered in all uppercase type |
Font.AllLowercase
|
alters the text to be rendered in all lowercase type |
Font.SmallCaps
|
alters the text to be rendered in small-caps type |
Font.Capitalize
|
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.
使用此函数使字体设备从属。使用
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.
默认值为 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 : int |
Sets the font's weight.
The weight can be one of:
常量 | 描述 |
---|---|
Font.Thin
|
100 |
Font.ExtraLight
|
200 |
Font.Light
|
300 |
Font.Normal
|
400 (default) |
Font.Medium
|
500 |
Font.DemiBold
|
600 |
Font.Bold
|
700 |
Font.ExtraBold
|
800 |
Font.Black
|
900
PathText { text: "Hello"; font.weight: Font.DemiBold } |
font.wordSpacing : real |
Sets the word spacing for the font.
单词间距改变单个单词之间的默认间距。正值按相应像素数量递增单词间距,而负值相应递减单词间间距。
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.
注意: 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.