【问题标题】:Text in QML rendered different accross platformsQML 中的文本在不同平台上呈现不同
【发布时间】:2016-09-17 21:51:02
【问题描述】:

我发现不同平台之间的文本呈现不一致:

左上角的图像是在android中生成的,如红色引导线所示,它与“参考”窗口输出的斜体样式的垂直位置和角度不同。

Rectangle {
  width: 100
  height: 50
  color: "grey"
  Text {
    x: 4
    y: 2
    font.family: sysfont
    font.pixelSize: 13
    width: contentWidth
    color: bgc
    text: "Type"
  }
  Text {
    x: 5
    y: 13
    font.family: sysfont
    font.pixelSize: 32
    font.italic: true
    font.letterSpacing: -1
    width: contentWidth
    color: topc
    style: Text.Sunken
    styleColor: bgc
    text: "Name"
  }
}

任何想法是什么原因造成的?它是相同的字体,相同的代码。顶部填充和行高值在平台上是相同的。

【问题讨论】:

    标签: qt text qml cross-platform rendering


    【解决方案1】:

    It turns out that it is a bug。所以它可能会在未来几年的某个时候得到修复......

    在此之前,至少在垂直位置方面,以下解决方法应该可以解决问题:

      property real offset: {
        switch (Qt.platform.os) {
        case "android": return androidValue
        case "windows": return windowsValue
        // and so on...
        }
      }
    

    我会调查同一平台的不同版本之间是否存在差异,并在必要时更新答案。

    更新: 事实证明,这里的例外是 windows,因为 android 和 ubuntu 的输出实际上是相同的(是的,无论如何,两者本质上都是 linux)。我没有 mac,所以我无法提供任何意见。

    【讨论】:

    • 我可以确认macOS匹配android/linux
    猜你喜欢
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 2012-06-12
    • 2023-03-27
    • 1970-01-01
    • 2017-12-22
    • 1970-01-01
    • 2020-09-26
    相关资源
    最近更新 更多