Ruleset#
Superclasses: Object
The PangoOTRuleset structure holds a set of features selected
from the tables in an OpenType font.
A feature is an operation such as adjusting glyph positioning that should be applied to a text feature such as a certain type of accent.
A PangoOTRuleset is created with new,
features are added to it with add_feature,
then it is applied to a PangoGlyphString with
position.
Constructors#
- class Ruleset
- classmethod new(info: Info) Ruleset#
Creates a new
PangoOTRulesetfor the given OpenType info.- Parameters:
info – a
PangoOTInfo
- classmethod new_for(info: Info, script: Script, language: Language) Ruleset#
Creates a new
PangoOTRulesetfor the given OpenType info, script, and language.This function is part of a convenience scheme that highly simplifies using a
PangoOTRulesetto 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 addition to what
newdoes, this function will:Find the
PangoOTTagscript and language tags associated withscriptandlanguageusingtag_from_scriptandtag_from_language,For each of table types
GSUBandGPOS, find the script index of the script tag found and the language system index of the language tag found in that script system, usingfind_scriptandfind_language,For found language-systems, if they have required feature index, add that feature to the ruleset using
add_feature,Remember found script and language indices for both table types, and use them in future
maybe_add_featureandmaybe_add_features.
Because of the way return values of
find_scriptandfind_languageare ignored, this function automatically finds and uses the ‘DFLT’ script and the default language-system.Added in version 1.18.
- Parameters:
info – a
PangoOTInfoscript – a
PangoScriptlanguage – a
PangoLanguage
- classmethod new_from_description(info: Info, desc: RulesetDescription) Ruleset#
Creates a new
PangoOTRulesetfor the given OpenType info and matching the given ruleset description.This is a convenience function that calls
new_forand adds the static GSUB/GPOS features to the resulting ruleset, followed by adding other features to both GSUB and GPOS.The static feature map members of
descshould be alive as long asinfois.Added in version 1.18.
- Parameters:
info – a
PangoOTInfodesc – a
PangoOTRulesetDescription
Methods#
- class Ruleset
- add_feature(table_type: TableType, feature_index: int, property_bit: int) None#
Adds a feature to the ruleset.
- Parameters:
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
ALL_GLYPHSif it should be applied to all glyphs.
- get_feature_count() tuple[int, int, int]#
Gets the number of GSUB and GPOS features in the ruleset.
Added in version 1.18.
- classmethod get_for_description(desc: RulesetDescription) Ruleset#
Returns a ruleset for the given OpenType info and ruleset description.
Rulesets are created on demand using
new_from_description. The returned ruleset should not be modified or destroyed.The static feature map members of
descshould be alive as long asinfois.Added in version 1.18.
- Parameters:
desc – a
PangoOTRulesetDescription
- maybe_add_feature(table_type: TableType, feature_tag: int, property_bit: int) bool#
This is a convenience function that first tries to find the feature using
find_featureand the ruleset script and language passed tonew_forand if the feature is found, adds it to the ruleset.If
rulesetwas not created usingnew_for, this function does nothing.Added in version 1.18.
- Parameters:
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
ALL_GLYPHSif it should be applied to all glyphs.
- maybe_add_features(table_type: TableType, features: FeatureMap, n_features: int) int#
This is a convenience function that for each feature in the feature map array
featuresconverts the feature name to aPangoOTTagfeature tag usingTAG_MAKE()and callsmaybe_add_featureon it.Added in version 1.18.
- Parameters:
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
featuresarray