From b492582b9c4cf679109ed4875aff912e186263cb Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 29 Jan 2024 14:47:33 +0100 Subject: [PATCH] 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 Reviewed-by: Konstantin Ritt Reviewed-by: Qt CI Bot --- src/gui/text/freetype/qfontengine_ft.cpp | 9 +++++++-- src/gui/text/freetype/qfontengine_ft_p.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/gui/text/freetype/qfontengine_ft.cpp b/src/gui/text/freetype/qfontengine_ft.cpp index 3d41cfda0a..b567da1afe 100644 --- a/src/gui/text/freetype/qfontengine_ft.cpp +++ b/src/gui/text/freetype/qfontengine_ft.cpp @@ -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) diff --git a/src/gui/text/freetype/qfontengine_ft_p.h b/src/gui/text/freetype/qfontengine_ft_p.h index 9245a271ad..c8e5e20d37 100644 --- a/src/gui/text/freetype/qfontengine_ft_p.h +++ b/src/gui/text/freetype/qfontengine_ft_p.h @@ -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);