diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2024-01-29 14:47:33 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2024-01-31 16:09:12 +0100 |
commit | b492582b9c4cf679109ed4875aff912e186263cb (patch) | |
tree | 219f1c75c9aec114cf1ea6b01af226779a5f9418 /src/gui/text | |
parent | 534e836b69b2f8c5f779b66b05c01bb00b9233f1 (diff) |
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>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/freetype/qfontengine_ft.cpp | 9 | ||||
-rw-r--r-- | 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); |