Qt QML文本中的多种字体类型
我需要写一个文本使用多种字体类型。我尝试通过使用富文本这样做:Qt QML文本中的多种字体类型,qt,qml,Qt,Qml,我需要写一个文本使用多种字体类型。我尝试通过使用富文本这样做: Text{ id: test textFormat: Text.RichText color: "#297fca" text: "<span style = 'font-family: Roboto Medium; font-size: 15px'>Text in on font.</span> And in another" anchors{ top:
Text{
id: test
textFormat: Text.RichText
color: "#297fca"
text: "<span style = 'font-family: Roboto Medium; font-size: 15px'>Text in on font.</span> And in another"
anchors{
top: description.bottom
topMargin: 40
left: headDesign.right
leftMargin: 75
}
}
文本{
id:测试
Text格式:Text.RichText
颜色:“297fca”
文本:“字体中的文本。另一个字体中的文本”
锚定{
顶部:description.bottom
上边距:40
左:headDesign.right
左边距:75
}
}
我要更改其字体的文本变大,但字体未加载。Roboto Medium是我使用字体加载器加载的字体
那么,你知道我做错了什么吗?请检查字体加载是否正确
FontLoader {
source: "riesling.ttf"
Component.onCompleted: console.log(name)
}
Text{
id: test
textFormat: Text.RichText
color: "#297fca"
text: "<div style = 'font-family: Riesling; font-size: 25px'>Same Text.</div>
<div style = 'font-size: 25px'>Same Text.</div>"
}
FontLoader{
资料来源:“雷司令.ttf”
Component.onCompleted:console.log(名称)
}
正文{
id:测试
Text格式:Text.RichText
颜色:“297fca”
文本:“相同的文本。
同一文本。”
}
字体:
使它们显示单独的行以清楚地看到差异
Qt 5.10.1结果
您是否尝试过使用字体加载器加载两种字体。对不起,我不清楚。我的意思是字体不会出现在消息中的内容中。这是所有默认字体
RichText
都没有实现完整的HTML规范。也许字体族内部样式没有实现。您可以设置字体,如Text{Text:“Fixed size font”;font.family:fixedFont.name}
,其中fixedFont
是FontLoader
元素的id。这种方法的问题是,在执行此操作时,需要为另一种字体创建一个全新的文本字段。当你的文本是一个段落,而字体变化在段落的中间时,这根本不是一个好的解决方案。你能发布你用来加载字体的代码吗?字体系列
是受支持的CSS属性,应该可以使用。当我尝试使用另一种字体时,你的代码对我来说效果很好,所以我相信你的加载程序有问题。看见请注意,您还可以使用font
标记:text:“字体中的文本”和另一个“