}
}
+ inline bool single_substitute (hb_codepoint_t &glyph_id) const {
+ switch (u.substFormat) {
+ case 1: return u.format1.single_substitute (glyph_id);
+ case 2: return u.format2.single_substitute (glyph_id);
+ default:return false;
+ }
+ }
+
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
HB_UNUSED (nesting_level_left);
hb_codepoint_t glyph_id = IN_CURGLYPH ();
- switch (u.substFormat) {
- case 1: if (!u.format1.single_substitute (glyph_id)) return false;
- case 2: if (!u.format2.single_substitute (glyph_id)) return false;
- default:return false;
- }
+ if (!single_substitute (glyph_id))
+ return false;
_hb_buffer_replace_output_glyph (buffer, glyph_id, context_length == NO_CONTEXT);
if (info->layout)
hb_ot_layout_destroy (info->layout);
- if (info->gsub)
- {
- HB_Done_GSUB_Table (info->gsub);
- info->gsub = NULL;
- }
if (info->gpos)
{
HB_Done_GPOS_Table (info->gpos);
FT_Set_Charmap (info->face, old_charmap);
}
-HB_GSUB
-pango_ot_info_get_gsub (PangoOTInfo *info)
-{
- g_return_val_if_fail (PANGO_IS_OT_INFO (info), NULL);
-
- if (!(info->loaded & INFO_LOADED_GSUB))
- {
- HB_Error error;
-
- info->loaded |= INFO_LOADED_GSUB;
-
- if (FT_IS_SFNT (info->face))
- {
- error = HB_Load_GSUB_Table (info->face, &info->gsub, _pango_ot_info_get_layout (info));
-
- if (error && error != HB_Err_Not_Covered)
- g_warning ("Error loading GSUB table 0x%04X", error);
- }
- }
-
- return info->gsub;
-}
-
HB_GPOS
pango_ot_info_get_gpos (PangoOTInfo *info)
{
return result;
}
+
+void
+_pango_ot_info_substitute (const PangoOTInfo *info,
+ const PangoOTRuleset *ruleset,
+ PangoOTBuffer *buffer)
+{
+ unsigned int i;
+
+ for (i = 0; i < ruleset->rules->len; i++)
+ {
+ PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
+ hb_ot_layout_feature_mask_t mask;
+ unsigned int lookup_count, j;
+
+ if (rule->table_type != PANGO_OT_TABLE_GSUB)
+ continue;
+
+ mask = rule->property_bit;
+ lookup_count = hb_ot_layout_feature_get_lookup_count (info->layout,
+ HB_OT_LAYOUT_TABLE_TYPE_GSUB,
+ rule->feature_index);
+
+ for (j = 0; j < lookup_count; j++)
+ {
+ unsigned int lookup_index;
+
+ lookup_index = hb_ot_layout_feature_get_lookup_index (info->layout,
+ HB_OT_LAYOUT_TABLE_TYPE_GSUB,
+ rule->feature_index,
+ j);
+ hb_ot_layout_substitute_lookup (info->layout,
+ buffer->buffer,
+ lookup_index,
+ rule->property_bit);
+ }
+ }
+}
FT_Face face;
hb_ot_layout_t *layout;
- HB_GSUB gsub;
HB_GPOS gpos;
};
};
+typedef struct _PangoOTRule PangoOTRule;
+
+struct _PangoOTRule
+{
+ gulong property_bit;
+ HB_UShort feature_index;
+ guint table_type : 1;
+};
+
typedef struct _PangoOTRulesetClass PangoOTRulesetClass;
struct _PangoOTRuleset
};
hb_ot_layout_t *_pango_ot_info_get_layout (PangoOTInfo *info);
-HB_GSUB pango_ot_info_get_gsub (PangoOTInfo *info);
+void _pango_ot_info_substitute (const PangoOTInfo *info,
+ const PangoOTRuleset *ruleset,
+ PangoOTBuffer *buffer);
HB_GPOS pango_ot_info_get_gpos (PangoOTInfo *info);
G_END_DECLS
#include "pango-ot-private.h"
#include "pango-impl-utils.h"
-typedef struct _PangoOTRule PangoOTRule;
-
-struct _PangoOTRule
-{
- gulong property_bit;
- HB_UShort feature_index;
- guint table_type : 1;
-};
-
static void pango_ot_ruleset_class_init (GObjectClass *object_class);
static void pango_ot_ruleset_init (PangoOTRuleset *ruleset);
static void pango_ot_ruleset_finalize (GObject *object);
pango_ot_ruleset_substitute (const PangoOTRuleset *ruleset,
PangoOTBuffer *buffer)
{
- unsigned int i;
-
- HB_GSUB gsub = NULL;
-
g_return_if_fail (PANGO_IS_OT_RULESET (ruleset));
g_return_if_fail (ruleset->info != NULL);
- for (i = 0; i < ruleset->rules->len; i++)
- {
- PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
-
- if (rule->table_type != PANGO_OT_TABLE_GSUB)
- continue;
-
- if (!gsub)
- {
- gsub = pango_ot_info_get_gsub (ruleset->info);
-
- if (gsub)
- HB_GSUB_Clear_Features (gsub);
- else
- return;
- }
-
- HB_GSUB_Add_Feature (gsub, rule->feature_index, rule->property_bit);
- }
-
- HB_GSUB_Apply_String (gsub, buffer->buffer);
+ _pango_ot_info_substitute (ruleset->info,
+ ruleset,
+ buffer);
}
/**