diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/xfaces.c | 104 |
1 files changed, 68 insertions, 36 deletions
diff --git a/src/xfaces.c b/src/xfaces.c index 8433460b47f..65cea12d2e5 100644 --- a/src/xfaces.c +++ b/src/xfaces.c | |||
| @@ -532,6 +532,8 @@ static int font_list P_ ((struct frame *, Lisp_Object, Lisp_Object, | |||
| 532 | Lisp_Object, struct font_name **)); | 532 | Lisp_Object, struct font_name **)); |
| 533 | static int try_font_list P_ ((struct frame *, Lisp_Object *, | 533 | static int try_font_list P_ ((struct frame *, Lisp_Object *, |
| 534 | Lisp_Object, Lisp_Object, struct font_name **)); | 534 | Lisp_Object, Lisp_Object, struct font_name **)); |
| 535 | static int try_alternative_families P_ ((struct frame *f, Lisp_Object, | ||
| 536 | Lisp_Object, struct font_name **)); | ||
| 535 | static int cmp_font_names P_ ((const void *, const void *)); | 537 | static int cmp_font_names P_ ((const void *, const void *)); |
| 536 | static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int, | 538 | static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int, |
| 537 | struct face *, int)); | 539 | struct face *, int)); |
| @@ -5786,6 +5788,44 @@ best_matching_font (f, attrs, fonts, nfonts, width_ratio) | |||
| 5786 | } | 5788 | } |
| 5787 | 5789 | ||
| 5788 | 5790 | ||
| 5791 | /* Get a list of matching fonts on frame F, considering alterntive | ||
| 5792 | font families from Vface_alternative_font_registry_alist. | ||
| 5793 | |||
| 5794 | FAMILY is the font family whose alternatives are considered. | ||
| 5795 | |||
| 5796 | REGISTRY, if a string, specifies a font registry and encoding to | ||
| 5797 | match. A value of nil means include fonts of any registry and | ||
| 5798 | encoding. | ||
| 5799 | |||
| 5800 | Return in *FONTS a pointer to a vector of font_name structures for | ||
| 5801 | the fonts matched. Value is the number of fonts found. */ | ||
| 5802 | |||
| 5803 | static int | ||
| 5804 | try_alternative_families (f, family, registry, fonts) | ||
| 5805 | struct frame *f; | ||
| 5806 | Lisp_Object family, registry; | ||
| 5807 | struct font_name **fonts; | ||
| 5808 | { | ||
| 5809 | Lisp_Object alter; | ||
| 5810 | int nfonts = 0; | ||
| 5811 | |||
| 5812 | /* Try alternative font families. */ | ||
| 5813 | alter = Fassoc (family, Vface_alternative_font_family_alist); | ||
| 5814 | if (CONSP (alter)) | ||
| 5815 | { | ||
| 5816 | for (alter = XCDR (alter); | ||
| 5817 | CONSP (alter) && nfonts == 0; | ||
| 5818 | alter = XCDR (alter)) | ||
| 5819 | { | ||
| 5820 | if (STRINGP (XCAR (alter))) | ||
| 5821 | nfonts = font_list (f, Qnil, XCAR (alter), registry, fonts); | ||
| 5822 | } | ||
| 5823 | } | ||
| 5824 | |||
| 5825 | return nfonts; | ||
| 5826 | } | ||
| 5827 | |||
| 5828 | |||
| 5789 | /* Get a list of matching fonts on frame F. | 5829 | /* Get a list of matching fonts on frame F. |
| 5790 | 5830 | ||
| 5791 | FAMILY, if a string, specifies a font family. If nil, use | 5831 | FAMILY, if a string, specifies a font family. If nil, use |
| @@ -5805,41 +5845,39 @@ try_font_list (f, attrs, family, registry, fonts) | |||
| 5805 | Lisp_Object family, registry; | 5845 | Lisp_Object family, registry; |
| 5806 | struct font_name **fonts; | 5846 | struct font_name **fonts; |
| 5807 | { | 5847 | { |
| 5808 | int nfonts; | 5848 | int nfonts = 0; |
| 5809 | 5849 | ||
| 5810 | if (NILP (family) && STRINGP (attrs[LFACE_FAMILY_INDEX])) | 5850 | if (STRINGP (attrs[LFACE_FAMILY_INDEX])) |
| 5811 | family = attrs[LFACE_FAMILY_INDEX]; | 5851 | { |
| 5852 | Lisp_Object face_family; | ||
| 5853 | face_family = attrs[LFACE_FAMILY_INDEX]; | ||
| 5854 | nfonts = font_list (f, Qnil, face_family, registry, fonts); | ||
| 5855 | if (nfonts == 0) | ||
| 5856 | nfonts = try_alternative_families (f, face_family, registry, fonts); | ||
| 5857 | } | ||
| 5812 | 5858 | ||
| 5813 | nfonts = font_list (f, Qnil, family, registry, fonts); | 5859 | if (nfonts == 0) |
| 5814 | if (nfonts == 0 && !NILP (family)) | ||
| 5815 | { | 5860 | { |
| 5816 | Lisp_Object alter; | 5861 | nfonts = font_list (f, Qnil, family, registry, fonts); |
| 5862 | if (nfonts == 0 && !NILP (family)) | ||
| 5863 | { | ||
| 5864 | nfonts = try_alternative_families (f, family, registry, fonts); | ||
| 5817 | 5865 | ||
| 5818 | /* Try alternative font families. */ | 5866 | /* Try font family of the default face or "fixed". */ |
| 5819 | alter = Fassoc (family, Vface_alternative_font_family_alist); | 5867 | if (nfonts == 0) |
| 5820 | if (CONSP (alter)) | 5868 | { |
| 5821 | for (alter = XCDR (alter); | 5869 | struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
| 5822 | CONSP (alter) && nfonts == 0; | 5870 | if (default_face) |
| 5823 | alter = XCDR (alter)) | 5871 | family = default_face->lface[LFACE_FAMILY_INDEX]; |
| 5824 | { | 5872 | else |
| 5825 | if (STRINGP (XCAR (alter))) | 5873 | family = build_string ("fixed"); |
| 5826 | nfonts = font_list (f, Qnil, XCAR (alter), registry, fonts); | 5874 | nfonts = font_list (f, Qnil, family, registry, fonts); |
| 5827 | } | 5875 | } |
| 5828 | 5876 | ||
| 5829 | /* Try font family of the default face or "fixed". */ | 5877 | /* Try any family with the given registry. */ |
| 5830 | if (nfonts == 0) | 5878 | if (nfonts == 0) |
| 5831 | { | 5879 | nfonts = font_list (f, Qnil, Qnil, registry, fonts); |
| 5832 | struct face *dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID); | ||
| 5833 | if (dflt) | ||
| 5834 | family = dflt->lface[LFACE_FAMILY_INDEX]; | ||
| 5835 | else | ||
| 5836 | family = build_string ("fixed"); | ||
| 5837 | nfonts = font_list (f, Qnil, family, registry, fonts); | ||
| 5838 | } | 5880 | } |
| 5839 | |||
| 5840 | /* Try any family with the given registry. */ | ||
| 5841 | if (nfonts == 0) | ||
| 5842 | nfonts = font_list (f, Qnil, Qnil, registry, fonts); | ||
| 5843 | } | 5881 | } |
| 5844 | 5882 | ||
| 5845 | return nfonts; | 5883 | return nfonts; |
| @@ -5891,17 +5929,11 @@ choose_face_font (f, attrs, fontset, c) | |||
| 5891 | xassert (!SINGLE_BYTE_CHAR_P (c)); | 5929 | xassert (!SINGLE_BYTE_CHAR_P (c)); |
| 5892 | return NULL; | 5930 | return NULL; |
| 5893 | } | 5931 | } |
| 5932 | |||
| 5894 | /* If what we got is a name pattern, return it. */ | 5933 | /* If what we got is a name pattern, return it. */ |
| 5895 | if (STRINGP (pattern)) | 5934 | if (STRINGP (pattern)) |
| 5896 | return xstrdup (XSTRING (pattern)->data); | 5935 | return xstrdup (XSTRING (pattern)->data); |
| 5897 | 5936 | ||
| 5898 | /* Family name may be specified both in ATTRS and car part of | ||
| 5899 | PATTERN. The former has higher priority if C is a single byte | ||
| 5900 | character. */ | ||
| 5901 | if (STRINGP (attrs[LFACE_FAMILY_INDEX]) | ||
| 5902 | && SINGLE_BYTE_CHAR_P (c)) | ||
| 5903 | XCAR (pattern) = Qnil; | ||
| 5904 | |||
| 5905 | /* Get a list of fonts matching that pattern and choose the | 5937 | /* Get a list of fonts matching that pattern and choose the |
| 5906 | best match for the specified face attributes from it. */ | 5938 | best match for the specified face attributes from it. */ |
| 5907 | nfonts = try_font_list (f, attrs, XCAR (pattern), XCDR (pattern), &fonts); | 5939 | nfonts = try_font_list (f, attrs, XCAR (pattern), XCDR (pattern), &fonts); |