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

QtQuick 2.x Canvas textBaseline middle isn't working

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.2.0
    • 5.1.0
    • Quick: Other
    • None
    • Windows 7 64x, Qt 5.1.0 32 bits MinGW version. Using qmlscene.
    • qtdeclarative/dev: 45792359f25813af18b7416e4c18737ed4b20bff

    Description

      It seems that Canvas variable textBaseline doesn't work properly when set to "middle". It behaves as the default value (alphabetic).

      I'm running the code through qmlscene and it happens with both QtQuick 2.0 and QtQuick 2.1.

      Sample code:

      import QtQuick 2.0
      
      Rectangle {
          id: root
          width: 800
          height: 600
      
          Canvas {
              id: canvas
              anchors.fill: parent
      
              onPaint: {
                  var ctx = canvas.getContext("2d");
                  if (ctx === null) {
                      console.log("ctx = null");
                  }
                  ctx.clearRect(0, 0, canvas.width, canvas.height);
                  ctx.textBaseline = "middle";
                  ctx.fillText("Hello Word", mouseArea.mouseX, mouseArea.mouseY);
                  ctx.fill();
              }
      
              MouseArea {
                  id: mouseArea
                  anchors.fill: parent
                  hoverEnabled: true
                  onClicked: canvas.requestPaint();
              }
          }
      }
      

      Sorry for my english...

      Attachments

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

        Activity

          People

            wesleyceraso Wesley Ceraso Prudencio
            wesleyceraso Wesley Ceraso Prudencio
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes