freetype: Fix scaling layouts with bitmap fonts

The FreeType font engine would wrongly claim to support scaling
transforms for bitmap fonts, despite ignoring the transform
later. We do support this for color fonts through special casing,
but for other bitmap fonts, we should return false and let the
paint engine handle the scaling instead.

Fixes: QTBUG-111796
Change-Id: I31732b909ef6e0c1afbf01ed4de1f67e994934c3
Reviewed-by: Lars Knoll <lars@knoll.priv.no>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
bb10
Eskil Abrahamsen Blomfeldt 2024-01-29 14:47:33 +01:00
parent 534e836b69
commit b492582b9c
2 changed files with 8 additions and 2 deletions

View File

@ -190,10 +190,15 @@ int QFreetypeFace::getPointInOutline(glyph_t glyph, int flags, quint32 point, QF
return Err_Ok;
}
bool QFreetypeFace::isScalable() const
{
return FT_IS_SCALABLE(face);
}
bool QFreetypeFace::isScalableBitmap() const
{
#ifdef FT_HAS_COLOR
return !FT_IS_SCALABLE(face) && FT_HAS_COLOR(face);
return !isScalable() && FT_HAS_COLOR(face);
#else
return false;
#endif
@ -1592,7 +1597,7 @@ void QFontEngineFT::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_me
bool QFontEngineFT::supportsTransformation(const QTransform &transform) const
{
return transform.type() <= QTransform::TxRotate;
return transform.type() <= QTransform::TxRotate && (freetype->isScalable() || freetype->isScalableBitmap());
}
void QFontEngineFT::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags)

View File

@ -77,6 +77,7 @@ public:
int getPointInOutline(glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints);
bool isScalable() const;
bool isScalableBitmap() const;
static void addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoint &point, QPainterPath *path, FT_Fixed x_scale, FT_Fixed y_scale);