aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman2006-05-17 22:51:07 +0000
committerRichard M. Stallman2006-05-17 22:51:07 +0000
commit6c1195abb7d1644c9d1b971dbf0fb80af3e97860 (patch)
tree3a0e7d821bba6db53f13fc020cf5690f01e494fc /src
parent59367bff6b65cb1992c43e1b57fdd9d4592b0a24 (diff)
downloademacs-6c1195abb7d1644c9d1b971dbf0fb80af3e97860.tar.gz
emacs-6c1195abb7d1644c9d1b971dbf0fb80af3e97860.zip
(better_font_p): Any font beats no font.
(best_matching_font): Simplify based on above change.
Diffstat (limited to 'src')
-rw-r--r--src/xfaces.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/src/xfaces.c b/src/xfaces.c
index a5c5a21f585..b65efa7961e 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -6383,6 +6383,12 @@ better_font_p (values, font1, font2, compare_pt_p, avgwidth)
6383{ 6383{
6384 int i; 6384 int i;
6385 6385
6386 /* Any font is better than no font. */
6387 if (! font1)
6388 return 0;
6389 if (! font2)
6390 return 1;
6391
6386 for (i = 0; i < DIM (font_sort_order); ++i) 6392 for (i = 0; i < DIM (font_sort_order); ++i)
6387 { 6393 {
6388 int xlfd_idx = font_sort_order[i]; 6394 int xlfd_idx = font_sort_order[i];
@@ -6627,29 +6633,19 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike)
6627 if (needs_overstrike) 6633 if (needs_overstrike)
6628 *needs_overstrike = 0; 6634 *needs_overstrike = 0;
6629 6635
6630 /* Start with the first non-scalable font in the list. */ 6636 best = NULL;
6631 for (i = 0; i < nfonts; ++i)
6632 if (!font_scalable_p (fonts + i))
6633 break;
6634 6637
6635 /* Find the best match among the non-scalable fonts. */ 6638 /* Find the best match among the non-scalable fonts. */
6636 if (i < nfonts) 6639 for (i = 1; i < nfonts; ++i)
6637 { 6640 if (!font_scalable_p (fonts + i)
6638 best = fonts + i; 6641 && better_font_p (specified, fonts + i, best, 1, avgwidth))
6639 6642 {
6640 for (i = 1; i < nfonts; ++i) 6643 best = fonts + i;
6641 if (!font_scalable_p (fonts + i)
6642 && better_font_p (specified, fonts + i, best, 1, avgwidth))
6643 {
6644 best = fonts + i;
6645 6644
6646 exact_p = exact_face_match_p (specified, best, avgwidth); 6645 exact_p = exact_face_match_p (specified, best, avgwidth);
6647 if (exact_p) 6646 if (exact_p)
6648 break; 6647 break;
6649 } 6648 }
6650 }
6651 else
6652 best = NULL;
6653 6649
6654 /* Unless we found an exact match among non-scalable fonts, see if 6650 /* Unless we found an exact match among non-scalable fonts, see if
6655 we can find a better match among scalable fonts. */ 6651 we can find a better match among scalable fonts. */
@@ -6673,8 +6669,7 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike)
6673 for (i = 0; i < nfonts; ++i) 6669 for (i = 0; i < nfonts; ++i)
6674 if (font_scalable_p (fonts + i)) 6670 if (font_scalable_p (fonts + i))
6675 { 6671 {
6676 if (best == NULL 6672 if (better_font_p (specified, fonts + i, best, 0, 0)
6677 || better_font_p (specified, fonts + i, best, 0, 0)
6678 || (!non_scalable_has_exact_height_p 6673 || (!non_scalable_has_exact_height_p
6679 && !better_font_p (specified, best, fonts + i, 0, 0))) 6674 && !better_font_p (specified, best, fonts + i, 0, 0)))
6680 { 6675 {
@@ -6702,6 +6697,10 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio, needs_overstrike)
6702 } 6697 }
6703 } 6698 }
6704 6699
6700 /* We should have found SOME font. */
6701 if (best == NULL)
6702 abort ();
6703
6705 if (font_scalable_p (best)) 6704 if (font_scalable_p (best))
6706 font_name = build_scalable_font_name (f, best, pt); 6705 font_name = build_scalable_font_name (f, best, pt);
6707 else 6706 else