hb_tag_t getIndFeature(XeTeXFont font, hb_tag_t script, hb_tag_t language, unsigned int index) { hb_tag_t rval = 0; hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->getHbFont()); for (int i = 0; i < 2; ++i) { unsigned int scriptIndex, langIndex = 0; hb_tag_t tableTag = i == 0 ? HB_OT_TAG_GSUB : HB_OT_TAG_GPOS; if (hb_ot_layout_table_find_script(face, tableTag, script, &scriptIndex)) { if (hb_ot_layout_script_find_language(face, tableTag, scriptIndex, language, &langIndex) || language == 0) { unsigned int featCount = hb_ot_layout_language_get_feature_tags(face, tableTag, scriptIndex, langIndex, 0, NULL, NULL); hb_tag_t* featList = (hb_tag_t*) xcalloc(featCount, sizeof(hb_tag_t*)); hb_ot_layout_language_get_feature_tags(face, tableTag, scriptIndex, langIndex, 0, &featCount, featList); if (index < featCount) { rval = featList[index]; break; } index -= featCount; } } } return rval; }
static void _hb_ot_layout_collect_lookups_languages (hb_face_t *face, hb_tag_t table_tag, unsigned int script_index, const hb_tag_t *languages, const hb_tag_t *features, hb_set_t *lookup_indexes /* OUT */) { _hb_ot_layout_collect_lookups_features (face, table_tag, script_index, HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX, features, lookup_indexes); if (!languages) { /* All languages */ unsigned int count = hb_ot_layout_script_get_language_tags (face, table_tag, script_index, 0, NULL, NULL); for (unsigned int language_index = 0; language_index < count; language_index++) _hb_ot_layout_collect_lookups_features (face, table_tag, script_index, language_index, features, lookup_indexes); } else { for (; *languages; languages++) { unsigned int language_index; if (hb_ot_layout_script_find_language (face, table_tag, script_index, *languages, &language_index)) _hb_ot_layout_collect_lookups_features (face, table_tag, script_index, language_index, features, lookup_indexes); } } }
unsigned int countFeatures(XeTeXFont font, hb_tag_t script, hb_tag_t language) { unsigned int rval = 0; hb_face_t* face = hb_font_get_face(((XeTeXFontInst*)font)->getHbFont()); for (int i = 0; i < 2; ++i) { unsigned int scriptIndex, langIndex = 0; hb_tag_t tableTag = i == 0 ? HB_OT_TAG_GSUB : HB_OT_TAG_GPOS; if (hb_ot_layout_table_find_script(face, tableTag, script, &scriptIndex)) { if (hb_ot_layout_script_find_language(face, tableTag, scriptIndex, language, &langIndex) || language == 0) { rval += hb_ot_layout_language_get_feature_tags(face, tableTag, scriptIndex, langIndex, 0, NULL, NULL); } } } return rval; }