diff options
| author | Kenichi Handa | 2008-01-28 07:03:27 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2008-01-28 07:03:27 +0000 |
| commit | d67f7f1a571584917dabc507330909c14fece5e1 (patch) | |
| tree | 8ce571b8078a26181723a0ef6e703de4cde23a15 /src | |
| parent | 43071057a26bf3f01e8ede479ca817096d7ff565 (diff) | |
| download | emacs-d67f7f1a571584917dabc507330909c14fece5e1.tar.gz emacs-d67f7f1a571584917dabc507330909c14fece5e1.zip | |
(reorder_font_vector): Fix typo.
(fontset_find_font): Don't add a font-spec specifying a script.
Use 0 (not Qt) for the indication of empty font-group. Change the
format of RFONT-DEF. Return Qt if no font in the font-group
support the character.
(fontset_font): Adjusted for the above change. If no font was
found the character, remember that.
(face_for_char): Adjusted for the change of RFONT-DEF.
(Fset_fontset_font): Allow nil for FONT-SPEC to explicitly specify
no font for the target.
(Finternal_char_font): Adjusted for the change of RFONT-DEF.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fontset.c | 220 |
1 files changed, 102 insertions, 118 deletions
diff --git a/src/fontset.c b/src/fontset.c index dd49af5177e..d6fe79bbc27 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -471,7 +471,7 @@ reorder_font_vector (font_group, charset_id, family) | |||
| 471 | break; | 471 | break; |
| 472 | for (i = 0; i < size; i++) | 472 | for (i = 0; i < size; i++) |
| 473 | if (charset_id_table[i] == XINT (XCAR (list)) | 473 | if (charset_id_table[i] == XINT (XCAR (list)) |
| 474 | && ! NILP (AREF (font_group, i + 2))) | 474 | && ! NILP (AREF (font_group, i + 3))) |
| 475 | { | 475 | { |
| 476 | new_vec[idx++] = AREF (font_group, i + 3); | 476 | new_vec[idx++] = AREF (font_group, i + 3); |
| 477 | ASET (font_group, i + 3, Qnil); | 477 | ASET (font_group, i + 3, Qnil); |
| @@ -539,11 +539,16 @@ static Lisp_Object fontset_find_font P_ ((Lisp_Object, int, struct face *, | |||
| 539 | int, int)); | 539 | int, int)); |
| 540 | 540 | ||
| 541 | /* Return RFONT-DEF (vector) in the realized fontset FONTSET for the | 541 | /* Return RFONT-DEF (vector) in the realized fontset FONTSET for the |
| 542 | character C. If the corresponding font is not yet opened, open it | 542 | character C. If no font is found, return Qnil if there's a |
| 543 | (if FACE is not NULL) or return Qnil (if FACE is NULL). | 543 | possibility that the default fontset or the fallback font groups |
| 544 | If no proper font is found for C, return Qnil. | 544 | have a proper font, and return Qt if not. |
| 545 | |||
| 546 | If a font is found but is not yet opened, open it (if FACE is not | ||
| 547 | NULL) or return Qnil (if FACE is NULL). | ||
| 548 | |||
| 545 | ID is a charset-id that must be preferred, or -1 meaning no | 549 | ID is a charset-id that must be preferred, or -1 meaning no |
| 546 | preference. | 550 | preference. |
| 551 | |||
| 547 | If FALLBACK is nonzero, search only fallback fonts. */ | 552 | If FALLBACK is nonzero, search only fallback fonts. */ |
| 548 | 553 | ||
| 549 | static Lisp_Object | 554 | static Lisp_Object |
| @@ -574,26 +579,6 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 574 | { | 579 | { |
| 575 | elt = char_table_ref_and_range (base_fontset, c, &from, &to); | 580 | elt = char_table_ref_and_range (base_fontset, c, &from, &to); |
| 576 | range = Fcons (make_number (from), make_number (to)); | 581 | range = Fcons (make_number (from), make_number (to)); |
| 577 | if (EQ (base_fontset, Vdefault_fontset)) | ||
| 578 | { | ||
| 579 | Lisp_Object script = CHAR_TABLE_REF (Vchar_script_table, c); | ||
| 580 | |||
| 581 | if (! NILP (script)) | ||
| 582 | { | ||
| 583 | Lisp_Object font_spec = Ffont_spec (0, NULL); | ||
| 584 | Lisp_Object args[2], tmp; | ||
| 585 | |||
| 586 | ASET (font_spec, FONT_REGISTRY_INDEX, Qiso10646_1); | ||
| 587 | ASET (font_spec, FONT_EXTRA_INDEX, | ||
| 588 | Fcons (Fcons (QCscript, script), Qnil)); | ||
| 589 | args[0] = elt; | ||
| 590 | tmp = Fmake_vector (make_number (3), Qnil); | ||
| 591 | ASET (tmp, 0, font_spec); | ||
| 592 | ASET (tmp, 1, CHARSET_SYMBOL_ID (Qunicode_bmp)); | ||
| 593 | args[1] = Fvector (1, &tmp); | ||
| 594 | elt = Fvconcat (2, args); | ||
| 595 | } | ||
| 596 | } | ||
| 597 | } | 582 | } |
| 598 | else | 583 | else |
| 599 | { | 584 | { |
| @@ -601,8 +586,8 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 601 | } | 586 | } |
| 602 | if (NILP (elt)) | 587 | if (NILP (elt)) |
| 603 | { | 588 | { |
| 604 | /* Qt means we have no font for characters of this range. */ | 589 | /* 0 means we have no font for characters of this range. */ |
| 605 | vec = Qt; | 590 | vec = make_number (0); |
| 606 | } | 591 | } |
| 607 | else | 592 | else |
| 608 | { | 593 | { |
| @@ -626,8 +611,8 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 626 | else | 611 | else |
| 627 | FONTSET_FALLBACK (fontset) = vec; | 612 | FONTSET_FALLBACK (fontset) = vec; |
| 628 | } | 613 | } |
| 629 | if (EQ (vec, Qt)) | 614 | if (! VECTORP (vec)) |
| 630 | return Qnil; | 615 | return (INTEGERP (vec) ? Qnil : Qt); |
| 631 | 616 | ||
| 632 | if (ASIZE (vec) > 4 | 617 | if (ASIZE (vec) > 4 |
| 633 | && (XINT (AREF (vec, 0)) != charset_ordered_list_tick | 618 | && (XINT (AREF (vec, 0)) != charset_ordered_list_tick |
| @@ -660,66 +645,55 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 660 | #ifdef USE_FONT_BACKEND | 645 | #ifdef USE_FONT_BACKEND |
| 661 | if (enable_font_backend) | 646 | if (enable_font_backend) |
| 662 | { | 647 | { |
| 663 | /* ELT == [ FACE-ID FONT-INDEX FONT-DEF FONT-LIST ] | 648 | /* ELT == [ FACE-ID FONT-INDEX FONT-DEF FONT-ENTITY ] |
| 664 | where FONT-LIST is a list of font-entity or font-object. */ | 649 | where FONT-ENTITY turns to a font-object once opened. */ |
| 665 | Lisp_Object font_list = AREF (elt, 3), prev = Qnil; | 650 | Lisp_Object font_entity = AREF (elt, 3); |
| 666 | Lisp_Object font_object; | 651 | int has_char = 0; |
| 667 | int has_char; | 652 | |
| 668 | 653 | if (NILP (font_entity)) | |
| 669 | for (; CONSP (font_list); | ||
| 670 | prev = font_list, font_list = XCDR (font_list)) | ||
| 671 | { | ||
| 672 | font_object = XCAR (font_list); | ||
| 673 | if (! (FONT_ENTITY_P (font_object) | ||
| 674 | && FONT_ENTITY_NOT_LOADABLE (font_object)) | ||
| 675 | && (has_char = font_has_char (f, font_object, c)) != 0) | ||
| 676 | { | ||
| 677 | if (has_char < 0) | ||
| 678 | { | ||
| 679 | Lisp_Object obj = font_open_for_lface (f, font_object, | ||
| 680 | face->lface, Qnil); | ||
| 681 | if (NILP (obj)) | ||
| 682 | { | ||
| 683 | FONT_ENTITY_SET_NOT_LOADABLE (font_object); | ||
| 684 | continue; | ||
| 685 | } | ||
| 686 | font_object = obj; | ||
| 687 | XSETCAR (font_list, font_object); | ||
| 688 | if (! font_has_char (f, font_object, c)) | ||
| 689 | continue; | ||
| 690 | } | ||
| 691 | if (! NILP (prev)) | ||
| 692 | { | ||
| 693 | /* Move this element to the head. */ | ||
| 694 | XSETCDR (prev, XCDR (font_list)); | ||
| 695 | ASET (elt, 3, Fcons (XCAR (font_list), AREF (elt, 3))); | ||
| 696 | } | ||
| 697 | break; | ||
| 698 | } | ||
| 699 | } | ||
| 700 | if (NILP (font_list)) | ||
| 701 | { | 654 | { |
| 702 | Lisp_Object font_spec = AREF (font_def, 0); | 655 | Lisp_Object args[2]; |
| 703 | Lisp_Object font_entity; | 656 | int j; |
| 704 | 657 | ||
| 705 | font_entity = font_find_for_lface (f, face->lface, font_spec, c); | 658 | font_entity = font_find_for_lface (f, face->lface, |
| 659 | AREF (font_def, 0), c); | ||
| 706 | if (NILP (font_entity)) | 660 | if (NILP (font_entity)) |
| 707 | continue; | 661 | continue; |
| 708 | font_list = Fcons (font_entity, AREF (elt, 3)); | 662 | has_char = 1; |
| 709 | ASET (elt, 3, font_list); | 663 | /* Extend the vector and insert the new ELT here. */ |
| 664 | args[0] = vec; | ||
| 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); | ||
| 671 | ASET (vec, i, elt); | ||
| 672 | if (! has_char) | ||
| 673 | continue; | ||
| 674 | } | ||
| 675 | else if (FONT_ENTITY_P (font_entity)) | ||
| 676 | { | ||
| 677 | if (FONT_ENTITY_NOT_LOADABLE (font_entity)) | ||
| 678 | continue; | ||
| 679 | has_char = font_has_char (f, font_entity, c); | ||
| 680 | if (! has_char) | ||
| 681 | continue; | ||
| 710 | } | 682 | } |
| 711 | font_object = XCAR (font_list); | 683 | if (! FONT_OBJECT_P (font_entity)) |
| 712 | if (FONT_ENTITY_P (font_object)) | ||
| 713 | { | 684 | { |
| 714 | font_object = font_open_for_lface (f, font_object, | 685 | font_entity = font_open_for_lface (f, font_entity, |
| 715 | face->lface, Qnil); | 686 | face->lface, Qnil); |
| 716 | if (NILP (font_object)) | 687 | if (NILP (font_entity)) |
| 717 | { | 688 | { |
| 718 | FONT_ENTITY_SET_NOT_LOADABLE (XCAR (font_list)); | 689 | FONT_ENTITY_SET_NOT_LOADABLE (font_entity); |
| 719 | continue; | 690 | continue; |
| 720 | } | 691 | } |
| 721 | XSETCAR (font_list, font_object); | 692 | ASET (elt, 3, font_entity); |
| 722 | } | 693 | } |
| 694 | if (! has_char | ||
| 695 | && ! font_has_char (f, font_entity, c)) | ||
| 696 | continue; | ||
| 723 | ASET (elt, 1, make_number (0)); | 697 | ASET (elt, 1, make_number (0)); |
| 724 | } | 698 | } |
| 725 | else | 699 | else |
| @@ -784,11 +758,10 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 784 | font_info = (*get_font_info_func) (f, font_idx); | 758 | font_info = (*get_font_info_func) (f, font_idx); |
| 785 | ASET (elt, 3, build_string (font_info->full_name)); | 759 | ASET (elt, 3, build_string (font_info->full_name)); |
| 786 | } | 760 | } |
| 787 | |||
| 788 | /* Now we have the opened font. */ | ||
| 789 | return elt; | 761 | return elt; |
| 790 | } | 762 | } |
| 791 | return Qnil; | 763 | |
| 764 | return Qt; | ||
| 792 | } | 765 | } |
| 793 | 766 | ||
| 794 | 767 | ||
| @@ -805,7 +778,7 @@ fontset_font (fontset, c, face, id) | |||
| 805 | /* Try a font-group for C. */ | 778 | /* Try a font-group for C. */ |
| 806 | rfont_def = fontset_find_font (fontset, c, face, id, 0); | 779 | rfont_def = fontset_find_font (fontset, c, face, id, 0); |
| 807 | if (! NILP (rfont_def)) | 780 | if (! NILP (rfont_def)) |
| 808 | return rfont_def; | 781 | return (VECTORP (rfont_def) ? rfont_def : Qnil); |
| 809 | base_fontset = FONTSET_BASE (fontset); | 782 | base_fontset = FONTSET_BASE (fontset); |
| 810 | /* Try a font-group for C of the default fontset. */ | 783 | /* Try a font-group for C of the default fontset. */ |
| 811 | if (! EQ (base_fontset, Vdefault_fontset)) | 784 | if (! EQ (base_fontset, Vdefault_fontset)) |
| @@ -814,16 +787,21 @@ fontset_font (fontset, c, face, id) | |||
| 814 | FONTSET_DEFAULT (fontset) | 787 | FONTSET_DEFAULT (fontset) |
| 815 | = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset); | 788 | = make_fontset (FONTSET_FRAME (fontset), Qnil, Vdefault_fontset); |
| 816 | rfont_def = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0); | 789 | rfont_def = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 0); |
| 790 | if (! NILP (rfont_def)) | ||
| 791 | return (VECTORP (rfont_def) ? rfont_def : Qnil); | ||
| 817 | } | 792 | } |
| 818 | if (! NILP (rfont_def)) | 793 | |
| 819 | return rfont_def; | ||
| 820 | /* Try a fallback font-group. */ | 794 | /* Try a fallback font-group. */ |
| 821 | rfont_def = fontset_find_font (fontset, c, face, id, 1); | 795 | rfont_def = fontset_find_font (fontset, c, face, id, 1); |
| 822 | if (! NILP (rfont_def)) | 796 | if (! VECTORP (rfont_def) |
| 823 | return rfont_def; | 797 | && ! EQ (base_fontset, Vdefault_fontset)) |
| 824 | /* Try a fallback font-group of the default fontset . */ | 798 | /* Try a fallback font-group of the default fontset . */ |
| 825 | if (! EQ (base_fontset, Vdefault_fontset)) | ||
| 826 | rfont_def = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 1); | 799 | rfont_def = fontset_find_font (FONTSET_DEFAULT (fontset), c, face, id, 1); |
| 800 | |||
| 801 | if (! VECTORP (rfont_def)) | ||
| 802 | /* Remeber that we have no font for C. */ | ||
| 803 | FONTSET_SET (fontset, make_number (c), Qt); | ||
| 804 | |||
| 827 | return rfont_def; | 805 | return rfont_def; |
| 828 | } | 806 | } |
| 829 | 807 | ||
| @@ -1015,7 +993,7 @@ face_for_char (f, face, c, pos, object) | |||
| 1015 | if (enable_font_backend | 993 | if (enable_font_backend |
| 1016 | && NILP (AREF (rfont_def, 0))) | 994 | && NILP (AREF (rfont_def, 0))) |
| 1017 | { | 995 | { |
| 1018 | struct font *font = XSAVE_VALUE (XCAR (AREF (rfont_def, 3)))->pointer; | 996 | struct font *font = XSAVE_VALUE (AREF (rfont_def, 3))->pointer; |
| 1019 | 997 | ||
| 1020 | face_id = face_for_font (f, font, face); | 998 | face_id = face_for_font (f, font, face); |
| 1021 | ASET (rfont_def, 0, make_number (face_id)); | 999 | ASET (rfont_def, 0, make_number (face_id)); |
| @@ -1577,47 +1555,53 @@ appended. By default, FONT-SPEC overrides the previous settings. */) | |||
| 1577 | args[i++] = registry; | 1555 | args[i++] = registry; |
| 1578 | font_spec = Ffont_spec (i, args); | 1556 | font_spec = Ffont_spec (i, args); |
| 1579 | } | 1557 | } |
| 1580 | else | 1558 | else if (STRINGP (font_spec)) |
| 1581 | { | 1559 | { |
| 1582 | Lisp_Object args[2]; | 1560 | Lisp_Object args[2]; |
| 1583 | 1561 | ||
| 1584 | CHECK_STRING (font_spec); | ||
| 1585 | args[0] = QCname; | 1562 | args[0] = QCname; |
| 1586 | args[1] = font_spec; | 1563 | args[1] = font_spec; |
| 1587 | font_spec = Ffont_spec (2, args); | 1564 | font_spec = Ffont_spec (2, args); |
| 1588 | } | 1565 | } |
| 1566 | else if (! NILP (font_spec)) | ||
| 1567 | wrong_type_argument (intern ("font-spec"), font_spec); | ||
| 1589 | 1568 | ||
| 1590 | family = AREF (font_spec, FONT_FAMILY_INDEX); | 1569 | if (! NILP (font_spec)) |
| 1591 | if (! NILP (family) && SYMBOLP (family)) | ||
| 1592 | family = SYMBOL_NAME (family); | ||
| 1593 | registry = AREF (font_spec, FONT_REGISTRY_INDEX); | ||
| 1594 | if (! NILP (registry) && SYMBOLP (registry)) | ||
| 1595 | registry = SYMBOL_NAME (registry); | ||
| 1596 | |||
| 1597 | encoding = find_font_encoding (concat2 (family, registry)); | ||
| 1598 | if (NILP (encoding)) | ||
| 1599 | encoding = Qascii; | ||
| 1600 | |||
| 1601 | if (SYMBOLP (encoding)) | ||
| 1602 | { | 1570 | { |
| 1603 | CHECK_CHARSET (encoding); | 1571 | family = AREF (font_spec, FONT_FAMILY_INDEX); |
| 1604 | encoding = repertory = CHARSET_SYMBOL_ID (encoding); | 1572 | if (! NILP (family) && SYMBOLP (family)) |
| 1605 | } | 1573 | family = SYMBOL_NAME (family); |
| 1606 | else | 1574 | registry = AREF (font_spec, FONT_REGISTRY_INDEX); |
| 1607 | { | 1575 | if (! NILP (registry) && SYMBOLP (registry)) |
| 1608 | repertory = XCDR (encoding); | 1576 | registry = SYMBOL_NAME (registry); |
| 1609 | encoding = XCAR (encoding); | 1577 | |
| 1610 | CHECK_CHARSET (encoding); | 1578 | encoding = find_font_encoding (concat2 (family, registry)); |
| 1611 | encoding = CHARSET_SYMBOL_ID (encoding); | 1579 | if (NILP (encoding)) |
| 1612 | if (! NILP (repertory) && SYMBOLP (repertory)) | 1580 | encoding = Qascii; |
| 1581 | |||
| 1582 | if (SYMBOLP (encoding)) | ||
| 1583 | { | ||
| 1584 | CHECK_CHARSET (encoding); | ||
| 1585 | encoding = repertory = CHARSET_SYMBOL_ID (encoding); | ||
| 1586 | } | ||
| 1587 | else | ||
| 1613 | { | 1588 | { |
| 1614 | CHECK_CHARSET (repertory); | 1589 | repertory = XCDR (encoding); |
| 1615 | repertory = CHARSET_SYMBOL_ID (repertory); | 1590 | encoding = XCAR (encoding); |
| 1591 | CHECK_CHARSET (encoding); | ||
| 1592 | encoding = CHARSET_SYMBOL_ID (encoding); | ||
| 1593 | if (! NILP (repertory) && SYMBOLP (repertory)) | ||
| 1594 | { | ||
| 1595 | CHECK_CHARSET (repertory); | ||
| 1596 | repertory = CHARSET_SYMBOL_ID (repertory); | ||
| 1597 | } | ||
| 1616 | } | 1598 | } |
| 1599 | font_def = Fmake_vector (make_number (3), font_spec); | ||
| 1600 | ASET (font_def, 1, encoding); | ||
| 1601 | ASET (font_def, 2, repertory); | ||
| 1617 | } | 1602 | } |
| 1618 | font_def = Fmake_vector (make_number (3), font_spec); | 1603 | else |
| 1619 | ASET (font_def, 1, encoding); | 1604 | font_def = Qnil; |
| 1620 | ASET (font_def, 2, repertory); | ||
| 1621 | 1605 | ||
| 1622 | if (CHARACTERP (target)) | 1606 | if (CHARACTERP (target)) |
| 1623 | range_list = Fcons (Fcons (target, target), Qnil); | 1607 | range_list = Fcons (Fcons (target, target), Qnil); |
| @@ -2062,7 +2046,7 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, | |||
| 2062 | { | 2046 | { |
| 2063 | if (VECTORP (rfont_def) && ! NILP (AREF (rfont_def, 3))) | 2047 | if (VECTORP (rfont_def) && ! NILP (AREF (rfont_def, 3))) |
| 2064 | { | 2048 | { |
| 2065 | Lisp_Object font_object = XCAR (AREF (rfont_def, 3)); | 2049 | Lisp_Object font_object = AREF (rfont_def, 3); |
| 2066 | struct font *font = XSAVE_VALUE (font_object)->pointer; | 2050 | struct font *font = XSAVE_VALUE (font_object)->pointer; |
| 2067 | unsigned code = font->driver->encode_char (font, c); | 2051 | unsigned code = font->driver->encode_char (font, c); |
| 2068 | Lisp_Object fontname = font_get_name (font_object); | 2052 | Lisp_Object fontname = font_get_name (font_object); |