Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-13971

anchors.centerIn doesn't center Text element as expected if font.letterSpacing is used

    XMLWordPrintable

Details

    Description

      The attached screenshot is produced by the folllowing code:

      Column {
      
          Rectangle {
              width: 200; height: 100
              border.width: 1
              Text {
                  text: "Hello"; font.pixelSize: 80
                  anchors.centerIn: parent
              }
          }
      
          Rectangle {
              width: 200; height: 100
              border.width: 1
              Text {
                  text: "Hello"; font.pixelSize: 40
                  anchors.centerIn: parent
                  font.letterSpacing: 20
              }
          }
      
      }
      

      Both text objects are positioned using anchors.centerIn. The bottom object has font.letterSpacing specified, and because of the letter spacing applied after the last letter, the item is not centered as expected. To center the item, it would have to be explicitly set with an x value that takes the letter spacing into account.

      Attachments

        1. snapshot2.png
          snapshot2.png
          5 kB
        2. snapshot1.png
          snapshot1.png
          5 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            brasser Michael Brasser (closed Nokia identity) (Inactive)
            bealam Bea Lam (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes