QT无法显示SVG中的文本的问题

1、QT使用SVG 1.2规范解析svg

SVG Tiny,不是完整的SVG规范,虽然SVG Tiny确实支持“tspan”,但它也声明了这一点:
“SVG Tiny 1.2中的'tspan'上没有诸如'x'、' y'和'rotate'等位置属性。

 

2、解决方法

将svg中tspan节点的位置属性和值挪到text中即可,如

<svg xmlns="http://www.w3.org/2000/svg"
     width="100%" height="100%" viewBox="0 0 400 400"
     direction="rtl" xml:lang="fa">

  <title direction="ltr" xml:lang="en">Right-to-left Text</title>
  <desc direction="ltr" xml:lang="en">
    A simple example for using the 'direction' property in documents
    that predominantly use right-to-left languages.
  </desc>

  <text x="200" y="200" font-size="20">داستان SVG Tiny 1.2 طولا ني است.</text>

</svg>

 3、参考

https://stackoverflow.com/questions/37548128/multi-line-centered-text-in-svg-rendered-in-qthttps://www.w3.org/TR/SVGTiny12/text.html#TSpanElement

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值