summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorTheppitak Karoonboonyanan <thep@linux.thai.net>2004-10-09 05:37:47 +0000
committerTheppitak Karoonboonyanan <tkaroonb@src.gnome.org>2004-10-09 05:37:47 +0000
commit9b0aef862faa8959dce96825dff23a373442c03f (patch)
tree0f59230b1c8d41b662d6feeadee0ad964f050f6e /modules
parent8251e4eda751a127b4a4d811f0f9c15d7bbf0f09 (diff)
downloadpango-9b0aef862faa8959dce96825dff23a373442c03f.tar.gz
Explicitly handle dangling upper/lower marks by optionally using
2004-10-09 Theppitak Karoonboonyanan <thep@linux.thai.net> Explicitly handle dangling upper/lower marks by optionally using dottedcircle as base, rather than requiring it. * modules/thai/thai-shaper.h: Explicitly declare make_glyph and get_glyph functions for 8-bit and Unicode chars as separate functions. * modules/thai/thai-shaper.c (get_adjusted_glyphs_list): Rename function calls to the new ones. Conditionally use dottedcircle glyph as base for dangling upper/lower marks if available; simply expand width to that of inkrect otherwise. * modules/thai/thai-fc.c: Implement those new functions declared in thai-shaper.h. Remove 0x25cc from tis620_2 glyph set.
Diffstat (limited to 'modules')
-rw-r--r--modules/thai/thai-fc.c55
-rw-r--r--modules/thai/thai-shaper.c132
-rw-r--r--modules/thai/thai-shaper.h13
3 files changed, 122 insertions, 78 deletions
diff --git a/modules/thai/thai-fc.c b/modules/thai/thai-fc.c
index ac4c65be..324d3fbf 100644
--- a/modules/thai/thai-fc.c
+++ b/modules/thai/thai-fc.c
@@ -110,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,
@@ -169,20 +169,32 @@ thai_get_font_info (PangoFont *font)
return font_info;
}
+static gint
+thai_get_glyph_index (ThaiFontInfo *font_info, gchar 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, gchar c)
+{
+ return pango_fc_font_get_glyph ((PangoFcFont *)font_info->font,
+ thai_get_glyph_index (font_info, c));
+}
+
PangoGlyph
-thai_make_glyph (ThaiFontInfo *font_info, unsigned int c)
+thai_make_glyph_tis (ThaiFontInfo *font_info, gchar c)
{
- int index;
+ gint index;
PangoGlyph result;
PangoFcFont *fc_font = (PangoFcFont *)font_info->font;
- switch (font_info->font_set) {
- 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;
- }
-
+ index = thai_get_glyph_index (font_info, c);
result = pango_fc_font_get_glyph (fc_font, index);
if (result)
return result;
@@ -191,9 +203,28 @@ thai_make_glyph (ThaiFontInfo *font_info, unsigned int c)
}
PangoGlyph
-thai_make_unknown_glyph (ThaiFontInfo *font_info, unsigned int c)
+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)
+{
+ PangoGlyph result;
+ PangoFcFont *fc_font = (PangoFcFont *)font_info->font;
+
+ result = pango_fc_font_get_glyph (fc_font, uc);
+ if (result)
+ return result;
+ else
+ return pango_fc_font_get_unknown_glyph (fc_font, uc);
+}
+
+PangoGlyph
+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-shaper.c b/modules/thai/thai-shaper.c
index f7d99f5d..7c036e9a 100644
--- a/modules/thai/thai-shaper.c
+++ b/modules/thai/thai-shaper.c
@@ -281,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,
@@ -293,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;
@@ -314,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;
}
@@ -351,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;
}
@@ -360,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;
}
@@ -369,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;
@@ -413,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) &&
@@ -425,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) &&
@@ -438,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;
}
@@ -450,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;
}
@@ -462,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;
}
@@ -474,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;
}
@@ -487,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;
@@ -562,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 675d95ae..19850730 100644
--- a/modules/thai/thai-shaper.h
+++ b/modules/thai/thai-shaper.h
@@ -34,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, gchar c);
PangoGlyph
-thai_make_unknown_glyph (ThaiFontInfo *font_info, unsigned int c);
+thai_make_glyph_tis (ThaiFontInfo *font_info, gchar 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