--- rxvt-unicode/src/rxvtfont.C 2007/11/24 10:32:33 1.123 +++ rxvt-unicode/src/rxvtfont.C 2008/01/23 05:59:29 1.130 @@ -21,7 +21,6 @@ #include "../config.h" #include "rxvt.h" -#include "rxvtlib.h" #include "rxvtutil.h" #include "rxvtfont.h" @@ -308,9 +307,11 @@ if (unicode <= 0x009f) return true; +#ifdef BUILTIN_GLYPHS if (unicode >= 0x2500 && unicode <= 0x259f && !term->option (Opt_skipBuiltinGlyphs)) return true; +#endif if (IS_COMPOSE (unicode)) return true; @@ -610,7 +611,7 @@ // fix the size of scalable fonts static bool -replace_field (char *buf, const char *name, int index, const char old, const char *replace) +replace_field (char **ptr, const char *name, int index, const char old, const char *replace) { int slashes = 0; const char *field, *end; @@ -630,17 +631,17 @@ if (slashes >= 13 && (!old || *field == old)) { - // TODO: check for overflow in font-name - strncpy (buf, name, field - name); - buf += field - name; - strcpy (buf, replace); - strcat (buf, end); + size_t len = field - name; + *ptr = (char *)malloc (len + strlen (replace) + strlen (end) + 1); + memcpy (*ptr, name, len); + strcpy (*ptr + len, replace); + strcat (*ptr, end); return true; } else { - strcpy (buf, name); + *ptr = strdup (name); return false; } @@ -658,7 +659,7 @@ // first morph the font if required if (force_prop) { - char fname[1024]; + char *fname; if (name[0] != '-') { @@ -680,18 +681,18 @@ if (prop.weight != rxvt_fontprop::unset) { - replace_field (fname, name, 2, 0, + replace_field (&fname, name, 2, 0, prop.weight < rxvt_fontprop::bold ? "medium" : "bold"); - set_name (strdup (fname)); + set_name (fname); } if (prop.slant != rxvt_fontprop::unset) { - replace_field (fname, name, 3, 0, + replace_field (&fname, name, 3, 0, prop.slant < rxvt_fontprop::italic ? "r" : "i"); // TODO: handle "o"blique, too - set_name (strdup (fname)); + set_name (fname); } } @@ -726,14 +727,18 @@ for (int i = 0; i < count; i++) { rxvt_fontprop p; - char fname[1024]; + char *fname; int diff = 0; - if (replace_field (fname, list[i], 6, '0', field_str)) + if (replace_field (&fname, list[i], 6, '0', field_str)) diff += 10; // slightly penalize scalable fonts - else if (replace_field (fname, list[i], 11, '0', "0")) - diff += 300; // more heavily penalize what looks like scaled bitmap fonts + else + { + free (fname); + if (replace_field (&fname, list[i], 11, '0', "0")) + diff += 300; // more heavily penalize what looks like scaled bitmap fonts + } if (!set_properties (p, fname)) continue; @@ -747,7 +752,7 @@ if (prop.slant != rxvt_fontprop::unset) diff += abs (prop.slant - p.slant); //if (prop.width != rxvt_fontprop::unset) diff += abs (prop.width - p.width); - fonts[i].name = strdup (fname); + fonts[i].name = fname; fonts[i].diff = diff; } @@ -1293,15 +1298,15 @@ int w = term->fwidth * len; int h = term->fheight; - /* TODO: this logic needs some more thinking, since we no longer do pseudo-transparency. + /* * Maybe make buffering into a resource flag? Compile time option doesn't seems like a * good idea from the perspective of packaging for wide variety of user configs. */ - bool buffered = true + bool buffered = bg >= Color_transparent; #ifdef FORCE_UNBUFFERED_XFT - && bg >= 0 + buffered = false; #endif - ; + // cut trailing spaces while (len && text [len - 1] == ' ') len--; @@ -1337,9 +1342,9 @@ if (buffered) { - bool back_rendered = false; if (ep != enc) { + bool back_rendered = false; rxvt_drawable &d2 = d.screen->scratch_drawable (w, h); #ifdef HAVE_BG_PIXMAP @@ -1347,12 +1352,12 @@ { Picture dst = 0; - if (bg >= 0 && term->pix_colors[bg].c.color.alpha < 0x0ff00) + if (bg >= 0 && term->pix_colors[bg].is_opaque ()) dst = XftDrawPicture (d2); - if (bg < 0 || dst != 0) + if (dst) { - int src_x = x, src_y = y ; + int src_x = x, src_y = y; if (term->bgPixmap.is_parentOrigin ()) { @@ -1529,7 +1534,7 @@ if (end - desc < 511) { - strncpy (buf, desc, end - desc); + memcpy (buf, desc, end - desc); buf[end - desc] = 0; fonts.push_back (new_font (buf, cs));