From f1f9705f93f67d3cb1e2c4cb370dfedecac33513 Mon Sep 17 00:00:00 2001 From: Nikolaus Waxweiler Date: Fri, 15 Jan 2021 23:52:04 +0000 Subject: [PATCH] [afshaper] Fix hb_ot_tags_from_script deprecation warning. * autofit/afshaper.c (af_shaper_get_coverage): Copy the source code of the function as suggested in https://github.com/harfbuzz/harfbuzz/issues/2737 and adjust to handle at most three tags. --- ChangeLog | 9 +++++++++ src/autofit/afshaper.c | 26 +++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d49a9f3d..6faa683a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2021-01-15 Nikolaus Waxweiler + + [afshaper] Fix hb_ot_tags_from_script deprecation warning. + + * autofit/afshaper.c (af_shaper_get_coverage): Copy the source code + of the function as suggested in + https://github.com/harfbuzz/harfbuzz/issues/2737 and adjust to handle + at most three tags. + 2021-01-17 Werner Lemberg * src/tools/update-copyright-year: Fix single-year entry handling. diff --git a/src/autofit/afshaper.c b/src/autofit/afshaper.c index 5625a8ba4..5d078937e 100644 --- a/src/autofit/afshaper.c +++ b/src/autofit/afshaper.c @@ -132,13 +132,24 @@ /* Convert a HarfBuzz script tag into the corresponding OpenType */ /* tag or tags -- some Indic scripts like Devanagari have an old */ /* and a new set of features. */ - hb_ot_tags_from_script( script, - &script_tags[0], - &script_tags[1] ); + { + unsigned int tags_count = 3; + hb_tag_t tags[3]; - /* `hb_ot_tags_from_script' usually returns HB_OT_TAG_DEFAULT_SCRIPT */ - /* as the second tag. We change that to HB_TAG_NONE except for the */ - /* default script. */ + + hb_ot_tags_from_script_and_language( script, + HB_LANGUAGE_INVALID, + &tags_count, + tags, + NULL, + NULL ); + script_tags[0] = tags_count > 0 ? tags[0] : HB_TAG_NONE; + script_tags[1] = tags_count > 1 ? tags[1] : HB_TAG_NONE; + script_tags[2] = tags_count > 2 ? tags[2] : HB_TAG_NONE; + } + + /* If the second tag is HB_OT_TAG_DEFAULT_SCRIPT, change that to */ + /* HB_TAG_NONE except for the default script. */ if ( default_script ) { if ( script_tags[0] == HB_TAG_NONE ) @@ -157,9 +168,6 @@ /* HarfBuzz maps them to `DFLT', which we don't want to handle here */ if ( script_tags[0] == HB_OT_TAG_DEFAULT_SCRIPT ) goto Exit; - - if ( script_tags[1] == HB_OT_TAG_DEFAULT_SCRIPT ) - script_tags[1] = HB_TAG_NONE; } gsub_lookups = hb_set_create();