/** * pango_ot_ruleset_substitute: * @ruleset: a #PangoOTRuleset. * @buffer: a #PangoOTBuffer. * * Performs the OpenType GSUB substitution on @buffer using the features * in @ruleset * * Since: 1.4 **/ void pango_ot_ruleset_substitute (PangoOTRuleset *ruleset, PangoOTBuffer *buffer) { unsigned int i; HB_GSUB gsub = NULL; g_return_if_fail (PANGO_IS_OT_RULESET (ruleset)); g_return_if_fail (PANGO_IS_OT_INFO (ruleset->info)); for (i = 0; i < ruleset->rules->len; i++) { PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i); if (rule->table_type != PANGO_OT_TABLE_GSUB) continue; if (!gsub) { gsub = pango_ot_info_get_gsub (ruleset->info); if (gsub) HB_GSUB_Clear_Features (gsub); else return; } HB_GSUB_Add_Feature (gsub, rule->feature_index, rule->property_bit); } HB_GSUB_Apply_String (gsub, buffer->buffer); }
/** * pango_ot_ruleset_new: * @info: a #PangoOTInfo. * * Creates a new #PangoOTRuleset for the given OpenType info. * * Return value: the newly allocated #PangoOTRuleset, which * should be freed with g_object_unref(). **/ PangoOTRuleset * pango_ot_ruleset_new (PangoOTInfo *info) { PangoOTRuleset *ruleset; g_return_val_if_fail (PANGO_IS_OT_INFO (info), NULL); ruleset = g_object_new (PANGO_TYPE_OT_RULESET, NULL); ruleset->info = info; g_object_add_weak_pointer (G_OBJECT (ruleset->info), (gpointer *)(void*)&ruleset->info); return ruleset; }
/** * pango_ot_ruleset_add_feature: * @ruleset: a #PangoOTRuleset. * @table_type: the table type to add a feature to. * @feature_index: the index of the feature to add. * @property_bit: the property bit to use for this feature. Used to identify * the glyphs that this feature should be applied to, or * %PANGO_OT_ALL_GLYPHS if it should be applied to all glyphs. * * Adds a feature to the ruleset. **/ void pango_ot_ruleset_add_feature (PangoOTRuleset *ruleset, PangoOTTableType table_type, guint feature_index, gulong property_bit) { PangoOTRule tmp_rule; g_return_if_fail (PANGO_IS_OT_RULESET (ruleset)); g_return_if_fail (PANGO_IS_OT_INFO (ruleset->info)); tmp_rule.table_type = table_type; tmp_rule.feature_index = feature_index; tmp_rule.property_bit = property_bit; g_array_append_val (ruleset->rules, tmp_rule); }
/** * 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; }
/** * pango_ot_ruleset_position: * @ruleset: a #PangoOTRuleset. * @buffer: a #PangoOTBuffer. * * Performs the OpenType GPOS positionoing on @buffer using the features * in @ruleset * * Since: 1.4 **/ void pango_ot_ruleset_position (PangoOTRuleset *ruleset, PangoOTBuffer *buffer) { unsigned int i; HB_GPOS gpos = NULL; g_return_if_fail (PANGO_IS_OT_RULESET (ruleset)); g_return_if_fail (PANGO_IS_OT_INFO (ruleset->info)); for (i = 0; i < ruleset->rules->len; i++) { PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i); if (rule->table_type != PANGO_OT_TABLE_GPOS) continue; if (!gpos) { gpos = pango_ot_info_get_gpos (ruleset->info); if (gpos) HB_GPOS_Clear_Features (gpos); else return; } HB_GPOS_Add_Feature (gpos, rule->feature_index, rule->property_bit); } if (HB_GPOS_Apply_String (ruleset->info->face, gpos, 0, buffer->buffer, FALSE /* enable device-dependant values */, buffer->rtl) == FT_Err_Ok) buffer->applied_gpos = TRUE; }