summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-05-04 20:21:57 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-05-05 00:47:44 -0400
commit0bb5d464baab47bb7b6e9852a5c7932bdb2df018 (patch)
tree76769d89f21d5140d88416db064c6c2e2700f556 /pango
parent644d9208ce6f916d702d41f35c3bd3f87552fa7b (diff)
downloadpango-0bb5d464baab47bb7b6e9852a5c7932bdb2df018.tar.gz
[GSUB] Hook new GSUB up in Pango
Diffstat (limited to 'pango')
-rw-r--r--pango/opentype/hb-ot-layout-gsub-private.h15
-rw-r--r--pango/pango-ot-info.c65
-rw-r--r--pango/pango-ot-private.h14
-rw-r--r--pango/pango-ot-ruleset.c37
4 files changed, 62 insertions, 69 deletions
diff --git a/pango/opentype/hb-ot-layout-gsub-private.h b/pango/opentype/hb-ot-layout-gsub-private.h
index 78c57014..73950dcc 100644
--- a/pango/opentype/hb-ot-layout-gsub-private.h
+++ b/pango/opentype/hb-ot-layout-gsub-private.h
@@ -125,6 +125,14 @@ struct SingleSubst {
}
}
+ 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);
@@ -138,11 +146,8 @@ struct SingleSubst {
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);
diff --git a/pango/pango-ot-info.c b/pango/pango-ot-info.c
index b1a5dfdb..fbd03772 100644
--- a/pango/pango-ot-info.c
+++ b/pango/pango-ot-info.c
@@ -83,11 +83,6 @@ pango_ot_info_finalize (GObject *object)
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);
@@ -290,29 +285,6 @@ synthesize_class_def (PangoOTInfo *info)
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)
{
@@ -573,3 +545,40 @@ pango_ot_info_list_features (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);
+ }
+ }
+}
diff --git a/pango/pango-ot-private.h b/pango/pango-ot-private.h
index 0ba3984b..c1ee4556 100644
--- a/pango/pango-ot-private.h
+++ b/pango/pango-ot-private.h
@@ -40,7 +40,6 @@ struct _PangoOTInfo
FT_Face face;
hb_ot_layout_t *layout;
- HB_GSUB gsub;
HB_GPOS gpos;
};
@@ -50,6 +49,15 @@ struct _PangoOTInfoClass
};
+typedef struct _PangoOTRule PangoOTRule;
+
+struct _PangoOTRule
+{
+ gulong property_bit;
+ HB_UShort feature_index;
+ guint table_type : 1;
+};
+
typedef struct _PangoOTRulesetClass PangoOTRulesetClass;
struct _PangoOTRuleset
@@ -81,7 +89,9 @@ struct _PangoOTBuffer
};
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
diff --git a/pango/pango-ot-ruleset.c b/pango/pango-ot-ruleset.c
index 2d0492b8..23f37cb3 100644
--- a/pango/pango-ot-ruleset.c
+++ b/pango/pango-ot-ruleset.c
@@ -24,15 +24,6 @@
#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);
@@ -491,34 +482,12 @@ void
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);
}
/**