diff options
| author | Kenichi Handa | 2007-12-01 02:39:01 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2007-12-01 02:39:01 +0000 |
| commit | 8b67c40a93d42716b912bd716903ef9991a15072 (patch) | |
| tree | 8bfd40baffbaf69bfaeb6d3c5e596e8145d25f62 /src | |
| parent | 1701724c31e96a930fa6f1de03f9f2f858826641 (diff) | |
| download | emacs-8b67c40a93d42716b912bd716903ef9991a15072.tar.gz emacs-8b67c40a93d42716b912bd716903ef9991a15072.zip | |
(fontset_find_font) [USE_FONT_BACKEND]: Try multiple
fonts of the same font-spec. Change the format of RFONT-DEF.
(face_for_char): Adjusted for the change of RFONT-DEF.
(make_fontset_for_ascii_face): Likewise.
(Finternal_char_font): Likewise.
(Fset_fontset_font) [USE_FONT_BACKEND]: Handle new format of
font-spec.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fontset.c | 142 |
1 files changed, 90 insertions, 52 deletions
diff --git a/src/fontset.c b/src/fontset.c index 045e632778e..58b5ee621d0 100644 --- a/src/fontset.c +++ b/src/fontset.c | |||
| @@ -681,14 +681,48 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 681 | #ifdef USE_FONT_BACKEND | 681 | #ifdef USE_FONT_BACKEND |
| 682 | if (enable_font_backend) | 682 | if (enable_font_backend) |
| 683 | { | 683 | { |
| 684 | /* ELT == [ FACE-ID FONT-INDEX FONT-DEF FONT-ENTITY FONT-OBJECT ] */ | 684 | /* ELT == [ FACE-ID FONT-INDEX FONT-DEF FONT-LIST ] |
| 685 | Lisp_Object font_entity = AREF (elt, 3); | 685 | where FONT-LIST is a list of font-entity or font-object. */ |
| 686 | Lisp_Object font_object = AREF (elt, 4); | 686 | Lisp_Object font_list = AREF (elt, 3), prev = Qnil; |
| 687 | Lisp_Object font_spec = AREF (font_def, 0); | 687 | Lisp_Object font_object; |
| 688 | int has_char; | 688 | int has_char; |
| 689 | 689 | ||
| 690 | if (NILP (font_entity)) | 690 | for (; CONSP (font_list); |
| 691 | prev = font_list, font_list = XCDR (font_list)) | ||
| 691 | { | 692 | { |
| 693 | font_object = XCAR (font_list); | ||
| 694 | if (! (FONT_ENTITY_P (font_object) | ||
| 695 | && FONT_ENTITY_NOT_LOADABLE (font_object)) | ||
| 696 | && (has_char = font_has_char (f, font_object, c)) != 0) | ||
| 697 | { | ||
| 698 | if (has_char < 0) | ||
| 699 | { | ||
| 700 | Lisp_Object obj = font_open_for_lface (f, font_object, | ||
| 701 | face->lface, Qnil); | ||
| 702 | if (NILP (obj)) | ||
| 703 | { | ||
| 704 | FONT_ENTITY_SET_NOT_LOADABLE (font_object); | ||
| 705 | continue; | ||
| 706 | } | ||
| 707 | font_object = obj; | ||
| 708 | XSETCAR (font_list, font_object); | ||
| 709 | if (! font_has_char (f, font_object, c)) | ||
| 710 | continue; | ||
| 711 | } | ||
| 712 | if (! NILP (prev)) | ||
| 713 | { | ||
| 714 | /* Move this element to the head. */ | ||
| 715 | XSETCDR (prev, XCDR (font_list)); | ||
| 716 | ASET (elt, 3, Fcons (XCAR (font_list), AREF (elt, 3))); | ||
| 717 | } | ||
| 718 | break; | ||
| 719 | } | ||
| 720 | } | ||
| 721 | if (NILP (font_list)) | ||
| 722 | { | ||
| 723 | Lisp_Object font_spec = AREF (font_def, 0); | ||
| 724 | Lisp_Object font_entity; | ||
| 725 | |||
| 692 | if (! FONT_SPEC_P (font_spec)) | 726 | if (! FONT_SPEC_P (font_spec)) |
| 693 | { | 727 | { |
| 694 | /* FONT_SPEC is FONT-NAME or (FAMILY . REGISTRY). */ | 728 | /* FONT_SPEC is FONT-NAME or (FAMILY . REGISTRY). */ |
| @@ -705,34 +739,25 @@ fontset_find_font (fontset, c, face, id, fallback) | |||
| 705 | } | 739 | } |
| 706 | ASET (font_def, 0, font_spec); | 740 | ASET (font_def, 0, font_spec); |
| 707 | } | 741 | } |
| 708 | font_entity = font_find_for_lface (f, face->lface, font_spec); | 742 | font_entity = font_find_for_lface (f, face->lface, font_spec, c); |
| 709 | ASET (elt, 3, font_entity); | ||
| 710 | if (NILP (font_entity)) | 743 | if (NILP (font_entity)) |
| 711 | { | 744 | continue; |
| 712 | ASET (elt, 1, make_number (-1)); | 745 | font_list = Fcons (font_entity, AREF (elt, 3)); |
| 713 | continue; | 746 | ASET (elt, 3, font_list); |
| 714 | } | ||
| 715 | font_object = Qnil; | ||
| 716 | } | 747 | } |
| 717 | has_char = font_has_char (f, font_entity, c); | 748 | font_object = XCAR (font_list); |
| 718 | if (has_char == 0) | 749 | if (FONT_ENTITY_P (font_object)) |
| 719 | continue; | ||
| 720 | if (NILP (font_object)) | ||
| 721 | { | 750 | { |
| 722 | font_object = font_open_for_lface (f, font_entity, | 751 | font_object = font_open_for_lface (f, font_object, |
| 723 | face->lface, font_spec); | 752 | face->lface, Qnil); |
| 724 | ASET (elt, 4, font_object); | ||
| 725 | if (NILP (font_object)) | 753 | if (NILP (font_object)) |
| 726 | { | 754 | { |
| 727 | ASET (elt, 1, make_number (-1)); | 755 | FONT_ENTITY_SET_NOT_LOADABLE (XCAR (font_list)); |
| 728 | continue; | 756 | continue; |
| 729 | } | 757 | } |
| 758 | XSETCAR (font_list, font_object); | ||
| 730 | } | 759 | } |
| 731 | ASET (elt, 1, make_number (0)); | 760 | ASET (elt, 1, make_number (0)); |
| 732 | ASET (elt, 4, font_object); | ||
| 733 | if (has_char < 0 | ||
| 734 | && font_encode_char (font_object, c) == FONT_INVALID_CODE) | ||
| 735 | continue; | ||
| 736 | } | 761 | } |
| 737 | else | 762 | else |
| 738 | #endif /* USE_FONT_BACKEND */ | 763 | #endif /* USE_FONT_BACKEND */ |
| @@ -1020,7 +1045,7 @@ face_for_char (f, face, c, pos, object) | |||
| 1020 | if (enable_font_backend | 1045 | if (enable_font_backend |
| 1021 | && NILP (AREF (rfont_def, 0))) | 1046 | && NILP (AREF (rfont_def, 0))) |
| 1022 | { | 1047 | { |
| 1023 | struct font *font = XSAVE_VALUE (AREF (rfont_def, 4))->pointer; | 1048 | struct font *font = XSAVE_VALUE (XCAR (AREF (rfont_def, 3)))->pointer; |
| 1024 | 1049 | ||
| 1025 | face_id = face_for_font (f, font, face); | 1050 | face_id = face_for_font (f, font, face); |
| 1026 | ASET (rfont_def, 0, make_number (face_id)); | 1051 | ASET (rfont_def, 0, make_number (face_id)); |
| @@ -1079,19 +1104,17 @@ make_fontset_for_ascii_face (f, base_fontset_id, face) | |||
| 1079 | 1104 | ||
| 1080 | elt = FONTSET_REF (base_fontset, 0); | 1105 | elt = FONTSET_REF (base_fontset, 0); |
| 1081 | xassert (VECTORP (elt) && ASIZE (elt) > 0); | 1106 | xassert (VECTORP (elt) && ASIZE (elt) > 0); |
| 1107 | rfont_def = Fmake_vector (make_number (4), Qnil); | ||
| 1082 | #ifdef USE_FONT_BACKEND | 1108 | #ifdef USE_FONT_BACKEND |
| 1083 | rfont_def = Fmake_vector (make_number (5), Qnil); | ||
| 1084 | if (enable_font_backend && face->font_info) | 1109 | if (enable_font_backend && face->font_info) |
| 1085 | { | 1110 | { |
| 1086 | struct font *font = (struct font *) face->font_info; | 1111 | struct font *font = (struct font *) face->font_info; |
| 1087 | 1112 | ||
| 1088 | ASET (rfont_def, 3, font->entity); | 1113 | ASET (rfont_def, 3, Fcons (font->entity, Qnil)); |
| 1089 | ASET (rfont_def, 4, font_find_object (font)); | ||
| 1090 | } | 1114 | } |
| 1091 | else | 1115 | else |
| 1092 | #endif /* USE_FONT_BACKEND */ | 1116 | #endif /* USE_FONT_BACKEND */ |
| 1093 | { | 1117 | { |
| 1094 | rfont_def = Fmake_vector (make_number (4), Qnil); | ||
| 1095 | ASET (rfont_def, 3, build_string (face->font_name)); | 1118 | ASET (rfont_def, 3, build_string (face->font_name)); |
| 1096 | } | 1119 | } |
| 1097 | ASET (rfont_def, 1, make_number (face->font_info_id)); | 1120 | ASET (rfont_def, 1, make_number (face->font_info_id)); |
| @@ -1544,6 +1567,7 @@ set_fontset_font (fontset, range) | |||
| 1544 | FONTSET_ADD (fontset, range, font_def_arg, add_arg); | 1567 | FONTSET_ADD (fontset, range, font_def_arg, add_arg); |
| 1545 | } | 1568 | } |
| 1546 | 1569 | ||
| 1570 | extern Lisp_Object QCfamily, QCregistry; | ||
| 1547 | 1571 | ||
| 1548 | DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 5, 0, | 1572 | DEFUN ("set-fontset-font", Fset_fontset_font, Sset_fontset_font, 3, 5, 0, |
| 1549 | doc: /* | 1573 | doc: /* |
| @@ -1593,27 +1617,41 @@ appended. By default, FONT-SPEC overrides the previous settings. */) | |||
| 1593 | 1617 | ||
| 1594 | if (VECTORP (font_spec)) | 1618 | if (VECTORP (font_spec)) |
| 1595 | { | 1619 | { |
| 1596 | /* FONT_SPEC should have this form: | 1620 | #ifdef USE_FONT_BACKEND |
| 1597 | [ FAMILY WEIGHT SLANT WIDTH ADSTYLE REGISTRY ] | 1621 | if (enable_font_backend && FONT_SPEC_P (font_spec)) |
| 1598 | This is a feature not yet documented because WEIGHT thru | 1622 | { |
| 1599 | ADSTYLE are ignored for the moment. */ | 1623 | family = Ffont_get (font_spec, QCfamily); |
| 1600 | int j; | 1624 | if (! NILP (family)) |
| 1601 | 1625 | family = SYMBOL_NAME (family); | |
| 1602 | if (ASIZE (font_spec) != FONT_SPEC_MAX_INDEX) | 1626 | registry = Ffont_get (font_spec, QCregistry); |
| 1603 | args_out_of_range (make_number (FONT_SPEC_MAX_INDEX), | 1627 | if (! NILP (registry)) |
| 1604 | make_number (ASIZE (font_spec))); | 1628 | registry = SYMBOL_NAME (registry); |
| 1605 | 1629 | } | |
| 1606 | font_spec = Fcopy_sequence (font_spec); | 1630 | else |
| 1607 | for (j = 0; j < FONT_SPEC_MAX_INDEX - 1; j++) | 1631 | #endif |
| 1608 | if (! NILP (AREF (font_spec, j))) | 1632 | { |
| 1609 | { | 1633 | /* FONT_SPEC should have this form: |
| 1610 | CHECK_STRING (AREF (font_spec, j)); | 1634 | [ FAMILY WEIGHT SLANT WIDTH ADSTYLE REGISTRY ] |
| 1611 | ASET (font_spec, j, Fdowncase (AREF (font_spec, j))); | 1635 | This is a feature not yet documented because WEIGHT thru |
| 1612 | } | 1636 | ADSTYLE are ignored for the moment. */ |
| 1613 | family = AREF (font_spec, FONT_SPEC_FAMILY_INDEX); | 1637 | int j; |
| 1614 | /* REGISTRY should not be omitted. */ | 1638 | |
| 1615 | CHECK_STRING (AREF (font_spec, FONT_SPEC_REGISTRY_INDEX)); | 1639 | if (ASIZE (font_spec) != FONT_SPEC_MAX_INDEX) |
| 1616 | registry = AREF (font_spec, FONT_SPEC_REGISTRY_INDEX); | 1640 | args_out_of_range (make_number (FONT_SPEC_MAX_INDEX), |
| 1641 | make_number (ASIZE (font_spec))); | ||
| 1642 | |||
| 1643 | font_spec = Fcopy_sequence (font_spec); | ||
| 1644 | for (j = 0; j < FONT_SPEC_MAX_INDEX - 1; j++) | ||
| 1645 | if (! NILP (AREF (font_spec, j))) | ||
| 1646 | { | ||
| 1647 | CHECK_STRING (AREF (font_spec, j)); | ||
| 1648 | ASET (font_spec, j, Fdowncase (AREF (font_spec, j))); | ||
| 1649 | } | ||
| 1650 | family = AREF (font_spec, FONT_SPEC_FAMILY_INDEX); | ||
| 1651 | /* REGISTRY should not be omitted. */ | ||
| 1652 | CHECK_STRING (AREF (font_spec, FONT_SPEC_REGISTRY_INDEX)); | ||
| 1653 | registry = AREF (font_spec, FONT_SPEC_REGISTRY_INDEX); | ||
| 1654 | } | ||
| 1617 | } | 1655 | } |
| 1618 | else if (CONSP (font_spec)) | 1656 | else if (CONSP (font_spec)) |
| 1619 | { | 1657 | { |
| @@ -2104,9 +2142,9 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0, | |||
| 2104 | #ifdef USE_FONT_BACKEND | 2142 | #ifdef USE_FONT_BACKEND |
| 2105 | if (enable_font_backend) | 2143 | if (enable_font_backend) |
| 2106 | { | 2144 | { |
| 2107 | if (VECTORP (rfont_def) && ! NILP (AREF (rfont_def, 4))) | 2145 | if (VECTORP (rfont_def) && ! NILP (AREF (rfont_def, 3))) |
| 2108 | { | 2146 | { |
| 2109 | Lisp_Object font_object = AREF (rfont_def, 4); | 2147 | Lisp_Object font_object = XCAR (AREF (rfont_def, 3)); |
| 2110 | struct font *font = XSAVE_VALUE (font_object)->pointer; | 2148 | struct font *font = XSAVE_VALUE (font_object)->pointer; |
| 2111 | unsigned code = font->driver->encode_char (font, c); | 2149 | unsigned code = font->driver->encode_char (font, c); |
| 2112 | Lisp_Object fontname = font_get_name (font_object); | 2150 | Lisp_Object fontname = font_get_name (font_object); |