static PangoOTRuleset * get_ruleset (FT_Face face) { PangoOTRuleset *ruleset; static GQuark ruleset_quark = 0; PangoOTInfo *info = pango_ot_info_get (face); if (!ruleset_quark) ruleset_quark = g_quark_from_string ("pango-khmer-ruleset"); if (!info) return NULL; ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark); if (!ruleset) { PangoOTTag khmer_tag = FT_MAKE_TAG ('k', 'h', 'm', 'r'); guint script_index; ruleset = pango_ot_ruleset_new (info); if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB, khmer_tag, &script_index)) { maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','f'), pref); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','f'), blwf); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','f'), abvf); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','f'), pstf); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','s'), pres); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','s'), blws); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','s'), abvs); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','s'), psts); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('c','l','i','g'), clig); } if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS, khmer_tag, &script_index)) { maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('d','i','s','t'), dist); maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','m'), blwm); maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','m'), abvm); maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','k','m','k'), mkmk); } g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, (GDestroyNotify)g_object_unref); } return ruleset; }
static PangoOTRuleset * get_gpos_ruleset (FT_Face face, const PangoIndicInfo *indic_info) { PangoOTInfo *info = pango_ot_info_get (face); GQuark ruleset_quark = g_quark_from_string (indic_info->gposQuarkName); PangoOTRuleset *ruleset; if (!info) return NULL; ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark); if (!ruleset) { guint script_index; ruleset = pango_ot_ruleset_new (info); if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS, indic_info->scriptTag, &script_index)) { maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','m'), blwm); maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','m'), abvm); maybe_add_GPOS_feature (ruleset, info, script_index, FT_MAKE_TAG ('d','i','s','t'), dist); } g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, (GDestroyNotify)g_object_unref); } return ruleset; }
static PangoOTRuleset * get_gsub_ruleset (FT_Face face, const PangoIndicInfo *indic_info) { PangoOTInfo *info = pango_ot_info_get (face); GQuark ruleset_quark = g_quark_from_string (indic_info->gsubQuarkName); PangoOTRuleset *ruleset; if (!info) return NULL; ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark); if (!ruleset) { guint script_index; ruleset = pango_ot_ruleset_new (info); if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB, indic_info->scriptTag, &script_index)) { maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('i','n','i','t'), init); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('n','u','k','t'), nukt); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','k','h','n'), akhn); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('r','p','h','f'), rphf); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','f'), blwf); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('h','a','l','f'), half); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','f'), pstf); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('v','a','t','u'), vatu); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','r','e','s'), pres); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('b','l','w','s'), blws); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('a','b','v','s'), abvs); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('p','s','t','s'), psts); maybe_add_GSUB_feature (ruleset, info, script_index, FT_MAKE_TAG ('h','a','l','n'), haln); } g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, (GDestroyNotify)g_object_unref); } return ruleset; }
/** * pango_ot_ruleset_new_for: * @info: a #PangoOTInfo. * @script: a #PangoScript. * @language: a #PangoLanguage. * * Creates a new #PangoOTRuleset for the given OpenType info, script, and * language. * * This function is part of a convenience scheme that highly simplifies * using a #PangoOTRuleset to represent features for a specific pair of script * and language. So one can use this function passing in the script and * language of interest, and later try to add features to the ruleset by just * specifying the feature name or tag, without having to deal with finding * script, language, or feature indices manually. * * In excess to what pango_ot_ruleset_new() does, this function will: * <itemizedlist> * <listitem> * Find the #PangoOTTag script and language tags associated with * @script and @language using pango_ot_tag_from_script() and * pango_ot_tag_from_language(), * </listitem> * <listitem> * For each of table types %PANGO_OT_TABLE_GSUB and %PANGO_OT_TABLE_GPOS, * find the script index of the script tag found and the language * system index of the language tag found in that script system, using * pango_ot_info_find_script() and pango_ot_info_find_language(), * </listitem> * <listitem> * For found language-systems, if they have required feature * index, add that feature to the ruleset using * pango_ot_ruleset_add_feature(), * </listitem> * <listitem> * Remember found script and language indices for both table types, * and use them in future pango_ot_ruleset_maybe_add_feature() and * pango_ot_ruleset_maybe_add_features(). * </listitem> * </itemizedlist> * * Because of the way return values of pango_ot_info_find_script() and * pango_ot_info_find_language() are ignored, this function automatically * finds and uses the 'DFLT' script and the default language-system. * * Return value: the newly allocated #PangoOTRuleset, which * should be freed with g_object_unref(). * * Since: 1.18 **/ PangoOTRuleset * pango_ot_ruleset_new_for (PangoOTInfo *info, PangoScript script, PangoLanguage *language) { PangoOTRuleset *ruleset; PangoOTTag script_tag, language_tag; PangoOTTableType table_type; g_return_val_if_fail (PANGO_IS_OT_INFO (info), NULL); ruleset = pango_ot_ruleset_new (info); script_tag = pango_ot_tag_from_script (script); language_tag = pango_ot_tag_from_language (language); for (table_type = PANGO_OT_TABLE_GSUB; table_type <= PANGO_OT_TABLE_GPOS; table_type++) { guint script_index, language_index, feature_index; pango_ot_info_find_script (ruleset->info, table_type, script_tag, &script_index); pango_ot_info_find_language (ruleset->info, table_type, script_index, language_tag, &language_index, &feature_index); ruleset->script_index[table_type] = script_index; ruleset->language_index[table_type] = language_index; /* add required feature of the language */ pango_ot_ruleset_add_feature (ruleset, table_type, feature_index, PANGO_OT_ALL_GLYPHS); } return ruleset; }