Mercurial > emacs
comparison src/xfaces.c @ 37724:3a5a6cd7ee9a
(try_alternative_families): First try the FAMILY.
And if nothing is found in the end, try again with scalable fonts.
(try_font_list): Let try_alternative_families do a bit more of
the work. Only use FAMILY if it is not nil.
(syms_of_xfaces) <scalable-fonts-allowed>: Fix docstring.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Mon, 14 May 2001 13:34:54 +0000 |
parents | 018b29727e8d |
children | d6f944b128c4 |
comparison
equal
deleted
inserted
replaced
37723:419538da0f94 | 37724:3a5a6cd7ee9a |
---|---|
5841 | 5841 |
5842 return font_name; | 5842 return font_name; |
5843 } | 5843 } |
5844 | 5844 |
5845 | 5845 |
5846 /* Get a list of matching fonts on frame F, considering alterntive | 5846 /* Get a list of matching fonts on frame F, considering FAMILY |
5847 font families from Vface_alternative_font_registry_alist. | 5847 and alternative font families from Vface_alternative_font_registry_alist. |
5848 | 5848 |
5849 FAMILY is the font family whose alternatives are considered. | 5849 FAMILY is the font family whose alternatives are considered. |
5850 | 5850 |
5851 REGISTRY, if a string, specifies a font registry and encoding to | 5851 REGISTRY, if a string, specifies a font registry and encoding to |
5852 match. A value of nil means include fonts of any registry and | 5852 match. A value of nil means include fonts of any registry and |
5862 struct font_name **fonts; | 5862 struct font_name **fonts; |
5863 { | 5863 { |
5864 Lisp_Object alter; | 5864 Lisp_Object alter; |
5865 int nfonts = 0; | 5865 int nfonts = 0; |
5866 | 5866 |
5867 /* Try alternative font families. */ | 5867 nfonts = font_list (f, Qnil, family, registry, fonts); |
5868 alter = Fassoc (family, Vface_alternative_font_family_alist); | 5868 if (nfonts == 0) |
5869 if (CONSP (alter)) | 5869 { |
5870 { | 5870 /* Try alternative font families. */ |
5871 for (alter = XCDR (alter); | 5871 alter = Fassoc (family, Vface_alternative_font_family_alist); |
5872 CONSP (alter) && nfonts == 0; | 5872 if (CONSP (alter)) |
5873 alter = XCDR (alter)) | |
5874 { | 5873 { |
5875 if (STRINGP (XCAR (alter))) | 5874 for (alter = XCDR (alter); |
5876 nfonts = font_list (f, Qnil, XCAR (alter), registry, fonts); | 5875 CONSP (alter) && nfonts == 0; |
5876 alter = XCDR (alter)) | |
5877 { | |
5878 if (STRINGP (XCAR (alter))) | |
5879 nfonts = font_list (f, Qnil, XCAR (alter), registry, fonts); | |
5880 } | |
5877 } | 5881 } |
5878 } | 5882 |
5879 | 5883 /* Try scalable fonts before giving up. */ |
5884 if (nfonts == 0 && NILP (Vscalable_fonts_allowed)) | |
5885 { | |
5886 int count = BINDING_STACK_SIZE (); | |
5887 specbind (Qscalable_fonts_allowed, Qt); | |
5888 nfonts = try_alternative_families (f, family, registry, fonts); | |
5889 unbind_to (count, Qnil); | |
5890 } | |
5891 } | |
5880 return nfonts; | 5892 return nfonts; |
5881 } | 5893 } |
5882 | 5894 |
5883 | 5895 |
5884 /* Get a list of matching fonts on frame F. | 5896 /* Get a list of matching fonts on frame F. |
5885 | 5897 |
5886 FAMILY, if a string, specifies a font family. If nil, use | 5898 FAMILY, if a string, specifies a font family derived from the fontset. |
5887 the family specified in Lisp face attributes ATTRS instead. | 5899 It is only used if the face does not specify any family in ATTRS or |
5900 if we cannot find any font of the face's family. | |
5888 | 5901 |
5889 REGISTRY, if a string, specifies a font registry and encoding to | 5902 REGISTRY, if a string, specifies a font registry and encoding to |
5890 match. A value of nil means include fonts of any registry and | 5903 match. A value of nil means include fonts of any registry and |
5891 encoding. | 5904 encoding. |
5892 | 5905 |
5899 Lisp_Object *attrs; | 5912 Lisp_Object *attrs; |
5900 Lisp_Object family, registry; | 5913 Lisp_Object family, registry; |
5901 struct font_name **fonts; | 5914 struct font_name **fonts; |
5902 { | 5915 { |
5903 int nfonts = 0; | 5916 int nfonts = 0; |
5904 | 5917 Lisp_Object face_family = attrs[LFACE_FAMILY_INDEX]; |
5905 if (STRINGP (attrs[LFACE_FAMILY_INDEX])) | 5918 |
5906 { | 5919 if (STRINGP (face_family)) |
5907 Lisp_Object face_family; | 5920 nfonts = try_alternative_families (f, face_family, registry, fonts); |
5908 face_family = attrs[LFACE_FAMILY_INDEX]; | 5921 |
5909 nfonts = font_list (f, Qnil, face_family, registry, fonts); | 5922 if (nfonts == 0 && !NILP (family)) |
5910 if (nfonts == 0) | 5923 nfonts = try_alternative_families (f, family, registry, fonts); |
5911 nfonts = try_alternative_families (f, face_family, registry, fonts); | 5924 |
5912 } | 5925 /* Try font family of the default face or "fixed". */ |
5913 | |
5914 if (nfonts == 0) | 5926 if (nfonts == 0) |
5915 { | 5927 { |
5928 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
5929 if (default_face) | |
5930 family = default_face->lface[LFACE_FAMILY_INDEX]; | |
5931 else | |
5932 family = build_string ("fixed"); | |
5916 nfonts = font_list (f, Qnil, family, registry, fonts); | 5933 nfonts = font_list (f, Qnil, family, registry, fonts); |
5917 if (nfonts == 0 && !NILP (family)) | 5934 } |
5918 { | 5935 |
5919 nfonts = try_alternative_families (f, family, registry, fonts); | 5936 /* Try any family with the given registry. */ |
5920 | 5937 if (nfonts == 0) |
5921 /* Try font family of the default face or "fixed". */ | 5938 nfonts = font_list (f, Qnil, Qnil, registry, fonts); |
5922 if (nfonts == 0) | |
5923 { | |
5924 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
5925 if (default_face) | |
5926 family = default_face->lface[LFACE_FAMILY_INDEX]; | |
5927 else | |
5928 family = build_string ("fixed"); | |
5929 nfonts = font_list (f, Qnil, family, registry, fonts); | |
5930 } | |
5931 | |
5932 /* Try any family with the given registry. */ | |
5933 if (nfonts == 0) | |
5934 nfonts = font_list (f, Qnil, Qnil, registry, fonts); | |
5935 } | |
5936 } | |
5937 | 5939 |
5938 return nfonts; | 5940 return nfonts; |
5939 } | 5941 } |
5940 | 5942 |
5941 | 5943 |
7198 DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed, | 7200 DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed, |
7199 "Allowed scalable fonts.\n\ | 7201 "Allowed scalable fonts.\n\ |
7200 A value of nil means don't allow any scalable fonts.\n\ | 7202 A value of nil means don't allow any scalable fonts.\n\ |
7201 A value of t means allow any scalable font.\n\ | 7203 A value of t means allow any scalable font.\n\ |
7202 Otherwise, value must be a list of regular expressions. A font may be\n\ | 7204 Otherwise, value must be a list of regular expressions. A font may be\n\ |
7203 scaled if its name matches a regular expression in the list."); | 7205 scaled if its name matches a regular expression in the list.\n\ |
7204 Vscalable_fonts_allowed = Qt; | 7206 Note that if value is nil, a scalable font might still be used, if no\n\ |
7207 other font of the appropriate family and registry is available."); | |
7208 Vscalable_fonts_allowed = Qnil; | |
7205 | 7209 |
7206 DEFVAR_LISP ("face-ignored-fonts", &Vface_ignored_fonts, | 7210 DEFVAR_LISP ("face-ignored-fonts", &Vface_ignored_fonts, |
7207 "List of ignored fonts.\n\ | 7211 "List of ignored fonts.\n\ |
7208 Each element is a regular expression that matches names of fonts to ignore."); | 7212 Each element is a regular expression that matches names of fonts to ignore."); |
7209 Vface_ignored_fonts = Qnil; | 7213 Vface_ignored_fonts = Qnil; |