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

TextInput and Text vertical alignment does not match when using multiple fonts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.3.0, 6.8.0, 6.9.3
    • GUI: Text handling
    • None
    • macOS, Windows

      The Text item and TextInput item have different alignment when using a mixture of fonts. For example a non-default font and then emojis so there two fonts in the text. The Text Input looks completely off center whereas the Text item looks correct.

       

      I used this code with Qt 6.9.3 on MacOS but it affects previous versions and Windows as well. (I've attached a video of the issue)

      Just type (or paste) in a string like "sss😀"

      import QtQuick
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")    
          
          Rectangle {
              anchors {
                  left: parent.left
                  right:parent.right
                  verticalCenter: parent.verticalCenter
              }
              height: 50
              color: "red"
              TextInput {
                  id: input
                  anchors.fill: parent
                  font: "Menlo" // Use Consolas on windows
                  verticalAlignment: Text.AlignVCenter
                  onEditingFinished: {
                      textb.visible = true;
                      visible = false;
                      enabled = false;
                      textb.text = text;
                  }
              }
          }    
          Text {
              id: textb
              anchors.fill: parent
              font: "Menlo" // Use Consolas on windows
              verticalAlignment: Text.AlignVCenter
              visible: false
          }
      } 

       

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            esabraha Eskil Abrahamsen Blomfeldt
            jamesk James Kerr
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes