--- rxvt-unicode/src/rxvtfont.C 2006/01/17 05:47:42 1.84 +++ rxvt-unicode/src/rxvtfont.C 2006/01/25 13:24:45 1.86 @@ -29,7 +29,14 @@ #include #include -#define MAX_OVERLAP (4 + 1) // max. character width in 4ths of the base width +#define MAX_OVERLAP_ROMAN (8 + 2) // max. character width in 8ths of the base width +#define MAX_OVERLAP_ITALIC (8 + 3) // max. overlap for italic fonts + +#define OVERLAP_OK(w,prop) (w) > ( \ + prop->slant >= rxvt_fontprop::italic \ + ? (prop->width * MAX_OVERLAP_ITALIC + 7) >> 3 \ + : (prop->width * MAX_OVERLAP_ROMAN + 7) >> 3 \ + ) const struct rxvt_fallback_font { codeset cs; @@ -175,26 +182,11 @@ ///////////////////////////////////////////////////////////////////////////// -static void *enc_buf; -static uint32_t enc_len; - -static inline void * -get_enc_buf (uint32_t len) -{ - if (len > enc_len) - { - free (enc_buf); - enc_buf = malloc (len); - enc_len = len; - } - - return enc_buf; -} - static const char * enc_char (const text_t *text, uint32_t len, codeset cs, bool &zero) { - uint8_t *buf = (uint8_t *)get_enc_buf (len); + uint8_t *buf = rxvt_temp_buf (len); + uint8_t *res = buf; while (len--) { @@ -209,13 +201,14 @@ *buf++ = c; } - return (const char *)enc_buf; + return (const char *)res; } static const XChar2b * enc_xchar2b (const text_t *text, uint32_t len, codeset cs, bool &zero) { - XChar2b *buf = (XChar2b *)get_enc_buf (len * sizeof (XChar2b)); + XChar2b *buf = rxvt_temp_buf (len); + XChar2b *res = buf; while (len--) { @@ -232,7 +225,7 @@ buf++; } - return (XChar2b *)enc_buf; + return res; } ///////////////////////////////////////////////////////////////////////////// @@ -864,7 +857,7 @@ int dir_ret, asc_ret, des_ret; XTextExtents16 (f, &ch, 1, &dir_ret, &asc_ret, &des_ret, &g); - int wcw = wcwidth (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; + int wcw = WCWIDTH (*t); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; if (width < g.width) width = g.width; } @@ -947,12 +940,12 @@ return true; // check character against base font bounding box - int w = xcs->width; - int wcw = wcwidth (unicode); + int w = xcs->rbearing - xcs->lbearing; + int wcw = WCWIDTH (unicode); if (wcw > 0) w = (w + wcw - 1) / wcw; careful = w > prop->width; - if (careful && w > prop->width * MAX_OVERLAP >> 2) + if (careful && OVERLAP_OK (w, prop)) return false; return true; @@ -1192,7 +1185,7 @@ g.width -= g.x; - int wcw = wcwidth (ch); + int wcw = WCWIDTH (ch); if (wcw > 0) g.width = (g.width + wcw - 1) / wcw; if (width < g.width ) width = g.width; @@ -1264,11 +1257,11 @@ XftTextExtents32 (term->display->display, f, &ch, 1, &g); int w = g.width - g.x; - int wcw = wcwidth (unicode); + int wcw = WCWIDTH (unicode); if (wcw > 0) w = (w + wcw - 1) / wcw; careful = w > prop->width; - if (careful && w > prop->width * MAX_OVERLAP >> 2) + if (careful && OVERLAP_OK (w, prop)) return false; return true; @@ -1282,7 +1275,7 @@ clear_rect (d, x, y, term->fwidth * len, term->fheight, bg); XGlyphInfo extents; - XftGlyphSpec *enc = (XftGlyphSpec *)get_enc_buf (len * sizeof (XftGlyphSpec)); + XftGlyphSpec *enc = (XftGlyphSpec *)rxvt_temp_buf (len * sizeof (XftGlyphSpec)); XftGlyphSpec *ep = enc; dTermDisplay;