dte*_*ech 4 formatting fonts qt richtext qml
我一直试图Text通过一些富文本格式来获取一个元素来显示不同大小的文本:
Text {
font.pointSize: 30
text: 'T' +
'<font size="40px">T</font>' +
'<font size="10px">T</font>' +
'<font size="5px">T</font>' +
'<font size="40pt">T</font>' +
'<font size="10pt">T</font>' +
'<font size="5pt">T</font>' +
'<font size="1">T</font>' +
'<font size="2">T</font>' +
'<font size="3">T</font>' +
'<font size="4">T</font>' +
'<font size="5">T</font>' +
'<font size="6">T</font>' +
'<font size="-1">T</font>' +
'<font size="-2">T</font>' +
'<font size="-3">T</font>' +
'<font size="-4">T</font>' +
'<font size="-5">T</font>' +
'<font size="-6">T</font>' +
'<font size="20%">T</font>' +
'<font size="60%">T</font>' +
'<font size="130%">T</font>'
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,正如最终结果所表明的那样,似乎只有1到7和-1到-2的大小按预期工作,其他一切都没有效果.

我特别想要的是文本明显小于设定值30pts,大约10左右是理想的,但是我不能使用任何有效的选项中的任何一个.
编辑:我能够通过更改基本大小获得所需的大小差异,并使用大小7表示"正常",大小-2表示小文本,但是,如果某人有通用解决方案,我会留下问题获得任意大小.
您尝试使用Text.RichText样式文本,因此需要这样做:
Text {
textFormat: Text.RichText
text: " <html>
<div style='font-size: 5px;'>T</div>
<div style='font-size: 10px;'>T</div>
<div style='font-size: 20px;'>T</div>
<div style='font-size: 30px;'>T</div>
</html>"
}
Run Code Online (Sandbox Code Playgroud)
我认为您的HTML文本应该被检测为Text.StyledText,这是HTML 3.2的风格.它支持font-sizeHTML标签的有限属性:
<font color="color_name" size="1-7"></font>
Run Code Online (Sandbox Code Playgroud)
Text.RichText支持更大的HTML 4子集,如支持的HTML子集页面所述.
HTML 4支持下面的CSS属性:
font-size [小| 中| 大| x-large | xx-large] | pt | PX