From c35795b413c6aedd6b02f03fdcaa5fb4888084d5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 22 Mar 2016 14:16:23 -0700 Subject: QFontEngine: Add handle() function Both QFont::handle() and QFont::freetypeFace() used to be available in Qt 4 but were removed in Qt 5. There's currently no API to get access to the native font handle, which the font engine holds in a way or another. Similar to the way it was in Qt 4, the actual handle type depends on the font engine currently in use. The types map as follows: Font Engine Native Handle ------------------------------------ DirectWrite IDWriteFontFace * Freetype FT_Face Mac CTFontRef Win HFONT All other font engines return a null handle. Change-Id: I3bea8259ac1378fd24079723aa6603bf9e74834c Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_ft.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gui/text/qfontengine_ft.cpp') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 8fbeff3596..ebfd2a8182 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -2005,6 +2005,11 @@ QFontEngine *QFontEngineFT::cloneWithSize(qreal pixelSize) const } } +Qt::HANDLE QFontEngineFT::handle() const +{ + return non_locked_face(); +} + QT_END_NAMESPACE #endif // QT_NO_FREETYPE -- cgit v1.2.3 From adc4e000fc1ffe1acba47ff932c092678a54b9f2 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Fri, 22 Jan 2016 14:56:18 +0300 Subject: QFontEngineFT: Apply hinting for non-scaled rotated glyphs Scaled hinted glyphs looks ugly, see QTBUG-24846. It was fixed in 6da6845f078e419ccb555fe1dd152e0ba82a7e88 by disabling hinting for them. But at the same time that commit also disabled hinting for glyphs with the most common transformation - rotating without scaling. Detect this type of transformation and don't disable hinting for it. Change-Id: I0e69a2b60e7e4bc24e9efc4fdedb984df07ad15c Task-number: QTBUG-50574 Reviewed-by: Friedemann Kleint Reviewed-by: Konstantin Ritt Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_ft.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gui/text/qfontengine_ft.cpp') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index ebfd2a8182..361702681f 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1780,6 +1780,12 @@ void QFontEngineFT::unlockAlphaMapForGlyph() QFontEngine::unlockAlphaMapForGlyph(); } +static inline bool is2dRotation(const QTransform &t) +{ + return qFuzzyCompare(t.m11(), t.m22()) && qFuzzyCompare(t.m12(), -t.m21()) + && qFuzzyCompare(t.m11()*t.m22() - t.m12()*t.m21(), 1.0); +} + QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g, QFixed subPixelPosition, GlyphFormat format, @@ -1793,7 +1799,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphFor(glyph_t g, Glyph *glyph = glyphSet != 0 ? glyphSet->getGlyph(g, subPixelPosition) : 0; if (!glyph || glyph->format != format || (!fetchBoundingBox && !glyph->data)) { QScopedValueRollback saved_default_hint_style(default_hint_style); - if (t.type() >= QTransform::TxScale) + if (t.type() >= QTransform::TxScale && !is2dRotation(t)) default_hint_style = HintNone; // disable hinting if the glyphs are transformed lockFace(); -- cgit v1.2.3