Mercurial > emacs
comparison src/xfaces.c @ 90428:a8190f7e546e
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 285-296)
- Update from CVS
- Merge from gnus--rel--5.10
- Update from CVS: admin/FOR-RELEASE: Update refcard section.
* gnus--rel--5.10 (patch 102-104)
- Update from CVS
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-64
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 07 Jun 2006 18:05:10 +0000 |
parents | 41626792e297 7ca4cd6f07f2 |
children | cd20cf7f26f9 |
comparison
equal
deleted
inserted
replaced
90427:ddb25860d044 | 90428:a8190f7e546e |
---|---|
6760 struct font_name *font1, *font2; | 6760 struct font_name *font1, *font2; |
6761 int compare_pt_p, avgwidth; | 6761 int compare_pt_p, avgwidth; |
6762 { | 6762 { |
6763 int i; | 6763 int i; |
6764 | 6764 |
6765 /* Any font is better than no font. */ | |
6766 if (! font1) | |
6767 return 0; | |
6768 if (! font2) | |
6769 return 1; | |
6770 | |
6765 for (i = 0; i < DIM (font_sort_order); ++i) | 6771 for (i = 0; i < DIM (font_sort_order); ++i) |
6766 { | 6772 { |
6767 int xlfd_idx = font_sort_order[i]; | 6773 int xlfd_idx = font_sort_order[i]; |
6768 | 6774 |
6769 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) | 6775 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) |
7010 exact_p = 0; | 7016 exact_p = 0; |
7011 | 7017 |
7012 if (needs_overstrike) | 7018 if (needs_overstrike) |
7013 *needs_overstrike = 0; | 7019 *needs_overstrike = 0; |
7014 | 7020 |
7015 /* Start with the first non-scalable font in the list. */ | 7021 best = NULL; |
7022 | |
7023 /* Find the best match among the non-scalable fonts. */ | |
7016 for (i = 0; i < nfonts; ++i) | 7024 for (i = 0; i < nfonts; ++i) |
7017 if (!font_scalable_p (fonts + i)) | 7025 if (!font_scalable_p (fonts + i) |
7018 break; | 7026 && better_font_p (specified, fonts + i, best, 1, avgwidth)) |
7019 | 7027 { |
7020 /* Find the best match among the non-scalable fonts. */ | 7028 best = fonts + i; |
7021 if (i < nfonts) | 7029 |
7022 { | 7030 exact_p = exact_face_match_p (specified, best, avgwidth); |
7023 best = fonts + i; | 7031 if (exact_p) |
7024 | 7032 break; |
7025 for (i = 1; i < nfonts; ++i) | 7033 } |
7026 if (!font_scalable_p (fonts + i) | |
7027 && better_font_p (specified, fonts + i, best, 1, avgwidth)) | |
7028 { | |
7029 best = fonts + i; | |
7030 | |
7031 exact_p = exact_face_match_p (specified, best, avgwidth); | |
7032 if (exact_p) | |
7033 break; | |
7034 } | |
7035 } | |
7036 else | |
7037 best = NULL; | |
7038 | 7034 |
7039 /* Unless we found an exact match among non-scalable fonts, see if | 7035 /* Unless we found an exact match among non-scalable fonts, see if |
7040 we can find a better match among scalable fonts. */ | 7036 we can find a better match among scalable fonts. */ |
7041 if (!exact_p) | 7037 if (!exact_p) |
7042 { | 7038 { |
7056 non_scalable_has_exact_height_p = 0; | 7052 non_scalable_has_exact_height_p = 0; |
7057 | 7053 |
7058 for (i = 0; i < nfonts; ++i) | 7054 for (i = 0; i < nfonts; ++i) |
7059 if (font_scalable_p (fonts + i)) | 7055 if (font_scalable_p (fonts + i)) |
7060 { | 7056 { |
7061 if (best == NULL | 7057 if (better_font_p (specified, fonts + i, best, 0, 0) |
7062 || better_font_p (specified, fonts + i, best, 0, 0) | |
7063 || (!non_scalable_has_exact_height_p | 7058 || (!non_scalable_has_exact_height_p |
7064 && !better_font_p (specified, best, fonts + i, 0, 0))) | 7059 && !better_font_p (specified, best, fonts + i, 0, 0))) |
7065 { | 7060 { |
7066 non_scalable_has_exact_height_p = 1; | 7061 non_scalable_has_exact_height_p = 1; |
7067 best = fonts + i; | 7062 best = fonts + i; |
7068 } | 7063 } |
7069 } | 7064 } |
7070 | 7065 } |
7071 if (needs_overstrike) | 7066 |
7072 { | 7067 /* We should have found SOME font. */ |
7073 enum xlfd_weight want_weight = specified[XLFD_WEIGHT]; | 7068 if (best == NULL) |
7074 enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT]; | 7069 abort (); |
7075 | 7070 |
7076 if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight) | 7071 if (! exact_p && needs_overstrike) |
7077 { | 7072 { |
7078 /* We want a bold font, but didn't get one; try to use | 7073 enum xlfd_weight want_weight = specified[XLFD_WEIGHT]; |
7079 overstriking instead to simulate bold-face. However, | 7074 enum xlfd_weight got_weight = best->numeric[XLFD_WEIGHT]; |
7080 don't overstrike an already-bold fontn unless the | 7075 |
7081 desired weight grossly exceeds the available weight. */ | 7076 if (want_weight > XLFD_WEIGHT_MEDIUM && want_weight > got_weight) |
7082 if (got_weight > XLFD_WEIGHT_MEDIUM) | 7077 { |
7083 *needs_overstrike = (got_weight - want_weight) > 2; | 7078 /* We want a bold font, but didn't get one; try to use |
7084 else | 7079 overstriking instead to simulate bold-face. However, |
7085 *needs_overstrike = 1; | 7080 don't overstrike an already-bold fontn unless the |
7086 } | 7081 desired weight grossly exceeds the available weight. */ |
7082 if (got_weight > XLFD_WEIGHT_MEDIUM) | |
7083 *needs_overstrike = (got_weight - want_weight) > 2; | |
7084 else | |
7085 *needs_overstrike = 1; | |
7087 } | 7086 } |
7088 } | 7087 } |
7089 | 7088 |
7090 if (font_scalable_p (best)) | 7089 if (font_scalable_p (best)) |
7091 font_name = build_scalable_font_name (f, best, pt); | 7090 font_name = build_scalable_font_name (f, best, pt); |
7486 check_lface (lface); | 7485 check_lface (lface); |
7487 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); | 7486 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); |
7488 face = realize_face (c, attrs, DEFAULT_FACE_ID); | 7487 face = realize_face (c, attrs, DEFAULT_FACE_ID); |
7489 | 7488 |
7490 #ifdef HAVE_WINDOW_SYSTEM | 7489 #ifdef HAVE_WINDOW_SYSTEM |
7491 #ifdef HAVE_X_WINDOWS | 7490 #ifdef HAVE_X_WINDOWS |
7492 if (face->font != FRAME_FONT (f)) | 7491 if (face->font != FRAME_FONT (f)) |
7493 /* As the font specified for the frame was not acceptable as a | 7492 /* As the font specified for the frame was not acceptable as a |
7494 font for the default face (perhaps because auto-scaled fonts | 7493 font for the default face (perhaps because auto-scaled fonts |
7495 are rejected), we must adjust the frame font. */ | 7494 are rejected), we must adjust the frame font. */ |
7496 x_set_font (f, build_string (face->font_name), Qnil); | 7495 x_set_font (f, build_string (face->font_name), Qnil); |