… | |
… | |
353 | bool |
353 | bool |
354 | rxvt_font_x11::load (int maxheight) |
354 | rxvt_font_x11::load (int maxheight) |
355 | { |
355 | { |
356 | clear (); |
356 | clear (); |
357 | |
357 | |
|
|
358 | char **list; |
|
|
359 | int count; |
|
|
360 | XFontStruct *info; |
|
|
361 | list = XListFontsWithInfo (DISPLAY, name, 128, &count, &info); |
|
|
362 | |
|
|
363 | if (!list) |
|
|
364 | return false; |
|
|
365 | |
|
|
366 | XFontStruct *best = 0; |
|
|
367 | for (int i = 0; i < count; i++) |
|
|
368 | { |
|
|
369 | XFontStruct *f = info + i; |
|
|
370 | if (f->ascent + f->descent <= maxheight) // weed out too large fonts |
|
|
371 | if (!best // compare against best found so far |
|
|
372 | || best->ascent + best->descent < f->ascent + f->descent) |
|
|
373 | best = f; |
|
|
374 | } |
|
|
375 | |
|
|
376 | set_name (strdup (list[best - info])); |
|
|
377 | |
|
|
378 | XFreeFontInfo (list, info, count); |
|
|
379 | |
358 | f = XLoadQueryFont (DISPLAY, name); |
380 | f = XLoadQueryFont (DISPLAY, name); |
359 | |
381 | |
360 | if (!f) |
382 | if (!f) |
361 | return false; |
383 | return false; |
362 | |
384 | |