--- rxvt-unicode/src/defaultfont.C 2004/03/16 06:04:28 1.47 +++ rxvt-unicode/src/defaultfont.C 2004/04/08 20:31:45 1.52 @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------*; +/*--------------------------------*-C-*---------------------------------* * File: defaultfont.C *----------------------------------------------------------------------* * Copyright (c) 2003-2004 Marc Lehmann @@ -232,7 +232,10 @@ if (unicode <= 0x001f) return true; - if (unicode >= 0x0080 && unicode <= 0x009f) + if (unicode <= 0x007f) + return false; + + if (unicode <= 0x009f) return true; if (unicode >= 0x2500 && unicode <= 0x259f) @@ -410,13 +413,13 @@ codeset cs; bool enc2b, encm; - const char *get_property (XFontStruct *f, const char *property, const char *repl) const; + char *get_property (XFontStruct *f, const char *property, const char *repl) const; bool set_properties (rxvt_fontprop &p, int height, const char *weight, const char *slant, int avgwidth); bool set_properties (rxvt_fontprop &p, XFontStruct *f); bool set_properties (rxvt_fontprop &p, const char *name); }; -const char * +char * rxvt_font_x11::get_property (XFontStruct *f, const char *property, const char *repl) const { unsigned long value; @@ -424,7 +427,7 @@ if (XGetFontProperty (f, XInternAtom (DISPLAY, property, 0), &value)) return XGetAtomName (DISPLAY, value); else - return repl; + return rxvt_strdup (repl); } rxvt_fontprop @@ -449,9 +452,6 @@ bool rxvt_font_x11::set_properties (rxvt_fontprop &p, XFontStruct *f) { - const char *weight = get_property (f, "WEIGHT_NAME", "medium"); - const char *slant = get_property (f, "SLANT", "r"); - unsigned long height; if (!XGetFontProperty (f, XInternAtom (DISPLAY, "PIXEL_SIZE", 0), &height)) return false; @@ -460,7 +460,15 @@ if (!XGetFontProperty (f, XInternAtom (DISPLAY, "AVERAGE_WIDTH", 0), &avgwidth)) avgwidth = 0; - return set_properties (p, height, weight, slant, avgwidth); + char *weight = get_property (f, "WEIGHT_NAME", "medium"); + char *slant = get_property (f, "SLANT", "r"); + + set_properties (p, height, weight, slant, avgwidth); + + free (weight); + free (slant); + + return true; } bool @@ -574,8 +582,8 @@ if (!f) return false; - const char *registry = get_property (f, "CHARSET_REGISTRY", 0); - const char *encoding = get_property (f, "CHARSET_ENCODING", 0); + char *registry = get_property (f, "CHARSET_REGISTRY", 0); + char *encoding = get_property (f, "CHARSET_ENCODING", 0); if (registry && encoding) { @@ -599,6 +607,9 @@ cs = codeset_from_name (charset); } + free (registry); + free (encoding); + if (cs == CS_UNICODE) cs = CS_UNICODE_16; // X11 can have a max. of 65536 chars per font @@ -720,7 +731,6 @@ XGCValues v; v.foreground = r->PixColors[fg]; - v.background = r->PixColors[bg]; v.font = f->fid; if (enc2b) @@ -729,6 +739,7 @@ if (bg == Color_bg && !slow) { + v.background = r->PixColors[bg]; XChangeGC (d.display->display, TGC, GCForeground | GCBackground | GCFont, &v); XDrawImageString16 (d.display->display, d, TGC, x, y + base, xc, len); } @@ -760,6 +771,7 @@ if (bg == Color_bg && !slow) { + v.background = r->PixColors[bg]; XChangeGC (d.display->display, TGC, GCForeground | GCBackground | GCFont, &v); XDrawImageString (d.display->display, d, TGC, x, y + base, xc, len); } @@ -988,7 +1000,7 @@ ///////////////////////////////////////////////////////////////////////////// rxvt_fontset::rxvt_fontset (rxvt_t r) -: r (r) +: r (r), fontdesc (0) { clear (); } @@ -1004,6 +1016,8 @@ for (rxvt_font **i = fonts.begin (); i != fonts.end (); i++) FONT_UNREF (*i); + free (fontdesc); fontdesc = 0; + fonts.clear (); base_id = 0; base_prop.height = 0x7fffffff; @@ -1120,6 +1134,8 @@ { clear (); + fontdesc = strdup (desc); + fonts.push_back (new_font (0, CS_UNICODE)); realize_font (0); @@ -1147,7 +1163,9 @@ int rxvt_fontset::find_font (unicode_t unicode) { - for (unsigned int i = 0; i < fonts.size (); i++) + for (unsigned int i = !!(0x20 <= unicode && unicode <= 0x7f); // skip pseudo-font for ascii + i < fonts.size (); + i++) { rxvt_font *f = fonts[i];