comparison src/xfaces.c @ 89047:3b6234eb229c

(QCfontset): New variable. (LFACE_FONTSET): New macro. (check_lface_attrs): Check also LFACE_FONTSET_INDEX. (set_lface_from_font_name): Setup LFACE_FONTSET (lface). (Finternal_set_lisp_face_attribute): Handle QCfontset. (Finternal_get_lisp_face_attribute): Likewise. (lface_same_font_attributes_p): Fix checking of LFACE_FONT_INDEX, check also LFACE_FONTSET_INDEX. (face_fontset): Check attrs[LFACE_FONTSET_INDEX], not attrs[LFACE_FONT_INDEX]. (syms_of_xfaces): Intern and staticpro QCfontset.
author Kenichi Handa <handa@m17n.org>
date Fri, 23 Aug 2002 02:26:44 +0000
parents 13e20ef7c935
children 81d88ca705db
comparison
equal deleted inserted replaced
89046:7a6ebd6b0c38 89047:3b6234eb229c
54 color. 54 color.
55 55
56 13. Whether or not a box should be drawn around characters, the box 56 13. Whether or not a box should be drawn around characters, the box
57 type, and, for simple boxes, in what color. 57 type, and, for simple boxes, in what color.
58 58
59 14. Font or fontset pattern, or nil. This is a special attribute. 59 14. Font pattern, or nil. This is a special attribute.
60 When this attribute is specified, the face uses a font opened by 60 When this attribute is specified, the face uses a font opened by
61 that pattern as is. In addition, all the other font-related 61 that pattern as is. In addition, all the other font-related
62 attributes (1st thru 5th) are generated from the opened font name. 62 attributes (1st thru 5th) are generated from the opened font name.
63 On the other hand, if one of the other font-related attributes are 63 On the other hand, if one of the other font-related attributes are
64 specified, this attribute is set to nil. In that case, the face 64 specified, this attribute is set to nil. In that case, the face
70 70
71 16. A specified average font width, which is invisible from Lisp, 71 16. A specified average font width, which is invisible from Lisp,
72 and is used to ensure that a font specified on the command line, 72 and is used to ensure that a font specified on the command line,
73 for example, can be matched exactly. 73 for example, can be matched exactly.
74 74
75 17. A fontset name.
76
75 Faces are frame-local by nature because Emacs allows to define the 77 Faces are frame-local by nature because Emacs allows to define the
76 same named face (face names are symbols) differently for different 78 same named face (face names are symbols) differently for different
77 frames. Each frame has an alist of face definitions for all named 79 frames. Each frame has an alist of face definitions for all named
78 faces. The value of a named face in such an alist is a Lisp vector 80 faces. The value of a named face in such an alist is a Lisp vector
79 with the symbol `face' in slot 0, and a slot for each of the face 81 with the symbol `face' in slot 0, and a slot for each of the face
121 time, assigned a specific realized fontset. Hereafter, we call 123 time, assigned a specific realized fontset. Hereafter, we call
122 such a face as `ASCII face'. When a face for a multibyte character 124 such a face as `ASCII face'. When a face for a multibyte character
123 is realized, it inherits (thus shares) a fontset of an ASCII face 125 is realized, it inherits (thus shares) a fontset of an ASCII face
124 that has the same attributes other than font-related ones. 126 that has the same attributes other than font-related ones.
125 127
126 Thus, all realized face have a realized fontset. 128 Thus, all realized faces have a realized fontset.
127 129
128 130
129 Unibyte text. 131 Unibyte text.
130 132
131 Unibyte text (i.e. raw 8-bit characters) is displayed with the same 133 Unibyte text (i.e. raw 8-bit characters) is displayed with the same
339 Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline; 341 Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline;
340 Lisp_Object QCinverse_video, QCforeground, QCbackground, QCstipple; 342 Lisp_Object QCinverse_video, QCforeground, QCbackground, QCstipple;
341 Lisp_Object QCwidth, QCfont, QCbold, QCitalic; 343 Lisp_Object QCwidth, QCfont, QCbold, QCitalic;
342 Lisp_Object QCreverse_video; 344 Lisp_Object QCreverse_video;
343 Lisp_Object QCoverline, QCstrike_through, QCbox, QCinherit; 345 Lisp_Object QCoverline, QCstrike_through, QCbox, QCinherit;
346 Lisp_Object QCfontset;
344 347
345 /* Symbols used for attribute values. */ 348 /* Symbols used for attribute values. */
346 349
347 Lisp_Object Qnormal, Qbold, Qultra_light, Qextra_light, Qlight; 350 Lisp_Object Qnormal, Qbold, Qultra_light, Qextra_light, Qlight;
348 Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold; 351 Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold;
1250 ***********************************************************************/ 1253 ***********************************************************************/
1251 1254
1252 #ifdef HAVE_WINDOW_SYSTEM 1255 #ifdef HAVE_WINDOW_SYSTEM
1253 1256
1254 /* Load font of face FACE which is used on frame F to display ASCII 1257 /* Load font of face FACE which is used on frame F to display ASCII
1255 characters. The name of the font to load is determined by lface 1258 characters. The name of the font to load is determined by lface. */
1256 and fontset of FACE. */
1257 1259
1258 static void 1260 static void
1259 load_face_font (f, face) 1261 load_face_font (f, face)
1260 struct frame *f; 1262 struct frame *f;
1261 struct face *face; 1263 struct face *face;
2983 #define LFACE_STRIKE_THROUGH(LFACE) AREF ((LFACE), LFACE_STRIKE_THROUGH_INDEX) 2985 #define LFACE_STRIKE_THROUGH(LFACE) AREF ((LFACE), LFACE_STRIKE_THROUGH_INDEX)
2984 #define LFACE_BOX(LFACE) AREF ((LFACE), LFACE_BOX_INDEX) 2986 #define LFACE_BOX(LFACE) AREF ((LFACE), LFACE_BOX_INDEX)
2985 #define LFACE_FONT(LFACE) AREF ((LFACE), LFACE_FONT_INDEX) 2987 #define LFACE_FONT(LFACE) AREF ((LFACE), LFACE_FONT_INDEX)
2986 #define LFACE_INHERIT(LFACE) AREF ((LFACE), LFACE_INHERIT_INDEX) 2988 #define LFACE_INHERIT(LFACE) AREF ((LFACE), LFACE_INHERIT_INDEX)
2987 #define LFACE_AVGWIDTH(LFACE) AREF ((LFACE), LFACE_AVGWIDTH_INDEX) 2989 #define LFACE_AVGWIDTH(LFACE) AREF ((LFACE), LFACE_AVGWIDTH_INDEX)
2990 #define LFACE_FONTSET(LFACE) AREF ((LFACE), LFACE_FONTSET_INDEX)
2988 2991
2989 /* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size 2992 /* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size
2990 LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */ 2993 LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */
2991 2994
2992 #define LFACEP(LFACE) \ 2995 #define LFACEP(LFACE) \
3046 || SYMBOLP (attrs[LFACE_STIPPLE_INDEX]) 3049 || SYMBOLP (attrs[LFACE_STIPPLE_INDEX])
3047 || !NILP (Fbitmap_spec_p (attrs[LFACE_STIPPLE_INDEX]))); 3050 || !NILP (Fbitmap_spec_p (attrs[LFACE_STIPPLE_INDEX])));
3048 xassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX]) 3051 xassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX])
3049 || NILP (attrs[LFACE_FONT_INDEX]) 3052 || NILP (attrs[LFACE_FONT_INDEX])
3050 || STRINGP (attrs[LFACE_FONT_INDEX])); 3053 || STRINGP (attrs[LFACE_FONT_INDEX]));
3054 xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX])
3055 || STRINGP (attrs[LFACE_FONTSET_INDEX]));
3051 #endif 3056 #endif
3052 } 3057 }
3053 3058
3054 3059
3055 /* Check consistency of attributes of Lisp face LFACE (a Lisp vector). */ 3060 /* Check consistency of attributes of Lisp face LFACE (a Lisp vector). */
3284 3289
3285 if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface))) 3290 if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface)))
3286 LFACE_SLANT (lface) 3291 LFACE_SLANT (lface)
3287 = have_xlfd_p ? xlfd_symbolic_slant (&font) : Qnormal; 3292 = have_xlfd_p ? xlfd_symbolic_slant (&font) : Qnormal;
3288 3293
3289 LFACE_FONT (lface) = fontname; 3294 if (fontset)
3290 3295 {
3296 LFACE_FONT (lface) = build_string (font_info->full_name);
3297 LFACE_FONTSET (lface) = fontset_name (fontset);
3298 }
3299 else
3300 LFACE_FONT (lface) = fontname;
3291 return 1; 3301 return 1;
3292 } 3302 }
3293 3303
3294 #endif /* HAVE_WINDOW_SYSTEM */ 3304 #endif /* HAVE_WINDOW_SYSTEM */
3295 3305
4122 } 4132 }
4123 old_value = LFACE_SWIDTH (lface); 4133 old_value = LFACE_SWIDTH (lface);
4124 LFACE_SWIDTH (lface) = value; 4134 LFACE_SWIDTH (lface) = value;
4125 font_related_attr_p = 1; 4135 font_related_attr_p = 1;
4126 } 4136 }
4127 else if (EQ (attr, QCfont)) 4137 else if (EQ (attr, QCfont) || EQ (attr, QCfontset))
4128 { 4138 {
4129 #ifdef HAVE_WINDOW_SYSTEM 4139 #ifdef HAVE_WINDOW_SYSTEM
4130 if (FRAME_WINDOW_P (XFRAME (frame))) 4140 if (FRAME_WINDOW_P (XFRAME (frame)))
4131 { 4141 {
4132 /* Set font-related attributes of the Lisp face from an XLFD 4142 /* Set font-related attributes of the Lisp face from an XLFD
4143 /* VALUE may be a fontset name or an alias of fontset. In 4153 /* VALUE may be a fontset name or an alias of fontset. In
4144 such a case, use the base fontset name. */ 4154 such a case, use the base fontset name. */
4145 tmp = Fquery_fontset (value, Qnil); 4155 tmp = Fquery_fontset (value, Qnil);
4146 if (!NILP (tmp)) 4156 if (!NILP (tmp))
4147 value = tmp; 4157 value = tmp;
4148 4158 else if (EQ (attr, QCfontset))
4149 if (!set_lface_from_font_name (f, lface, value, 1, 1)) 4159 error ("Invalid fontset", XSTRING (value)->data);
4150 signal_error ("Invalid font or fontset name", value); 4160
4161 if (EQ (attr, QCfont))
4162 {
4163 if (!set_lface_from_font_name (f, lface, value, 1, 1))
4164 signal_error ("Invalid font or fontset name", value);
4165 }
4166 else
4167 LFACE_FONTSET (lface) = value;
4151 4168
4152 font_attr_p = 1; 4169 font_attr_p = 1;
4153 } 4170 }
4154 #endif /* HAVE_WINDOW_SYSTEM */ 4171 #endif /* HAVE_WINDOW_SYSTEM */
4155 } 4172 }
4195 depend on the face, make sure they are all removed. This is done 4212 depend on the face, make sure they are all removed. This is done
4196 by incrementing face_change_count. The next call to 4213 by incrementing face_change_count. The next call to
4197 init_iterator will then free realized faces. */ 4214 init_iterator will then free realized faces. */
4198 if (!EQ (frame, Qt) 4215 if (!EQ (frame, Qt)
4199 && (EQ (attr, QCfont) 4216 && (EQ (attr, QCfont)
4217 || EQ (attr, QCfontset)
4200 || NILP (Fequal (old_value, value)))) 4218 || NILP (Fequal (old_value, value))))
4201 { 4219 {
4202 ++face_change_count; 4220 ++face_change_count;
4203 ++windows_or_buffers_changed; 4221 ++windows_or_buffers_changed;
4204 } 4222 }
4302 4320
4303 4321
4304 #ifdef HAVE_WINDOW_SYSTEM 4322 #ifdef HAVE_WINDOW_SYSTEM
4305 4323
4306 /* Set the `font' frame parameter of FRAME determined from `default' 4324 /* Set the `font' frame parameter of FRAME determined from `default'
4307 face attributes LFACE. If a face or fontset name is explicitely 4325 face attributes LFACE. If a font name is explicitely
4308 specfied in LFACE, use it as is. Otherwise, determine a font name 4326 specfied in LFACE, use it as is. Otherwise, determine a font name
4309 from the other font-related atrributes of LFACE. In that case, if 4327 from the other font-related atrributes of LFACE. In that case, if
4310 there's no matching font, signals an error. */ 4328 there's no matching font, signals an error. */
4311 4329
4312 static void 4330 static void
4678 value = LFACE_SWIDTH (lface); 4696 value = LFACE_SWIDTH (lface);
4679 else if (EQ (keyword, QCinherit)) 4697 else if (EQ (keyword, QCinherit))
4680 value = LFACE_INHERIT (lface); 4698 value = LFACE_INHERIT (lface);
4681 else if (EQ (keyword, QCfont)) 4699 else if (EQ (keyword, QCfont))
4682 value = LFACE_FONT (lface); 4700 value = LFACE_FONT (lface);
4701 else if (EQ (keyword, QCfontset))
4702 value = LFACE_FONTSET (lface);
4683 else 4703 else
4684 signal_error ("Invalid face attribute name", keyword); 4704 signal_error ("Invalid face attribute name", keyword);
4685 4705
4686 return value; 4706 return value;
4687 } 4707 }
4964 } 4984 }
4965 4985
4966 4986
4967 /* Return non-zero if LFACE1 and LFACE2 specify the same font (without 4987 /* Return non-zero if LFACE1 and LFACE2 specify the same font (without
4968 considering charsets/registries). They do if they specify the same 4988 considering charsets/registries). They do if they specify the same
4969 family, point size, weight, width, slant, and fontset. Both LFACE1 4989 family, point size, weight, width, slant, font, and fontset. Both
4970 and LFACE2 must be fully-specified. */ 4990 LFACE1 and LFACE2 must be fully-specified. */
4971 4991
4972 static INLINE int 4992 static INLINE int
4973 lface_same_font_attributes_p (lface1, lface2) 4993 lface_same_font_attributes_p (lface1, lface2)
4974 Lisp_Object *lface1, *lface2; 4994 Lisp_Object *lface1, *lface2;
4975 { 4995 {
4983 && EQ (lface1[LFACE_WEIGHT_INDEX], lface2[LFACE_WEIGHT_INDEX]) 5003 && EQ (lface1[LFACE_WEIGHT_INDEX], lface2[LFACE_WEIGHT_INDEX])
4984 && EQ (lface1[LFACE_SLANT_INDEX], lface2[LFACE_SLANT_INDEX]) 5004 && EQ (lface1[LFACE_SLANT_INDEX], lface2[LFACE_SLANT_INDEX])
4985 && (EQ (lface1[LFACE_FONT_INDEX], lface2[LFACE_FONT_INDEX]) 5005 && (EQ (lface1[LFACE_FONT_INDEX], lface2[LFACE_FONT_INDEX])
4986 || (STRINGP (lface1[LFACE_FONT_INDEX]) 5006 || (STRINGP (lface1[LFACE_FONT_INDEX])
4987 && STRINGP (lface2[LFACE_FONT_INDEX]) 5007 && STRINGP (lface2[LFACE_FONT_INDEX])
4988 && xstricmp (XSTRING (lface1[LFACE_FONT_INDEX])->data, 5008 && ! xstricmp (XSTRING (lface1[LFACE_FONT_INDEX])->data,
4989 XSTRING (lface2[LFACE_FONT_INDEX])->data)))); 5009 XSTRING (lface2[LFACE_FONT_INDEX])->data)))
5010 && (EQ (lface1[LFACE_FONTSET_INDEX], lface2[LFACE_FONTSET_INDEX])
5011 || (STRINGP (lface1[LFACE_FONTSET_INDEX])
5012 && STRINGP (lface2[LFACE_FONTSET_INDEX])
5013 && ! xstricmp (XSTRING (lface1[LFACE_FONTSET_INDEX])->data,
5014 XSTRING (lface2[LFACE_FONTSET_INDEX])->data)))
5015 );
4990 } 5016 }
4991 5017
4992 5018
4993 5019
4994 /*********************************************************************** 5020 /***********************************************************************
6165 static int 6191 static int
6166 face_fontset (attrs) 6192 face_fontset (attrs)
6167 Lisp_Object *attrs; 6193 Lisp_Object *attrs;
6168 { 6194 {
6169 Lisp_Object name; 6195 Lisp_Object name;
6170 6196 int fontset;
6171 name = attrs[LFACE_FONT_INDEX]; 6197
6198 name = attrs[LFACE_FONTSET_INDEX];
6172 if (!STRINGP (name)) 6199 if (!STRINGP (name))
6173 return -1; 6200 return -1;
6174 return fs_query_fontset (name, 0); 6201 return fs_query_fontset (name, 0);
6175 } 6202 }
6176 6203
7286 staticpro (&QCstipple); 7313 staticpro (&QCstipple);
7287 QCwidth = intern (":width"); 7314 QCwidth = intern (":width");
7288 staticpro (&QCwidth); 7315 staticpro (&QCwidth);
7289 QCfont = intern (":font"); 7316 QCfont = intern (":font");
7290 staticpro (&QCfont); 7317 staticpro (&QCfont);
7318 QCfontset = intern (":fontset");
7319 staticpro (&QCfontset);
7291 QCbold = intern (":bold"); 7320 QCbold = intern (":bold");
7292 staticpro (&QCbold); 7321 staticpro (&QCbold);
7293 QCitalic = intern (":italic"); 7322 QCitalic = intern (":italic");
7294 staticpro (&QCitalic); 7323 staticpro (&QCitalic);
7295 QCoverline = intern (":overline"); 7324 QCoverline = intern (":overline");