From e3d01840656a07f17549864da163b67094c03c0e Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Wed, 18 Mar 2020 05:36:49 +0300 Subject: Follow bundled Harfbuzz update as we raised the minimum requirement for harfbuzz to version 2.6.0: * use new HB_SCRIPT values instead of tags * get rid of deprecated (and no-more-used) callbacks * replace deprecated hb_ot_tags_from_script() usage with a more flexible and up-to-date hb_ot_tags_from_script_and_language() Change-Id: I0eafdd2d2028c353fa3a93f5868efceccd364a70 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine.cpp | 21 +++++++-------- src/gui/text/qharfbuzzng.cpp | 63 +++++++++++++------------------------------- src/gui/text/qtextengine.cpp | 11 ++++---- 3 files changed, 33 insertions(+), 62 deletions(-) diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 126c085521..70cc20cbe6 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -232,20 +232,17 @@ bool QFontEngine::supportsScript(QChar::Script script) const if (getSfntTableData(MAKE_TAG('m','o','r','t'), 0, &len) || getSfntTableData(MAKE_TAG('m','o','r','x'), 0, &len)) return true; - bool ret = false; if (hb_face_t *face = hb_qt_face_get_for_engine(const_cast(this))) { - hb_tag_t script_tag_1, script_tag_2; - hb_ot_tags_from_script(hb_qt_script_to_script(script), &script_tag_1, &script_tag_2); - - unsigned int script_index; - ret = hb_ot_layout_table_find_script(face, HB_OT_TAG_GSUB, script_tag_1, &script_index); - if (!ret) { - ret = hb_ot_layout_table_find_script(face, HB_OT_TAG_GSUB, script_tag_2, &script_index); - if (!ret && script_tag_2 != HB_OT_TAG_DEFAULT_SCRIPT) - ret = hb_ot_layout_table_find_script(face, HB_OT_TAG_GSUB, HB_OT_TAG_DEFAULT_SCRIPT, &script_index); - } + unsigned int script_count = HB_OT_MAX_TAGS_PER_SCRIPT; + hb_tag_t script_tags[HB_OT_MAX_TAGS_PER_SCRIPT]; + + hb_ot_tags_from_script_and_language(hb_qt_script_to_script(script), HB_LANGUAGE_INVALID, + &script_count, script_tags, + nullptr, nullptr); + + if (hb_ot_layout_table_select_script(face, HB_OT_TAG_GSUB, script_count, script_tags, nullptr, nullptr)) + return true; } - return ret; } #endif return false; diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp index d802d1d58f..0ee44192b1 100644 --- a/src/gui/text/qharfbuzzng.cpp +++ b/src/gui/text/qharfbuzzng.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Copyright (C) 2013 Konstantin Ritt ** Contact: https://www.qt.io/licensing/ ** @@ -82,7 +82,7 @@ static const hb_script_t _qtscript_to_hbscript[] = { HB_SCRIPT_HANGUL, HB_SCRIPT_ETHIOPIC, HB_SCRIPT_CHEROKEE, - HB_SCRIPT_CANADIAN_ABORIGINAL, + HB_SCRIPT_CANADIAN_SYLLABICS, HB_SCRIPT_OGHAM, HB_SCRIPT_RUNIC, HB_SCRIPT_KHMER, @@ -218,20 +218,22 @@ static const hb_script_t _qtscript_to_hbscript[] = { HB_SCRIPT_SOYOMBO, HB_SCRIPT_ZANABAZAR_SQUARE, - // Unicode 12.1 additions (not present in harfbuzz-ng 1.7.4) - hb_script_t(HB_TAG('D', 'o', 'g', 'r')), // Script_Dogra - hb_script_t(HB_TAG('G', 'o', 'n', 'g')), // Script_GunjalaGondi - hb_script_t(HB_TAG('R', 'o', 'h', 'g')), // Script_HanifiRohingya - hb_script_t(HB_TAG('M', 'a', 'k', 'a')), // Script_Makasar - hb_script_t(HB_TAG('M', 'e', 'd', 'f')), // Script_Medefaidrin - hb_script_t(HB_TAG('S', 'o', 'g', 'o')), // Script_OldSogdian - hb_script_t(HB_TAG('S', 'o', 'g', 'd')), // Script_Sogdian - hb_script_t(HB_TAG('E', 'l', 'y', 'm')), // Script_Elymaic - hb_script_t(HB_TAG('N', 'a', 'n', 'd')), // Script_Nandinagari - hb_script_t(HB_TAG('H', 'm', 'n', 'p')), // Script_NyiakengPuachueHmong - hb_script_t(HB_TAG('W', 'c', 'h', 'o')), // Script_Wancho - - // Unicode 13.0 additions (as above) + // Unicode 11.0 additions + HB_SCRIPT_DOGRA, + HB_SCRIPT_GUNJALA_GONDI, + HB_SCRIPT_HANIFI_ROHINGYA, + HB_SCRIPT_MAKASAR, + HB_SCRIPT_MEDEFAIDRIN, + HB_SCRIPT_OLD_SOGDIAN, + HB_SCRIPT_SOGDIAN, + + // Unicode 12.0 additions + HB_SCRIPT_ELYMAIC, + HB_SCRIPT_NANDINAGARI, + HB_SCRIPT_NYIAKENG_PUACHUE_HMONG, + HB_SCRIPT_WANCHO, + + // Unicode 13.0 additions (not present in harfbuzz-ng 2.6.4) hb_script_t(HB_TAG('C', 'h', 'o', 'r')), // Script_Chorasmian hb_script_t(HB_TAG('D', 'i', 'v', 'e')), // Script_DivesAkuru hb_script_t(HB_TAG('K', 'h', 'i', 't')), // Script_KhitanSmallScript @@ -261,15 +263,6 @@ _hb_qt_unicode_combining_class(hb_unicode_funcs_t * /*ufuncs*/, return hb_unicode_combining_class_t(QChar::combiningClass(unicode)); } -static unsigned int -_hb_qt_unicode_eastasian_width(hb_unicode_funcs_t * /*ufuncs*/, - hb_codepoint_t /*unicode*/, - void * /*user_data*/) -{ - qCritical("hb_qt_unicode_eastasian_width: not implemented!"); - return 1; -} - static const hb_unicode_general_category_t _qtcategory_to_hbcategory[] = { HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK, // Mn HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK, // Mc @@ -405,37 +398,17 @@ _hb_qt_unicode_decompose(hb_unicode_funcs_t * /*ufuncs*/, return true; } -static unsigned int -_hb_qt_unicode_decompose_compatibility(hb_unicode_funcs_t * /*ufuncs*/, - hb_codepoint_t u, - hb_codepoint_t *decomposed, - void * /*user_data*/) -{ - const QString normalized = QChar::decomposition(u); - - uint outlen = 0; - QStringIterator it(normalized); - while (it.hasNext()) { - Q_ASSERT(outlen < HB_UNICODE_MAX_DECOMPOSITION_LEN); - decomposed[outlen++] = it.next(); - } - - return outlen; -} - struct _hb_unicode_funcs_t { _hb_unicode_funcs_t() { funcs = hb_unicode_funcs_create(NULL); hb_unicode_funcs_set_combining_class_func(funcs, _hb_qt_unicode_combining_class, NULL, NULL); - hb_unicode_funcs_set_eastasian_width_func(funcs, _hb_qt_unicode_eastasian_width, NULL, NULL); hb_unicode_funcs_set_general_category_func(funcs, _hb_qt_unicode_general_category, NULL, NULL); hb_unicode_funcs_set_mirroring_func(funcs, _hb_qt_unicode_mirroring, NULL, NULL); hb_unicode_funcs_set_script_func(funcs, _hb_qt_unicode_script, NULL, NULL); hb_unicode_funcs_set_compose_func(funcs, _hb_qt_unicode_compose, NULL, NULL); hb_unicode_funcs_set_decompose_func(funcs, _hb_qt_unicode_decompose, NULL, NULL); - hb_unicode_funcs_set_decompose_compatibility_func(funcs, _hb_qt_unicode_decompose_compatibility, NULL, NULL); } ~_hb_unicode_funcs_t() { diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 81fc9db9c7..990dfa2537 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1665,11 +1665,12 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, 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) } }; + { HB_TAG('k','e','r','n'), !!kerningEnabled, HB_FEATURE_GLOBAL_START, HB_FEATURE_GLOBAL_END }, + { HB_TAG('l','i','g','a'), false, HB_FEATURE_GLOBAL_START, HB_FEATURE_GLOBAL_END }, + { HB_TAG('c','l','i','g'), false, HB_FEATURE_GLOBAL_START, HB_FEATURE_GLOBAL_END }, + { HB_TAG('d','l','i','g'), false, HB_FEATURE_GLOBAL_START, HB_FEATURE_GLOBAL_END }, + { HB_TAG('h','l','i','g'), false, HB_FEATURE_GLOBAL_START, HB_FEATURE_GLOBAL_END } + }; const int num_features = dontLigate ? 5 : 1; // whitelist cross-platforms shapers only -- cgit v1.2.3