a font value with the properties of
QFont
.
The
font
type refers to a font value with the properties of
QFont
.
更多...
Properties of type
font
default to the application's default
font
.
The most commonly used properties are:
font.family
font.bold
font.italic
font.underline
font.pointSize
font.pixelSize
If both
pointSize
和
pixelSize
are specified,
pixelSize
会被使用。
The following properties are also available:
font.weight
font.overline
font.strikeout
font.capitalization
font.letterSpacing
font.wordSpacing
font.kerning
font.preferShaping
font.hintingPreference
对象
font.features
font.styleName
对象
[QML]
{QtQuick::Text::}{font.variableAxes}
范例:
Text { font.family: "Helvetica" font.pointSize: 13 font.bold: true }
As
font
是
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
值
passed into QML from C++
is automatically converted into a
font
value, and vice-versa.
This value type is provided by the QtQuick 导入。
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:
常量 | 描述 |
---|---|
Font.Thin
|
100 |
Font.ExtraLight
|
200 |
Font.Light
|
300 |
Font.Normal
|
400 |
Font.Medium
|
500 |
Font.DemiBold
|
600 |
Font.Bold
|
700 |
Font.ExtraBold
|
800 |
Font.Black
|
900 |
Capitalization supports the following values:
常量 | 描述 |
---|---|
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. |
Setting the hinting preference only has an effect when using the "NativeRendering" render type. The property supports the following values:
常量 | 描述 |
---|---|
Font.PreferDefaultHinting
|
Use the default hinting level for the target platform. |
Font.PreferNoHinting
|
If possible, render text without hinting the outlines of the glyphs. |
Font.PreferVerticalHinting
|
If possible, render text with no horizontal hinting, but align glyphs to the pixel grid in the vertical direction. |
Font.PreferFullHinting
|
If possible, render text with hinting in both horizontal and vertical directions. |
另请参阅 QML 值类型 .