diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2007-05-14 04:02:58 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2007-05-14 04:02:58 +0000 |
commit | 5268099b137dee60aacc04cbeb5051242c35b256 (patch) | |
tree | c974955ad45cabb06fd7166f7507c1ba8541e547 /pango | |
parent | 9f09571a932149e77ceeb7ccec8bd7bdea6aac4a (diff) | |
download | pango-5268099b137dee60aacc04cbeb5051242c35b256.tar.gz |
Part of Bug 325714 – Pango should respect $LANGUAGE
2007-05-13 Behdad Esfahbod <behdad@gnome.org>
Part of Bug 325714 – Pango should respect $LANGUAGE
* pango/pango-ot.h:
* pango/pango-ot-private.h:
* pango/pango-ot-tag.c (pango_ot_tag_from_script),
(pango_ot_tag_from_language):
* pango/pango-ot-info.c (pango_ot_info_find_script),
(pango_ot_info_find_language), (pango_ot_info_find_feature),
(pango_ot_info_list_languages), (pango_ot_info_list_features):
* pango/pango-ot-ruleset.c (pango_ot_ruleset_new),
(pango_ot_ruleset_new_for), (pango_ot_ruleset_add_feature),
(pango_ot_ruleset_maybe_add_feature),
(pango_ot_ruleset_maybe_add_features):
Add new engine API:
PANGO_OT_NO_FEATURE
PANGO_OT_NO_SCRIPT
PANGO_OT_TAG_DEFAULT_SCRIPT
PANGO_OT_TAG_DEFAULT_LANGUAGE
pango_ot_ruleset_new_for()
pango_ot_ruleset_maybe_add_feature()
pango_ot_ruleset_maybe_add_features()
Using pango_ot_ruleset_new_for() and
pango_ot_ruleset_maybe_add_features() drastically simplifies ruleset
building in modules, and does correct script and language selection
too. Modules need to be updated to use it though.
* docs/pango-docs.sgml:
* docs/pango-sections.txt:
* docs/tmpl/opentype.sgml:
Update.
svn path=/trunk/; revision=2284
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-ot-info.c | 119 | ||||
-rw-r--r-- | pango/pango-ot-private.h | 3 | ||||
-rw-r--r-- | pango/pango-ot-ruleset.c | 184 | ||||
-rw-r--r-- | pango/pango-ot-tag.c | 49 | ||||
-rw-r--r-- | pango/pango-ot.h | 36 |
5 files changed, 365 insertions, 26 deletions
diff --git a/pango/pango-ot-info.c b/pango/pango-ot-info.c index 5f3ff33f..75d14e2b 100644 --- a/pango/pango-ot-info.c +++ b/pango/pango-ot-info.c @@ -404,7 +404,15 @@ get_tables (PangoOTInfo *info, * @script_tag: the tag of the script to find. * @script_index: location to store the index of the script, or %NULL. * - * Finds the index of a script. + * Finds the index of a script. If not found, tries to find the 'DFLT' + * and then 'dflt' scripts and return the index of that in @script_index. + * If none of those is found either, %PANGO_OT_NO_SCRIPT is placed in + * @script_index. + * + * All other functions taking an input script_index parameter know + * how to handle %PANGO_OT_NO_SCRIPT, so one can ignore the return + * value of this function completely and proceed, to enjoy the automatic + * fallback to the 'DFLT'/'dflt' script. * * Return value: %TRUE if the script was found. **/ @@ -417,6 +425,9 @@ pango_ot_info_find_script (PangoOTInfo *info, HB_ScriptList *script_list; int i; + if (script_index) + *script_index = PANGO_OT_NO_SCRIPT; + g_return_val_if_fail (PANGO_IS_OT_INFO (info), FALSE); if (!get_tables (info, table_type, &script_list, NULL)) @@ -433,6 +444,34 @@ pango_ot_info_find_script (PangoOTInfo *info, } } + /* try finding 'DFLT' */ + script_tag = PANGO_OT_TAG_DEFAULT_SCRIPT; + + for (i=0; i < script_list->ScriptCount; i++) + { + if (script_list->ScriptRecord[i].ScriptTag == script_tag) + { + if (script_index) + *script_index = i; + + return FALSE; + } + } + + /* try with 'dflt'; MS site has had typos and many fonts use it now :( */ + script_tag = FT_MAKE_TAG ('d', 'f', 'l', 't'); + + for (i=0; i < script_list->ScriptCount; i++) + { + if (script_list->ScriptRecord[i].ScriptTag == script_tag) + { + if (script_index) + *script_index = i; + + return FALSE; + } + } + return FALSE; } @@ -447,6 +486,13 @@ pango_ot_info_find_script (PangoOTInfo *info, * the language, or %NULL. * * Finds the index of a language and its required feature index. + * If the language is not found, sets @language_index to + * PANGO_OT_DEFAULT_LANGUAGE and the required feature of the default language + * system is returned in required_feature_index. For best compatibility with + * some fonts, also searches the language system tag 'dflt' before falling + * back to the default language system, but that is transparent to the user. + * The user can simply ignore the return value of this function to + * automatically fall back to the default language system. * * Return value: %TRUE if the language was found. **/ @@ -462,8 +508,16 @@ pango_ot_info_find_language (PangoOTInfo *info, HB_Script *script; int i; + if (language_index) + *language_index = PANGO_OT_DEFAULT_LANGUAGE; + if (required_feature_index) + *required_feature_index = PANGO_OT_NO_FEATURE; + g_return_val_if_fail (PANGO_IS_OT_INFO (info), FALSE); + if (script_index == PANGO_OT_NO_SCRIPT) + return FALSE; + if (!get_tables (info, table_type, &script_list, NULL)) return FALSE; @@ -483,6 +537,27 @@ pango_ot_info_find_language (PangoOTInfo *info, } } + /* try with 'dflt'; MS site has had typos and many fonts use it now :( */ + language_tag = FT_MAKE_TAG ('d', 'f', 'l', 't'); + + for (i = 0; i < script->LangSysCount; i++) + { + if (script->LangSysRecord[i].LangSysTag == language_tag) + { + if (language_index) + *language_index = i; + if (required_feature_index) + *required_feature_index = script->LangSysRecord[i].LangSys.ReqFeatureIndex; + return FALSE; + } + } + + /* DefaultLangSys */ + if (language_index) + *language_index = PANGO_OT_DEFAULT_LANGUAGE; + if (required_feature_index) + *required_feature_index = script->DefaultLangSys.ReqFeatureIndex; + return FALSE; } @@ -496,7 +571,15 @@ pango_ot_info_find_language (PangoOTInfo *info, * or %PANGO_OT_DEFAULT_LANGUAGE to use the default language of the script. * @feature_index: location to store the index of the feature, or %NULL. * - * Finds the index of a feature. + * Finds the index of a feature. If the feature is not found, sets + * @feature_index to PANGO_OT_NO_FEATURE, which is safe to pass to + * pango_ot_ruleset_add_feature() and similar functions. + * + * In the future, this may set @feature_index to an special value that if used + * in pango_ot_ruleset_add_feature() will ask Pango to synthesize the + * requested feature based on Unicode properties and data. However, this + * function will still return %FALSE in those cases. So, users may want to + * ignore the return value of this function in certain cases. * * Return value: %TRUE if the feature was found. **/ @@ -515,8 +598,14 @@ pango_ot_info_find_feature (PangoOTInfo *info, int i; + if (feature_index) + *feature_index = PANGO_OT_NO_FEATURE; + g_return_val_if_fail (PANGO_IS_OT_INFO (info), FALSE); + if (script_index == PANGO_OT_NO_SCRIPT) + return FALSE; + if (!get_tables (info, table_type, &script_list, &feature_list)) return FALSE; @@ -555,8 +644,8 @@ pango_ot_info_find_feature (PangoOTInfo *info, * * Obtains the list of available scripts. * - * Return value: a newly-allocated array containing the tags of the - * available scripts. + * Return value: a newly-allocated zero-terminated array containing the tags of the + * available scripts that should be freed using g_free(). **/ PangoOTTag * pango_ot_info_list_scripts (PangoOTInfo *info, @@ -590,8 +679,8 @@ pango_ot_info_list_scripts (PangoOTInfo *info, * * Obtains the list of available languages for a given script. * - * Return value: a newly-allocated array containing the tags of the - * available languages. + * Return value: a newly-allocated zero-terminated array containing the tags of the + * available languages that should be freed using g_free(). **/ PangoOTTag * pango_ot_info_list_languages (PangoOTInfo *info, @@ -606,6 +695,13 @@ pango_ot_info_list_languages (PangoOTInfo *info, g_return_val_if_fail (PANGO_IS_OT_INFO (info), NULL); + if (script_index == PANGO_OT_NO_SCRIPT) + { + result = g_new (PangoOTTag, 1); + result[0] = 0; + return result; + } + if (!get_tables (info, table_type, &script_list, NULL)) return NULL; @@ -635,8 +731,8 @@ pango_ot_info_list_languages (PangoOTInfo *info, * * Obtains the list of features for the given language of the given script. * - * Return value: a newly-allocated array containing the tags of the - * available features. + * Return value: a newly-allocated zero-terminated array containing the tags of the + * available features that should be freed using g_free(). **/ PangoOTTag * pango_ot_info_list_features (PangoOTInfo *info, @@ -656,6 +752,13 @@ pango_ot_info_list_features (PangoOTInfo *info, g_return_val_if_fail (PANGO_IS_OT_INFO (info), NULL); + if (script_index == PANGO_OT_NO_SCRIPT) + { + result = g_new (PangoOTTag, 1); + result[0] = 0; + return result; + } + if (!get_tables (info, table_type, &script_list, &feature_list)) return NULL; diff --git a/pango/pango-ot-private.h b/pango/pango-ot-private.h index c301a56f..089c57c9 100644 --- a/pango/pango-ot-private.h +++ b/pango/pango-ot-private.h @@ -71,6 +71,9 @@ struct _PangoOTRuleset GArray *rules; PangoOTInfo *info; + + guint script_index[2]; + guint language_index[2]; }; struct _PangoOTRulesetClass diff --git a/pango/pango-ot-ruleset.c b/pango/pango-ot-ruleset.c index a54c87ef..75896f56 100644 --- a/pango/pango-ot-ruleset.c +++ b/pango/pango-ot-ruleset.c @@ -115,6 +115,94 @@ pango_ot_ruleset_new (PangoOTInfo *info) ruleset->info = info; g_object_add_weak_pointer (ruleset->info, &ruleset->info); + ruleset->script_index[0] = PANGO_OT_NO_SCRIPT; + ruleset->script_index[1] = PANGO_OT_NO_SCRIPT; + ruleset->language_index[0] = PANGO_OT_DEFAULT_LANGUAGE; + ruleset->language_index[1] = PANGO_OT_DEFAULT_LANGUAGE; + + 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 = pango_ot_ruleset_new (info); + PangoOTTag script_tag, language_tag; + PangoOTTableType table_type; + + 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; } @@ -140,6 +228,9 @@ pango_ot_ruleset_add_feature (PangoOTRuleset *ruleset, g_return_if_fail (PANGO_IS_OT_RULESET (ruleset)); g_return_if_fail (PANGO_IS_OT_INFO (ruleset->info)); + if (feature_index == PANGO_OT_NO_FEATURE) + return; + tmp_rule.table_type = table_type; tmp_rule.feature_index = feature_index; tmp_rule.property_bit = property_bit; @@ -148,6 +239,99 @@ pango_ot_ruleset_add_feature (PangoOTRuleset *ruleset, } /** + * pango_ot_ruleset_maybe_add_feature: + * @ruleset: a #PangoOTRuleset. + * @table_type: the table type to add a feature to. + * @feature_tag: the tag 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. + * + * This is a convenience function that first tries to find the feature + * using pango_ot_info_find_feature() and the ruleset script and language + * passed to pango_ot_ruleset_new_for(), + * and if the feature is found, adds it to the ruleset. + * + * If @ruleset was not created using pango_ot_ruleset_new_for(), this function + * does nothing. + * + * Return value: %TRUE if the feature was found and added to ruleset, + * %FALSE otherwise. + * + * Since: 1.18 + **/ +gboolean +pango_ot_ruleset_maybe_add_feature (PangoOTRuleset *ruleset, + PangoOTTableType table_type, + PangoOTTag feature_tag, + gulong property_bit) +{ + guint feature_index; + + g_return_val_if_fail (PANGO_IS_OT_RULESET (ruleset), FALSE); + g_return_val_if_fail (PANGO_IS_OT_INFO (ruleset->info), FALSE); + + pango_ot_info_find_feature (ruleset->info, table_type, + feature_tag, + ruleset->script_index[table_type], + ruleset->language_index[table_type], + &feature_index); + + if (feature_index != PANGO_OT_NO_FEATURE) + { + pango_ot_ruleset_add_feature (ruleset, table_type, + feature_index, property_bit); + return TRUE; + } + + return FALSE; +} + +/** + * pango_ot_ruleset_maybe_add_features: + * @ruleset: a #PangoOTRuleset. + * @table_type: the table type to add features to. + * @features: array of feature name and property bits to add. + * @n_features: number of feature records in @features array. + * + * This is a convenience function that + * for each feature in the feature map array @features + * converts the feature name to a #PangoOTTag feature tag using FT_MAKE_TAG() + * and calls pango_ot_ruleset_maybe_add_feature() on it. + * + * Return value: The number of features in @features that were found + * and added to @ruleset. + * + * Since: 1.18 + **/ +int +pango_ot_ruleset_maybe_add_features (PangoOTRuleset *ruleset, + PangoOTTableType table_type, + const PangoOTFeatureMap *features, + int n_features) +{ + int i, n_found_features = 0; + + g_return_val_if_fail (PANGO_IS_OT_RULESET (ruleset), 0); + g_return_val_if_fail (PANGO_IS_OT_INFO (ruleset->info), 0); + + for (i = 0; i < n_features; i++) + { + PangoOTTag feature_tag = FT_MAKE_TAG (features[i].feature_name[0], + features[i].feature_name[1], + features[i].feature_name[2], + features[i].feature_name[3]); + + n_found_features += pango_ot_ruleset_maybe_add_feature (ruleset, + table_type, + feature_tag, + features[i].property_bit); + } + + return n_found_features; +} + +/** * pango_ot_ruleset_substitute: * @ruleset: a #PangoOTRuleset. * @buffer: a #PangoOTBuffer. diff --git a/pango/pango-ot-tag.c b/pango/pango-ot-tag.c index c3d853d4..eb6a19d3 100644 --- a/pango/pango-ot-tag.c +++ b/pango/pango-ot-tag.c @@ -106,21 +106,21 @@ static const char ot_scripts[][4] = { * The %PANGO_SCRIPT_COMMON, %PANGO_SCRIPT_INHERITED, and * %PANGO_SCRIPT_UNKNOWN scripts are mapped to the OpenType * 'DFLT' script tag that is also defined as - * %PANGO_OT_DEFAULT_SCRIPT. + * %PANGO_OT_TAG_DEFAULT_SCRIPT. * * Note that multiple #PangoScript values may map to the same * OpenType script tag. In particular, %PANGO_SCRIPT_HIRAGANA * and %PANGO_SCRIPT_KATAKANA both map to the OT tag 'kana'. * * Return value: #PangoOTTag corresponding to @script or - * %PANGO_OT_DEFAULT_SCRIPT if none found. + * %PANGO_OT_TAG_DEFAULT_SCRIPT if none found. * * Since: 1.18 **/ PangoOTTag pango_ot_tag_from_script (PangoScript script) { - g_return_val_if_fail (script >= 0 && (guint)script < G_N_ELEMENTS (ot_scripts), PANGO_OT_DEFAULT_SCRIPT); + g_return_val_if_fail (script >= 0 && (guint)script < G_N_ELEMENTS (ot_scripts), PANGO_OT_TAG_DEFAULT_SCRIPT); return GUINT32_FROM_BE (* (PangoOTTag *) ot_scripts[script]); } @@ -189,7 +189,9 @@ static const LangTag ot_languages[] = { {"ay", "AYM "}, {"az", "AZE "}, {"ba", "BSH "}, + {"bal", "BLI "}, {"bem", "BEM "}, + {"ber", "BBR "}, {"bg", "BGR "}, {"bho", "BHO "}, {"bik", "BIK "}, @@ -198,6 +200,7 @@ static const LangTag ot_languages[] = { {"bn", "BEN "}, {"bo", "TIB "}, {"br", "BRE "}, + {"brh", "BRH "}, {"ca", "CAT "}, {"ce", "CHE "}, {"ceb", "CEB "}, @@ -212,18 +215,22 @@ static const LangTag ot_languages[] = { {"cy", "WEL "}, {"da", "DAN "}, {"dar", "DAR "}, + {"de", "DEU "}, {"din", "DNK "}, {"doi", "DGR "}, + {"dsb", "LSB "}, {"dv", "DHV "}, {"dz", "DZN "}, {"ee", "EWE "}, {"efi", "EFI "}, + {"el", "ELL "}, {"en", "ENG "}, {"eo", "NTO "}, {"es", "ESP "}, {"et", "ETI "}, {"eu", "EUQ "}, {"fa", "FAR "}, + {"ff", "FUL "}, {"fi", "FIN "}, {"fil", "PIL "}, {"fj", "FJI "}, @@ -231,6 +238,7 @@ static const LangTag ot_languages[] = { {"fon", "FON "}, {"fr", "FRA "}, {"fur", "FRL "}, + {"fy", "FRI "}, {"ga", "IRI "}, {"gaa", "GAD "}, {"gd", "GAE "}, @@ -249,6 +257,8 @@ static const LangTag ot_languages[] = { {"hy", "HYE "}, {"id", "IND "}, {"ig", "IBO "}, + {"inc", "SRK "}, + {"ine", "KHW "}, {"inh", "ING "}, {"is", "ISL "}, {"it", "ITA "}, @@ -262,6 +272,7 @@ static const LangTag ot_languages[] = { {"ki", "KIK "}, {"kk", "KAZ "}, {"kl", "GRN "}, + {"km", "KHM "}, {"kn", "KAN "}, {"ko", "KOR "}, {"kok", "KOK "}, @@ -273,15 +284,23 @@ static const LangTag ot_languages[] = { {"ku", "KUR "}, {"kum", "KUM "}, {"ky", "KIR "}, + {"la", "LAT "}, + {"lad", "JUD "}, + {"lbj", "LDK "}, {"ln", "LIN "}, + {"lo", "LAO "}, {"lt", "LTH "}, + {"lv", "LVI "}, {"mai", "MTH "}, {"mdf", "MOK "}, {"men", "MDE "}, {"mg", "MLG "}, {"mi", "MRI "}, + {"mkh", "KUY "}, + {"ml", "MLR "}, {"mnc", "MCH "}, {"mni", "MNI "}, + {"mnk", "MND "}, {"mo", "MOL "}, {"mr", "MAR "}, {"ms", "MLY "}, @@ -289,10 +308,11 @@ static const LangTag ot_languages[] = { {"mwr", "MAW "}, {"my", "BRM "}, {"myv", "ERZ "}, - {"nl", "FLE "}, + {"ne", "NEP "}, {"nl", "NLD "}, {"no", "NOR "}, {"ny", "CHI "}, + {"oc", "PRO "}, {"om", "ORO "}, {"or", "ORI "}, {"os", "OSS "}, @@ -326,7 +346,10 @@ static const LangTag ot_languages[] = { {"sv", "SVE "}, {"sw", "SWK "}, {"syr", "SYR "}, + {"ta", "TAM "}, + {"te", "TEL "}, {"tg", "TAJ "}, + {"th", "THA "}, {"ti", "TGY "}, {"tig", "TGR "}, {"tk", "TKM "}, @@ -344,6 +367,7 @@ static const LangTag ot_languages[] = { {"wo", "WLF "}, {"xal", "KLM "}, {"xh", "XHS "}, + {"yi", "JII "}, {"yo", "YBA "}, {"zh-cn", "ZHS "}, {"zh-hk", "ZHH "}, @@ -377,19 +401,24 @@ lang_compare_first_component (gconstpointer pa, * Finds the OpenType language-system tag best describing @language. * * Return value: #PangoOTTag best matching @language or - * %PANGO_OT_DEFAULT_LANGUAGE if none found. + * %PANGO_OT_TAG_DEFAULT_LANGUAGE if none found. * * Since: 1.18 **/ PangoOTTag pango_ot_tag_from_language (PangoLanguage *language) { - const char *lang_str = pango_language_to_string (language); + const char *lang_str; + LangTag *lang_tag; + + g_return_val_if_fail (language != NULL, PANGO_OT_TAG_DEFAULT_LANGUAGE); + + lang_str = pango_language_to_string (language); /* find a language matching in the first component */ - LangTag *lang_tag = bsearch (lang_str, ot_languages, - G_N_ELEMENTS (ot_languages), sizeof (LangTag), - lang_compare_first_component); + lang_tag = bsearch (lang_str, ot_languages, + G_N_ELEMENTS (ot_languages), sizeof (LangTag), + lang_compare_first_component); /* we now need to find the best language matching */ if (lang_tag) @@ -421,7 +450,7 @@ pango_ot_tag_from_language (PangoLanguage *language) if (lang_tag) return GUINT32_FROM_BE (* (PangoOTTag *) lang_tag->tag); - return PANGO_OT_DEFAULT_LANGUAGE; + return PANGO_OT_TAG_DEFAULT_LANGUAGE; } /** diff --git a/pango/pango-ot.h b/pango/pango-ot.h index ce8778f3..df049378 100644 --- a/pango/pango-ot.h +++ b/pango/pango-ot.h @@ -34,10 +34,11 @@ G_BEGIN_DECLS typedef guint32 PangoOTTag; -typedef struct _PangoOTInfo PangoOTInfo; -typedef struct _PangoOTBuffer PangoOTBuffer; -typedef struct _PangoOTGlyph PangoOTGlyph; -typedef struct _PangoOTRuleset PangoOTRuleset; +typedef struct _PangoOTInfo PangoOTInfo; +typedef struct _PangoOTBuffer PangoOTBuffer; +typedef struct _PangoOTGlyph PangoOTGlyph; +typedef struct _PangoOTRuleset PangoOTRuleset; +typedef struct _PangoOTFeatureMap PangoOTFeatureMap; typedef enum { @@ -47,8 +48,12 @@ typedef enum #define PANGO_OT_ALL_GLYPHS ((guint) 0xFFFF) -#define PANGO_OT_DEFAULT_LANGUAGE ((PangoOTTag) 0xFFFF) -#define PANGO_OT_DEFAULT_SCRIPT ((PangoOTTag) FT_MAKE_TAG ('D', 'F', 'L', 'T')) +#define PANGO_OT_NO_FEATURE ((guint) 0xFFFF) +#define PANGO_OT_NO_SCRIPT ((guint) 0xFFFF) +#define PANGO_OT_DEFAULT_LANGUAGE ((guint) 0xFFFF) + +#define PANGO_OT_TAG_DEFAULT_SCRIPT ((PangoOTTag) (FT_MAKE_TAG ('D', 'F', 'L', 'T'))) +#define PANGO_OT_TAG_DEFAULT_LANGUAGE ((PangoOTTag) (FT_MAKE_TAG ('d', 'f', 'l', 't'))) /* Note that this must match HB_GlyphItem */ struct _PangoOTGlyph @@ -61,6 +66,12 @@ struct _PangoOTGlyph gushort property_cache; /* Internal */ }; +struct _PangoOTFeatureMap +{ + char feature_name[5]; + gulong property_bit; +}; + PangoOTInfo *pango_ot_info_get (FT_Face face); gboolean pango_ot_info_find_script (PangoOTInfo *info, @@ -111,16 +122,25 @@ void pango_ot_buffer_set_zero_width_marks (PangoOTBuffer *buffer, gboolean zero_width_marks); PangoOTRuleset *pango_ot_ruleset_new (PangoOTInfo *info); - +PangoOTRuleset *pango_ot_ruleset_new_for (PangoOTInfo *info, + PangoScript script, + PangoLanguage *language); void pango_ot_ruleset_add_feature (PangoOTRuleset *ruleset, PangoOTTableType table_type, guint feature_index, gulong property_bit); +gboolean pango_ot_ruleset_maybe_add_feature (PangoOTRuleset *ruleset, + PangoOTTableType table_type, + PangoOTTag feature_tag, + gulong property_bit); +int pango_ot_ruleset_maybe_add_features (PangoOTRuleset *ruleset, + PangoOTTableType table_type, + const PangoOTFeatureMap *features, + int n_features); void pango_ot_ruleset_substitute (PangoOTRuleset *ruleset, PangoOTBuffer *buffer); void pango_ot_ruleset_position (PangoOTRuleset *ruleset, PangoOTBuffer *buffer); - PangoScript pango_ot_tag_to_script (PangoOTTag script_tag); PangoOTTag pango_ot_tag_from_script (PangoScript script); PangoLanguage* pango_ot_tag_to_language (PangoOTTag language_tag); |