PangoOT.Ruleset

g GObject.Object GObject.Object PangoOT.Ruleset PangoOT.Ruleset GObject.Object->PangoOT.Ruleset

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_for_description (info, desc)

class

new (info)

class

new_for (info, script, language)

class

new_from_description (info, desc)

add_feature (table_type, feature_index, property_bit)

get_feature_count ()

maybe_add_feature (table_type, feature_tag, property_bit)

maybe_add_features (table_type, features, n_features)

position (buffer)

substitute (buffer)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class PangoOT.Ruleset(**kwargs)
Bases:

GObject.Object

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 a PangoGlyphString with [method`PangoOT`.Ruleset.position].

classmethod get_for_description(info, desc)
Parameters:
Returns:

the PangoOTRuleset for desc. This object will have the same lifetime as info.

Return type:

PangoOT.Ruleset

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) – a PangoOTInfo

Returns:

the newly allocated PangoOTRuleset

Return type:

PangoOT.Ruleset

Creates a new PangoOTRuleset for the given OpenType info.

classmethod new_for(info, script, language)
Parameters:
Returns:

the newly allocated PangoOTRuleset

Return type:

PangoOT.Ruleset

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 and PangoOT.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:
Returns:

the newly allocated PangoOTRuleset

Return type:

PangoOT.Ruleset

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 to

  • feature_index (int) – the index of the feature to add

  • property_bit (int) – the property bit to use for this feature. Used to identify the glyphs that this feature should be applied to, or PangoOT.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:

(int, n_gsub_features: int, n_gpos_features: int)

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 to

  • feature_tag (int) – the tag of the feature to add

  • property_bit (int) – the property bit to use for this feature. Used to identify the glyphs that this feature should be applied to, or PangoOT.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:

bool

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 to

  • features (PangoOT.FeatureMap) – array of feature name and property bits to add

  • n_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:

int

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) – a PangoOTBuffer

Performs the OpenType GPOS positioning on buffer using the features in self.

New in version 1.4.

substitute(buffer)
Parameters:

buffer (PangoOT.Buffer) – a PangoOTBuffer

Performs the OpenType GSUB substitution on buffer using the features in self.

New in version 1.4.