+/* Prototypes for callback functions of FontInfo.font. */
+
+static int get_glyph_id (MFLTFont *, MFLTGlyphString *, int, int);
+static int get_metrics (MFLTFont *, MFLTGlyphString *, int, int);
+static int check_otf (MFLTFont *, MFLTOtfSpec *);
+static int drive_otf (MFLTFont *, MFLTOtfSpec *,
+ MFLTGlyphString *, int, int,
+ MFLTGlyphString *, MFLTGlyphAdjustment *);
+
+
+/* This function works in two ways.
+
+ If INFO is NULL, it checks if the features specified in SPEC match
+ with the OpenType font in OT_INFO, and return 1 (match) or 0 (no
+ match).
+
+ If INFO is non-NULL, it creates a PangoOTRuleset object from SPEC
+ and stores it in INFO. In this case, non-existing features in SPEC
+ are just ignored.
+
+ Features in SPEC are stored in an array in this format:
+ P P ... [ 0xFFFFFFFF [ N N ... ] ]
+ where
+ Ps are positive features that should be in the font (INFO is
+ NULL), or should be applied in this order (INFO is non-NULL),
+
+ 0xFFFFFFFF is a separater between Ps and Ns (INFO is NULL), or
+ is a wildcard meaning that all the other features (except for
+ Ns) must be applied (INFO is non-NULL),
+
+ Ns are negative features that should not be in the font (INFO
+ is NULL), or should not be applied (INFO is non-NULL). */
+
+static int
+otf_check_features (PangoOTInfo *ot_info, PangoOTTableType type,
+ MFLTOtfSpec *spec, FeatureInfo *info)
+{
+ unsigned int *features;
+ unsigned int langsys_tag;
+ guint script_idx, langsys_idx;
+ guint index;
+ guint *feature_list;
+ int i, j;
+ /* Used as an index to spec->features[] and info->ruleset[]. */
+ int for_gpos = type == PANGO_OT_TABLE_GPOS;
+
+ features = spec->features[for_gpos];
+ if (! features)
+ return 1;
+ if (! pango_ot_info_find_script (ot_info, type, spec->script, &script_idx))
+ /* No feature for the specified script exist. If the first
+ feature in SPEC is a wildcard, the remaining features are all
+ negative, so we can return 1. */
+ return (features[0] == 0xFFFFFFFF);
+ langsys_tag = spec->langsys;
+ if (! langsys_tag)
+ langsys_tag = PANGO_OT_DEFAULT_LANGUAGE;
+ pango_ot_info_find_language (ot_info, type, script_idx,
+ langsys_tag, &langsys_idx, &index);
+
+ if (index != 0xFFFF)