PangoOT.Ruleset¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class PangoOT.Ruleset(**kwargs)¶
- Bases:
- Abstract:
No
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 [ctor`PangoOT`.Ruleset.new], features are added to it with [method`PangoOT`.Ruleset.add_feature], then it is applied to aPangoGlyphString
with [method`PangoOT`.Ruleset.position].- classmethod get_for_description(info, desc)¶
- Parameters:
info (
PangoOT.Info
) – aPangoOTInfo
desc (
PangoOT.RulesetDescription
) – aPangoOTRulesetDescription
- Returns:
the
PangoOTRuleset
for desc. This object will have the same lifetime as info.- Return type:
Returns a ruleset for the given OpenType info and ruleset description.
Rulesets are created on demand using [ctor`PangoOT`.Ruleset.new_from_description]. The returned ruleset should not be modified or destroyed.
The static feature map members of desc should be alive as long as info is.
New in version 1.18.
- classmethod new(info)¶
- Parameters:
info (
PangoOT.Info
) – aPangoOTInfo
- Returns:
the newly allocated
PangoOTRuleset
- Return type:
Creates a new
PangoOTRuleset
for the given OpenType info.
- classmethod new_for(info, script, language)¶
- Parameters:
info (
PangoOT.Info
) – aPangoOTInfo
script (
Pango.Script
) – aPangoScript
language (
Pango.Language
) – aPangoLanguage
- Returns:
the newly allocated
PangoOTRuleset
- Return type:
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 addition to what [ctor`PangoOT`.Ruleset.new] does, this function will:
Find the
PangoOTTag
script and language tags associated with script and language using [func`PangoOT`.tag_from_script] and [func`PangoOT`.tag_from_language],For each of table types
PangoOT.TableType.GSUB
andPangoOT.TableType.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 [method`PangoOT`.Info.find_script] and [method`PangoOT`.Info.find_language],For found language-systems, if they have required feature index, add that feature to the ruleset using [method`PangoOT`.Ruleset.add_feature],
Remember found script and language indices for both table types, and use them in future [method`PangoOT`.Ruleset.maybe_add_feature] and [method`PangoOT`.Ruleset.maybe_add_features].
Because of the way return values of [method`PangoOT`.Info.find_script] and [method`PangoOT`.Info.find_language] are ignored, this function automatically finds and uses the ‘DFLT’ script and the default language-system.
New in version 1.18.
- classmethod new_from_description(info, desc)¶
- Parameters:
info (
PangoOT.Info
) – aPangoOTInfo
desc (
PangoOT.RulesetDescription
) – aPangoOTRulesetDescription
- Returns:
the newly allocated
PangoOTRuleset
- Return type:
Creates a new
PangoOTRuleset
for the given OpenType info and matching the given ruleset description.This is a convenience function that calls [ctor`PangoOT`.Ruleset.new_for] and 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 desc should be alive as long as info is.
New in version 1.18.
- add_feature(table_type, feature_index, property_bit)¶
- Parameters:
table_type (
PangoOT.TableType
) – the table type to add a feature tofeature_index (
int
) – the index of the feature to addproperty_bit (
int
) – the property bit to use for this feature. Used to identify the glyphs that this feature should be applied to, orPangoOT.ALL_GLYPHS
if it should be applied to all glyphs.
Adds a feature to the ruleset.
- get_feature_count()¶
- Returns:
Total number of features in the self
- n_gsub_features:
location to store number of GSUB features
- n_gpos_features:
location to store number of GPOS features
- Return type:
Gets the number of GSUB and GPOS features in the ruleset.
New in version 1.18.
- maybe_add_feature(table_type, feature_tag, property_bit)¶
- Parameters:
table_type (
PangoOT.TableType
) – the table type to add a feature tofeature_tag (
int
) – the tag of the feature to addproperty_bit (
int
) – the property bit to use for this feature. Used to identify the glyphs that this feature should be applied to, orPangoOT.ALL_GLYPHS
if it should be applied to all glyphs.
- Returns:
True
if the feature was found and added to ruleset,False
otherwise- Return type:
This is a convenience function that first tries to find the feature using [method`PangoOT`.Info.find_feature] and the ruleset script and language passed to [ctor`PangoOT`.Ruleset.new_for] and if the feature is found, adds it to the ruleset.
If self was not created using [ctor`PangoOT`.Ruleset.new_for], this function does nothing.
New in version 1.18.
- maybe_add_features(table_type, features, n_features)¶
- Parameters:
table_type (
PangoOT.TableType
) – the table type to add features tofeatures (
PangoOT.FeatureMap
) – array of feature name and property bits to addn_features (
int
) – number of feature records in features array
- Returns:
The number of features in features that were found and added to self
- Return type:
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 PANGO_OT_TAG_MAKE() and calls [method`PangoOT`.Ruleset.maybe_add_feature] on it.New in version 1.18.
- position(buffer)¶
- Parameters:
buffer (
PangoOT.Buffer
) – aPangoOTBuffer
Performs the OpenType GPOS positioning on buffer using the features in self.
New in version 1.4.
- substitute(buffer)¶
- Parameters:
buffer (
PangoOT.Buffer
) – aPangoOTBuffer
Performs the OpenType GSUB substitution on buffer using the features in self.
New in version 1.4.