diff options
author | Mathias Hasselmann <mathias.hasselmann@kdab.com> | 2014-11-07 22:22:10 +0100 |
---|---|---|
committer | Andreas Hartmetz <ahartmetz@gmail.com> | 2015-08-11 09:40:30 +0000 |
commit | bf013c9e745c63cb112be4d3a37027ff997927dd (patch) | |
tree | e692a93ec24e8a2e4b3be81e971dcad3a234dca9 /src/gui/text/qtextengine.cpp | |
parent | 55512950281260b85ea40c08239e459c76b696d2 (diff) |
OSX: Add initial FreeType support
This permits text rendering consistent with other FreeType enabled platforms,
like Windows and Linux.
Task-number: QTBUG-42839
Change-Id: I8c99bcaa3fb07c16e935a0c3705af467bc3da584
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/gui/text/qtextengine.cpp')
-rw-r--r-- | src/gui/text/qtextengine.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index d2174c5e06..6b98c14205 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1120,6 +1120,15 @@ QT_BEGIN_INCLUDE_NAMESPACE QT_END_INCLUDE_NAMESPACE +#if defined(Q_OS_OSX) && !defined(QT_NO_FREETYPE) +static const char *s_shapersForOsxFreeType[] = +{ + "ot", + "fallback", + Q_NULLPTR +}; +#endif + int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *string, int itemLength, QFontEngine *fontEngine, const QVector<uint> &itemBoundaries, bool kerningEnabled) const { uint glyphs_shaped = 0; @@ -1172,7 +1181,15 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st }; const int num_features = 1; - bool shapedOk = hb_shape_full(hb_font, buffer, features, num_features, 0); + const char *const *shaper_list = Q_NULLPTR; +#if defined(Q_OS_OSX) && !defined(QT_NO_FREETYPE) + // What's behind QFontEngine::FaceData::user_data isn't compatible between CoreText and + // FreeType font engines - specifically functions in hb-coretext.cc would run into undefined + // behavior with data from the FreeType engine. The OpenType shaper works with that engine. + if (actualFontEngine->type() == QFontEngine::Freetype) + shaper_list = s_shapersForOsxFreeType; +#endif + bool shapedOk = hb_shape_full(hb_font, buffer, features, num_features, shaper_list); if (Q_UNLIKELY(!shapedOk)) { hb_buffer_destroy(buffer); return 0; |