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

Text underline scaled two times on retina display

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.2, 5.10.1
    • GUI: Font handling
    • None
    • macOS Sierra 10.12.6(MacBook Pro Retina, 15-inch, Mid 2014)
    • macOS

    Description

      Drawing text with underline using QPainter::drawGlyphRun on the retina display is incorrect if pixelSize < 32. Please see attached example.
      Please take a look at the code (QT_MAX_CACHED_GLYPH_SIZE == 64):

      bool QPaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const
      {
          if (fontEngine->glyphFormat == QFontEngine::Format_ARGB)
              return true;
      
          qreal pixelSize = fontEngine->fontDef.pixelSize;
          return (pixelSize * pixelSize * qAbs(m.determinant())) <
                  QT_MAX_CACHED_GLYPH_SIZE * QT_MAX_CACHED_GLYPH_SIZE;
      }
      

      And at this code in QPainter::drawGlyphRun:

      QRawFontPrivate *fontD = QRawFontPrivate::get(font);
      bool engineRequiresPretransformedGlyphPositions = d->extended
          ? d->extended->requiresPretransformedGlyphPositions(fontD->fontEngine, d->state->matrix)
          : d->engine->type() != QPaintEngine::CoreGraphics && !d->state->matrix.isAffine();
      
      for (int i=0; i<count; ++i) {
          QPointF processedPosition = position + glyphPositions[i];
          if (engineRequiresPretransformedGlyphPositions)
              processedPosition = d->state->transform().map(processedPosition);
          fixedPointPositions[i] = QFixedPoint::fromPointF(processedPosition);
      }
      

      The engineRequiresPretransformedGlyphPositions is true because of the first code block.
      The underline size and position are calculated after the second code block.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            yurik147 Yurii Olenych
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes