font QML Value Type
QFont font
类型指具有 属性的字体值 ...QFont更多...
详细说明
font
类型的属性默认为应用程序的默认font 。
最常用的属性有
- string
font.family
- bool
font.bold
- bool
font.italic
- bool
font.underline
- real
font.pointSize
- int
font.pixelSize
如果同时指定了pointSize
和pixelSize
,则将使用pixelSize
。
以下属性也可用:
- 枚举
font.weight
- bool
font.overline
- bool
font.strikeout
- 枚举
font.capitalization
- real
font.letterSpacing
- real
font.wordSpacing
- bool
font.kerning
- bool
font.preferShaping
- 枚举
font.hintingPreference
object
font.features- string
font.styleName
object
[QML]
{QtQuick::Text::}{font.variableAxes}。- bool
font.contextFontMerging
- bool
font.preferTypoLineMetrics
示例:
Text { font.family: "Helvetica" font.pointSize: 13 font.bold: true }
由于font
是structured value 类型,它也可以用 JavaScript 对象构建:
readonly property font myFont: ({ family: "Helvetica", pointSize: 13, bold: true })
当与 C++ 整合时,请注意任何从 C++ 传入 QML 的 QFont 值都会自动转换为font
值,反之亦然。
这种值类型由QtQuick import 提供。
字体权重的数值遵循 CSS 规范,权重为 100 表示极轻,900 表示极粗。支持以下值:
常量 | 说明 |
---|---|
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 |
大写支持以下值:
常量 | 说明 |
---|---|
Font.MixedCase | 不更改大写。 |
Font.AllUppercase | 将文本改为全大写。 |
Font.AllLowercase | 将文本改成全小写。 |
Font.SmallCaps | 将文字改成小写。 |
Font.Capitalize | 将文本改为每个单词的第一个字符为大写字符。 |
设置提示首选项只有在使用 "NativeRendering "呈现类型时才有效。该属性支持以下值:
常量 | 说明 |
---|---|
Font.PreferDefaultHinting | 使用目标平台的默认提示级别。 |
Font.PreferNoHinting | 如果可能,渲染文本时不提示字形轮廓。 |
Font.PreferVerticalHinting | 如果可能,在渲染文本时不显示水平提示,但在垂直方向将字形与像素网格对齐。 |
Font.PreferFullHinting | 如果可能,渲染文本时在水平和垂直方向都有提示。 |
另请参阅 QML 值类型。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.