From c47a31fb4793b825f4be57e9cb1b10db352b9512 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 30 Jul 2011 20:57:01 -0400 Subject: [PATCH] [OT] Save chosen script tag --- src/hb-ot-layout.cc | 20 ++++++++++++++++---- src/hb-ot-layout.h | 3 ++- src/hb-ot-map-private.hh | 1 + src/hb-ot-map.cc | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 5e2d6ac19..e7a1f9899 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -264,27 +264,39 @@ hb_bool_t hb_ot_layout_table_choose_script (hb_face_t *face, hb_tag_t table_tag, const hb_tag_t *script_tags, - unsigned int *script_index) + unsigned int *script_index, + hb_tag_t *chosen_script) { ASSERT_STATIC (Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX); const GSUBGPOS &g = get_gsubgpos_table (face, table_tag); while (*script_tags) { - if (g.find_script_index (*script_tags, script_index)) + if (g.find_script_index (*script_tags, script_index)) { + if (chosen_script) + *chosen_script = *script_tags; return TRUE; + } script_tags++; } /* try finding 'DFLT' */ - if (g.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, script_index)) + if (g.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, script_index)) { + if (chosen_script) + *chosen_script = HB_OT_TAG_DEFAULT_SCRIPT; return FALSE; + } /* try with 'dflt'; MS site has had typos and many fonts use it now :( */ - if (g.find_script_index (HB_OT_TAG_DEFAULT_LANGUAGE, script_index)) + if (g.find_script_index (HB_OT_TAG_DEFAULT_LANGUAGE, script_index)) { + if (chosen_script) + *chosen_script = HB_OT_TAG_DEFAULT_LANGUAGE; return FALSE; + } if (script_index) *script_index = HB_OT_LAYOUT_NO_SCRIPT_INDEX; + if (chosen_script) + *chosen_script = HB_OT_LAYOUT_NO_SCRIPT_INDEX; return FALSE; } diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h index 632043710..447e35dbf 100644 --- a/src/hb-ot-layout.h +++ b/src/hb-ot-layout.h @@ -92,7 +92,8 @@ hb_bool_t hb_ot_layout_table_choose_script (hb_face_t *face, hb_tag_t table_tag, const hb_tag_t *script_tags, - unsigned int *script_index); + unsigned int *script_index, + hb_tag_t *chosen_script); unsigned int hb_ot_layout_table_get_feature_tags (hb_face_t *face, diff --git a/src/hb-ot-map-private.hh b/src/hb-ot-map-private.hh index 84b4ccf9c..2327e04f5 100644 --- a/src/hb-ot-map-private.hh +++ b/src/hb-ot-map-private.hh @@ -123,6 +123,7 @@ struct hb_ot_map_t hb_mask_t global_mask; + hb_tag_t chosen_script[2]; hb_prealloced_array_t features; hb_prealloced_array_t lookups[2]; /* GSUB/GPOS */ hb_prealloced_array_t pauses[2]; /* GSUB/GPOS */ diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index 67035baf7..ad1290fbf 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -134,7 +134,7 @@ hb_ot_map_builder_t::compile (hb_face_t *face, unsigned int script_index[2], language_index[2]; for (unsigned int table_index = 0; table_index < 2; table_index++) { hb_tag_t table_tag = table_tags[table_index]; - hb_ot_layout_table_choose_script (face, table_tag, script_tags, &script_index[table_index]); + hb_ot_layout_table_choose_script (face, table_tag, script_tags, &script_index[table_index], &m.chosen_script[table_index]); hb_ot_layout_script_find_language (face, table_tag, script_index[table_index], language_tag, &language_index[table_index]); }