Mercurial > pidgin
changeset 305:77404a4692b1
[gaim-migrate @ 315]
12:10:45 EWarmenhoven: ok, the new method for chosing a font: it tries the requested font at the requested size. if it can't do that, it tries the requested font at any size. if it can't do that, it tries courier at any size, then helvetica at any size. if it can't do *that*, it tries the person's default outgoing font, if they have one. if it can't do that, it tries courier, helvetica, then times, all in their most boring form (no bold, italics, etc) at any size. if it *still* can't do that, then there's just no hope, and it segfaults. but at least there's a few more layers of protection and probability that you're going to get *something* right
12:11:43 EWarmenhoven: i don't even know that it'll segfault, but i'm pretty sure it will, since by the time you get down there, it returns NULL :-P
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 01 Jun 2000 19:13:00 +0000 |
parents | b4880624ec78 |
children | a8f964718837 |
files | src/gtkhtml.c |
diffstat | 1 files changed, 60 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkhtml.c Thu Jun 01 17:10:05 2000 +0000 +++ b/src/gtkhtml.c Thu Jun 01 19:13:00 2000 +0000 @@ -477,7 +477,7 @@ gchar font_spec[1024]; g_snprintf(font_spec, sizeof font_spec, - "-*-%s-%s-%c-normal-*-*-%d-*-*-*-*-iso8859-1", + "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*", name, weight, slant, size); if((*font_return = g_datalist_id_get_data(&font_cache, @@ -509,7 +509,7 @@ /* try both 'i'talic and 'o'blique for italic fonts, and keep * increasing the size until we get one that works. */ - while (size < 720) { + while (size <= 720) { if (load_font_with_cache(font, weight, slant, size, &my_font)) return my_font; if (italic && load_font_with_cache(font, weight, 'o', size, &my_font)) @@ -521,13 +521,65 @@ * default fonts. */ font = fixed ? "courier" : "helvetica"; - - if (load_font_with_cache(font, weight, slant, 120, &my_font)) - return my_font; - else { - fprintf(stderr, "gaim: can't load default font\n"); - exit(1); + size = 120; + while (size <= 720) { + if (load_font_with_cache(font, weight, slant, size, &my_font)) + return my_font; + size += 10; + } + + font = fixed ? "helvetica" : "courier"; + size = 120; + while (size <= 720) { + if (load_font_with_cache(font, weight, slant, size, &my_font)) + return my_font; + size += 10; + } + + /* whoops, couldn't do any of those. maybe they have a default outgoing + * font? maybe we can use that. */ + if (font_options & OPT_FONT_FACE) { + if (fontname != NULL) { + /* woohoo! */ + size = 120; + while (size <= 720) { + if (load_font_with_cache(fontname, "medium", 'r', size, &my_font)) + return my_font; + size += 10; + } + } } + + /* ok, now we're in a pickle. if we can't do any of the above, let's + * try doing the most boring font we can find. */ + size = 120; + while (size <= 720) { + if (load_font_with_cache("courier", "medium", 'r', size, &my_font)) + return my_font; + size += 10; + } + + size = 120; + while (size <= 720) { + if (load_font_with_cache("helvetica", "medium", 'r', size, &my_font)) + return my_font; + size += 10; + } + + size = 120; + while (size <= 720) { + if (load_font_with_cache("times", "medium", 'r', size, &my_font)) + return my_font; + size += 10; + } + + /* my god, how did we end up here. is there a 'generic font' function + * in gdk? that would be incredibly useful here. there's gotta be a + * better way to do this. */ + + /* well, if they can't do any of the fonts above, they're screwed, might + * as well segfault. */ + return NULL; }