Freetype: Fix transformed text when subpixel AA is on
6ba003f73295b896aa6dc1fba099daadb4760209 fixed transforming bitmap fonts for the case where 8 bit antialiasing is used. This is the case when a transform is set on the painter by the user, but for some reason it is not when high-dpi is enabled, triggering QTBUG-111796. An attempt was made at fixing this by drawing the untransformed glyphs into the cache and then transforming them as they were put on the screen. This worked with Qt Quick, but the raster engine does not support this and instead falls back to QPainterPath rendering in that case. So b492582b9c4cf679109ed4875aff912e186263cb caused a regression and was reverted. A simpler fix which works for both Qt Quick and QPainter is to draw the pre-transformed image of the glyph into the cache for 24-bit AA, same as for 8-bit AA. In addition, this changes the transformation to nearest neighbor instead of interpolating, because bitmap fonts are typically intended to look crisp and it also matches how native rendered fonts are scaled in Qt Quick. Fixes: QTBUG-111796 Change-Id: I2d9fd9d98d32820e677916c3d1c744331a72175b Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> (cherry picked from commit b6247ced7e83af4d51ba20be8068f28cc8c006bc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
60065cc08e
commit
3a0e4b6147
@ -2095,7 +2095,7 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g,
|
||||
|
||||
QImage img = alphaMapFromGlyphData(glyph, neededFormat);
|
||||
if (needsImageTransform)
|
||||
img = img.transformed(t, Qt::SmoothTransformation);
|
||||
img = img.transformed(t, Qt::FastTransformation);
|
||||
else
|
||||
img = img.copy();
|
||||
|
||||
@ -2112,12 +2112,19 @@ QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g,
|
||||
if (t.type() > QTransform::TxRotate)
|
||||
return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, t);
|
||||
|
||||
const bool needsImageTransform = !FT_IS_SCALABLE(freetype->face)
|
||||
&& t.type() > QTransform::TxTranslate;
|
||||
|
||||
|
||||
const GlyphFormat neededFormat = Format_A32;
|
||||
|
||||
Glyph *glyph = loadGlyphFor(g, subPixelPosition, neededFormat, t, false, true);
|
||||
|
||||
QImage img = alphaMapFromGlyphData(glyph, neededFormat);
|
||||
img = img.copy();
|
||||
if (needsImageTransform)
|
||||
img = img.transformed(t, Qt::FastTransformation);
|
||||
else
|
||||
img = img.copy();
|
||||
|
||||
if (!cacheEnabled && glyph != &emptyGlyph)
|
||||
delete glyph;
|
||||
|
Loading…
x
Reference in New Issue
Block a user