--- rxvt-unicode/src/rxvtfont.C 2004/08/25 02:33:09 1.41 +++ rxvt-unicode/src/rxvtfont.C 2004/12/10 19:55:55 1.56 @@ -90,17 +90,22 @@ { CS_JIS0212_1990_0, "-*-*-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, #endif -#if ENCODING_CN || ENCODING_CN_EXT +#if ENCODING_ZH || ENCODING_ZH_EXT # if XFT + { CS_GBK_0, "xft:AR PL KaitiM GB" }, + { CS_GBK_0, "xft:AR PL SungtiL GB" }, + { CS_GBK_0, "xft::spacing=100:lang=zh" }, { CS_BIG5_EXT, "xft:AR PL Mingti2L Big5" }, { CS_BIG5_EXT, "xft:AR PL KaitiM Big5" }, { CS_GB2312_1980_0, "xft:AR PL KaitiM GB" }, { CS_GB2312_1980_0, "xft:AR PL SungtiL GB" }, { CS_GB2312_1980_0, "xft::spacing=100:lang=zh" }, # endif + { CS_GBK_0, "-*-*-*-*-*-*-*-*-*-*-c-*-gbk*-0" }, { CS_BIG5, "-*-*-*-*-*-*-*-*-*-*-c-*-big5-0" }, { CS_BIG5_PLUS, "-*-*-*-*-*-*-*-*-*-*-c-*-big5p-0" }, { CS_BIG5_EXT, "-*-*-*-*-*-*-*-*-*-*-c-*-big5.eten-0" }, + { CS_GB2312_1980_0, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-gb2312*-0" }, { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-1" }, { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643*-2" }, @@ -127,13 +132,13 @@ { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, #if XFT - { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false"}, + { CS_UNICODE, "xft:Bitstream Vera Sans Mono:antialias=false:autohint=true"}, + { CS_UNICODE, "xft:Courier New:antialias=false:autohint=true" }, { CS_UNICODE, "xft:Andale Mono:antialias=false" }, { CS_UNICODE, "xft:Arial Unicode MS:antialias=false" }, - { CS_UNICODE, "xft:Courier New:antialias=false" }, // FreeMono is usually uglier than x fonts, so try last only. - { CS_UNICODE, "xft:FreeMono" }, + { CS_UNICODE, "xft:FreeMono:autohint=true" }, #endif { CS_UNKNOWN, 0 } @@ -332,12 +337,19 @@ XSetForeground (d.display->display, TGC, r->pix_colors[fg]); - while (len--) + while (len) { #if ENABLE_COMBINING compose_char *cc; #endif - text_t t = *text++; + const text_t *tp = text; + text_t t = *tp; + + while (++text, --len && *text == NOCHAR) + ; + + int width = text - tp; + int fwidth = r->TermWin.fwidth * width; if (0x2500 <= t && t <= 0x259f) { @@ -345,7 +357,7 @@ uint32_t *a = linedraw_command + (offs >> 4); uint32_t *b = a + (offs & 15); - int W = r->TermWin.fwidth; + int W = fwidth; int H = r->TermWin.fheight; int x_[16]; @@ -420,17 +432,25 @@ #if ENABLE_COMBINING else if (IS_COMPOSE (t) && (cc = rxvt_composite[t])) { + text_t chrs[2]; + width = min (2, width); + chrs [1] = NOCHAR; + + *chrs = cc->c1; rxvt_font *f1 = (*fs)[fs->find_font (cc->c1)]; - f1->draw (d, x, y, &(t = cc->c1), 1, fg, bg); + f1->draw (d, x, y, chrs, width, fg, bg); + if (cc->c2 != NOCHAR) { - // prefer font of first character, for no good reasons bool careful; - rxvt_font *f2 = f1->has_char (cc->c2, 0, careful) + + // prefer font of first character, for no good reasons + *chrs = cc->c2; + rxvt_font *f2 = (f1->has_char (cc->c2, 0, careful) && !careful) ? f1 : (*fs)[fs->find_font (cc->c2)]; - f2->draw (d, x, y, &(t = cc->c2), 1, fg, -1); + f2->draw (d, x, y, chrs, width, fg, -1); } } #endif @@ -443,20 +463,11 @@ break; default: - int w = 0; - while (len > 0 && *text == NOCHAR) - { - ++text; - --len; - w += r->TermWin.fwidth; - } - XDrawRectangle (d.display->display, d, TGC, x + 2, y + 2, - w + r->TermWin.fwidth - 4, r->TermWin.fheight - 4); - x += w; + fwidth - 4, r->TermWin.fheight - 4); } - x += r->TermWin.fwidth; + x += fwidth; } } @@ -680,7 +691,7 @@ char fname[1024]; int diff = 0; - + if (replace_field (fname, list[i], 6, '0', field_str)) diff += 10; // slightly penalize scalable fonts @@ -1044,7 +1055,8 @@ FcValue v; if (prop.height != rxvt_fontprop::unset - && FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch) + || (FcPatternGet (p, FC_PIXEL_SIZE, 0, &v) != FcResultMatch + && FcPatternGet (p, FC_SIZE, 0, &v) != FcResultMatch)) FcPatternAddInteger (p, FC_PIXEL_SIZE, prop.height); if (prop.weight != rxvt_fontprop::unset @@ -1266,6 +1278,9 @@ void rxvt_fontset::clear () { + prop.width = prop.height = prop.weight = prop.slant + = rxvt_fontprop::unset; + for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) FONT_UNREF (*i); @@ -1395,7 +1410,7 @@ } bool -rxvt_fontset::populate (const char *desc, const rxvt_fontprop &prop) +rxvt_fontset::populate (const char *desc) { clear (); @@ -1404,8 +1419,6 @@ fonts.push_back (new_font (0, CS_UNICODE)); realize_font (0); - this->prop = prop; - add_fonts (desc); return true;