diff options
author | Changwoo Ryu <cwryu@debian.org> | 2002-11-03 19:56:24 +0000 |
---|---|---|
committer | Changwoo Ryu <cwryu@src.gnome.org> | 2002-11-03 19:56:24 +0000 |
commit | 5472a80224c3054772b3920df4b1b4e42a319ec9 (patch) | |
tree | b2c77a9e0c06f597a11e8704c7849444abbb7a31 /modules | |
parent | 71d62a7febe8a8ee7fb4b00410fe9c4f13da44e0 (diff) | |
download | pango-5472a80224c3054772b3920df4b1b4e42a319ec9.tar.gz |
Fixed wrong syllable check.
2002-11-04 Changwoo Ryu <cwryu@debian.org>
* modules/hangul/hangul-defs.h (IS_S): Fixed wrong syllable
check.
* modules/hangul/hangul-defs.h:
* modules/hangul/hangul-x.c: No more use of TFILL, the internal
trailing consonant filler.
(render_syllable_with_*): Appended empty syllable
(ex. LFILL+VFILL) rendering case (#96175).
(render_syllable_with_ksx1005): Fixed wrong fallback glyphs
indices (from #95800 by Jungshik Shin).
Diffstat (limited to 'modules')
-rw-r--r-- | modules/hangul/hangul-defs.h | 7 | ||||
-rw-r--r-- | modules/hangul/hangul-fc.c | 16 | ||||
-rw-r--r-- | modules/hangul/hangul-x.c | 111 | ||||
-rw-r--r-- | modules/hangul/hangul-xft.c | 16 |
4 files changed, 109 insertions, 41 deletions
diff --git a/modules/hangul/hangul-defs.h b/modules/hangul/hangul-defs.h index 8ed34b60..2ddf339a 100644 --- a/modules/hangul/hangul-defs.h +++ b/modules/hangul/hangul-defs.h @@ -44,20 +44,19 @@ */ #define LFILL 0x115F #define VFILL 0x1160 -#define TFILL 0x11A7 #define HTONE1 0x302E #define HTONE2 0x302F #define IS_L(wc) (wc >= LBASE && wc <= LEND) #define IS_V(wc) (wc >= VFILL && wc <= VEND) -#define IS_T(wc) (wc >= TBASE && wc <= TEND) +#define IS_T(wc) (wc > TBASE && wc <= TEND) #define IS_M(wc) (wc == HTONE1 || wc == HTONE2) /* jamo which can be composited as a Hangul syllable */ #define IS_L_S(wc) (wc >= LBASE && wc < LBASE + LCOUNT) #define IS_V_S(wc) (wc >= VBASE && wc < VBASE + VCOUNT) -#define IS_T_S(wc) (wc >= TBASE && wc < TBASE + TCOUNT) +#define IS_T_S(wc) (wc > TBASE && wc < TBASE + TCOUNT) #define S_FROM_LVT(l,v,t) (SBASE + (((l) - LBASE) * VCOUNT + ((v) - VBASE)) * TCOUNT + ((t) - TBASE)) #define S_FROM_LV(l,v) (SBASE + (((l) - LBASE) * VCOUNT + ((v) - VBASE)) * TCOUNT) @@ -65,5 +64,5 @@ #define V_FROM_S(s) (VBASE + (((s) - SBASE) % NCOUNT) / TCOUNT) #define T_FROM_S(s) (TBASE + (((s) - SBASE) % TCOUNT)) -#define IS_S(wc) (SBASE <= (wc) && (wc) <= SCOUNT) +#define IS_S(wc) (SBASE <= (wc) && (wc) < (SBASE + SCOUNT)) #define S_HAS_T(s) (((s) - SBASE) % TCOUNT) diff --git a/modules/hangul/hangul-fc.c b/modules/hangul/hangul-fc.c index 461ad264..49cbf9f9 100644 --- a/modules/hangul/hangul-fc.c +++ b/modules/hangul/hangul-fc.c @@ -157,6 +157,7 @@ static void render_syllable (PangoFont *font, gunichar *text, int length, PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) { + int n_prev_glyphs = *n_glyphs; int index; gunichar wc, tone; int i, j, composed; @@ -199,6 +200,9 @@ render_syllable (PangoFont *font, gunichar *text, int length, { int jindex; + if (text[i] == LFILL || text[i] == VFILL) + continue; + index = find_char (font, text[i]); if (index) { @@ -224,6 +228,18 @@ render_syllable (PangoFont *font, gunichar *text, int length, (*n_glyphs)++; } } + if (n_prev_glyphs == *n_glyphs) + { + index = find_char (font, 0x3164); + pango_glyph_string_set_size (glyphs, *n_glyphs + 1); + if (!index) + set_glyph (font, glyphs, *n_glyphs, cluster_offset, + pango_xft_font_get_unknown_glyph (font, index)); + else + set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); + glyphs->log_clusters[*n_glyphs] = cluster_offset; + (*n_glyphs)++; + } if (tone) render_tone(font, tone, glyphs, n_glyphs, cluster_offset); } diff --git a/modules/hangul/hangul-x.c b/modules/hangul/hangul-x.c index 799f3bc1..12d568c4 100644 --- a/modules/hangul/hangul-x.c +++ b/modules/hangul/hangul-x.c @@ -139,33 +139,19 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont, if (n_cho <= 1 && n_jung <= 1) \ { \ int composed = 0; \ - gunichar2 l, v, t; \ + gunichar2 l, v, t = 0; \ \ - if (n_cho > 0) \ - l = text[0]; \ - else \ - l = LFILL; \ - \ - if (n_jung > 0) \ - v = text[n_cho]; \ - else \ - v = VFILL; \ - \ - if (n_jong > 0) \ - t = text[n_cho + n_jung]; \ - else \ - t = TFILL; \ + l = (n_cho > 0) ? text[0] : LFILL; \ + v = (n_jung > 0) ? text[n_cho] : VFILL; \ + t = (n_jong > 0) ? text[n_cho + n_jung] : 0; \ \ if ((__choseong_johabfont_base[l - LBASE] != 0 || l == LFILL) && \ (__jungseong_johabfont_base[v - VBASE] != 0 || v == VFILL) && \ - (__jongseong_johabfont_base[t - TBASE] != 0 || t == TFILL)) \ + (!t || (__jongseong_johabfont_base[t - TBASE] != 0))) \ composed = n_cho + n_jung + ((n_jong > 0) ? 1 : 0); \ else if ((__choseong_johabfont_base[l - LBASE] != 0 || l == LFILL) && \ (__jungseong_johabfont_base[v - VBASE] != 0 || v == VFILL)) \ - { \ - composed = n_cho + n_jung; \ - t = TFILL; \ - } \ + composed = n_cho + n_jung; \ \ /* COMPOSABLE */ \ if (composed) \ @@ -173,7 +159,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont, if (l != LFILL) \ { \ gindex = __choseong_johabfont_base[l - LBASE]; \ - if (t == TFILL) \ + if (!t) \ { \ if (v == VFILL) \ gindex += 1; \ @@ -199,11 +185,12 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont, switch (__johabfont_jungseong_kind[v - VBASE]) \ { \ case 3: \ - gindex += __johabfont_jongseong_kind[t - TBASE]; \ + if (t) \ + gindex += __johabfont_jongseong_kind[t - TBASE]; \ break; \ case 4: \ gindex += ((l == 0x1100 || l == 0x110f) ? 0 : 1) + \ - ((t != TFILL) ? 2 : 0); \ + (t ? 2 : 0); \ break; \ } \ \ @@ -213,7 +200,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont, (*n_glyphs)++; \ } \ \ - if (t != TFILL) \ + if (t) \ { \ gindex = __jongseong_johabfont_base[t - TBASE] + \ __jongseong_map[v - VBASE]; \ @@ -223,7 +210,7 @@ typedef void (* RenderSyllableFunc) (PangoFont *font, PangoXSubfont subfont, (*n_glyphs)++; \ } \ \ - if (v == VFILL && t == TFILL) /* dummy for no zero width */ \ + if (v == VFILL && !t) /* dummy for no zero width */ \ { \ pango_glyph_string_set_size (glyphs, *n_glyphs + 1); \ set_glyph (glyphs, *n_glyphs, font, subfont, JOHAB_FILLER); \ @@ -242,6 +229,7 @@ render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont, PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) { + int n_prev_glyphs = *n_glyphs; JOHAB_COMMON /* Render as uncomposed forms as a fallback. */ @@ -249,7 +237,7 @@ render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont, { int j; - if (text[i] == LFILL || text[i] == VFILL || text[i] == TFILL) + if (text[i] == LFILL || text[i] == VFILL) continue; /* * Uses KSC5601 symbol glyphs which johabS-1 has; they're @@ -275,7 +263,15 @@ render_syllable_with_johabs (PangoFont *font, PangoXSubfont subfont, if (j == 0) set_unknown_glyph (glyphs, n_glyphs, font, text[i], cluster_offset); } - + /* No glyph rendered yet; it means the empty syllable (ex. LFILL+VFILL) */ + if (n_prev_glyphs == *n_glyphs) + { + gindex = JOHAB_FILLER; + pango_glyph_string_set_size (glyphs, *n_glyphs + 1); + set_glyph (glyphs, *n_glyphs, font, subfont, gindex); + glyphs->log_clusters[*n_glyphs] = cluster_offset; + (*n_glyphs)++; + } } static void @@ -284,6 +280,7 @@ render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont, PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) { + int n_prev_glyphs = *n_glyphs; JOHAB_COMMON /* Render as uncomposed forms as a fallback. */ @@ -291,7 +288,7 @@ render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont, { int j; - if (text[i] == LFILL || text[i] == VFILL || text[i] == TFILL) + if (text[i] == LFILL || text[i] == VFILL) continue; for (j = 0; (j < 3) && (__jamo_to_johabfont[text[i]-LBASE][j] != 0); j++) { @@ -311,8 +308,15 @@ render_syllable_with_johab (PangoFont *font, PangoXSubfont subfont, if (j == 0) set_unknown_glyph (glyphs, n_glyphs, font, text[i], cluster_offset); } - if (*n_glyphs == 0) - set_unknown_glyph (glyphs, n_glyphs, font, 0, cluster_offset); + /* No glyph rendered yet; it means the empty syllable (ex. LFILL+VFILL) */ + if (n_prev_glyphs == *n_glyphs) + { + gindex = JOHAB_FILLER; + pango_glyph_string_set_size (glyphs, *n_glyphs + 1); + set_glyph (glyphs, *n_glyphs, font, subfont, gindex); + glyphs->log_clusters[*n_glyphs] = cluster_offset; + (*n_glyphs)++; + } } static void @@ -321,6 +325,7 @@ render_syllable_with_ksx1005 (PangoFont *font, PangoXSubfont subfont, PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) { + int n_prev_glyphs = *n_glyphs; guint16 gindex; int i, composed; @@ -359,7 +364,7 @@ render_syllable_with_ksx1005 (PangoFont *font, PangoXSubfont subfont, { int j; - if (text[i] == LFILL || text[i] == VFILL || text[i] == TFILL) + if (text[i] == LFILL || text[i] == VFILL) continue; gindex = text[i]; @@ -369,7 +374,7 @@ render_syllable_with_ksx1005 (PangoFont *font, PangoXSubfont subfont, if (index >= 0x2400 && index < 0x2500) index = 0xda80 + index % 256; else /* 0x2300 - 0x2400 */ - index = 0xda10 + index % 256; + index = 0xda10 + index % 256 + (index > 0x236e ? 0x12 : 0); pango_glyph_string_set_size (glyphs, *n_glyphs + 1); set_glyph (glyphs, *n_glyphs, font, subfont, index); glyphs->log_clusters[*n_glyphs] = cluster_offset; @@ -378,6 +383,15 @@ render_syllable_with_ksx1005 (PangoFont *font, PangoXSubfont subfont, if (j == 0) set_unknown_glyph (glyphs, n_glyphs, font, gindex, cluster_offset); } + /* No glyph rendered yet; it means the empty syllable (ex. LFILL+VFILL) */ + if (n_prev_glyphs == *n_glyphs) + { + gindex = 0xd931; + pango_glyph_string_set_size (glyphs, *n_glyphs + 1); + set_glyph (glyphs, *n_glyphs, font, subfont, gindex); + glyphs->log_clusters[*n_glyphs] = cluster_offset; + (*n_glyphs)++; + } } static void @@ -386,6 +400,7 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont, PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) { + int n_prev_glyphs = *n_glyphs; guint16 gindex; int i, composed; @@ -413,12 +428,24 @@ render_syllable_with_iso10646 (PangoFont *font, PangoXSubfont subfont, /* Render as uncomposed forms as a fallback. */ for (i = 0; i < length; i++) { + if (text[i] == LFILL || text[i] == VFILL) + continue; + gindex = text[i]; pango_glyph_string_set_size (glyphs, *n_glyphs + 1); set_glyph (glyphs, *n_glyphs, font, subfont, gindex); glyphs->log_clusters[*n_glyphs] = cluster_offset; (*n_glyphs)++; } + /* No glyph rendered yet; it means the empty syllable (ex. LFILL+VFILL) */ + if (n_prev_glyphs == *n_glyphs) + { + gindex = 0x3164; + pango_glyph_string_set_size (glyphs, *n_glyphs + 1); + set_glyph (glyphs, *n_glyphs, font, subfont, gindex); + glyphs->log_clusters[*n_glyphs] = cluster_offset; + (*n_glyphs)++; + } } static int @@ -500,6 +527,7 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont, PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) { + int n_prev_glyphs = *n_glyphs; int gindex = 0, composed = 0; gunichar2 jong1, jong2 = 0; int i; @@ -567,6 +595,15 @@ render_syllable_with_ksc5601 (PangoFont *font, PangoXSubfont subfont, if (j == 0) set_unknown_glyph (glyphs, n_glyphs, font, gindex, cluster_offset); } + /* No glyph rendered yet; it means the empty syllable (ex. LFILL+VFILL) */ + if (n_prev_glyphs == *n_glyphs) + { + gindex = 0x2121; + pango_glyph_string_set_size (glyphs, *n_glyphs + 1); + set_glyph (glyphs, *n_glyphs, font, subfont, gindex); + glyphs->log_clusters[*n_glyphs] = cluster_offset; + (*n_glyphs)++; + } } static gboolean @@ -714,10 +751,10 @@ hangul_engine_shape (PangoFont *font, gint16 sindex; sindex = wc4 - SBASE; - wcs[0] = LBASE + (sindex / NCOUNT); - wcs[1] = VBASE + ((sindex % NCOUNT) / TCOUNT); - wcs[2] = TBASE + (sindex % TCOUNT); - n_code = 3; + wcs[n_code++] = LBASE + (sindex / NCOUNT); + wcs[n_code++] = VBASE + ((sindex % NCOUNT) / TCOUNT); + if (sindex % TCOUNT) + wcs[n_code++] = TBASE + (sindex % TCOUNT); if (n_jamos > 0) { @@ -728,7 +765,7 @@ hangul_engine_shape (PangoFont *font, } /* Draw a syllable. */ - (*render_func) (font, subfont, wcs, 3, + (*render_func) (font, subfont, wcs, n_code, glyphs, &n_glyphs, cluster_offset); cluster_offset = next - text; /* Clear. */ diff --git a/modules/hangul/hangul-xft.c b/modules/hangul/hangul-xft.c index 461ad264..49cbf9f9 100644 --- a/modules/hangul/hangul-xft.c +++ b/modules/hangul/hangul-xft.c @@ -157,6 +157,7 @@ static void render_syllable (PangoFont *font, gunichar *text, int length, PangoGlyphString *glyphs, int *n_glyphs, int cluster_offset) { + int n_prev_glyphs = *n_glyphs; int index; gunichar wc, tone; int i, j, composed; @@ -199,6 +200,9 @@ render_syllable (PangoFont *font, gunichar *text, int length, { int jindex; + if (text[i] == LFILL || text[i] == VFILL) + continue; + index = find_char (font, text[i]); if (index) { @@ -224,6 +228,18 @@ render_syllable (PangoFont *font, gunichar *text, int length, (*n_glyphs)++; } } + if (n_prev_glyphs == *n_glyphs) + { + index = find_char (font, 0x3164); + pango_glyph_string_set_size (glyphs, *n_glyphs + 1); + if (!index) + set_glyph (font, glyphs, *n_glyphs, cluster_offset, + pango_xft_font_get_unknown_glyph (font, index)); + else + set_glyph (font, glyphs, *n_glyphs, cluster_offset, index); + glyphs->log_clusters[*n_glyphs] = cluster_offset; + (*n_glyphs)++; + } if (tone) render_tone(font, tone, glyphs, n_glyphs, cluster_offset); } |