Exemplo n.º 1
0
/**
 * pango_ot_ruleset_maybe_add_feature:
 * @ruleset: a #PangoOTRuleset.
 * @table_type: the table type to add a feature to.
 * @feature_tag: the tag of the feature to add.
 * @property_bit: 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.
 *
 * 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.
 *
 * Return value: %TRUE if the feature was found and added to ruleset,
 *               %FALSE otherwise.
 *
 * Since: 1.18
 **/
gboolean
pango_ot_ruleset_maybe_add_feature (PangoOTRuleset          *ruleset,
                                    PangoOTTableType         table_type,
                                    PangoOTTag               feature_tag,
                                    gulong                   property_bit)
{
    guint feature_index;

    g_return_val_if_fail (PANGO_IS_OT_RULESET (ruleset), FALSE);
    g_return_val_if_fail (ruleset->info != NULL, FALSE);

    pango_ot_info_find_feature (ruleset->info, table_type,
                                feature_tag,
                                ruleset->script_index[table_type],
                                ruleset->language_index[table_type],
                                &feature_index);

    if (feature_index != PANGO_OT_NO_FEATURE)
    {
        pango_ot_ruleset_add_feature (ruleset, table_type,
                                      feature_index, property_bit);
        return TRUE;
    }

    return FALSE;
}
Exemplo n.º 2
0
static void
maybe_add_GPOS_feature (PangoOTRuleset *ruleset,
                        PangoOTInfo    *info,
                        guint           script_index,
                        PangoOTTag      tag,
                        gulong          property_bit)
{
  guint feature_index;

  /* 0xffff == default language system */
  if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GPOS,
                                  tag, script_index, 0xffff, &feature_index))
    pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index,
                                  property_bit);
}
Exemplo n.º 3
0
static void
maybe_add_GPOS_feature (PangoOTRuleset *ruleset,
		        PangoOTInfo    *info,
			guint           script_index,
			PangoOTTag      feature_tag,
			gulong          property_bit)
{
  guint feature_index;

  if (pango_ot_info_find_feature (info, PANGO_OT_TABLE_GPOS,
				  feature_tag,script_index, 0xffff, &feature_index))
    {
      /*
      printf("Added GPOS feature '%c%c%c%c' = %8.8X\n", feature_tag>>24, feature_tag>>16&0xFF, feature_tag>>8&0xFF, feature_tag&0xFF, property_bit);
      */

      pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index,
				    property_bit);
    }
}
Exemplo n.º 4
0
/**
 * pango_ot_ruleset_new_for:
 * @info: a #PangoOTInfo.
 * @script: a #PangoScript.
 * @language: a #PangoLanguage.
 *
 * 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 excess to what pango_ot_ruleset_new() does, this function will:
 * <itemizedlist>
 *   <listitem>
 *   Find the #PangoOTTag script and language tags associated with
 *   @script and @language 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.
 *
 * Return value: the newly allocated #PangoOTRuleset, which
 *               should be freed with g_object_unref().
 *
 * Since: 1.18
 **/
PangoOTRuleset *
pango_ot_ruleset_new_for (PangoOTInfo       *info,
                          PangoScript        script,
                          PangoLanguage     *language)
{
    PangoOTRuleset *ruleset;
    PangoOTTag script_tag, language_tag;
    PangoOTTableType table_type;

    g_return_val_if_fail (PANGO_IS_OT_INFO (info), NULL);

    ruleset = pango_ot_ruleset_new (info);

    script_tag   = pango_ot_tag_from_script (script);
    language_tag = pango_ot_tag_from_language (language);

    for (table_type = PANGO_OT_TABLE_GSUB; table_type <= PANGO_OT_TABLE_GPOS; table_type++)
    {
        guint script_index, language_index, feature_index;

        pango_ot_info_find_script   (ruleset->info, table_type,
                                     script_tag, &script_index);
        pango_ot_info_find_language (ruleset->info, table_type, script_index,
                                     language_tag, &language_index,
                                     &feature_index);

        ruleset->script_index[table_type] = script_index;
        ruleset->language_index[table_type] = language_index;

        /* add required feature of the language */
        pango_ot_ruleset_add_feature (ruleset, table_type,
                                      feature_index, PANGO_OT_ALL_GLYPHS);
    }

    return ruleset;
}