--- rxvt-unicode/src/rxvtfont.C 2006/01/25 00:42:21 1.85 +++ rxvt-unicode/src/rxvtfont.C 2006/01/29 20:51:28 1.89 @@ -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; @@ -152,7 +159,7 @@ #define NUM_EXTENT_TEST_CHARS (sizeof (extent_test_chars) / sizeof (extent_test_chars[0])) -#define dTermDisplay Display *disp = term->display->display +#define dTermDisplay Display *disp = term->xdisp #define dTermGC GC gc = term->gc ///////////////////////////////////////////////////////////////////////////// @@ -167,7 +174,7 @@ rxvt_drawable::operator XftDraw *() { if (!xftdrawable) - xftdrawable = XftDrawCreate (display->display, drawable, display->visual, display->cmap); + xftdrawable = XftDrawCreate (screen->xdisp, drawable, screen->visual, screen->cmap); return xftdrawable; } @@ -240,7 +247,7 @@ dTermGC; if (color == Color_bg) - XClearArea (disp, d, x, y, w, h, FALSE); + XClearArea (disp, d, x, y, w, h, false); else if (color >= 0) { #if XFT @@ -499,8 +506,8 @@ { unsigned long value; - if (XGetFontProperty (f, XInternAtom (term->display->display, property, 0), &value)) - return XGetAtomName (term->display->display, value); + if (XGetFontProperty (f, XInternAtom (term->xdisp, property, 0), &value)) + return XGetAtomName (term->xdisp, value); else return rxvt_strdup (repl); } @@ -531,14 +538,14 @@ unsigned long height; #if 0 - if (!XGetFontProperty (f, XInternAtom (term->display->display, "PIXEL_SIZE", 0), &height)) + if (!XGetFontProperty (f, XInternAtom (term->xdisp, "PIXEL_SIZE", 0), &height)) return false; #else height = f->ascent + f->descent; #endif unsigned long avgwidth; - if (!XGetFontProperty (f, XInternAtom (term->display->display, "AVERAGE_WIDTH", 0), &avgwidth)) + if (!XGetFontProperty (f, XInternAtom (term->xdisp, "AVERAGE_WIDTH", 0), &avgwidth)) avgwidth = 0; char *weight = get_property (f, "WEIGHT_NAME", "medium"); @@ -850,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; } @@ -879,7 +886,7 @@ { if (f) { - XFreeFont (term->display->display, f); + XFreeFont (term->xdisp, f); f = 0; } } @@ -933,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; @@ -1061,7 +1068,7 @@ { if (f) { - XftFontClose (term->display->display, f); + XftFontClose (term->xdisp, f); f = 0; } } @@ -1178,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; @@ -1238,7 +1245,7 @@ { careful = false; - if (!XftCharExists (term->display->display, f, unicode)) + if (!XftCharExists (term->xdisp, f, unicode)) return false; if (!prop || prop->width == rxvt_fontprop::unset) @@ -1247,14 +1254,14 @@ // check character against base font bounding box FcChar32 ch = unicode; XGlyphInfo g; - XftTextExtents32 (term->display->display, f, &ch, 1, &g); + XftTextExtents32 (term->xdisp, 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; @@ -1555,7 +1562,7 @@ //FcPatternAddBool (p, FC_ANTIALIAS, 1); XftResult result; - FcPattern *match = XftFontMatch (term->display->display, term->display->screen, p, &result); + FcPattern *match = XftFontMatch (term->xdisp, term->display->screen, p, &result); FcPatternDestroy (p);