diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> | 2016-02-22 16:17:10 +0100 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2016-02-24 09:01:29 +0000 |
commit | 63b5f5cb98fe19af5bf20d4f581723cb91a46dcb (patch) | |
tree | b0bdd524f154d7963e487c4944822fe61c5881d9 /src/gui/text | |
parent | bf44f002ca0caa789e1f6316598bf7cd7fe19ae5 (diff) |
Disable ligatures using existing mechanism in HB, not workaround
This is a partial revert of fef629cd9191bb73f22c5efb6f943e6b672953c1.
When doing the original fix, I didn't realize that there was a
mechanism for disabling specific OpenType features in Harfbuzz.
This commit reverts the hack to disable GSUB completely and disables
the ligature features instead.
Task-number: QTBUG-44393
Change-Id: I30f0080eb3897f37219df7f2d50843f3a4556e13
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r-- | src/gui/text/qharfbuzzng.cpp | 15 | ||||
-rw-r--r-- | src/gui/text/qharfbuzzng_p.h | 3 | ||||
-rw-r--r-- | src/gui/text/qtextengine.cpp | 19 |
3 files changed, 12 insertions, 25 deletions
diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index 6437465da8..b2edfc00a0 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -573,27 +573,17 @@ _hb_qt_font_get_glyph_from_name(hb_font_t * /*font*/, void * /*font_data*/, static hb_user_data_key_t _useDesignMetricsKey; -static hb_user_data_key_t _ignoreGSUB; void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value) { hb_font_set_user_data(font, &_useDesignMetricsKey, (void *)quintptr(value), NULL, true); } -void hb_qt_face_set_ignore_gsub(hb_face_t *face, uint value) -{ - hb_face_set_user_data(face, &_ignoreGSUB, (void *)quintptr(value), NULL, true); -} - uint hb_qt_font_get_use_design_metrics(hb_font_t *font) { return quintptr(hb_font_get_user_data(font, &_useDesignMetricsKey)); } -uint hb_qt_face_get_ignore_gsub(hb_face_t *face) -{ - return quintptr(hb_face_get_user_data(face, &_ignoreGSUB)); -} struct _hb_qt_font_funcs_t { _hb_qt_font_funcs_t() @@ -628,14 +618,11 @@ hb_font_funcs_t *hb_qt_get_font_funcs() static hb_blob_t * -_hb_qt_reference_table(hb_face_t *face, hb_tag_t tag, void *user_data) +_hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data) { QFontEngine::FaceData *data = static_cast<QFontEngine::FaceData *>(user_data); Q_ASSERT(data); - if (hb_qt_face_get_ignore_gsub(face) && tag == HB_TAG('G','S','U','B')) - return hb_blob_get_empty(); - qt_get_font_table_func_t get_font_table = data->get_font_table; Q_ASSERT(get_font_table); diff --git a/src/gui/text/qharfbuzzng_p.h b/src/gui/text/qharfbuzzng_p.h index 8beadbc72c..d5e11e6264 100644 --- a/src/gui/text/qharfbuzzng_p.h +++ b/src/gui/text/qharfbuzzng_p.h @@ -72,9 +72,6 @@ Q_GUI_EXPORT hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe); Q_GUI_EXPORT void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value); Q_GUI_EXPORT uint hb_qt_font_get_use_design_metrics(hb_font_t *font); -Q_GUI_EXPORT void hb_qt_face_set_ignore_gsub(hb_face_t *font, uint value); -Q_GUI_EXPORT uint hb_qt_face_get_ignore_gsub(hb_face_t *font); - QT_END_NAMESPACE #endif // QHARFBUZZNG_P_H diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 7dc8e8fadb..c545240c57 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1175,16 +1175,19 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, Q_ASSERT(hb_font); hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ### + // Ligatures are incompatible with custom letter spacing, so when a letter spacing is set, + // we disable them for writing systems where they are purely cosmetic. bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala) || script == QChar::Script_Khmer || script == QChar::Script_Nko); - hb_face_t *hb_face = hb_font_get_face(hb_font); - Q_ASSERT(hb_face); - hb_qt_face_set_ignore_gsub(hb_face, hasLetterSpacing && !scriptRequiresOpenType); - - const hb_feature_t features[1] = { - { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) } - }; - const int num_features = 1; + + bool dontLigate = hasLetterSpacing && !scriptRequiresOpenType; + const hb_feature_t features[5] = { + { HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) }, + { HB_TAG('l','i','g','a'), !dontLigate, 0, uint(-1) }, + { HB_TAG('c','l','i','g'), !dontLigate, 0, uint(-1) }, + { HB_TAG('d','l','i','g'), !dontLigate, 0, uint(-1) }, + { HB_TAG('h','l','i','g'), !dontLigate, 0, uint(-1) } }; + const int num_features = dontLigate ? 5 : 1; const char *const *shaper_list = Q_NULLPTR; #if defined(Q_OS_DARWIN) |