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

Inconsistent rendering of underlines between QPainter and QtQuick text items

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2, 6.3.0
    • GUI: Font handling
    • None
    • Tested on Windows 11
    • Windows

    Description

      I've notice that there is an inconsistency between the behavior of the underline position in a text rendered using QPainter and text rendered in Qt Quick.

      For example, in the picture below the left text is rendered using QPainter (in a QQuickPaintedItem) and the right text is rendered using Text from QtQuick

       

      As you can see on the left hand side the underline is much closer to the baseline, while there is a noticeable gap on the right.

      The code I've used for the LHS is:

          painter->setRenderHint(QPainter::Antialiasing);
      
          QFont font {"Arial", 50};
          font.setUnderline(true);
      
          QPointF pos (100, 60);
          painter->setFont(font);
          painter->drawText(pos, "hello");

      While the RHS is rendered using:

              Text{
                  text: "hello"
                  font.family: "Arial"
                  font.underline: true
                  font.pointSize: 50
                  renderType: Text.QtRendering
              }

      I would've expected the two rendering systems to behave similarly as I thought QtQuick was using QFontMetricsF internally.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            daljit97 Daljit Singh
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes