diff -uNrp libXft-2.1.6.orig/xftfreetype.c libXft-2.1.6/xftfreetype.c --- libXft-2.1.6.orig/xftfreetype.c 2004-03-20 02:54:08.000000000 +0800 +++ libXft-2.1.6/xftfreetype.c 2004-11-28 21:49:49.466303848 +0800 @@ -223,34 +263,48 @@ XftFontLoadGlyphs (Display *dpy, * Try to keep monospace fonts ink-inside * XXX transformed? */ + /*--------------------------------------------------------------- + * Modified by Firefly (firefly@firefly.idv.tw) + * + * 絕對不能用 font->public.max_advance_width 來當作字元的寬高值, + * 因為 CJK 字元有半形以及全形, 如果一律用同一數值, 一定會造成 + * monospace CJK 字型的英文與 CJK 字元等寬, 必須改用每個字符的 + * 實際讀取的寬高值. + * + * Don't use "font->public.max_advance_width", because CJK fonts + * have both half-width and full-width. + * So must use "glyphslot->metrics.vertAdvance" & + * "glyphslot->metrics.horiAdvance" in order to get correctly width. + *----------------------------------------------------------------*/ + glyphslot->metrics.horiAdvance += bold_advance_width; if (font->info.spacing != FC_PROPORTIONAL && !font->info.transform) { if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT) { - if (TRUNC(bottom) > font->public.max_advance_width) + if (bottom > glyphslot->metrics.vertAdvance) { int adjust; - adjust = bottom - (font->public.max_advance_width << 6); + adjust = bottom - glyphslot->metrics.vertAdvance; if (adjust > top) adjust = top; top -= adjust; bottom -= adjust; - height = font->public.max_advance_width; + height = TRUNC(glyphslot->metrics.vertAdvance); } } else { - if (TRUNC(right) > font->public.max_advance_width) + if (right > glyphslot->metrics.horiAdvance) { int adjust; - adjust = right - (font->public.max_advance_width << 6); + adjust = right - glyphslot->metrics.horiAdvance; if (adjust > left) adjust = left; left -= adjust; right -= adjust; - width = font->public.max_advance_width; + width = TRUNC(glyphslot->metrics.horiAdvance); } } } @@ -274,11 +328,11 @@ XftFontLoadGlyphs (Display *dpy, if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT) { vector.x = 0; - vector.y = -face->size->metrics.max_advance; + vector.y = -glyphslot->metrics.vertAdvance; } else { - vector.x = face->size->metrics.max_advance; + vector.x = glyphslot->metrics.horiAdvance; vector.y = 0; } FT_Vector_Transform (&vector, &font->info.matrix); @@ -290,18 +344,18 @@ XftFontLoadGlyphs (Display *dpy, if (font->info.load_flags & FT_LOAD_VERTICAL_LAYOUT) { xftg->metrics.xOff = 0; - xftg->metrics.yOff = -font->public.max_advance_width; + xftg->metrics.yOff = -(glyphslot->metrics.vertAdvance >> 6); } else { - xftg->metrics.xOff = font->public.max_advance_width; + xftg->metrics.xOff = glyphslot->metrics.horiAdvance >> 6; xftg->metrics.yOff = 0; } } } else { - xftg->metrics.xOff = TRUNC(ROUND(glyphslot->advance.x)); + xftg->metrics.xOff = TRUNC(ROUND(glyphslot->advance.x + bold_advance_width)); xftg->metrics.yOff = -TRUNC(ROUND(glyphslot->advance.y)); }