Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.9.2, 5.10.1
-
None
-
macOS Sierra 10.12.6(MacBook Pro Retina, 15-inch, Mid 2014)
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.