From 1bc4bad7a59e9d4d79d8faeb9e695df19aa494da Mon Sep 17 00:00:00 2001 From: Alexis King Date: Mon, 7 Feb 2022 19:57:25 -0600 Subject: [PATCH] =?UTF-8?q?[ot-tag]=20Add=20HB=5FSCRIPT=5FMATH=20(Zmth)=20?= =?UTF-8?q?and=20map=20it=20to=20OT=20=E2=80=98math=E2=80=99=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ISO 15924 code for mathematical notation is ‘Zmth’, but the OpenType script is ‘math’. --- docs/harfbuzz-sections.txt | 3 ++- src/hb-common.h | 6 ++++++ src/hb-ot-deprecated.h | 15 +++++++++++++++ src/hb-ot-math.h | 14 +++++++++----- src/hb-ot-tag.cc | 3 +++ test/api/test-ot-tag.c | 2 ++ 6 files changed, 37 insertions(+), 6 deletions(-) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index 9dda7ccd8..a114a6bff 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -191,6 +191,7 @@ HB_SCRIPT_CANADIAN_ABORIGINAL hb_font_funcs_set_glyph_func hb_font_get_glyph_func_t HB_MATH_GLYPH_PART_FLAG_EXTENDER +HB_OT_MATH_SCRIPT hb_ot_layout_table_choose_script hb_ot_layout_table_find_script hb_ot_tag_from_language @@ -542,7 +543,7 @@ hb_ot_layout_glyph_sequence_func_t
hb-ot-math HB_OT_TAG_MATH -HB_OT_MATH_SCRIPT +HB_OT_TAG_MATH_SCRIPT hb_ot_math_constant_t hb_ot_math_kern_t hb_ot_math_glyph_variant_t diff --git a/src/hb-common.h b/src/hb-common.h index 0384117a4..b0c688ce7 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -481,6 +481,7 @@ hb_language_get_default (void); * @HB_SCRIPT_TANGSA: `Tnsa`, Since: 3.0.0 * @HB_SCRIPT_TOTO: `Toto`, Since: 3.0.0 * @HB_SCRIPT_VITHKUQI: `Vith`, Since: 3.0.0 + * @HB_SCRIPT_MATH: `Zmth`, Since: REPLACEME * @HB_SCRIPT_INVALID: No script set * * Data type for scripts. Each #hb_script_t's value is an #hb_tag_t corresponding @@ -697,6 +698,11 @@ typedef enum HB_SCRIPT_TOTO = HB_TAG ('T','o','t','o'), /*14.0*/ HB_SCRIPT_VITHKUQI = HB_TAG ('V','i','t','h'), /*14.0*/ + /* + * Since REPLACEME + */ + HB_SCRIPT_MATH = HB_TAG ('Z','m','t','h'), + /* No script set. */ HB_SCRIPT_INVALID = HB_TAG_NONE, diff --git a/src/hb-ot-deprecated.h b/src/hb-ot-deprecated.h index ce6b6fef1..f01075795 100644 --- a/src/hb-ot-deprecated.h +++ b/src/hb-ot-deprecated.h @@ -50,6 +50,21 @@ HB_BEGIN_DECLS */ #define HB_MATH_GLYPH_PART_FLAG_EXTENDER HB_OT_MATH_GLYPH_PART_FLAG_EXTENDER +/* https://github.com/harfbuzz/harfbuzz/pull/3417 */ +/** + * HB_OT_MATH_SCRIPT: + * + * Use #HB_SCRIPT_MATH or #HB_OT_TAG_MATH_SCRIPT instead. + * + * Previous versions of this documentation recommended passing + * #HB_OT_MATH_SCRIPT to hb_buffer_set_script() to enable math shaping, but this + * usage is no longer supported. Use #HB_SCRIPT_MATH instead. + * + * Since: 1.3.3 + * Deprecated: REPLACEME + */ +#define HB_OT_MATH_SCRIPT HB_OT_TAG_MATH_SCRIPT + /* Like hb_ot_layout_table_find_script, but takes zero-terminated array of scripts to test */ HB_EXTERN HB_DEPRECATED_FOR (hb_ot_layout_table_select_script) hb_bool_t diff --git a/src/hb-ot-math.h b/src/hb-ot-math.h index d3ffa19d8..d4ea517e4 100644 --- a/src/hb-ot-math.h +++ b/src/hb-ot-math.h @@ -50,14 +50,18 @@ HB_BEGIN_DECLS #define HB_OT_TAG_MATH HB_TAG('M','A','T','H') /** - * HB_OT_MATH_SCRIPT: + * HB_OT_TAG_MATH_SCRIPT: * - * OpenType script tag for math shaping, for use with - * Use with hb_buffer_set_script(). + * OpenType script tag, `math`, for features specific to math shaping. * - * Since: 1.3.3 + * #HB_OT_TAG_MATH_SCRIPT is not a valid #hb_script_t and should only be + * used with functions that accept raw OpenType script tags, such as + * #hb_ot_layout_collect_features. In other cases, #HB_SCRIPT_MATH should be + * used instead. + * + * Since: REPLACEME */ -#define HB_OT_MATH_SCRIPT HB_TAG('m','a','t','h') +#define HB_OT_TAG_MATH_SCRIPT HB_TAG('m','a','t','h') /* Types */ diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc index 1837063af..f50be97ad 100644 --- a/src/hb-ot-tag.cc +++ b/src/hb-ot-tag.cc @@ -41,6 +41,7 @@ hb_ot_old_tag_from_script (hb_script_t script) switch ((hb_tag_t) script) { case HB_SCRIPT_INVALID: return HB_OT_TAG_DEFAULT_SCRIPT; + case HB_SCRIPT_MATH: return HB_OT_TAG_MATH_SCRIPT; /* KATAKANA and HIRAGANA both map to 'kana' */ case HB_SCRIPT_HIRAGANA: return HB_TAG('k','a','n','a'); @@ -63,6 +64,8 @@ hb_ot_old_tag_to_script (hb_tag_t tag) { if (unlikely (tag == HB_OT_TAG_DEFAULT_SCRIPT)) return HB_SCRIPT_INVALID; + if (unlikely (tag == HB_OT_TAG_MATH_SCRIPT)) + return HB_SCRIPT_MATH; /* This side of the conversion is fully algorithmic. */ diff --git a/test/api/test-ot-tag.c b/test/api/test-ot-tag.c index 75131ab7a..14928e0af 100644 --- a/test/api/test-ot-tag.c +++ b/test/api/test-ot-tag.c @@ -140,6 +140,8 @@ test_ot_tag_script_simple (void) test_simple_tags ("kana", HB_SCRIPT_KATAKANA); test_simple_tags ("latn", HB_SCRIPT_LATIN); + test_simple_tags ("math", HB_SCRIPT_MATH); + /* These are trickier since their OT script tags have space. */ test_simple_tags ("lao ", HB_SCRIPT_LAO); test_simple_tags ("yi ", HB_SCRIPT_YI);