From 2c7859e70f161414803f21d2055f5c37a3f8033f Mon Sep 17 00:00:00 2001 From: Theppitak Karoonboonyanan Date: Sat, 16 Oct 2004 17:10:51 +0000 Subject: Merge from HEAD. 2004-10-16 Theppitak Karoonboonyanan Merge from HEAD. * modules/thai/thai-ot.[ch] (thai_ot_get_ruleset), modules/thai/thai-fc.c (thai_get_font_info): Prefer OpenType to PUA substitutions. * modules/thai/thai-shaper.c (groups, group1_map, group2_map): Remove unused data for XTIS. * modules/thai/thai-shaper.[ch] (enum ThaiFontSet, get_glyphs_list), modules/thai/thai-fc.c (thai_get_font_info, thai_make_glyph): Remove THAI_FONT_ISO10646 font set. * modules/thai/thai-fc.c (tis620_1): Fix the PUA glyph table. * modules/thai/thai-shaper.h (thai_{get,make}_glyph_{tis,uni}), modules/thai/thai-shaper.c (get_adjusted_glyphs_list), modules/thai/thai-fc.c (thai_{get,make}_glyph_{tis,uni}, tis620_2): Explicitly handle dangling upper/lower marks with dottedcircle and fails gracefully if the glyph is not available. * modules/thai/thai-shaper.[ch] (thai_get_glyph_tis, thai_make_glyph_tis): Use guchar instead of gchar as argument type. Make *_tis functions wrappers to *_uni functions. --- ChangeLog | 27 +++++++ ChangeLog.pre-1-10 | 27 +++++++ ChangeLog.pre-1-8 | 27 +++++++ modules/thai/thai-fc.c | 77 ++++++++++++-------- modules/thai/thai-ot.c | 148 +++++++++++++++++++------------------- modules/thai/thai-ot.h | 3 + modules/thai/thai-shaper.c | 172 ++++++++++++++++++--------------------------- modules/thai/thai-shaper.h | 16 +++-- 8 files changed, 284 insertions(+), 213 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c6f4573..178d533f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,30 @@ +2004-10-16 Theppitak Karoonboonyanan + + Merge from HEAD. + + * modules/thai/thai-ot.[ch] (thai_ot_get_ruleset), + modules/thai/thai-fc.c (thai_get_font_info): Prefer OpenType to PUA + substitutions. + + * modules/thai/thai-shaper.c (groups, group1_map, group2_map): + Remove unused data for XTIS. + + * modules/thai/thai-shaper.[ch] (enum ThaiFontSet, get_glyphs_list), + modules/thai/thai-fc.c (thai_get_font_info, thai_make_glyph): + Remove THAI_FONT_ISO10646 font set. + + * modules/thai/thai-fc.c (tis620_1): Fix the PUA glyph table. + + * modules/thai/thai-shaper.h (thai_{get,make}_glyph_{tis,uni}), + modules/thai/thai-shaper.c (get_adjusted_glyphs_list), + modules/thai/thai-fc.c (thai_{get,make}_glyph_{tis,uni}, tis620_2): + Explicitly handle dangling upper/lower marks with dottedcircle and + fails gracefully if the glyph is not available. + + * modules/thai/thai-shaper.[ch] (thai_get_glyph_tis, + thai_make_glyph_tis): Use guchar instead of gchar as argument type. + Make *_tis functions wrappers to *_uni functions. + 2004-09-15 Tor Lillqvist * pango/pangowin32-fontmap.c (pango_win32_insert_font): Ignore diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 0c6f4573..178d533f 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,30 @@ +2004-10-16 Theppitak Karoonboonyanan + + Merge from HEAD. + + * modules/thai/thai-ot.[ch] (thai_ot_get_ruleset), + modules/thai/thai-fc.c (thai_get_font_info): Prefer OpenType to PUA + substitutions. + + * modules/thai/thai-shaper.c (groups, group1_map, group2_map): + Remove unused data for XTIS. + + * modules/thai/thai-shaper.[ch] (enum ThaiFontSet, get_glyphs_list), + modules/thai/thai-fc.c (thai_get_font_info, thai_make_glyph): + Remove THAI_FONT_ISO10646 font set. + + * modules/thai/thai-fc.c (tis620_1): Fix the PUA glyph table. + + * modules/thai/thai-shaper.h (thai_{get,make}_glyph_{tis,uni}), + modules/thai/thai-shaper.c (get_adjusted_glyphs_list), + modules/thai/thai-fc.c (thai_{get,make}_glyph_{tis,uni}, tis620_2): + Explicitly handle dangling upper/lower marks with dottedcircle and + fails gracefully if the glyph is not available. + + * modules/thai/thai-shaper.[ch] (thai_get_glyph_tis, + thai_make_glyph_tis): Use guchar instead of gchar as argument type. + Make *_tis functions wrappers to *_uni functions. + 2004-09-15 Tor Lillqvist * pango/pangowin32-fontmap.c (pango_win32_insert_font): Ignore diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 0c6f4573..178d533f 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,30 @@ +2004-10-16 Theppitak Karoonboonyanan + + Merge from HEAD. + + * modules/thai/thai-ot.[ch] (thai_ot_get_ruleset), + modules/thai/thai-fc.c (thai_get_font_info): Prefer OpenType to PUA + substitutions. + + * modules/thai/thai-shaper.c (groups, group1_map, group2_map): + Remove unused data for XTIS. + + * modules/thai/thai-shaper.[ch] (enum ThaiFontSet, get_glyphs_list), + modules/thai/thai-fc.c (thai_get_font_info, thai_make_glyph): + Remove THAI_FONT_ISO10646 font set. + + * modules/thai/thai-fc.c (tis620_1): Fix the PUA glyph table. + + * modules/thai/thai-shaper.h (thai_{get,make}_glyph_{tis,uni}), + modules/thai/thai-shaper.c (get_adjusted_glyphs_list), + modules/thai/thai-fc.c (thai_{get,make}_glyph_{tis,uni}, tis620_2): + Explicitly handle dangling upper/lower marks with dottedcircle and + fails gracefully if the glyph is not available. + + * modules/thai/thai-shaper.[ch] (thai_get_glyph_tis, + thai_make_glyph_tis): Use guchar instead of gchar as argument type. + Make *_tis functions wrappers to *_uni functions. + 2004-09-15 Tor Lillqvist * pango/pangowin32-fontmap.c (pango_win32_insert_font): Ignore diff --git a/modules/thai/thai-fc.c b/modules/thai/thai-fc.c index e67c05c5..8fa0a3e3 100644 --- a/modules/thai/thai-fc.c +++ b/modules/thai/thai-fc.c @@ -34,6 +34,7 @@ #include "pangofc-font.h" #include "thai-shaper.h" +#include "thai-ot.h" /* No extra fields needed */ typedef PangoEngineShape ThaiEngineFc; @@ -79,22 +80,22 @@ static int tis620_0[128] = { }; static int tis620_1[128] = { - 0x00ab, 0x00bb, 0x2026, 0xf88c, 0xf88f, 0xf892, 0xf895, 0xf898, - 0xf88b, 0xf88e, 0xf891, 0xf894, 0xf897, 0x201c, 0x201d, 0xf899, - /**/ 0, 0x2022, 0xf884, 0xf889, 0xf885, 0xf886, 0xf887, 0xf888, - 0xf88a, 0xf88d, 0xf890, 0xf893, 0xf896, 0x2018, 0x2019, 0, - 0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, + /**/ 0, 0, 0, 0xf88c, 0xf88f, 0xf892, 0xf895, 0xf898, + 0xf88b, 0xf88e, 0xf891, 0xf894, 0xf897, 0, 0, 0xf899, + /**/ 0, 0, 0xf884, 0xf889, 0xf885, 0xf886, 0xf887, 0xf888, + 0xf88a, 0xf88d, 0xf890, 0xf893, 0xf896, 0, 0, 0, + /**/ 0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, - 0x0e38, 0x0e39, 0x0e3a, 0xfeff, 0x200b, 0x2013, 0x2014, 0x0e3f, + 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0, 0, 0x0e3f, 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, - 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x2122, 0x0e4f, + 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0, 0x0e4f, 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, - 0x0e58, 0x0e59, 0x00ae, 0x00a9, 0, 0, 0, 0 + 0x0e58, 0x0e59, 0, 0, 0, 0, 0, 0 }; static int tis620_2[128] = { @@ -109,7 +110,7 @@ static int tis620_2[128] = { 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, - 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0x25cc, 0, 0x0e3f, + 0x0e38, 0x0e39, 0x0e3a, 0, 0, 0, 0, 0x0e3f, 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f, 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, @@ -152,15 +153,15 @@ thai_get_font_info (PangoFont *font) font_info = g_new (ThaiFontInfo, 1); font_info->font = font; - /* detect font set by determining availibility of glyphs */ - if (contain_glyphs(font, tis620_2)) + /* detect font set by determining availibility of OT ruleset & glyphs */ + if (thai_ot_get_ruleset (font)) + font_info->font_set = THAI_FONT_TIS; + else if (contain_glyphs(font, tis620_2)) font_info->font_set = THAI_FONT_TIS_WIN; else if (contain_glyphs(font, tis620_1)) font_info->font_set = THAI_FONT_TIS_MAC; - else if (contain_glyphs(font, tis620_0)) - font_info->font_set = THAI_FONT_TIS; else - font_info->font_set = THAI_FONT_ISO10646; + font_info->font_set = THAI_FONT_TIS; g_object_set_qdata_full (G_OBJECT (font), info_id, font_info, (GDestroyNotify)g_free); } @@ -168,32 +169,52 @@ thai_get_font_info (PangoFont *font) return font_info; } +static gunichar +get_glyph_index_tis (ThaiFontInfo *font_info, guchar c) +{ + switch (font_info->font_set) { + case THAI_FONT_TIS: return (c & 0x80) ? tis620_0[c & 0x7f] : c; + case THAI_FONT_TIS_MAC: return (c & 0x80) ? tis620_1[c & 0x7f] : c; + case THAI_FONT_TIS_WIN: return (c & 0x80) ? tis620_2[c & 0x7f] : c; + default: return 0; + } +} + +PangoGlyph +thai_get_glyph_tis (ThaiFontInfo *font_info, guchar c) +{ + return thai_get_glyph_uni (font_info, get_glyph_index_tis (font_info, c)); +} + PangoGlyph -thai_make_glyph (ThaiFontInfo *font_info, unsigned int c) +thai_make_glyph_tis (ThaiFontInfo *font_info, guchar c) +{ + return thai_make_glyph_uni (font_info, get_glyph_index_tis (font_info, c)); +} + +PangoGlyph +thai_get_glyph_uni (ThaiFontInfo *font_info, gunichar uc) +{ + return pango_fc_font_get_glyph ((PangoFcFont *)font_info->font, uc); +} + +PangoGlyph +thai_make_glyph_uni (ThaiFontInfo *font_info, gunichar uc) { - int index; PangoGlyph result; PangoFcFont *fc_font = (PangoFcFont *)font_info->font; - switch (font_info->font_set) { - case THAI_FONT_ISO10646:index = c; break; - case THAI_FONT_TIS: index = (c & 0x80) ? tis620_0[c & 0x7f] : c; break; - case THAI_FONT_TIS_MAC: index = (c & 0x80) ? tis620_1[c & 0x7f] : c; break; - case THAI_FONT_TIS_WIN: index = (c & 0x80) ? tis620_2[c & 0x7f] : c; break; - default: index = 0; break; - } - - result = pango_fc_font_get_glyph (fc_font, index); + result = pango_fc_font_get_glyph (fc_font, uc); if (result) return result; else - return pango_fc_font_get_unknown_glyph (fc_font, index); + return pango_fc_font_get_unknown_glyph (fc_font, uc); } PangoGlyph -thai_make_unknown_glyph (ThaiFontInfo *font_info, unsigned int c) +thai_make_unknown_glyph (ThaiFontInfo *font_info, gunichar uc) { - return pango_fc_font_get_unknown_glyph ((PangoFcFont *)font_info->font, c); + return pango_fc_font_get_unknown_glyph ((PangoFcFont *)font_info->font, uc); } static void diff --git a/modules/thai/thai-ot.c b/modules/thai/thai-ot.c index 33fdce3f..bd57b9b9 100644 --- a/modules/thai/thai-ot.c +++ b/modules/thai/thai-ot.c @@ -9,7 +9,7 @@ #include "thai-ot.h" -static void +static gint maybe_add_gsub_feature (PangoOTRuleset *ruleset, PangoOTInfo *info, guint script_index, @@ -24,10 +24,12 @@ maybe_add_gsub_feature (PangoOTRuleset *ruleset, { pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GSUB, feature_index, property_bit); + return 1; } + return 0; } -static void +static gint maybe_add_gpos_feature (PangoOTRuleset *ruleset, PangoOTInfo *info, guint script_index, @@ -41,73 +43,79 @@ maybe_add_gpos_feature (PangoOTRuleset *ruleset, { pango_ot_ruleset_add_feature (ruleset, PANGO_OT_TABLE_GPOS, feature_index, property_bit); + return 1; } + return 0; } -static PangoOTRuleset * -get_gsub_ruleset (FT_Face face) +PangoOTRuleset * +thai_ot_get_ruleset (PangoFont *font) { - PangoOTInfo *info = pango_ot_info_get (face); - GQuark ruleset_quark = g_quark_from_string ("thai-gsub-ruleset"); - PangoOTRuleset *ruleset; + PangoFcFont *fc_font; + FT_Face face; + PangoOTInfo *info; + PangoOTRuleset *ruleset = NULL; - if (!info) - return NULL; + g_return_val_if_fail (font != NULL, NULL); - ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark); + fc_font = PANGO_FC_FONT (font); + face = pango_fc_font_lock_face (fc_font); + g_assert (face != NULL); - if (!ruleset) + info = pango_ot_info_get (face); + if (info != NULL) { - PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i'); - guint script_index; - - ruleset = pango_ot_ruleset_new (info); + static GQuark ruleset_quark = 0; - if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB, - thai_tag, &script_index)) - { - maybe_add_gsub_feature (ruleset, info, script_index, FT_MAKE_TAG ('c','c','m','p'), 0xFFFF); - maybe_add_gsub_feature (ruleset, info, script_index, FT_MAKE_TAG ('l','i','g','a'), 0xFFFF); - } + if (!ruleset_quark) + ruleset_quark = g_quark_from_string ("thai-ot-ruleset"); - g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, - (GDestroyNotify)g_object_unref); + ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark); + if (!ruleset) + { + PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i'); + guint script_index; + gint n = 0; + + ruleset = pango_ot_ruleset_new (info); + + if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GSUB, + thai_tag, &script_index)) + { + n += maybe_add_gsub_feature (ruleset, info, script_index, + FT_MAKE_TAG ('c','c','m','p'), + 0xFFFF); + n += maybe_add_gsub_feature (ruleset, info, script_index, + FT_MAKE_TAG ('l','i','g','a'), + 0xFFFF); + } + + if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS, + thai_tag, &script_index)) + { + n += maybe_add_gpos_feature (ruleset, info, script_index, + FT_MAKE_TAG ('k','e','r','n'), + 0xFFFF); + n += maybe_add_gpos_feature (ruleset, info, script_index, + FT_MAKE_TAG ('m','a','r','k'), + 0xFFFF); + n += maybe_add_gpos_feature (ruleset, info, script_index, + FT_MAKE_TAG ('m','k','m','k'), + 0xFFFF); + } + + if (n > 0) + g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, + (GDestroyNotify)g_object_unref); + else + { + g_object_unref (ruleset); + ruleset = NULL; + } + } } - return ruleset; -} - - -static PangoOTRuleset * -get_gpos_ruleset (FT_Face face) -{ - PangoOTInfo *info = pango_ot_info_get (face); - GQuark ruleset_quark = g_quark_from_string ("thai-gpos-ruleset"); - PangoOTRuleset *ruleset; - - if (!info) - return NULL; - - ruleset = g_object_get_qdata (G_OBJECT (info), ruleset_quark); - - if (!ruleset) - { - PangoOTTag thai_tag = FT_MAKE_TAG ('t', 'h', 'a', 'i'); - guint script_index; - - ruleset = pango_ot_ruleset_new (info); - - if (pango_ot_info_find_script (info, PANGO_OT_TABLE_GPOS, - thai_tag, &script_index)) - { - maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('k','e','r','n'), 0xFFFF); - maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','a','r','k'), 0xFFFF); - maybe_add_gpos_feature (ruleset, info, script_index, FT_MAKE_TAG ('m','k','m','k'), 0xFFFF); - } - - g_object_set_qdata_full (G_OBJECT (info), ruleset_quark, ruleset, - (GDestroyNotify)g_object_unref); - } + pango_fc_font_unlock_face (fc_font); return ruleset; } @@ -117,27 +125,20 @@ void thai_ot_shape (PangoFont *font, PangoGlyphString *glyphs) { - FT_Face face; - PangoOTRuleset *gsub_ruleset, *gpos_ruleset; - PangoFcFont *fc_font; + PangoOTRuleset *ot_ruleset; g_return_if_fail (font != NULL); g_return_if_fail (glyphs != NULL); - fc_font = PANGO_FC_FONT (font); - face = pango_fc_font_lock_face (fc_font); - g_assert (face != NULL); - - gsub_ruleset = get_gsub_ruleset (face); - gpos_ruleset = get_gpos_ruleset (face); + ot_ruleset = thai_ot_get_ruleset (font); - if (gsub_ruleset != NULL || gpos_ruleset != NULL) + if (ot_ruleset != NULL) { gint i; PangoOTBuffer *buffer; /* prepare ot buffer */ - buffer = pango_ot_buffer_new (fc_font); + buffer = pango_ot_buffer_new (PANGO_FC_FONT (font)); for (i = 0; i < glyphs->num_glyphs; i++) { pango_ot_buffer_add_glyph (buffer, @@ -146,18 +147,11 @@ thai_ot_shape (PangoFont *font, glyphs->log_clusters[i]); } - /* do gsub processing */ - if (gsub_ruleset != NULL) - pango_ot_ruleset_substitute (gsub_ruleset, buffer); - - /* do gpos processing */ - if (gpos_ruleset != NULL) - pango_ot_ruleset_position (gpos_ruleset, buffer); + pango_ot_ruleset_substitute (ot_ruleset, buffer); + pango_ot_ruleset_position (ot_ruleset, buffer); pango_ot_buffer_output (buffer, glyphs); pango_ot_buffer_destroy (buffer); } - - pango_fc_font_unlock_face (fc_font); } diff --git a/modules/thai/thai-ot.h b/modules/thai/thai-ot.h index 43f79ef8..4e195e8c 100644 --- a/modules/thai/thai-ot.h +++ b/modules/thai/thai-ot.h @@ -10,6 +10,9 @@ #include "pango-ot.h" +PangoOTRuleset * +thai_ot_get_ruleset (PangoFont *font); + void thai_ot_shape (PangoFont *font, PangoGlyphString *glyphs); diff --git a/modules/thai/thai-shaper.c b/modules/thai/thai-shaper.c index 3a0b4d88..7c036e9a 100644 --- a/modules/thai/thai-shaper.c +++ b/modules/thai/thai-shaper.c @@ -83,41 +83,6 @@ #define char_class(wc) TAC_char_class[(unsigned int)(wc)] #define is_char_type(wc, mask) (char_type_table[ucs2tis ((wc))] & (mask)) -/* All combining marks for Thai fall in the range U+0E30-U+0E50, - * so we confine our data tables to that range, and use - * default values for characters outside those ranges. - */ - -/* Map from code point to group used for rendering with XTIS fonts - * (0 == base character) - */ -static const char groups[32] = { - 0, 1, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2, - 2, 2, 2, 2, 2, 2, 1, 0 -}; - -/* Map from code point to index within group 1 - * (0 == no combining mark from group 1) - */ -static const char group1_map[32] = { - 0, 1, 0, 0, 2, 3, 4, 5, - 6, 7, 8, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 -}; - -/* Map from code point to index within group 2 - * (0 == no combining mark from group 2) - */ -static const char group2_map[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, - 2, 3, 4, 5, 6, 7, 1, 0 -}; - static const gint char_type_table[256] = { /* 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F */ @@ -316,6 +281,12 @@ add_glyph (ThaiFontInfo *font_info, glyphs->glyphs[index].geometry.y_offset = 0; } +static PangoGlyph +get_null_base_glyph (ThaiFontInfo *font_info) +{ + return thai_get_glyph_uni (font_info, 0x25cc); +} + static gint get_adjusted_glyphs_list (ThaiFontInfo *font_info, gunichar *cluster, @@ -328,18 +299,17 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, case 1: if (is_char_type (cluster[0], BelowVowel|BelowDiac|AboveVowel|AboveDiac|Tone)) { - if (font_info->font_set == THAI_FONT_TIS) - glyph_lists[0] = thai_make_glyph (font_info, 0x20); - else - glyph_lists[0] = thai_make_glyph (font_info, 0xDD); - glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - return 2; + gint n; + glyph_lists[0] = get_null_base_glyph (font_info); + n = glyph_lists[0] ? 1 : 0; + glyph_lists[n++] = + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + return n; } else { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); return 1; } break; @@ -349,36 +319,36 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[1], SaraAm)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, 0xED); - glyph_lists[2] = thai_make_glyph (font_info, 0xD2); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, 0xED); + glyph_lists[2] = thai_make_glyph_tis (font_info, 0xD2); return 3; } else if (is_char_type (cluster[0], UpTailCons) && is_char_type (cluster[1], SaraAm)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, shiftleft_tone_ad (0xED, shaping_table)); - glyph_lists[2] = thai_make_glyph (font_info, 0xD2); + glyph_lists[2] = thai_make_glyph_tis (font_info, 0xD2); return 3; } else if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) && is_char_type (cluster[1], AboveVowel)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); return 2; } else if (is_char_type (cluster[0], NoTailCons|BotTailCons|SpltTailCons) && is_char_type (cluster[1], AboveDiac|Tone)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, shiftdown_tone_ad (ucs2tis (cluster[1]), shaping_table)); return 2; } @@ -386,8 +356,8 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[1], AboveVowel)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, shiftleft_av (ucs2tis (cluster[1]), shaping_table)); return 2; } @@ -395,8 +365,8 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[1], AboveDiac|Tone)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, shiftdownleft_tone_ad (ucs2tis (cluster[1]), shaping_table)); return 2; } @@ -404,41 +374,40 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[1], BelowVowel|BelowDiac)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); return 2; } else if (is_char_type (cluster[0], BotTailCons) && is_char_type (cluster[1], BelowVowel|BelowDiac)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = - thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, shiftdown_bv_bd (ucs2tis (cluster[1]), shaping_table)); return 2; } else if (is_char_type (cluster[0], SpltTailCons) && is_char_type (cluster[1], BelowVowel|BelowDiac)) { - glyph_lists[0] = thai_make_glyph (font_info, + glyph_lists[0] = thai_make_glyph_tis (font_info, tailcutcons (ucs2tis (cluster[0]), shaping_table)); glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); return 2; } else { - if (font_info->font_set == THAI_FONT_TIS) - glyph_lists[0] = thai_make_glyph (font_info, 0x20); - else - glyph_lists[0] = thai_make_glyph (font_info, 0xDD); - glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[2] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); - return 3; + gint n; + glyph_lists[0] = get_null_base_glyph (font_info); + n = glyph_lists[0] ? 1 : 0; + glyph_lists[n++] = + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[n++] = + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); + return n; } break; @@ -448,11 +417,11 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[2], SaraAm)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, 0xED); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, 0xED); glyph_lists[2] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); - glyph_lists[3] = thai_make_glyph (font_info, 0xD2); + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); + glyph_lists[3] = thai_make_glyph_tis (font_info, 0xD2); return 4; } else if (is_char_type (cluster[0], UpTailCons) && @@ -460,12 +429,12 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[2], SaraAm)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, shiftleft_tone_ad (0xED, shaping_table)); - glyph_lists[2] = thai_make_glyph (font_info, + glyph_lists[2] = thai_make_glyph_tis (font_info, shiftleft_tone_ad (ucs2tis (cluster[1]), shaping_table)); - glyph_lists[3] = thai_make_glyph (font_info, 0xD2); + glyph_lists[3] = thai_make_glyph_tis (font_info, 0xD2); return 4; } else if (is_char_type (cluster[0], UpTailCons) && @@ -473,10 +442,10 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, shiftleft_av (ucs2tis (cluster[1]), shaping_table)); - glyph_lists[2] = thai_make_glyph (font_info, + glyph_lists[2] = thai_make_glyph_tis (font_info, shiftleft_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } @@ -485,10 +454,10 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); - glyph_lists[2] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); + glyph_lists[2] = thai_make_glyph_tis (font_info, shiftdownleft_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } @@ -497,11 +466,11 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); glyph_lists[2] = - thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } @@ -509,11 +478,11 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[1], BelowVowel) && is_char_type (cluster[2], AboveDiac|Tone)) { - glyph_lists[0] = thai_make_glyph (font_info, + glyph_lists[0] = thai_make_glyph_tis (font_info, tailcutcons (ucs2tis (cluster[0]), shaping_table)); glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); - glyph_lists[2] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); + glyph_lists[2] = thai_make_glyph_tis (font_info, shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } @@ -522,21 +491,21 @@ get_adjusted_glyphs_list (ThaiFontInfo *font_info, is_char_type (cluster[2], AboveDiac|Tone)) { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); - glyph_lists[1] = thai_make_glyph (font_info, + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); + glyph_lists[1] = thai_make_glyph_tis (font_info, shiftdown_bv_bd (ucs2tis (cluster[1]), shaping_table)); - glyph_lists[2] = thai_make_glyph (font_info, + glyph_lists[2] = thai_make_glyph_tis (font_info, shiftdown_tone_ad (ucs2tis (cluster[2]), shaping_table)); return 3; } else { glyph_lists[0] = - thai_make_glyph (font_info, ucs2tis (cluster[0])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[0])); glyph_lists[1] = - thai_make_glyph (font_info, ucs2tis (cluster[1])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[1])); glyph_lists[2] = - thai_make_glyph (font_info, ucs2tis (cluster[2])); + thai_make_glyph_tis (font_info, ucs2tis (cluster[2])); return 3; } break; @@ -577,11 +546,6 @@ get_glyphs_list (ThaiFontInfo *font_info, */ return get_adjusted_glyphs_list (font_info, cluster, num_chrs, glyph_lists, &Win_shape_table); - - case THAI_FONT_ISO10646: - for (i=0; i < num_chrs; i++) - glyph_lists[i] = thai_make_glyph (font_info, cluster[i]); - return num_chrs; } return 0; /* Quiet GCC */ @@ -602,7 +566,7 @@ add_cluster (ThaiFontInfo *font_info, { g_assert (num_chrs == 1); add_glyph (font_info, glyphs, cluster_start, - thai_make_glyph (font_info, cluster[0]), + thai_make_glyph_uni (font_info, cluster[0]), FALSE); } else diff --git a/modules/thai/thai-shaper.h b/modules/thai/thai-shaper.h index 8055ce85..f54814b8 100644 --- a/modules/thai/thai-shaper.h +++ b/modules/thai/thai-shaper.h @@ -13,8 +13,7 @@ typedef enum { THAI_FONT_NONE, THAI_FONT_TIS, THAI_FONT_TIS_MAC, - THAI_FONT_TIS_WIN, - THAI_FONT_ISO10646 + THAI_FONT_TIS_WIN } ThaiFontSet; typedef enum { @@ -35,10 +34,19 @@ ThaiFontInfo * thai_get_font_info (PangoFont *font); PangoGlyph -thai_make_glyph (ThaiFontInfo *font_info, unsigned int c); +thai_get_glyph_tis (ThaiFontInfo *font_info, guchar c); PangoGlyph -thai_make_unknown_glyph (ThaiFontInfo *font_info, unsigned int c); +thai_make_glyph_tis (ThaiFontInfo *font_info, guchar c); + +PangoGlyph +thai_get_glyph_uni (ThaiFontInfo *font_info, gunichar uc); + +PangoGlyph +thai_make_glyph_uni (ThaiFontInfo *font_info, gunichar uc); + +PangoGlyph +thai_make_unknown_glyph (ThaiFontInfo *font_info, gunichar uc); /* * Public functions -- cgit v1.2.1