--- rxvt-unicode/src/defaultfont.C 2003/11/29 18:42:07 1.4 +++ rxvt-unicode/src/defaultfont.C 2003/12/17 22:29:03 1.6 @@ -355,6 +355,28 @@ { clear (); + char **list; + int count; + XFontStruct *info; + list = XListFontsWithInfo (DISPLAY, name, 128, &count, &info); + + if (!list) + return false; + + XFontStruct *best = 0; + for (int i = 0; i < count; i++) + { + XFontStruct *f = info + i; + if (f->ascent + f->descent <= maxheight) // weed out too large fonts + if (!best // compare against best found so far + || best->ascent + best->descent < f->ascent + f->descent) + best = f; + } + + set_name (strdup (list[best - info])); + + XFreeFontInfo (list, info, count); + f = XLoadQueryFont (DISPLAY, name); if (!f) @@ -893,13 +915,15 @@ if (fonts[i]->loaded) return true; - if (fonts[i]->load (height)) - return fonts[i]->loaded = true; + fonts[i]->loaded = true; - delete fonts[i]; - fonts.erase (fonts.begin () + i); + if (!fonts[i]->load (height)) + { + fonts[i]->cs = CS_UNKNOWN; + return false; + } - return false; + return true; } void @@ -946,15 +970,10 @@ goto next_font; if (!realize_font (i)) - { - --i; - goto next_font; - } - - //printf ("added font %s for %04lx\n", f->name, unicode); + goto next_font; } - if (f->has_codepoint (unicode)) + if (f->cs != CS_UNKNOWN && f->has_codepoint (unicode)) return i; next_font: @@ -962,6 +981,7 @@ { fonts.push_back (new_font (fallback->name, fallback->cs)); fallback++; + i = 0; } }