--- rxvt-unicode/src/defaultfont.C 2003/12/18 04:14:30 1.7 +++ rxvt-unicode/src/defaultfont.C 2003/12/24 09:40:30 1.11 @@ -61,38 +61,39 @@ #if ENCODING_JP || ENCODING_JP_EXT # if XFT // prefer xft for complex scripts - { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, + { CS_UNICODE, "xft:Kochi Gothic:antialias=false" }, # endif - { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, - { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, - { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, + { CS_JIS0201_1976_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0201*-0" }, + { CS_JIS0208_1983_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0208*-0" }, + { CS_JIS0212_1990_0, "-*-mincho-*-r-*--*-*-*-*-c-*-jisx0212*-0" }, #endif #if ENCODING_CN || ENCODING_CN_EXT # if XFT - { 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_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" }, # endif - { CS_CNS11643_1992_1, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-1" }, - { CS_CNS11643_1992_2, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-2" }, - { CS_CNS11643_1992_3, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-3" }, - { CS_CNS11643_1992_4, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-4" }, - { CS_CNS11643_1992_5, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-5" }, - { CS_CNS11643_1992_6, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-6" }, - { CS_CNS11643_1992_7, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-7" }, - { CS_CNS11643_1992_F, "-*-*-*-r-*-*-*-*-*-*-c-*-cns11643.1992-f" }, + { CS_CNS11643_1992_1, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-1" }, + { CS_CNS11643_1992_2, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-2" }, + { CS_CNS11643_1992_3, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-3" }, + { CS_CNS11643_1992_4, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-4" }, + { CS_CNS11643_1992_5, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-5" }, + { CS_CNS11643_1992_6, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-6" }, + { CS_CNS11643_1992_7, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-7" }, + { CS_CNS11643_1992_F, "-*-*-*-*-*-*-*-*-*-*-c-*-cns11643.1992-f" }, #endif #if XFT - { CS_UNICODE, "xft:Andale Mono" }, - { CS_UNICODE, "xft:Arial Unicode MS" }, + { CS_UNICODE, "xft:Andale Mono" }, + { CS_UNICODE, "xft:Arial Unicode MS" }, #endif - { CS_UNICODE, "-*-lucidatypewriter-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, - { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, - { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, - { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, + { CS_UNICODE, "-*-lucidatypewriter-*-*-*-*-*-*-*-*-m-*-iso10646-1" }, + { CS_UNICODE, "xft:FreeMono" }, + { CS_UNICODE, "-*-unifont-*-*-*-*-*-*-*-*-c-*-iso10646-1" }, + { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-c-*-iso10646-1" }, + { CS_UNICODE, "-*-*-*-r-*-*-*-*-*-*-m-*-iso10646-1" }, { CS_UNKNOWN, 0 } }; @@ -228,7 +229,7 @@ { rxvt_fontprop p; - p.height = 1; + p.width = p.height = 1; p.weight = rxvt_fontprop::medium; p.slant = rxvt_fontprop::roman; @@ -380,6 +381,10 @@ const char *weight = get_property (f, "WEIGHT_NAME", "medium"); const char *slant = get_property (f, "SLANT", "r"); + unsigned long avgwidth; + p.width = XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth) + ? avgwidth / 10 + : (height + 1) / 2; p.height = height; p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium; p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic; @@ -422,6 +427,9 @@ } } + if (!best) + return false; + set_name (strdup (list[best - info])); XFreeFontInfo (list, info, count); @@ -656,32 +664,6 @@ #endif struct rxvt_font_xft : rxvt_font { -#if 0 - enum { - SWATHCOUNT = 1 << (21 - UNIBITS), - SWATHSIZE = 1 << (SWATHBITS - 5) - }; - typedef uint32_t swath[SWATHSIZE]; - - swath *cvr[SWATHCOUNT]; -#endif - -#if 0 - void gen_coverage_swath (unsigned int page); - - bool has_char (uint32_t ch) - { - unsigned int page = ch >> SWATHBITS; - unsigned int idx = ch & ((1 << SWATHBITS) - 1); - - if (page >= SWATHCOUNT) - return false; - - if (!cvr[page]) gen_coverage_swath (page); - - return cvr[page][idx >> 5] & (1 << (idx & 31)); - } -#endif rxvt_font_xft () { f = 0; d = 0; } void clear (); @@ -699,14 +681,6 @@ protected: XftFont *f; XftDraw *d; - -#if 0 - virtual void populate_coverage_swath (uint32_t lo, uint32_t hi) = 0; - void set_swath (uint32_t ch) - { - cvr[ch >> SWATHBITS] |= 1 << (ch & ((1 << SWATHBITS) - 1)); - } -#endif }; void @@ -723,11 +697,6 @@ XftDrawDestroy (d); d = 0; } - -#if 0 - for (int i = 0; i < SWATHCOUNT; i++) - delete cvr[i]; -#endif } rxvt_fontprop @@ -737,7 +706,7 @@ FT_Face face = XftLockFace (f); - p.height = height; + p.width = width; p.height = height; p.weight = face->style_flags & FT_STYLE_FLAG_BOLD ? rxvt_fontprop::bold : rxvt_fontprop::medium; p.slant = face->style_flags & FT_STYLE_FLAG_ITALIC ? rxvt_fontprop::italic : rxvt_fontprop::roman; @@ -769,6 +738,12 @@ if (FcPatternGet (p, FC_SLANT, 0, &v) != FcResultMatch) FcPatternAddInteger (p, FC_SLANT, prop.slant); +#if 0 // clipping unfortunately destroys our precious double-width-characters + // clip width, we can't do better, or can we? + if (FcPatternGet (p, FC_CHAR_WIDTH, 0, &v) != FcResultMatch) + FcPatternAddInteger (p, FC_CHAR_WIDTH, prop.width); +#endif + //FcPatternAddBool (p, FC_MINSPACE, 1); XftResult result; @@ -781,10 +756,11 @@ f = XftFontOpenPattern (DISPLAY, match); - FcPatternDestroy (match); - if (!f) - return false; + { + FcPatternDestroy (match); + return false; + } FT_Face face = XftLockFace (f); @@ -829,18 +805,6 @@ return true; } -#if 0 -void rxvt_font::gen_coverage_swath (unsigned int page) -{ - cvr[page] = new swath; - - for (int i = 0; i < SWATHSIZE; i++) - cvr[page][i] = 0; - - populate_coverage_swath (cvr[page], page << SWATHBITS, ((page + 1) << SWATHBITS) - 1); -} -#endif - bool rxvt_font_xft::has_codepoint (uint32_t unicode) {