Index: hangul-x.c
===================================================================
RCS file: /cvs/gnome/pango/modules/hangul/hangul-x.c,v
retrieving revision 1.22
diff -u -r1.22 hangul-x.c
--- hangul-x.c	15 Oct 2002 08:48:34 -0000	1.22
+++ hangul-x.c	15 Oct 2002 20:25:40 -0000
@@ -315,11 +315,22 @@
     set_unknown_glyph (glyphs, n_glyphs, font, 0, cluster_offset);
 }
 
+#define LVT_TO_JOHAB(lidx,vidx,tidx,c) \
+    { \
+      gindex = 0x8000 + (larray[lidx] << 10) + (varray[vidx] << 5) + tarray[tidx]; \
+      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)++; \
+      text += (c); \
+      length -= (c); \
+    }
+
 static void
-render_syllable_with_ksx1005 (PangoFont *font, PangoXSubfont subfont,
-			       gunichar2 *text, int length,
-			       PangoGlyphString *glyphs,
-			       int *n_glyphs, int cluster_offset)
+render_syllable_with_ksx1001johab (PangoFont *font, PangoXSubfont subfont,
+			           gunichar2 *text, int length,
+			           PangoGlyphString *glyphs,
+			           int *n_glyphs, int cluster_offset)
 {
   guint16 gindex;
   int i, composed;
@@ -341,17 +352,8 @@
 	tindex = text[2] - TBASE;
       else
 	tindex = 0;
-
-      /* convert to JOHAB */
  
-      gindex = 0x8000 + (larray[lindex] << 10) + (varray[vindex] << 5) + tarray[tindex];
-
-      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)++;
-      text += composed;
-      length -= composed;
+      LVT_TO_JOHAB(lindex+1,vindex+1,tindex,composed)
     }
 
   /* Render as uncomposed forms as a fallback.  */
@@ -362,6 +364,31 @@
       if (text[i] == LFILL || text[i] == VFILL || text[i] == TFILL)
 	continue;
 
+/* 
+   Modern Jamo code points in ksc5601.1992-3 font cannot be obtained 
+	 by shifting Jamo code points in ksc5601.1987-0  code points.
+	 Their code points have to be calculated as if they're 
+	 incomplete syllables with L/V/T fillers in place of L/V/T. 
+	 ( ref. : KS X 1001:1998 Annex 3, table 3, row 4)
+*/
+      if ( IS_L_S(text[i]) )  
+        {
+          LVT_TO_JOHAB(text[i]-LBASE+1,0,0,1)
+          continue; 
+        }
+      else if ( IS_V_S(text[i]) ) 
+        {
+          LVT_TO_JOHAB(0,text[i]-VBASE+1,0,1)
+          continue; 
+        }
+      else if ( IS_T_S(text[i]) ) 
+        {
+          LVT_TO_JOHAB(0,0,text[i]-TBASE,1)
+          continue; 
+        }
+
+  /* Obsolete Jamo code points are obtained by shifting ksc5601 code points. */
+
       gindex = text[i];
       for (j = 0; (j < 3) && (__jamo_to_ksc5601[gindex - LBASE][j] != 0); j++)
 	{
@@ -369,7 +396,7 @@
           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;
@@ -627,7 +654,7 @@
       else if (strcmp (charsets[subfont_charsets[i]], "ksc5601.1992-3") == 0)
 	{
 	      *subfont = subfonts[i];
-	      *render_func = render_syllable_with_ksx1005;
+	      *render_func = render_syllable_with_ksx1001johab;
 	      break;
 	}
       else if (strcmp (charsets[subfont_charsets[i]], "ksc5601.1987-0") == 0)
@@ -713,12 +740,6 @@
 	  /* decompose the syllable.  */
 	  gint16 sindex;
 
-	  sindex = wc4 - SBASE;
-	  wcs[0] = LBASE + (sindex / NCOUNT);
-	  wcs[1] = VBASE + ((sindex % NCOUNT) / TCOUNT);
-	  wcs[2] = TBASE + (sindex % TCOUNT);
-	  n_code = 3;
-
 	  if (n_jamos > 0)
 	    {
 	      (*render_func) (font, subfont, jamos, n_jamos,
@@ -727,8 +748,16 @@
 	      n_jamos = 0;
 	    }
 
+	  sindex = wc4 - SBASE;
+	  wcs[n_code++] = LBASE + (sindex / NCOUNT);
+	  wcs[n_code++] = VBASE + ((sindex % NCOUNT) / TCOUNT);
+          if ( sindex % TCOUNT ) 
+            {
+              wcs[n_code++] = TBASE + (sindex % TCOUNT);
+            }
+
 	  /* 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.  */
@@ -836,7 +865,7 @@
 	  for (i=0; i<KSC5601_HANGUL; i++)
 	    pango_coverage_set (result, __ksc5601_hangul_to_ucs[i], PANGO_COVERAGE_EXACT);
 	}
-      else if (render_func == render_syllable_with_ksx1005)
+      else if (render_func == render_syllable_with_ksx1001johab)
 	{
 	  for (i = 0x1100; i <= 0x11ff; i++)
 	    pango_coverage_set (result, i, PANGO_COVERAGE_EXACT);
Index: hangul-defs.h
===================================================================
RCS file: /cvs/gnome/pango/modules/hangul/hangul-defs.h,v
retrieving revision 1.1
diff -u -r1.1 hangul-defs.h
--- hangul-defs.h	31 Jul 2002 19:08:14 -0000	1.1
+++ hangul-defs.h	15 Oct 2002 20:25:40 -0000
@@ -20,13 +20,16 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#ifndef __PANGO_HANGUL_DEFS_H
+#define __PANGO_HANGUL_DEFS_H
+
 /*
- * From 3.10 of the Unicode 2.0 Book; used for combining Jamos.
+ * From 3.10 of the Unicode 2.0 Book; used for conjoining Jamos.
  */
 #define SBASE 0xAC00
 #define LBASE 0x1100
 #define VBASE 0x1161
-#define TBASE 0x11A7
+#define TBASE 0x11A7  
 
 #define LEND 0x115F
 #define VEND 0x11A6
@@ -48,15 +51,16 @@
 
 #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)
 
 /* 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)
 #define L_FROM_S(s)		(LBASE + (((s) - SBASE) / NCOUNT))
 #define V_FROM_S(s)		(VBASE + (((s) - SBASE) % NCOUNT) / TCOUNT)
 #define T_FROM_S(s)		(TBASE + (((s) - SBASE) % TCOUNT))
+#endif
Index: tables-ksc5601.i
===================================================================
RCS file: /cvs/gnome/pango/modules/hangul/tables-ksc5601.i,v
retrieving revision 1.3
diff -u -r1.3 tables-ksc5601.i
--- tables-ksc5601.i	31 Jul 2002 19:08:14 -0000	1.3
+++ tables-ksc5601.i	15 Oct 2002 20:25:44 -0000
@@ -313,8 +313,8 @@
 /* mapping table used to convert indexes to JOHAB
 bit 43210  초 성	중 성		종 성
 00000	   no code	no code		no code
-00001      file code	no code		file code
-00010      ㄱ		file code	ㄱ
+00001      fill 	no code		fill
+00010      ㄱ		fill	ㄱ
 00011      ㄲ		ㅏ		ㄲ
 00100      ㄴ		ㅐ		ㄳ
 00101      ㄷ		ㅑ		ㄴ
@@ -345,14 +345,16 @@
 11110      no code	no code		no code
 11111      no code	no code		no code
 */
-/* The following arrays are based on the above table: */
+/* The following arrays are based on the above table.
+   Note that the first element in each array is for filler.
+*/
 static guint16 larray[32]=
 {
-2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,0,0,0,0,0,0,0,0,0,0,0,0,0
+1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,0,0,0,0,0,0,0,0,0,0,0,0
 };
 static guint16 varray[32]=
 {
-3,4,5,6,7,10,11,12,13,14,15,18,19,20,21,22,23,26,27,28,29,0,0,0,0,0,0,0,0,0,0,0
+2,3,4,5,6,7,10,11,12,13,14,15,18,19,20,21,22,23,26,27,28,29,0,0,0,0,0,0,0,0,0,0
 };
 static guint16 tarray[32]=
 {
