Index: src/vte.c
===================================================================
RCS file: /cvs/gnome/vte/src/vte.c,v
retrieving revision 1.308
diff -u -r1.308 vte.c
--- src/vte.c	25 Feb 2003 00:18:03 -0000	1.308
+++ src/vte.c	26 Feb 2003 13:21:56 -0000
@@ -108,6 +108,10 @@
 					"0123456789./+@"
 #define VTE_REPRESENTATIVE_WIDER_CHARACTER	'M'
 #define VTE_REPRESENTATIVE_NARROWER_CHARACTER	'l'
+/*  "一二三四五" */
+#define VTE_REPRESENTATIVE_CJK_STRING	"\xe4\xb8\x80\xe4\xba\x8c\xe4\xb8\x89" \
+                                        "\xe5\x9b\x9b\xe4\xba\x94"
+#define VTE_REPRESENTATIVE_CJK_STRING_CHAR_COUNT	5
 #define VTE_ADJUSTMENT_PRIORITY		G_PRIORITY_DEFAULT_IDLE
 #define VTE_INPUT_RETRY_PRIORITY	G_PRIORITY_HIGH
 #define VTE_INPUT_PRIORITY		G_PRIORITY_DEFAULT_IDLE
@@ -10586,6 +10590,7 @@
 
 	/* Read the metrics for the new font, if one was loaded. */
 	if (terminal->pvt->ftfont != NULL) {
+		gint cjk_width;
 		ascent = terminal->pvt->ftfont->ascent;
 		descent = terminal->pvt->ftfont->descent;
 		memset(&glyph_info, 0, sizeof(glyph_info));
@@ -10595,6 +10600,16 @@
 				&glyph_info);
 		width = howmany(glyph_info.width,
 				strlen(VTE_REPRESENTATIVE_CHARACTERS));
+		memset(&glyph_info, 0, sizeof(glyph_info));
+		XftTextExtentsUtf8(GDK_DISPLAY(), terminal->pvt->ftfont,
+				VTE_REPRESENTATIVE_CJK_STRING,
+				strlen(VTE_REPRESENTATIVE_CJK_STRING),
+				&glyph_info);
+		cjk_width = howmany(glyph_info.width,
+				VTE_REPRESENTATIVE_CJK_STRING_CHAR_COUNT);
+		/* CJK bi-width font with Xft/freetype unpatched */
+		if (width == cjk_width)
+			width /= 2;
 		height = MAX(terminal->pvt->ftfont->height, (ascent + descent));
 		if (height == 0) {
 			height = glyph_info.height;
@@ -10750,6 +10765,7 @@
 	/* Load a font using this description and read its metrics to find
 	 * the ascent and descent. */
 	if ((context != NULL) && (desc != NULL)) {
+		gint cjk_width;
 		lang = pango_context_get_language(context);
 		metrics = pango_context_get_metrics(context, desc, lang);
 		ascent = pango_font_metrics_get_ascent(metrics);
@@ -10764,8 +10780,18 @@
 				      VTE_REPRESENTATIVE_CHARACTERS,
 				      strlen(VTE_REPRESENTATIVE_CHARACTERS));
 		pango_layout_get_extents(layout, &ink, &logical);
-		width = howmany(logical.width, PANGO_SCALE);
+		width = logical.width;
 		width = howmany(width, strlen(VTE_REPRESENTATIVE_CHARACTERS));
+		pango_layout_set_text(layout,
+				      VTE_REPRESENTATIVE_CJK_STRING,
+				      strlen(VTE_REPRESENTATIVE_CJK_STRING));
+		pango_layout_get_extents(layout, &ink, &logical);
+		cjk_width = logical.width;
+		cjk_width = howmany(cjk_width, VTE_REPRESENTATIVE_CJK_STRING_CHAR_COUNT);
+		/* CJK bi-width font with Xft/freetype unpatched */
+                if(cjk_width == width) 
+			width /= 2;
+		width = howmany(width, PANGO_SCALE);
 		height = howmany(logical.height, PANGO_SCALE);
 		g_object_unref(G_OBJECT(layout));
 		layout = NULL;
