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

Bounding boxes are incorrect with the DirectWrite font engine

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.0.0
    • 4.8.0
    • GUI: Font handling
    • None
    • Windows 7
    • 6fb5b6fa58df4b622d47a8d71ba0f5f2b938cd63

    Description

      The return value of QFontMetricsF::boundingRect and tightBoundingRect are incorrect when using the new DirectWrite font engine. The X and Y origins are both wrong, as is the height. The width is correct.

      To see the problem, build and run the attached test app. Observe that the bounding rectangle is correct without DirectWrite. Then switch on the 'DirectWrite' checkbox and see that the bounding rectangle moves.

      The error seems to be in QFontEngineDirectWrite::boundingBox(glyph_t g). This currently returns like this:

      return glyph_metrics_t(-leftSideBearing, -verticalOriginY,
      width, m_ascent + m_descent,
      advanceWidth, advanceHeight);

      but should be

      QFixed height = advanceHeight - topSideBearing - bottomSideBearing;
      return glyph_metrics_t(leftSideBearing, -verticalOriginY + topSideBearing,
      width, height,
      advanceWidth, advanceHeight);

      where topSideBearing and bottomSideBearing are extracted from the DWRITE_GLYPH_METRICS structure just like the other variables. The documentation at http://msdn.microsoft.com/en-us/library/windows/desktop/dd368084(v=VS.85).aspx gives the relationship between these metrics and explains why the original code in Qt 4.8 isn't quite right - the leftSideBearing is negative if the black box extends to the left of the layout box, and the vertical origin is the top of the layout box, not the black box.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            jlarcombe James Larcombe
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes