:right-sidebar: True Ruleset =================================================================== .. currentmodule:: gi.repository.PangoOT .. class:: Ruleset(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.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 :obj:`~gi.repository.PangoOT.Ruleset.new`\, features are added to it with :obj:`~gi.repository.PangoOT.Ruleset.add_feature`\, then it is applied to a ``PangoGlyphString`` with :obj:`~gi.repository.PangoOT.Ruleset.position`\. Constructors ------------ .. rst-class:: interim-class .. class:: Ruleset :no-index: .. classmethod:: new(info: ~gi.repository.PangoOT.Info) -> ~gi.repository.PangoOT.Ruleset Creates a new ``PangoOTRuleset`` for the given OpenType info. :param info: a ``PangoOTInfo`` .. classmethod:: new_for(info: ~gi.repository.PangoOT.Info, script: ~gi.repository.Pango.Script, language: ~gi.repository.Pango.Language) -> ~gi.repository.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 :obj:`~gi.repository.PangoOT.Ruleset.new` does, this function will: - Find the ``PangoOTTag`` script and language tags associated with ``script`` and ``language`` using :obj:`~gi.repository.PangoOT.tag_from_script` and :obj:`~gi.repository.PangoOT.tag_from_language`\, - For each of table types :const:`~gi.repository.PangoOT.TableType.GSUB` and :const:`~gi.repository.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 :obj:`~gi.repository.PangoOT.Info.find_script` and :obj:`~gi.repository.PangoOT.Info.find_language`\, - For found language-systems, if they have required feature index, add that feature to the ruleset using :obj:`~gi.repository.PangoOT.Ruleset.add_feature`\, - Remember found script and language indices for both table types, and use them in future :obj:`~gi.repository.PangoOT.Ruleset.maybe_add_feature` and :obj:`~gi.repository.PangoOT.Ruleset.maybe_add_features`\. Because of the way return values of :obj:`~gi.repository.PangoOT.Info.find_script` and :obj:`~gi.repository.PangoOT.Info.find_language` are ignored, this function automatically finds and uses the 'DFLT' script and the default language-system. .. versionadded:: 1.18 :param info: a ``PangoOTInfo`` :param script: a ``PangoScript`` :param language: a ``PangoLanguage`` .. classmethod:: new_from_description(info: ~gi.repository.PangoOT.Info, desc: ~gi.repository.PangoOT.RulesetDescription) -> ~gi.repository.PangoOT.Ruleset Creates a new ``PangoOTRuleset`` for the given OpenType info and matching the given ruleset description. This is a convenience function that calls :obj:`~gi.repository.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. .. versionadded:: 1.18 :param info: a ``PangoOTInfo`` :param desc: a ``PangoOTRulesetDescription`` Methods ------- .. rst-class:: interim-class .. class:: Ruleset :no-index: .. method:: add_feature(table_type: ~gi.repository.PangoOT.TableType, feature_index: int, property_bit: int) -> None Adds a feature to the ruleset. :param table_type: the table type to add a feature to :param feature_index: the index of the feature to add :param property_bit: the property bit to use for this feature. Used to identify the glyphs that this feature should be applied to, or :const:`~gi.repository.PangoOT.ALL_GLYPHS` if it should be applied to all glyphs. .. method:: get_feature_count() -> ~typing.Tuple[int, int, int] Gets the number of GSUB and GPOS features in the ruleset. .. versionadded:: 1.18 .. classmethod:: get_for_description(desc: ~gi.repository.PangoOT.RulesetDescription) -> ~gi.repository.PangoOT.Ruleset Returns a ruleset for the given OpenType info and ruleset description. Rulesets are created on demand using :obj:`~gi.repository.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. .. versionadded:: 1.18 :param desc: a ``PangoOTRulesetDescription`` .. method:: maybe_add_feature(table_type: ~gi.repository.PangoOT.TableType, feature_tag: int, property_bit: int) -> bool This is a convenience function that first tries to find the feature using :obj:`~gi.repository.PangoOT.Info.find_feature` and the ruleset script and language passed to :obj:`~gi.repository.PangoOT.Ruleset.new_for` and if the feature is found, adds it to the ruleset. If ``ruleset`` was not created using :obj:`~gi.repository.PangoOT.Ruleset.new_for`\, this function does nothing. .. versionadded:: 1.18 :param table_type: the table type to add a feature to :param feature_tag: the tag of the feature to add :param property_bit: the property bit to use for this feature. Used to identify the glyphs that this feature should be applied to, or :const:`~gi.repository.PangoOT.ALL_GLYPHS` if it should be applied to all glyphs. .. method:: maybe_add_features(table_type: ~gi.repository.PangoOT.TableType, features: ~gi.repository.PangoOT.FeatureMap, n_features: int) -> 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 :func:`~gi.repository.PangoOT.TAG_MAKE` and calls :obj:`~gi.repository.PangoOT.Ruleset.maybe_add_feature` on it. .. versionadded:: 1.18 :param table_type: the table type to add features to :param features: array of feature name and property bits to add :param n_features: number of feature records in ``features`` array .. method:: position(buffer: ~gi.repository.PangoOT.Buffer) -> None Performs the OpenType GPOS positioning on ``buffer`` using the features in ``ruleset``\. .. versionadded:: 1.4 :param buffer: a ``PangoOTBuffer`` .. method:: substitute(buffer: ~gi.repository.PangoOT.Buffer) -> None Performs the OpenType GSUB substitution on ``buffer`` using the features in ``ruleset``\. .. versionadded:: 1.4 :param buffer: a ``PangoOTBuffer``