Class: PangoOT::Ruleset

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

Overview

The Pango::OTRuleset 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 Pango::OTRuleset is created with pango_ot_ruleset_new(), features are added to it with pango_ot_ruleset_add_feature(), then it is applied to a Pango::GlyphString with pango_ot_ruleset_shape().

Instance Method Summary collapse

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, or nil.

  • n_gpos_features (Integer)

    location to store number of GPOS features, or nil.

Returns:

  • (Integer)

    Total number of features in the ruleset.

#maybe_add_feature(table_type, feature_tag, property_bit) ⇒ TrueClass

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.

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:

  • (TrueClass)

    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 Pango::OTTag feature tag using PANGO_OT_TAG_MAKE() and calls pango_ot_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.

#new(info) ⇒ PangoOT::Ruleset

Creates a new Pango::OTRuleset for the given OpenType info.

Parameters:

Returns:

  • (PangoOT::Ruleset)

    the newly allocated Pango::OTRuleset, which should be freed with g_object_unref().

#new_for(info, script, language) ⇒ PangoOT::Ruleset

Creates a new Pango::OTRuleset for the given OpenType info, script, and language.

This function is part of a convenience scheme that highly simplifies using a Pango::OTRuleset 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 Pango::OTTag script and language tags associated with
<b>script</b> and <b>language</b> 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.

Parameters:

  • info (PangoOT::Info)

    a Pango::OTInfo.

  • script (Pango::Script)

    a Pango::Script.

  • language (Pango::Language)

    a Pango::Language.

Returns:

  • (PangoOT::Ruleset)

    the newly allocated Pango::OTRuleset, which should be freed with g_object_unref().

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

Creates a new Pango::OTRuleset for the given OpenType infor and matching the given ruleset description.

This is a convenience function that calls pango_ot_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 Pango::OTInfo.

  • desc (PangoOT::RulesetDescription)

    a Pango::OTRulesetDescription.

Returns:

  • (PangoOT::Ruleset)

    the newly allocated Pango::OTRuleset, which should be freed with g_object_unref().

#position(buffer) ⇒ nil

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

Parameters:

  • buffer (PangoOT::Buffer)

    a Pango::OTBuffer.

Returns:

  • (nil)

#substitute(buffer) ⇒ nil

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

Parameters:

  • buffer (PangoOT::Buffer)

    a Pango::OTBuffer.

Returns:

  • (nil)