Class: PangoOT::Ruleset

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

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 [ctorPangoOT.Ruleset.new], features are added to it with [methodPangoOT.Ruleset.add_feature], then it is applied to a PangoGlyphString with [methodPangoOT.Ruleset.position].

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(info, desc) ⇒ PangoOT::Ruleset

Creates a new PangoOTRuleset for the given OpenType info and matching the given ruleset description.

This is a convenience function that calls [ctorPangoOT.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.

Parameters:

  • info (PangoOT::Info)

    a PangoOTInfo

  • desc (PangoOT::RulesetDescription)

    a PangoOTRulesetDescription

Class Method Details

.get_for_description(info, desc) ⇒ PangoOT::Ruleset

Returns a ruleset for the given OpenType info and ruleset description.

Rulesets are created on demand using [ctorPangoOT.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.

Parameters:

  • info (PangoOT::Info)

    a PangoOTInfo

  • desc (PangoOT::RulesetDescription)

    a PangoOTRulesetDescription

Returns:

  • (PangoOT::Ruleset)

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

Instance Method Details

#add_feature(table_type, feature_index, property_bit) ⇒ nil

Adds a feature to the ruleset.

Parameters:

  • table_type (PangoOT::TableType)

    the table type to add a feature to

  • feature_index (Integer)

    the index of the feature to add

  • property_bit (PangoOT::gulong)

    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.

Returns:

  • (nil)

#get_feature_count(n_gsub_features, n_gpos_features) ⇒ Integer

Gets the number of GSUB and GPOS features in the ruleset.

Parameters:

  • n_gsub_features (Integer)

    location to store number of GSUB features

  • n_gpos_features (Integer)

    location to store number of GPOS features

Returns:

  • (Integer)

    Total number of features in the ruleset

#maybe_add_feature(table_type, feature_tag, property_bit) ⇒ Boolean

This is a convenience function that first tries to find the feature using [methodPangoOT.Info.find_feature] and the ruleset script and language passed to [ctorPangoOT.Ruleset.new_for] and if the feature is found, adds it to the ruleset.

If ruleset was not created using [ctorPangoOT.Ruleset.new_for], this function does nothing.

Parameters:

  • table_type (PangoOT::TableType)

    the table type to add a feature to

  • feature_tag (PangoOT::Tag)

    the tag of the feature to add

  • property_bit (PangoOT::gulong)

    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.

Returns:

  • (Boolean)

    true if the feature was found and added to ruleset, false otherwise

#maybe_add_features(table_type, features, n_features) ⇒ Integer

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 [methodPangoOT.Ruleset.maybe_add_feature] on it.

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 (Integer)

    number of feature records in features array

Returns:

  • (Integer)

    The number of features in features that were found and added to ruleset

#position(buffer) ⇒ nil

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

Parameters:

  • buffer (PangoOT::Buffer)

    a PangoOTBuffer

Returns:

  • (nil)

#substitute(buffer) ⇒ nil

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

Parameters:

  • buffer (PangoOT::Buffer)

    a PangoOTBuffer

Returns:

  • (nil)