diff options
| author | Kenichi Handa | 2009-06-25 08:02:34 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2009-06-25 08:02:34 +0000 |
| commit | a71ccf3ac8766a1099d8457f4968e50082928456 (patch) | |
| tree | 6071593a3f5b0571bc8fffd43686b386e058d312 /src | |
| parent | ca27c21bf2b7e45eba5a06e9e4bd9eeecf300881 (diff) | |
| download | emacs-a71ccf3ac8766a1099d8457f4968e50082928456.tar.gz emacs-a71ccf3ac8766a1099d8457f4968e50082928456.zip | |
(fontset_find_font): When a usable rfont_def is found
in a fallback font-group, make it the first element of the group.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/fontset.c | 35 |
2 files changed, 33 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index c82e6e86407..70f5def9a9d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2009-06-25 <handa@m17n.org> | ||
| 2 | |||
| 3 | * fontset.c (fontset_find_font): When a usable rfont_def is found | ||
| 4 | in a fallback font-group, make it the first element of the group. | ||
| 5 | |||
| 1 | 2009-06-24 Chong Yidong <cyd@stupidchicken.com> | 6 | 2009-06-24 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 7 | ||
| 3 | * emacs-icon.h: Always define gnu_xpm_bits on GTK (bug#3671). | 8 | * emacs-icon.h: Always define gnu_xpm_bits on GTK (bug#3671). |
diff --git a/src/fontset.c b/src/fontset.c index f144cb1dd96..d7e61d54408 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -531,9 +531,10 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 531 | int id, fallback; | 531 | int id, fallback; |
| 532 | { | 532 | { |
| 533 | Lisp_Object vec, font_group; | 533 | Lisp_Object vec, font_group; |
| 534 | int i, charset_matched = -1; | 534 | int i, charset_matched = -1, found_index; |
| 535 | FRAME_PTR f = (FRAMEP (FONTSET_FRAME (fontset))) | 535 | FRAME_PTR f = (FRAMEP (FONTSET_FRAME (fontset))) |
| 536 | ? XFRAME (selected_frame) : XFRAME (FONTSET_FRAME (fontset)); | 536 | ? XFRAME (selected_frame) : XFRAME (FONTSET_FRAME (fontset)); |
| 537 | Lisp_Object rfont_def; | ||
| 537 | 538 | ||
| 538 | font_group = fontset_get_font_group (fontset, fallback ? -1 : c); | 539 | font_group = fontset_get_font_group (fontset, fallback ? -1 : c); |
| 539 | if (! CONSP (font_group)) | 540 | if (! CONSP (font_group)) |
| @@ -553,9 +554,9 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 553 | first. */ | 554 | first. */ |
| 554 | for (i = 0; i < ASIZE (vec); i++) | 555 | for (i = 0; i < ASIZE (vec); i++) |
| 555 | { | 556 | { |
| 556 | Lisp_Object rfont_def = AREF (vec, i); | ||
| 557 | Lisp_Object repertory; | 557 | Lisp_Object repertory; |
| 558 | 558 | ||
| 559 | rfont_def = AREF (vec, i); | ||
| 559 | if (NILP (rfont_def)) | 560 | if (NILP (rfont_def)) |
| 560 | break; | 561 | break; |
| 561 | repertory = FONT_DEF_REPERTORY (RFONT_DEF_FONT_DEF (rfont_def)); | 562 | repertory = FONT_DEF_REPERTORY (RFONT_DEF_FONT_DEF (rfont_def)); |
| @@ -571,18 +572,22 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 571 | /* Find the first available font in the vector of RFONT-DEF. */ | 572 | /* Find the first available font in the vector of RFONT-DEF. */ |
| 572 | for (i = 0; i < ASIZE (vec); i++) | 573 | for (i = 0; i < ASIZE (vec); i++) |
| 573 | { | 574 | { |
| 574 | Lisp_Object rfont_def, font_def; | 575 | Lisp_Object font_def; |
| 575 | Lisp_Object font_entity, font_object; | 576 | Lisp_Object font_entity, font_object; |
| 576 | 577 | ||
| 577 | if (i == 0 && charset_matched >= 0) | 578 | if (i == 0 && charset_matched >= 0) |
| 578 | { | 579 | { |
| 579 | /* Try the element matching with the charset ID at first. */ | 580 | /* Try the element matching with the charset ID at first. */ |
| 580 | rfont_def = AREF (vec, charset_matched); | 581 | rfont_def = AREF (vec, charset_matched); |
| 582 | found_index = charset_matched; | ||
| 581 | charset_matched = -1; | 583 | charset_matched = -1; |
| 582 | i--; | 584 | i--; |
| 583 | } | 585 | } |
| 584 | else if (i != charset_matched) | 586 | else if (i != charset_matched) |
| 585 | rfont_def = AREF (vec, i); | 587 | { |
| 588 | rfont_def = AREF (vec, i); | ||
| 589 | found_index = i; | ||
| 590 | } | ||
| 586 | else | 591 | else |
| 587 | continue; | 592 | continue; |
| 588 | 593 | ||
| @@ -630,7 +635,7 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 630 | } | 635 | } |
| 631 | 636 | ||
| 632 | if (font_has_char (f, font_object, c)) | 637 | if (font_has_char (f, font_object, c)) |
| 633 | return rfont_def; | 638 | goto found; |
| 634 | 639 | ||
| 635 | /* Find a font already opened, maching with the current spec, | 640 | /* Find a font already opened, maching with the current spec, |
| 636 | and supporting C. */ | 641 | and supporting C. */ |
| @@ -644,7 +649,7 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 644 | break; | 649 | break; |
| 645 | font_object = RFONT_DEF_OBJECT (AREF (vec, i)); | 650 | font_object = RFONT_DEF_OBJECT (AREF (vec, i)); |
| 646 | if (! NILP (font_object) && font_has_char (f, font_object, c)) | 651 | if (! NILP (font_object) && font_has_char (f, font_object, c)) |
| 647 | return rfont_def; | 652 | goto found; |
| 648 | } | 653 | } |
| 649 | 654 | ||
| 650 | /* Find a font-entity with the current spec and supporting C. */ | 655 | /* Find a font-entity with the current spec and supporting C. */ |
| @@ -661,6 +666,7 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 661 | Qnil); | 666 | Qnil); |
| 662 | if (NILP (font_object)) | 667 | if (NILP (font_object)) |
| 663 | continue; | 668 | continue; |
| 669 | found_index = i; | ||
| 664 | RFONT_DEF_NEW (rfont_def, font_def); | 670 | RFONT_DEF_NEW (rfont_def, font_def); |
| 665 | RFONT_DEF_SET_OBJECT (rfont_def, font_object); | 671 | RFONT_DEF_SET_OBJECT (rfont_def, font_object); |
| 666 | RFONT_DEF_SET_SCORE (rfont_def, RFONT_DEF_SCORE (rfont_def)); | 672 | RFONT_DEF_SET_SCORE (rfont_def, RFONT_DEF_SCORE (rfont_def)); |
| @@ -668,10 +674,12 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 668 | for (j = 0; j < i; j++) | 674 | for (j = 0; j < i; j++) |
| 669 | ASET (new_vec, j, AREF (vec, j)); | 675 | ASET (new_vec, j, AREF (vec, j)); |
| 670 | ASET (new_vec, j, rfont_def); | 676 | ASET (new_vec, j, rfont_def); |
| 677 | found_index = j; | ||
| 671 | for (j++; j < ASIZE (new_vec); j++) | 678 | for (j++; j < ASIZE (new_vec); j++) |
| 672 | ASET (new_vec, j, AREF (vec, j - 1)); | 679 | ASET (new_vec, j, AREF (vec, j - 1)); |
| 673 | XSETCDR (font_group, new_vec); | 680 | XSETCDR (font_group, new_vec); |
| 674 | return rfont_def; | 681 | vec = new_vec; |
| 682 | goto found; | ||
| 675 | } | 683 | } |
| 676 | 684 | ||
| 677 | /* No font of the current spec for C. Try the next spec. */ | 685 | /* No font of the current spec for C. Try the next spec. */ |
| @@ -680,6 +688,19 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 680 | 688 | ||
| 681 | FONTSET_SET (fontset, make_number (c), make_number (0)); | 689 | FONTSET_SET (fontset, make_number (c), make_number (0)); |
| 682 | return Qnil; | 690 | return Qnil; |
| 691 | |||
| 692 | found: | ||
| 693 | if (fallback && found_index > 0) | ||
| 694 | { | ||
| 695 | /* The order of fonts in the fallback font-group is not that | ||
| 696 | important, and it is better to move the found font to the | ||
| 697 | first of the group so that the next try will find it | ||
| 698 | quickly. */ | ||
| 699 | for (i = found_index; i > 0; i--) | ||
| 700 | ASET (vec, i, AREF (vec, i - 1)); | ||
| 701 | ASET (vec, 0, rfont_def); | ||
| 702 | } | ||
| 703 | return rfont_def; | ||
| 683 | } | 704 | } |
| 684 | 705 | ||
| 685 | 706 | ||