aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-01-30 04:07:47 +0000
committerKenichi Handa2008-01-30 04:07:47 +0000
commiteaa0402c9248272d63a045c62ab5de7a455144d5 (patch)
treec7fe786a239966e7e93bad1ddc22f5191192da51 /src
parentc9228487a255639d68f7094e1bc3c86ee6deba97 (diff)
downloademacs-eaa0402c9248272d63a045c62ab5de7a455144d5.tar.gz
emacs-eaa0402c9248272d63a045c62ab5de7a455144d5.zip
(reorder_font_vector): Exclude nil elements from the
font group. Don't try multiple fonts. (fontset_font): Adjusted for the above change. (Finternal_char_font): Return nil if the found font doesn't contain the character ch.
Diffstat (limited to 'src')
-rw-r--r--src/fontset.c99
1 files changed, 57 insertions, 42 deletions
diff --git a/src/fontset.c b/src/fontset.c
index d6fe79bbc27..a6d06c5d040 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -415,6 +415,8 @@ reorder_font_vector (font_group, charset_id, family)
415 Lisp_Object preferred_by_charset, preferred_by_family; 415 Lisp_Object preferred_by_charset, preferred_by_family;
416 416
417 size = ASIZE (font_group) - 3; 417 size = ASIZE (font_group) - 3;
418 /* Exclude the tailing nil elements from the reordering. */
419 while (NILP (AREF (font_group, size - 1))) size--;
418 charset_id_table = (int *) alloca (sizeof (int) * size); 420 charset_id_table = (int *) alloca (sizeof (int) * size);
419 new_vec = (Lisp_Object *) alloca (sizeof (Lisp_Object) * size); 421 new_vec = (Lisp_Object *) alloca (sizeof (Lisp_Object) * size);
420 422
@@ -568,6 +570,7 @@ fontset_find_font (fontset, c, face, id, fallback)
568 vec = CHAR_TABLE_REF (fontset, c); 570 vec = CHAR_TABLE_REF (fontset, c);
569 else 571 else
570 vec = FONTSET_FALLBACK (fontset); 572 vec = FONTSET_FALLBACK (fontset);
573
571 if (NILP (vec)) 574 if (NILP (vec))
572 { 575 {
573 Lisp_Object range; 576 Lisp_Object range;
@@ -586,33 +589,44 @@ fontset_find_font (fontset, c, face, id, fallback)
586 } 589 }
587 if (NILP (elt)) 590 if (NILP (elt))
588 { 591 {
589 /* 0 means we have no font for characters of this range. */ 592 /* This fontset doesn't specify any font for C. */
590 vec = make_number (0); 593 vec = make_number (0);
591 } 594 }
595 else if (ASIZE (elt) == 1 && NILP (AREF (elt, 0)))
596 {
597 /* Explicitly specified no font. */
598 vec = Qt;
599 }
592 else 600 else
593 { 601 {
594 /* Build a vector [ -1 -1 nil NEW-ELT0 NEW-ELT1 NEW-ELT2 ... ], 602 /* Build a vector [ -1 -1 nil NEW-ELT0 NEW-ELT1 NEW-ELT2 ... ],
595 where the first -1 is to force reordering of NEW-ELTn, 603 where the first -1 is to force reordering of NEW-ELTn,
596 NEW-ELTn is [nil nil AREF (elt, n) nil]. */ 604 NEW-ELTn is [nil nil AREF (elt, n) nil]. */
597 vec = Fmake_vector (make_number (ASIZE (elt) + 3), Qnil); 605 int size = ASIZE (elt);
606 int j;
607
608 vec = Fmake_vector (make_number (size + 3), Qnil);
598 ASET (vec, 0, make_number (-1)); 609 ASET (vec, 0, make_number (-1));
599 ASET (vec, 1, make_number (-1)); 610 ASET (vec, 1, make_number (-1));
600 for (i = 0; i < ASIZE (elt); i++) 611 for (i = j = 0; i < size; i++)
601 { 612 if (! NILP (AREF (elt, i)))
602 Lisp_Object tmp; 613 {
603 tmp = Fmake_vector (make_number (5), Qnil); 614 Lisp_Object tmp;
604 ASET (tmp, 2, AREF (elt, i)); 615 tmp = Fmake_vector (make_number (5), Qnil);
605 ASET (vec, i + 3, tmp); 616 ASET (tmp, 2, AREF (elt, i));
606 } 617 ASET (vec, j + 3, tmp);
618 j++;
619 }
607 } 620 }
608 /* Then store it in the fontset. */ 621 /* Then store it in the fontset. */
609 if (! fallback) 622 if (! fallback)
610 FONTSET_SET (fontset, range, vec); 623 FONTSET_SET (fontset, range, vec);
611 else 624 else
612 FONTSET_FALLBACK (fontset) = vec; 625 FONTSET_FALLBACK (fontset) = vec;
626
613 } 627 }
614 if (! VECTORP (vec)) 628 if (! VECTORP (vec))
615 return (INTEGERP (vec) ? Qnil : Qt); 629 return (EQ (vec, Qt) ? Qt : Qnil);
616 630
617 if (ASIZE (vec) > 4 631 if (ASIZE (vec) > 4
618 && (XINT (AREF (vec, 0)) != charset_ordered_list_tick 632 && (XINT (AREF (vec, 0)) != charset_ordered_list_tick
@@ -629,7 +643,8 @@ fontset_find_font (fontset, c, face, id, fallback)
629 { 643 {
630 elt = AREF (vec, i); 644 elt = AREF (vec, i);
631 if (NILP (elt)) 645 if (NILP (elt))
632 continue; 646 /* This is the sign of not to try fallback fonts. */
647 return Qt;
633 /* ELT == [ FACE-ID FONT-INDEX FONT-DEF ... ] */ 648 /* ELT == [ FACE-ID FONT-INDEX FONT-DEF ... ] */
634 if (INTEGERP (AREF (elt, 1)) && XINT (AREF (elt, 1)) < 0) 649 if (INTEGERP (AREF (elt, 1)) && XINT (AREF (elt, 1)) < 0)
635 /* We couldn't open this font last time. */ 650 /* We couldn't open this font last time. */
@@ -652,48 +667,42 @@ fontset_find_font (fontset, c, face, id, fallback)
652 667
653 if (NILP (font_entity)) 668 if (NILP (font_entity))
654 { 669 {
655 Lisp_Object args[2];
656 int j;
657
658 font_entity = font_find_for_lface (f, face->lface, 670 font_entity = font_find_for_lface (f, face->lface,
659 AREF (font_def, 0), c); 671 AREF (font_def, 0), -1);
660 if (NILP (font_entity)) 672 if (NILP (font_entity))
661 continue; 673 {
662 has_char = 1; 674 ASET (elt, 1, make_number (-1));
663 /* Extend the vector and insert the new ELT here. */ 675 continue;
664 args[0] = vec; 676 }
665 args[1] = Qnil;
666 vec = Fvconcat (2, args);
667 for (j = ASIZE (vec) - 2; j >= i; j--)
668 ASET (vec, j + 1, AREF (vec, j));
669 elt = Fcopy_sequence (elt);
670 ASET (elt, 3, font_entity); 677 ASET (elt, 3, font_entity);
671 ASET (vec, i, elt);
672 if (! has_char)
673 continue;
674 } 678 }
675 else if (FONT_ENTITY_P (font_entity)) 679 else if (FONT_ENTITY_P (font_entity))
676 { 680 {
677 if (FONT_ENTITY_NOT_LOADABLE (font_entity)) 681 if (FONT_ENTITY_NOT_LOADABLE (font_entity))
678 continue; 682 continue;
679 has_char = font_has_char (f, font_entity, c);
680 if (! has_char)
681 continue;
682 } 683 }
684 has_char = font_has_char (f, font_entity, c);
685 if (! has_char)
686 continue;
683 if (! FONT_OBJECT_P (font_entity)) 687 if (! FONT_OBJECT_P (font_entity))
684 { 688 {
685 font_entity = font_open_for_lface (f, font_entity, 689 Lisp_Object font_object
686 face->lface, Qnil); 690 = font_open_for_lface (f, font_entity, face->lface, Qnil);
687 if (NILP (font_entity)) 691
692 if (NILP (font_object))
688 { 693 {
689 FONT_ENTITY_SET_NOT_LOADABLE (font_entity); 694 FONT_ENTITY_SET_NOT_LOADABLE (font_entity);
690 continue; 695 continue;
691 } 696 }
692 ASET (elt, 3, font_entity); 697 ASET (elt, 3, font_object);
698 if (has_char < 0)
699 {
700 has_char = font_has_char (f, font_object, c);
701 if (! has_char)
702 continue;
703 }
693 } 704 }
694 if (! has_char 705 /* Decide to use this font. */
695 && ! font_has_char (f, font_entity, c))
696 continue;
697 ASET (elt, 1, make_number (0)); 706 ASET (elt, 1, make_number (0));
698 } 707 }
699 else 708 else
@@ -761,7 +770,7 @@ fontset_find_font (fontset, c, face, id, fallback)
761 return elt; 770 return elt;
762 } 771 }
763 772
764 return Qt; 773 return Qnil;
765} 774}
766 775
767 776
@@ -777,8 +786,10 @@ fontset_font (fontset, c, face, id)
777 786
778 /* Try a font-group for C. */ 787 /* Try a font-group for C. */
779 rfont_def = fontset_find_font (fontset, c, face, id, 0); 788 rfont_def = fontset_find_font (fontset, c, face, id, 0);
780 if (! NILP (rfont_def)) 789 if (VECTORP (rfont_def))
781 return (VECTORP (rfont_def) ? rfont_def : Qnil); 790 return rfont_def;
791 if (EQ (rfont_def, Qt))
792 return Qnil;
782 base_fontset = FONTSET_BASE (fontset); 793 base_fontset = FONTSET_BASE (fontset);
783 /* Try a font-group for C of the default fontset. */ 794 /* Try a font-group for C of the default fontset. */
784 if (! EQ (base_fontset, Vdefault_fontset)) 795 if (! EQ (base_fontset, Vdefault_fontset))
@@ -787,8 +798,11 @@ fontset_font (fontset, c, face, id)
787 FONTSET_DEFAULT (fontset) 798 FONTSET_DEFAULT (fontset)
788 = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset); 799 = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset);
789 rfont_def = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0); 800 rfont_def = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0);
801 if (VECTORP (rfont_def))
802 return (rfont_def);
790 if (! NILP (rfont_def)) 803 if (! NILP (rfont_def))
791 return (VECTORP (rfont_def) ? rfont_def : Qnil); 804 /* Remeber that we have no font for C. */
805 FONTSET_SET (fontset, make_number (c), Qt);
792 } 806 }
793 807
794 /* Try a fallback font-group. */ 808 /* Try a fallback font-group. */
@@ -1507,6 +1521,7 @@ FONT-SPEC may one of these:
1507 REGISTRY is a font registry name. FAMILY may contains foundry 1521 REGISTRY is a font registry name. FAMILY may contains foundry
1508 name, and REGISTRY may contains encoding name. 1522 name, and REGISTRY may contains encoding name.
1509 * A font name string. 1523 * A font name string.
1524 * nil, which explicitly specifies that there's no font for TARGET.
1510 1525
1511Optional 4th argument FRAME, if non-nil, is a frame. This argument is 1526Optional 4th argument FRAME, if non-nil, is a frame. This argument is
1512kept for backward compatibility and has no meaning. 1527kept for backward compatibility and has no meaning.
@@ -2052,7 +2067,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
2052 Lisp_Object fontname = font_get_name (font_object); 2067 Lisp_Object fontname = font_get_name (font_object);
2053 2068
2054 if (code == FONT_INVALID_CODE) 2069 if (code == FONT_INVALID_CODE)
2055 return Fcons (fontname, Qnil); 2070 return Qnil;
2056 if (code <= MOST_POSITIVE_FIXNUM) 2071 if (code <= MOST_POSITIVE_FIXNUM)
2057 return Fcons (fontname, make_number (code)); 2072 return Fcons (fontname, make_number (code));
2058 return Fcons (fontname, Fcons (make_number (code >> 16), 2073 return Fcons (fontname, Fcons (make_number (code >> 16),