Mercurial > pidgin
comparison src/gtkhtml.c @ 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 | 37a1d222b7f8 |
children | a8f964718837 |
comparison
equal
deleted
inserted
replaced
304:b4880624ec78 | 305:77404a4692b1 |
---|---|
475 int size, GdkFont **font_return) | 475 int size, GdkFont **font_return) |
476 { | 476 { |
477 gchar font_spec[1024]; | 477 gchar font_spec[1024]; |
478 | 478 |
479 g_snprintf(font_spec, sizeof font_spec, | 479 g_snprintf(font_spec, sizeof font_spec, |
480 "-*-%s-%s-%c-normal-*-*-%d-*-*-*-*-iso8859-1", | 480 "-*-%s-%s-%c-*-*-*-%d-*-*-*-*-*-*", |
481 name, weight, slant, size); | 481 name, weight, slant, size); |
482 | 482 |
483 if((*font_return = g_datalist_id_get_data(&font_cache, | 483 if((*font_return = g_datalist_id_get_data(&font_cache, |
484 g_quark_from_string(font_spec)))) { | 484 g_quark_from_string(font_spec)))) { |
485 return TRUE; | 485 return TRUE; |
507 size = font_sizes[size-1]; | 507 size = font_sizes[size-1]; |
508 | 508 |
509 /* try both 'i'talic and 'o'blique for italic fonts, and keep | 509 /* try both 'i'talic and 'o'blique for italic fonts, and keep |
510 * increasing the size until we get one that works. */ | 510 * increasing the size until we get one that works. */ |
511 | 511 |
512 while (size < 720) { | 512 while (size <= 720) { |
513 if (load_font_with_cache(font, weight, slant, size, &my_font)) | 513 if (load_font_with_cache(font, weight, slant, size, &my_font)) |
514 return my_font; | 514 return my_font; |
515 if (italic && load_font_with_cache(font, weight, 'o', size, &my_font)) | 515 if (italic && load_font_with_cache(font, weight, 'o', size, &my_font)) |
516 return my_font; | 516 return my_font; |
517 size += 10; | 517 size += 10; |
519 | 519 |
520 /* since we couldn't get any size up to 72, fall back to the | 520 /* since we couldn't get any size up to 72, fall back to the |
521 * default fonts. */ | 521 * default fonts. */ |
522 | 522 |
523 font = fixed ? "courier" : "helvetica"; | 523 font = fixed ? "courier" : "helvetica"; |
524 | 524 size = 120; |
525 if (load_font_with_cache(font, weight, slant, 120, &my_font)) | 525 while (size <= 720) { |
526 return my_font; | 526 if (load_font_with_cache(font, weight, slant, size, &my_font)) |
527 else { | 527 return my_font; |
528 fprintf(stderr, "gaim: can't load default font\n"); | 528 size += 10; |
529 exit(1); | 529 } |
530 } | 530 |
531 font = fixed ? "helvetica" : "courier"; | |
532 size = 120; | |
533 while (size <= 720) { | |
534 if (load_font_with_cache(font, weight, slant, size, &my_font)) | |
535 return my_font; | |
536 size += 10; | |
537 } | |
538 | |
539 /* whoops, couldn't do any of those. maybe they have a default outgoing | |
540 * font? maybe we can use that. */ | |
541 if (font_options & OPT_FONT_FACE) { | |
542 if (fontname != NULL) { | |
543 /* woohoo! */ | |
544 size = 120; | |
545 while (size <= 720) { | |
546 if (load_font_with_cache(fontname, "medium", 'r', size, &my_font)) | |
547 return my_font; | |
548 size += 10; | |
549 } | |
550 } | |
551 } | |
552 | |
553 /* ok, now we're in a pickle. if we can't do any of the above, let's | |
554 * try doing the most boring font we can find. */ | |
555 size = 120; | |
556 while (size <= 720) { | |
557 if (load_font_with_cache("courier", "medium", 'r', size, &my_font)) | |
558 return my_font; | |
559 size += 10; | |
560 } | |
561 | |
562 size = 120; | |
563 while (size <= 720) { | |
564 if (load_font_with_cache("helvetica", "medium", 'r', size, &my_font)) | |
565 return my_font; | |
566 size += 10; | |
567 } | |
568 | |
569 size = 120; | |
570 while (size <= 720) { | |
571 if (load_font_with_cache("times", "medium", 'r', size, &my_font)) | |
572 return my_font; | |
573 size += 10; | |
574 } | |
575 | |
576 /* my god, how did we end up here. is there a 'generic font' function | |
577 * in gdk? that would be incredibly useful here. there's gotta be a | |
578 * better way to do this. */ | |
579 | |
580 /* well, if they can't do any of the fonts above, they're screwed, might | |
581 * as well segfault. */ | |
582 return NULL; | |
531 } | 583 } |
532 | 584 |
533 | 585 |
534 /* 'Borrowed' from ETerm */ | 586 /* 'Borrowed' from ETerm */ |
535 GdkWindow *get_desktop_window(GtkWidget * widget) | 587 GdkWindow *get_desktop_window(GtkWidget * widget) |