--- rxvt-unicode/src/rxvtfont.C 2005/12/18 00:59:42 1.75 +++ rxvt-unicode/src/rxvtfont.C 2006/01/09 07:35:07 1.82 @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: rxvtfont.C *----------------------------------------------------------------------* - * Copyright (c) 2003-2004 Marc Lehmann + * Copyright (c) 2003-2006 Marc Lehmann * - original version. * * This program is free software; you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include "../config.h" #include "rxvt.h" +#include "rxvtlib.h" #include "rxvtutil.h" #include "rxvtfont.h" @@ -278,6 +279,7 @@ rxvt_fontprop p; p.width = p.height = 1; + p.ascent = rxvt_fontprop::unset; p.weight = rxvt_fontprop::medium; p.slant = rxvt_fontprop::roman; @@ -307,7 +309,8 @@ if (unicode <= 0x009f) return true; - if (unicode >= 0x2500 && unicode <= 0x259f) + if (unicode >= 0x2500 && unicode <= 0x259f && + !r->option (Opt_skipBuiltinGlyphs)) return true; if (IS_COMPOSE (unicode)) @@ -525,6 +528,7 @@ { p.width = avgwidth ? (avgwidth + 1) / 10 : (height + 1) / 2; p.height = height; + p.ascent = rxvt_fontprop::unset; p.weight = *weight == 'B' || *weight == 'b' ? rxvt_fontprop::bold : rxvt_fontprop::medium; p.slant = *slant == 'r' || *slant == 'R' ? rxvt_fontprop::roman : rxvt_fontprop::italic; @@ -555,6 +559,8 @@ free (weight); free (slant); + p.ascent = f->ascent; + return true; } @@ -1075,6 +1081,7 @@ p.width = width; p.height = height; + p.ascent = ascent; p.weight = face->style_flags & FT_STYLE_FLAG_BOLD ? rxvt_fontprop::bold : rxvt_fontprop::medium; p.slant = face->style_flags & FT_STYLE_FLAG_ITALIC @@ -1266,12 +1273,13 @@ { clear_rect (d, x, y, r->fwidth * len, r->fheight, bg); - int base = ascent; // should be fbase, but that is incorrect - XGlyphInfo extents; - FcChar32 *enc = (FcChar32 *) get_enc_buf (len * sizeof (FcChar32)); - FcChar32 *ep = enc; - int ewidth = 0; + XftGlyphSpec *enc = (XftGlyphSpec *)get_enc_buf (len * sizeof (XftGlyphSpec)); + XftGlyphSpec *ep = enc; + + // cut trailing spaces + while (len && text [len - 1] == ' ') + len--; while (len) { @@ -1281,44 +1289,22 @@ while (len && *text == NOCHAR) text++, len--, cwidth += r->fwidth; - if (fc == ' ' && ep == enc) // skip leading spaces - x += cwidth; - else + if (fc != ' ') // skip spaces { - FT_UInt gl = XftCharIndex (d.display->display, f, fc); - XftGlyphExtents (d.display->display, f, &gl, 1, &extents); - - if (extents.xOff != cwidth) - { - if (ewidth) - { - XftDrawGlyphs (d, &r->pix_colors[fg].c, f, - x, y + base, enc, ep - enc); - x += ewidth; - - ep = enc; - ewidth = 0; - } - - if (extents.xOff > cwidth) - extents.xOff = cwidth; + FT_UInt glyph = XftCharIndex (d.display->display, f, fc); + XftGlyphExtents (d.display->display, f, &glyph, 1, &extents); - XftDrawGlyphs (d, &r->pix_colors[fg].c, f, - x + (cwidth - extents.xOff >> 1), - y + base, &gl, 1); - x += cwidth; - } - else - { - *ep++ = gl; - ewidth += cwidth; - } + ep->glyph = glyph; + ep->x = x + (cwidth - extents.xOff >> 1); + ep->y = y + ascent; + ep++; } + + x += cwidth; } if (ep != enc) - XftDrawGlyphs (d, &r->pix_colors[fg].c, f, - x, y + base, enc, ep - enc); + XftDrawGlyphSpec (d, &r->pix_colors[fg].c, f, enc, ep - enc); } #endif @@ -1338,7 +1324,7 @@ void rxvt_fontset::clear () { - prop.width = prop.height = prop.weight = prop.slant + prop.width = prop.height = prop.ascent = prop.weight = prop.slant = rxvt_fontprop::unset; for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) @@ -1521,6 +1507,9 @@ if (!realize_font (i)) goto next_font; + + if (prop.ascent != rxvt_fontprop::unset) + max_it (f->ascent, prop.ascent); } if (f->cs == CS_UNKNOWN)