Mercurial > emacs
annotate src/xfaces.c @ 25881:54d9b33d9c4b
(enum face_id): Add MENU_FACE_ID.
(toplevel): Include X11/Intrinsic.h.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 06 Oct 1999 23:00:50 +0000 |
parents | 1c370ec939da |
children | 2955c353186a |
rev | line source |
---|---|
24995 | 1 /* xfaces.c -- "Face" primitives. |
2 Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation. | |
2342 | 3 |
2336 | 4 This file is part of GNU Emacs. |
5 | |
6 GNU Emacs is free software; you can redistribute it and/or modify | |
7 it under the terms of the GNU General Public License as published by | |
2342 | 8 the Free Software Foundation; either version 2, or (at your option) |
2336 | 9 any later version. |
10 | |
11 GNU Emacs is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14090
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14090
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
2336 | 20 |
24995 | 21 /* New face implementation by Gerd Moellmann <gerd@gnu.org>. */ |
22 | |
23 /* Faces. | |
24 | |
25 When using Emacs with X, the display style of characters can be | |
26 changed by defining `faces'. Each face can specify the following | |
27 display attributes: | |
28 | |
29 1. Font family or fontset alias name. | |
30 | |
31 2. Relative proportionate width, aka character set width or set | |
32 width (swidth), e.g. `semi-compressed'. | |
33 | |
34 3. Font height in 1/10pt | |
35 | |
36 4. Font weight, e.g. `bold'. | |
37 | |
38 5. Font slant, e.g. `italic'. | |
39 | |
40 6. Foreground color. | |
41 | |
42 7. Background color. | |
43 | |
44 8. Whether or not characters should be underlined, and in what color. | |
45 | |
46 9. Whether or not characters should be displayed in inverse video. | |
47 | |
48 10. A background stipple, a bitmap. | |
49 | |
50 11. Whether or not characters should be overlined, and in what color. | |
51 | |
52 12. Whether or not characters should be strike-through, and in what | |
53 color. | |
54 | |
55 13. Whether or not a box should be drawn around characters, the box | |
56 type, and, for simple boxes, in what color. | |
57 | |
58 Faces are frame-local by nature because Emacs allows to define the | |
59 same named face (face names are symbols) differently for different | |
60 frames. Each frame has an alist of face definitions for all named | |
61 faces. The value of a named face in such an alist is a Lisp vector | |
62 with the symbol `face' in slot 0, and a slot for each each of the | |
63 face attributes mentioned above. | |
64 | |
65 There is also a global face alist `Vface_new_frame_defaults'. Face | |
66 definitions from this list are used to initialize faces of newly | |
67 created frames. | |
68 | |
69 A face doesn't have to specify all attributes. Those not specified | |
70 have a value of `unspecified'. Faces specifying all attributes are | |
71 called `fully-specified'. | |
72 | |
73 | |
74 Face merging. | |
75 | |
76 The display style of a given character in the text is determined by | |
77 combining several faces. This process is called `face merging'. | |
78 Any aspect of the display style that isn't specified by overlays or | |
79 text properties is taken from the `default' face. Since it is made | |
80 sure that the default face is always fully-specified, face merging | |
81 always results in a fully-specified face. | |
82 | |
83 | |
84 Face realization. | |
85 | |
86 After all face attributes for a character have been determined by | |
87 merging faces of that character, that face is `realized'. The | |
88 realization process maps face attributes to what is physically | |
89 available on the system where Emacs runs. The result is a | |
90 `realized face' in form of a struct face which is stored in the | |
91 face cache of the frame on which it was realized. | |
92 | |
93 Face realization is done in the context of the charset of the | |
94 character to display because different fonts and encodings are used | |
95 for different charsets. In other words, for characters of | |
96 different charsets, different realized faces are needed to display | |
97 them. | |
98 | |
99 Except for composite characters (CHARSET_COMPOSITION), faces are | |
100 always realized for a specific character set and contain a specific | |
101 font, even if the face being realized specifies a fontset (see | |
102 `font selection' below). The reason is that the result of the new | |
103 font selection stage is better than what can be done with | |
104 statically defined font name patterns in fontsets. | |
105 | |
106 | |
107 Unibyte text. | |
108 | |
109 In unibyte text, Emacs' charsets aren't applicable; function | |
110 `char-charset' reports CHARSET_ASCII for all characters, including | |
111 those > 0x7f. The X registry and encoding of fonts to use is | |
112 determined from the variable `x-unibyte-registry-and-encoding' in | |
113 this case. The variable is initialized at Emacs startup time from | |
114 the font the user specified for Emacs. | |
115 | |
116 Currently all unibyte text, i.e. all buffers with | |
117 enable_multibyte_characters nil are displayed with fonts of the | |
118 same registry and encoding `x-unibyte-registry-and-encoding'. This | |
119 is consistent with the fact that languages can also be set | |
120 globally, only. | |
121 | |
122 | |
123 Font selection. | |
124 | |
125 Font selection tries to find the best available matching font for a | |
126 given (charset, face) combination. This is done slightly | |
127 differently for faces specifying a fontset, or a font family name. | |
128 | |
129 If the face specifies a fontset alias name, that fontset determines | |
130 a pattern for fonts of the given charset. If the face specifies a | |
131 font family, a font pattern is constructed. Charset symbols have a | |
132 property `x-charset-registry' for that purpose that maps a charset | |
133 to an XLFD registry and encoding in the font pattern constructed. | |
134 | |
135 Available fonts on the system on which Emacs runs are then matched | |
136 against the font pattern. The result of font selection is the best | |
137 match for the given face attributes in this font list. | |
138 | |
139 Font selection can be influenced by the user. | |
140 | |
141 1. The user can specify the relative importance he gives the face | |
142 attributes width, height, weight, and slant by setting | |
143 face-font-selection-order (faces.el) to a list of face attribute | |
144 names. The default is '(:width :height :weight :slant), and means | |
145 that font selection first tries to find a good match for the font | |
146 width specified by a face, then---within fonts with that | |
147 width---tries to find a best match for the specified font height, | |
148 etc. | |
149 | |
150 2. Setting face-alternative-font-family-alist allows the user to | |
151 specify alternative font families to try if a family specified by a | |
152 face doesn't exist. | |
153 | |
154 | |
155 Composite characters. | |
156 | |
157 Realized faces for composite characters are the only ones having a | |
158 fontset id >= 0. When a composite character is encoded into a | |
159 sequence of non-composite characters (in xterm.c), a suitable font | |
160 for the non-composite characters is then selected and realized, | |
161 i.e. the realization process is delayed but in principle the same. | |
162 | |
163 | |
164 Initialization of basic faces. | |
165 | |
166 The faces `default', `modeline' are considered `basic faces'. | |
167 When redisplay happens the first time for a newly created frame, | |
168 basic faces are realized for CHARSET_ASCII. Frame parameters are | |
169 used to fill in unspecified attributes of the default face. */ | |
170 | |
171 /* Define SCALABLE_FONTS to a non-zero value to enable scalable | |
172 font use. Define it to zero to disable scalable font use. | |
173 | |
174 Use of too many or too large scalable fonts can crash XFree86 | |
175 servers. That's why I've put the code dealing with scalable fonts | |
176 in #if's. */ | |
177 | |
178 #define SCALABLE_FONTS 1 | |
2342 | 179 |
2336 | 180 #include <sys/types.h> |
181 #include <sys/stat.h> | |
4696
1fc792473491
Include <config.h> instead of "config.h".
Roland McGrath <roland@gnu.org>
parents:
4258
diff
changeset
|
182 #include <config.h> |
2336 | 183 #include "lisp.h" |
17047 | 184 #include "charset.h" |
18083
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
185 #include "frame.h" |
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
186 |
9572 | 187 #ifdef HAVE_X_WINDOWS |
2336 | 188 #include "xterm.h" |
17047 | 189 #include "fontset.h" |
9572 | 190 #endif |
24995 | 191 |
9572 | 192 #ifdef MSDOS |
193 #include "dosfns.h" | |
194 #endif | |
24995 | 195 |
2336 | 196 #include "buffer.h" |
2391 | 197 #include "dispextern.h" |
2438 | 198 #include "blockinput.h" |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
199 #include "window.h" |
8848 | 200 #include "intervals.h" |
2336 | 201 |
9572 | 202 #ifdef HAVE_X_WINDOWS |
24995 | 203 |
204 /* Compensate for a bug in Xos.h on some systems, on which it requires | |
3997
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
205 time.h. On some such systems, Xos.h tries to redefine struct |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
206 timeval and struct timezone if USG is #defined while it is |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
207 #included. */ |
24995 | 208 |
3436
291f28da7ea1
Test XOS_NEEDS_TIME_H, not HPUX, for including time.hj.
Richard M. Stallman <rms@gnu.org>
parents:
3401
diff
changeset
|
209 #ifdef XOS_NEEDS_TIME_H |
3997
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
210 #include <time.h> |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
211 #undef USG |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
212 #include <X11/Xos.h> |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
213 #define USG |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
214 #define __TIMEVAL__ |
24995 | 215 #else /* not XOS_NEEDS_TIME_H */ |
2336 | 216 #include <X11/Xos.h> |
24995 | 217 #endif /* not XOS_NEEDS_TIME_H */ |
218 | |
9572 | 219 #endif /* HAVE_X_WINDOWS */ |
24995 | 220 |
221 #include <stdio.h> | |
222 #include <stdlib.h> | |
223 #include <ctype.h> | |
224 #include "keyboard.h" | |
225 | |
226 #ifndef max | |
227 #define max(A, B) ((A) > (B) ? (A) : (B)) | |
228 #define min(A, B) ((A) < (B) ? (A) : (B)) | |
229 #define abs(X) ((X) < 0 ? -(X) : (X)) | |
230 #endif | |
231 | |
232 /* Non-zero if face attribute ATTR is unspecified. */ | |
233 | |
234 #define UNSPECIFIEDP(ATTR) EQ ((ATTR), Qunspecified) | |
235 | |
236 /* Value is the number of elements of VECTOR. */ | |
237 | |
238 #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR)) | |
239 | |
240 /* Make a copy of string S on the stack using alloca. Value is a pointer | |
241 to the copy. */ | |
242 | |
243 #define STRDUPA(S) strcpy ((char *) alloca (strlen ((S)) + 1), (S)) | |
244 | |
245 /* Make a copy of the contents of Lisp string S on the stack using | |
246 alloca. Value is a pointer to the copy. */ | |
247 | |
248 #define LSTRDUPA(S) STRDUPA (XSTRING ((S))->data) | |
249 | |
250 /* Size of hash table of realized faces in face caches (should be a | |
251 prime number). */ | |
252 | |
253 #define FACE_CACHE_BUCKETS_SIZE 1001 | |
254 | |
255 /* Keyword symbols used for face attribute names. */ | |
256 | |
257 Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline; | |
258 Lisp_Object QCinverse_video, QCforeground, QCbackground, QCstipple; | |
259 Lisp_Object QCwidth, QCfont, QCbold, QCitalic; | |
260 Lisp_Object QCreverse_video; | |
261 Lisp_Object QCoverline, QCstrike_through, QCbox; | |
262 | |
263 /* Symbols used for attribute values. */ | |
264 | |
265 Lisp_Object Qnormal, Qbold, Qultra_light, Qextra_light, Qlight; | |
266 Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold; | |
267 Lisp_Object Qoblique, Qitalic, Qreverse_oblique, Qreverse_italic; | |
268 Lisp_Object Qultra_condensed, Qextra_condensed, Qcondensed; | |
269 Lisp_Object Qsemi_condensed, Qsemi_expanded, Qexpanded, Qextra_expanded; | |
270 Lisp_Object Qultra_expanded; | |
271 Lisp_Object Qreleased_button, Qpressed_button; | |
272 Lisp_Object QCstyle, QCcolor, QCline_width; | |
273 Lisp_Object Qunspecified; | |
274 | |
275 /* The symbol `x-charset-registry'. This property of charsets defines | |
276 the X registry and encoding that fonts should have that are used to | |
277 display characters of that charset. */ | |
278 | |
279 Lisp_Object Qx_charset_registry; | |
280 | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
281 /* The name of the function to call when the background of the frame |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
282 has changed, frame_update_face_colors. */ |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
283 |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
284 Lisp_Object Qframe_update_face_colors; |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
285 |
24995 | 286 /* Names of basic faces. */ |
287 | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
288 Lisp_Object Qdefault, Qmode_line, Qtool_bar, Qregion, Qfringe; |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
289 Lisp_Object Qheader_line, Qscroll_bar, Qcursor, Qborder, Qmouse;; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
290 |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
291 /* The symbol `face-alias'. A symbols having that property is an |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
292 alias for another face. Value of the property is the name of |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
293 the aliased face. */ |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
294 |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
295 Lisp_Object Qface_alias; |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
296 |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
297 /* Names of frame parameters related to faces. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
298 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
299 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
300 extern Lisp_Object Qborder_color, Qcursor_color, Qmouse_color; |
24995 | 301 |
302 /* Default stipple pattern used on monochrome displays. This stipple | |
303 pattern is used on monochrome displays instead of shades of gray | |
304 for a face background color. See `set-face-stipple' for possible | |
305 values for this variable. */ | |
306 | |
307 Lisp_Object Vface_default_stipple; | |
308 | |
309 /* Default registry and encoding to use for charsets whose charset | |
310 symbols don't specify one. */ | |
311 | |
312 Lisp_Object Vface_default_registry; | |
313 | |
314 /* Alist of alternative font families. Each element is of the form | |
315 (FAMILY FAMILY1 FAMILY2 ...). If fonts of FAMILY can't be loaded, | |
316 try FAMILY1, then FAMILY2, ... */ | |
317 | |
318 Lisp_Object Vface_alternative_font_family_alist; | |
319 | |
320 /* Allowed scalable fonts. A value of nil means don't allow any | |
321 scalable fonts. A value of t means allow the use of any scalable | |
322 font. Otherwise, value must be a list of regular expressions. A | |
323 font may be scaled if its name matches a regular expression in the | |
324 list. */ | |
325 | |
326 #if SCALABLE_FONTS | |
327 Lisp_Object Vscalable_fonts_allowed; | |
328 #endif | |
329 | |
25270 | 330 /* Maximum number of fonts to consider in font_list. If not an |
331 integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */ | |
332 | |
333 Lisp_Object Vfont_list_limit; | |
334 #define DEFAULT_FONT_LIST_LIMIT 100 | |
335 | |
24995 | 336 /* The symbols `foreground-color' and `background-color' which can be |
337 used as part of a `face' property. This is for compatibility with | |
338 Emacs 20.2. */ | |
339 | |
340 Lisp_Object Qforeground_color, Qbackground_color; | |
341 | |
342 /* The symbols `face' and `mouse-face' used as text properties. */ | |
2342 | 343 |
23730
c71c3ac4b80a
(Qmouse_face): Replace definition with extern decl.
Richard M. Stallman <rms@gnu.org>
parents:
21766
diff
changeset
|
344 Lisp_Object Qface; |
24995 | 345 extern Lisp_Object Qmouse_face; |
346 | |
347 /* Error symbol for wrong_type_argument in load_pixmap. */ | |
348 | |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
349 Lisp_Object Qpixmap_spec_p; |
2391 | 350 |
24995 | 351 /* Alist of global face definitions. Each element is of the form |
352 (FACE . LFACE) where FACE is a symbol naming a face and LFACE | |
353 is a Lisp vector of face attributes. These faces are used | |
354 to initialize faces for new frames. */ | |
355 | |
356 Lisp_Object Vface_new_frame_defaults; | |
357 | |
358 /* The next ID to assign to Lisp faces. */ | |
359 | |
360 static int next_lface_id; | |
361 | |
362 /* A vector mapping Lisp face Id's to face names. */ | |
363 | |
364 static Lisp_Object *lface_id_to_name; | |
365 static int lface_id_to_name_size; | |
366 | |
367 /* An alist of elements (COLOR-NAME . INDEX) mapping color names | |
368 to color indices for tty frames. */ | |
369 | |
370 Lisp_Object Vface_tty_color_alist; | |
371 | |
372 /* Counter for calls to clear_face_cache. If this counter reaches | |
373 CLEAR_FONT_TABLE_COUNT, and a frame has more than | |
374 CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed. */ | |
375 | |
376 static int clear_font_table_count; | |
377 #define CLEAR_FONT_TABLE_COUNT 100 | |
378 #define CLEAR_FONT_TABLE_NFONTS 10 | |
379 | |
380 /* Non-zero means face attributes have been changed since the last | |
381 redisplay. Used in redisplay_internal. */ | |
382 | |
383 int face_change_count; | |
384 | |
385 /* The total number of colors currently allocated. */ | |
386 | |
387 #if GLYPH_DEBUG | |
388 static int ncolors_allocated; | |
389 static int npixmaps_allocated; | |
390 static int ngcs; | |
391 #endif | |
392 | |
393 | |
2336 | 394 |
24995 | 395 /* Function prototypes. */ |
396 | |
397 struct font_name; | |
398 struct table_entry; | |
399 | |
400 static int may_use_scalable_font_p P_ ((struct font_name *, char *)); | |
401 static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); | |
402 static int better_font_p P_ ((int *, struct font_name *, struct font_name *, | |
403 int)); | |
404 static int first_font_matching P_ ((struct frame *f, char *, | |
405 struct font_name *)); | |
406 static int x_face_list_fonts P_ ((struct frame *, char *, | |
407 struct font_name *, int, int, int)); | |
408 static int font_scalable_p P_ ((struct font_name *)); | |
409 static Lisp_Object deduce_unibyte_registry P_ ((struct frame *, char *)); | |
410 static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int)); | |
411 static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); | |
412 static char *xstrdup P_ ((char *)); | |
413 static unsigned char *xstrlwr P_ ((unsigned char *)); | |
414 static void signal_error P_ ((char *, Lisp_Object)); | |
415 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); | |
416 static void load_face_font_or_fontset P_ ((struct frame *, struct face *, char *, int)); | |
417 static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); | |
418 static void free_face_colors P_ ((struct frame *, struct face *)); | |
419 static int face_color_gray_p P_ ((struct frame *, char *)); | |
420 static char *build_font_name P_ ((struct font_name *)); | |
421 static void free_font_names P_ ((struct font_name *, int)); | |
422 static int sorted_font_list P_ ((struct frame *, char *, | |
423 int (*cmpfn) P_ ((const void *, const void *)), | |
424 struct font_name **)); | |
425 static int font_list P_ ((struct frame *, char *, char *, char *, struct font_name **)); | |
426 static int try_font_list P_ ((struct frame *, Lisp_Object *, char *, char *, char *, | |
427 struct font_name **)); | |
428 static int cmp_font_names P_ ((const void *, const void *)); | |
429 static struct face *realize_face P_ ((struct face_cache *, | |
430 Lisp_Object *, int)); | |
431 static struct face *realize_x_face P_ ((struct face_cache *, | |
432 Lisp_Object *, int)); | |
433 static struct face *realize_tty_face P_ ((struct face_cache *, | |
434 Lisp_Object *, int)); | |
435 static int realize_basic_faces P_ ((struct frame *)); | |
436 static int realize_default_face P_ ((struct frame *)); | |
437 static void realize_named_face P_ ((struct frame *, Lisp_Object, int)); | |
438 static int lface_fully_specified_p P_ ((Lisp_Object *)); | |
439 static int lface_equal_p P_ ((Lisp_Object *, Lisp_Object *)); | |
440 static unsigned hash_string_case_insensitive P_ ((Lisp_Object)); | |
441 static unsigned lface_hash P_ ((Lisp_Object *)); | |
442 static int lface_same_font_attributes_p P_ ((Lisp_Object *, Lisp_Object *)); | |
443 static struct face_cache *make_face_cache P_ ((struct frame *)); | |
444 static void free_realized_face P_ ((struct frame *, struct face *)); | |
445 static void clear_face_gcs P_ ((struct face_cache *)); | |
446 static void free_face_cache P_ ((struct face_cache *)); | |
447 static int face_numeric_weight P_ ((Lisp_Object)); | |
448 static int face_numeric_slant P_ ((Lisp_Object)); | |
449 static int face_numeric_swidth P_ ((Lisp_Object)); | |
450 static int face_fontset P_ ((struct frame *, Lisp_Object *)); | |
451 static char *choose_face_font P_ ((struct frame *, Lisp_Object *, int, | |
452 Lisp_Object)); | |
453 static char *choose_face_fontset_font P_ ((struct frame *, Lisp_Object *, | |
454 int, int)); | |
455 static void merge_face_vectors P_ ((Lisp_Object *from, Lisp_Object *)); | |
456 static void merge_face_vector_with_property P_ ((struct frame *, Lisp_Object *, | |
457 Lisp_Object)); | |
458 static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object, char *, | |
459 int)); | |
460 static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); | |
461 static struct face *make_realized_face P_ ((Lisp_Object *, int, Lisp_Object)); | |
462 static void free_realized_faces P_ ((struct face_cache *)); | |
463 static char *best_matching_font P_ ((struct frame *, Lisp_Object *, | |
464 struct font_name *, int)); | |
465 static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); | |
466 static void uncache_face P_ ((struct face_cache *, struct face *)); | |
467 static int xlfd_numeric_slant P_ ((struct font_name *)); | |
468 static int xlfd_numeric_weight P_ ((struct font_name *)); | |
469 static int xlfd_numeric_swidth P_ ((struct font_name *)); | |
470 static Lisp_Object xlfd_symbolic_slant P_ ((struct font_name *)); | |
471 static Lisp_Object xlfd_symbolic_weight P_ ((struct font_name *)); | |
472 static Lisp_Object xlfd_symbolic_swidth P_ ((struct font_name *)); | |
473 static int xlfd_fixed_p P_ ((struct font_name *)); | |
474 static int xlfd_numeric_value P_ ((struct table_entry *, int, struct font_name *, | |
475 int, int)); | |
476 static Lisp_Object xlfd_symbolic_value P_ ((struct table_entry *, int, | |
477 struct font_name *, int, int)); | |
478 static struct table_entry *xlfd_lookup_field_contents P_ ((struct table_entry *, int, | |
479 struct font_name *, int)); | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
480 |
9572 | 481 #ifdef HAVE_X_WINDOWS |
24995 | 482 |
483 static int split_font_name P_ ((struct frame *, struct font_name *, int)); | |
484 static int xlfd_point_size P_ ((struct frame *, struct font_name *)); | |
485 static void sort_fonts P_ ((struct frame *, struct font_name *, int, | |
486 int (*cmpfn) P_ ((const void *, const void *)))); | |
487 static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *)); | |
488 static void x_free_gc P_ ((struct frame *, GC)); | |
489 static void clear_font_table P_ ((struct frame *)); | |
490 | |
491 #endif /* HAVE_X_WINDOWS */ | |
492 | |
493 | |
494 /*********************************************************************** | |
495 Utilities | |
496 ***********************************************************************/ | |
497 | |
498 #ifdef HAVE_X_WINDOWS | |
499 | |
500 /* Create and return a GC for use on frame F. GC values and mask | |
501 are given by XGCV and MASK. */ | |
502 | |
503 static INLINE GC | |
504 x_create_gc (f, mask, xgcv) | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
505 struct frame *f; |
24995 | 506 unsigned long mask; |
507 XGCValues *xgcv; | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
508 { |
2336 | 509 GC gc; |
24995 | 510 BLOCK_INPUT; |
511 gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), mask, xgcv); | |
512 UNBLOCK_INPUT; | |
513 IF_DEBUG (++ngcs); | |
514 return gc; | |
515 } | |
516 | |
517 | |
518 /* Free GC which was used on frame F. */ | |
519 | |
520 static INLINE void | |
521 x_free_gc (f, gc) | |
522 struct frame *f; | |
523 GC gc; | |
524 { | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
525 BLOCK_INPUT; |
24995 | 526 xassert (--ngcs >= 0); |
527 XFreeGC (FRAME_X_DISPLAY (f), gc); | |
528 UNBLOCK_INPUT; | |
529 } | |
530 | |
531 #endif /* HAVE_X_WINDOWS */ | |
532 | |
533 | |
534 /* Like strdup, but uses xmalloc. */ | |
535 | |
536 static char * | |
537 xstrdup (s) | |
538 char *s; | |
539 { | |
540 int len = strlen (s) + 1; | |
541 char *p = (char *) xmalloc (len); | |
542 bcopy (s, p, len); | |
543 return p; | |
544 } | |
545 | |
546 | |
547 /* Like stricmp. Used to compare parts of font names which are in | |
548 ISO8859-1. */ | |
549 | |
550 int | |
551 xstricmp (s1, s2) | |
552 unsigned char *s1, *s2; | |
553 { | |
554 while (*s1 && *s2) | |
555 { | |
556 unsigned char c1 = tolower (*s1); | |
557 unsigned char c2 = tolower (*s2); | |
558 if (c1 != c2) | |
559 return c1 < c2 ? -1 : 1; | |
560 ++s1, ++s2; | |
561 } | |
562 | |
563 if (*s1 == 0) | |
564 return *s2 == 0 ? 0 : -1; | |
565 return 1; | |
566 } | |
567 | |
568 | |
569 /* Like strlwr, which might not always be available. */ | |
570 | |
571 static unsigned char * | |
572 xstrlwr (s) | |
573 unsigned char *s; | |
574 { | |
575 unsigned char *p = s; | |
576 | |
577 for (p = s; *p; ++p) | |
578 *p = tolower (*p); | |
579 | |
580 return s; | |
581 } | |
582 | |
583 | |
584 /* Signal `error' with message S, and additional argument ARG. */ | |
585 | |
586 static void | |
587 signal_error (s, arg) | |
588 char *s; | |
589 Lisp_Object arg; | |
590 { | |
591 Fsignal (Qerror, Fcons (build_string (s), Fcons (arg, Qnil))); | |
592 } | |
593 | |
594 | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
595 /* If FRAME is nil, return a pointer to the selected frame. |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
596 Otherwise, check that FRAME is a live frame, and return a pointer |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
597 to it. NPARAM is the parameter number of FRAME, for |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
598 CHECK_LIVE_FRAME. This is here because it's a frequent pattern in |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
599 Lisp function definitions. */ |
24995 | 600 |
601 static INLINE struct frame * | |
602 frame_or_selected_frame (frame, nparam) | |
603 Lisp_Object frame; | |
604 int nparam; | |
605 { | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
606 if (NILP (frame)) |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
607 frame = selected_frame; |
24995 | 608 |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
609 CHECK_LIVE_FRAME (frame, nparam); |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
610 return XFRAME (frame); |
24995 | 611 } |
612 | |
613 | |
614 /*********************************************************************** | |
615 Frames and faces | |
616 ***********************************************************************/ | |
617 | |
618 /* Initialize face cache and basic faces for frame F. */ | |
9529
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
619 |
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
620 void |
24995 | 621 init_frame_faces (f) |
622 struct frame *f; | |
9529
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
623 { |
24995 | 624 /* Make a face cache, if F doesn't have one. */ |
625 if (FRAME_FACE_CACHE (f) == NULL) | |
626 FRAME_FACE_CACHE (f) = make_face_cache (f); | |
627 | |
628 #ifdef HAVE_X_WINDOWS | |
629 /* Make the image cache. */ | |
630 if (FRAME_X_P (f)) | |
9529
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
631 { |
24995 | 632 if (FRAME_X_IMAGE_CACHE (f) == NULL) |
633 FRAME_X_IMAGE_CACHE (f) = make_image_cache (); | |
634 ++FRAME_X_IMAGE_CACHE (f)->refcount; | |
635 } | |
636 #endif /* HAVE_X_WINDOWS */ | |
637 | |
638 /* Realize basic faces. Must have enough information in frame | |
639 parameters to realize basic faces at this point. */ | |
640 #ifdef HAVE_X_WINDOWS | |
641 if (!FRAME_X_P (f) || FRAME_X_WINDOW (f)) | |
642 #endif | |
643 if (!realize_basic_faces (f)) | |
644 abort (); | |
645 } | |
646 | |
647 | |
648 /* Free face cache of frame F. Called from Fdelete_frame. */ | |
649 | |
650 void | |
651 free_frame_faces (f) | |
652 struct frame *f; | |
653 { | |
654 struct face_cache *face_cache = FRAME_FACE_CACHE (f); | |
655 | |
656 if (face_cache) | |
657 { | |
658 free_face_cache (face_cache); | |
659 FRAME_FACE_CACHE (f) = NULL; | |
660 } | |
661 | |
662 #ifdef HAVE_X_WINDOWS | |
663 if (FRAME_X_P (f)) | |
664 { | |
665 struct image_cache *image_cache = FRAME_X_IMAGE_CACHE (f); | |
666 if (image_cache) | |
9529
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
667 { |
24995 | 668 --image_cache->refcount; |
669 if (image_cache->refcount == 0) | |
670 free_image_cache (f); | |
671 } | |
672 } | |
673 #endif /* HAVE_X_WINDOWS */ | |
674 } | |
675 | |
676 | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
677 /* Clear face caches, and recompute basic faces for frame F. Call |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
678 this after changing frame parameters on which those faces depend, |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
679 or when realized faces have been freed due to changing attributes |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
680 of named faces. */ |
24995 | 681 |
682 void | |
683 recompute_basic_faces (f) | |
684 struct frame *f; | |
685 { | |
686 if (FRAME_FACE_CACHE (f)) | |
687 { | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
688 int realized_p; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
689 clear_face_cache (0); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
690 realized_p = realize_basic_faces (f); |
24995 | 691 xassert (realized_p); |
692 } | |
693 } | |
694 | |
695 | |
696 /* Clear the face caches of all frames. CLEAR_FONTS_P non-zero means | |
697 try to free unused fonts, too. */ | |
698 | |
699 void | |
700 clear_face_cache (clear_fonts_p) | |
701 int clear_fonts_p; | |
702 { | |
703 #ifdef HAVE_X_WINDOWS | |
704 Lisp_Object tail, frame; | |
705 struct frame *f; | |
706 | |
707 if (clear_fonts_p | |
708 || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT) | |
709 { | |
710 /* From time to time see if we can unload some fonts. This also | |
711 frees all realized faces on all frames. Fonts needed by | |
712 faces will be loaded again when faces are realized again. */ | |
713 clear_font_table_count = 0; | |
714 | |
715 FOR_EACH_FRAME (tail, frame) | |
716 { | |
717 f = XFRAME (frame); | |
718 if (FRAME_X_P (f) | |
719 && FRAME_X_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS) | |
9529
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
720 { |
24995 | 721 free_all_realized_faces (frame); |
722 clear_font_table (f); | |
9529
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
723 } |
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
724 } |
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
725 } |
24995 | 726 else |
13460
5513606156bc
(unload_font): Invalidate computed faces.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
727 { |
24995 | 728 /* Clear GCs of realized faces. */ |
729 FOR_EACH_FRAME (tail, frame) | |
13460
5513606156bc
(unload_font): Invalidate computed faces.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
730 { |
24995 | 731 f = XFRAME (frame); |
732 if (FRAME_X_P (f)) | |
733 { | |
734 clear_face_gcs (FRAME_FACE_CACHE (f)); | |
735 clear_image_cache (f, 0); | |
736 } | |
13460
5513606156bc
(unload_font): Invalidate computed faces.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
737 } |
5513606156bc
(unload_font): Invalidate computed faces.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
738 } |
24995 | 739 #endif /* HAVE_X_WINDOWS */ |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
740 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
741 |
24995 | 742 |
743 DEFUN ("clear-face-cache", Fclear_face_cache, Sclear_face_cache, 0, 1, 0, | |
744 "Clear face caches on all frames.\n\ | |
745 Optional THOROUGHLY non-nil means try to free unused fonts, too.") | |
746 (thorougly) | |
747 Lisp_Object thorougly; | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
748 { |
24995 | 749 clear_face_cache (!NILP (thorougly)); |
750 return Qnil; | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
751 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
752 |
24995 | 753 |
754 | |
755 #ifdef HAVE_X_WINDOWS | |
756 | |
757 | |
758 /* Remove those fonts from the font table of frame F that are not used | |
759 by fontsets. Called from clear_face_cache from time to time. */ | |
760 | |
761 static void | |
762 clear_font_table (f) | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
763 struct frame *f; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
764 { |
24995 | 765 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
766 char *used; | |
767 Lisp_Object rest, frame; | |
768 int i; | |
769 | |
770 xassert (FRAME_X_P (f)); | |
771 | |
772 used = (char *) alloca (dpyinfo->n_fonts * sizeof *used); | |
773 bzero (used, dpyinfo->n_fonts * sizeof *used); | |
774 | |
775 /* For all frames with the same x_display_info as F, record | |
776 in `used' those fonts that are in use by fontsets. */ | |
777 FOR_EACH_FRAME (rest, frame) | |
778 if (FRAME_X_DISPLAY_INFO (XFRAME (frame)) == dpyinfo) | |
779 { | |
780 struct frame *f = XFRAME (frame); | |
781 struct fontset_data *fontset_data = FRAME_FONTSET_DATA (f); | |
782 | |
783 for (i = 0; i < fontset_data->n_fontsets; ++i) | |
784 { | |
785 struct fontset_info *info = fontset_data->fontset_table[i]; | |
786 int j; | |
787 | |
788 for (j = 0; j <= MAX_CHARSET; ++j) | |
789 { | |
790 int idx = info->font_indexes[j]; | |
791 if (idx >= 0) | |
792 used[idx] = 1; | |
793 } | |
794 } | |
795 } | |
796 | |
797 /* Free those fonts that are not used by fontsets. */ | |
798 for (i = 0; i < dpyinfo->n_fonts; ++i) | |
799 if (used[i] == 0 && dpyinfo->font_table[i].name) | |
800 { | |
801 struct font_info *font_info = dpyinfo->font_table + i; | |
802 | |
803 /* Free names. In xfns.c there is a comment that full_name | |
804 should never be freed because it is always shared with | |
805 something else. I don't think this is true anymore---see | |
806 x_load_font. It's either equal to font_info->name or | |
807 allocated via xmalloc, and there seems to be no place in | |
808 the source files where full_name is transferred to another | |
809 data structure. */ | |
810 if (font_info->full_name != font_info->name) | |
811 xfree (font_info->full_name); | |
812 xfree (font_info->name); | |
813 | |
814 /* Free the font. */ | |
815 BLOCK_INPUT; | |
816 XFreeFont (dpyinfo->display, font_info->font); | |
817 UNBLOCK_INPUT; | |
818 | |
819 /* Mark font table slot free. */ | |
820 font_info->font = NULL; | |
821 font_info->name = font_info->full_name = NULL; | |
822 } | |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
823 } |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
824 |
24995 | 825 |
826 #endif /* HAVE_X_WINDOWS */ | |
827 | |
828 | |
829 | |
830 /*********************************************************************** | |
831 X Pixmaps | |
832 ***********************************************************************/ | |
833 | |
834 #ifdef HAVE_X_WINDOWS | |
835 | |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
836 DEFUN ("pixmap-spec-p", Fpixmap_spec_p, Spixmap_spec_p, 1, 1, 0, |
24995 | 837 "Non-nil if OBJECT is a valid pixmap specification.\n\ |
838 A pixmap specification is either a string, or a list (WIDTH HEIGHT DATA)\n\ | |
839 where WIDTH is the pixel width of the pixmap, HEIGHT is its height,\n\ | |
840 and DATA contains the bits of the pixmap.") | |
14090
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
841 (object) |
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
842 Lisp_Object object; |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
843 { |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
844 Lisp_Object height, width; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
845 |
14090
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
846 return ((STRINGP (object) |
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
847 || (CONSP (object) |
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
848 && CONSP (XCONS (object)->cdr) |
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
849 && CONSP (XCONS (XCONS (object)->cdr)->cdr) |
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
850 && NILP (XCONS (XCONS (XCONS (object)->cdr)->cdr)->cdr) |
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
851 && (width = XCONS (object)->car, INTEGERP (width)) |
24995 | 852 && (height = XCONS (XCONS (object)->cdr)->car, |
853 INTEGERP (height)) | |
14090
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
854 && STRINGP (XCONS (XCONS (XCONS (object)->cdr)->cdr)->car) |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
855 && XINT (width) > 0 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
856 && XINT (height) > 0 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
857 /* The string must have enough bits for width * height. */ |
14090
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
858 && ((XSTRING (XCONS (XCONS (XCONS (object)->cdr)->cdr)->car)->size |
13363
941c37982f37
(BITS_PER_SHORT, BITS_PER_INT, BITS_PER_LONG):
Karl Heuer <kwzh@gnu.org>
parents:
12667
diff
changeset
|
859 * (BITS_PER_INT / sizeof (int))) |
9944
dd9afae74baf
(Fpixmap_spec_p): Avoid function calls and assignments as arguments to a
Karl Heuer <kwzh@gnu.org>
parents:
9902
diff
changeset
|
860 >= XFASTINT (width) * XFASTINT (height)))) |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
861 ? Qt : Qnil); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
862 } |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
863 |
24995 | 864 |
865 /* Load a bitmap according to NAME (which is either a file name or a | |
866 pixmap spec) for use on frame F. Value is the bitmap_id (see | |
867 xfns.c). If NAME is nil, return with a bitmap id of zero. If | |
868 bitmap cannot be loaded, display a message saying so, and return | |
869 zero. Store the bitmap width in *W_PTR and its height in *H_PTR, | |
870 if these pointers are not null. */ | |
871 | |
872 static int | |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
873 load_pixmap (f, name, w_ptr, h_ptr) |
9902
32ed712a45a3
(load_pixmap): Handle bitmap_id < 0. F is a FRAME_PTR.
Richard M. Stallman <rms@gnu.org>
parents:
9671
diff
changeset
|
874 FRAME_PTR f; |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
875 Lisp_Object name; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
876 unsigned int *w_ptr, *h_ptr; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
877 { |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
878 int bitmap_id; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
879 Lisp_Object tem; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
880 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
881 if (NILP (name)) |
24995 | 882 return 0; |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
883 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
884 tem = Fpixmap_spec_p (name); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
885 if (NILP (tem)) |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
886 wrong_type_argument (Qpixmap_spec_p, name); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
887 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
888 BLOCK_INPUT; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
889 if (CONSP (name)) |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
890 { |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
891 /* Decode a bitmap spec into a bitmap. */ |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
892 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
893 int h, w; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
894 Lisp_Object bits; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
895 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
896 w = XINT (Fcar (name)); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
897 h = XINT (Fcar (Fcdr (name))); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
898 bits = Fcar (Fcdr (Fcdr (name))); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
899 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
900 bitmap_id = x_create_bitmap_from_data (f, XSTRING (bits)->data, |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
901 w, h); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
902 } |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
903 else |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
904 { |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
905 /* It must be a string -- a file name. */ |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
906 bitmap_id = x_create_bitmap_from_file (f, name); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
907 } |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
908 UNBLOCK_INPUT; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
909 |
9902
32ed712a45a3
(load_pixmap): Handle bitmap_id < 0. F is a FRAME_PTR.
Richard M. Stallman <rms@gnu.org>
parents:
9671
diff
changeset
|
910 if (bitmap_id < 0) |
24995 | 911 { |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
912 add_to_log ("Invalid or undefined bitmap %s", name, Qnil); |
24995 | 913 bitmap_id = 0; |
914 | |
915 if (w_ptr) | |
916 *w_ptr = 0; | |
917 if (h_ptr) | |
918 *h_ptr = 0; | |
919 } | |
920 else | |
921 { | |
922 #if GLYPH_DEBUG | |
923 ++npixmaps_allocated; | |
924 #endif | |
925 if (w_ptr) | |
926 *w_ptr = x_bitmap_width (f, bitmap_id); | |
927 | |
928 if (h_ptr) | |
929 *h_ptr = x_bitmap_height (f, bitmap_id); | |
930 } | |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
931 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
932 return bitmap_id; |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
933 } |
9572 | 934 |
24995 | 935 #endif /* HAVE_X_WINDOWS */ |
936 | |
9572 | 937 |
2336 | 938 |
24995 | 939 /*********************************************************************** |
940 Minimum font bounds | |
941 ***********************************************************************/ | |
942 | |
9572 | 943 #ifdef HAVE_X_WINDOWS |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
944 |
25062
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
945 /* Update the line_height of frame F. Return non-zero if line height |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
946 changes. */ |
6768
0b61d2b74e64
(frame_update_line_height): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6615
diff
changeset
|
947 |
6879
471aebc1b151
(frame_update_line_height): Don't call x_set_window_size.
Richard M. Stallman <rms@gnu.org>
parents:
6784
diff
changeset
|
948 int |
6768
0b61d2b74e64
(frame_update_line_height): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6615
diff
changeset
|
949 frame_update_line_height (f) |
24995 | 950 struct frame *f; |
6768
0b61d2b74e64
(frame_update_line_height): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6615
diff
changeset
|
951 { |
25062
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
952 int fontset, line_height, changed_p; |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
953 |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
954 fontset = f->output_data.x->fontset; |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
955 if (fontset > 0) |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
956 line_height = FRAME_FONTSET_DATA (f)->fontset_table[fontset]->height; |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
957 else |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
958 line_height = FONT_HEIGHT (f->output_data.x->font); |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
959 |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
960 changed_p = line_height != f->output_data.x->line_height; |
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
961 f->output_data.x->line_height = line_height; |
24995 | 962 return changed_p; |
6768
0b61d2b74e64
(frame_update_line_height): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6615
diff
changeset
|
963 } |
24995 | 964 |
965 #endif /* HAVE_X_WINDOWS */ | |
966 | |
6784
d41c216ccd27
(frame_update_line_height): Check param_faces[i] not null.
Richard M. Stallman <rms@gnu.org>
parents:
6768
diff
changeset
|
967 |
24995 | 968 /*********************************************************************** |
969 Fonts | |
970 ***********************************************************************/ | |
971 | |
972 #ifdef HAVE_X_WINDOWS | |
973 | |
974 /* Load font or fontset of face FACE which is used on frame F. | |
975 FONTSET is the fontset FACE should use or -1, if FACE doesn't use a | |
976 fontset. FONT_NAME is the name of the font to load, if no fontset | |
977 is used. It is null if no suitable font name could be determined | |
978 for the face. */ | |
6784
d41c216ccd27
(frame_update_line_height): Check param_faces[i] not null.
Richard M. Stallman <rms@gnu.org>
parents:
6768
diff
changeset
|
979 |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
980 static void |
24995 | 981 load_face_font_or_fontset (f, face, font_name, fontset) |
982 struct frame *f; | |
983 struct face *face; | |
984 char *font_name; | |
985 int fontset; | |
986 { | |
987 struct font_info *font_info = NULL; | |
988 | |
989 face->font_info_id = -1; | |
990 face->fontset = fontset; | |
991 face->font = NULL; | |
992 | |
993 BLOCK_INPUT; | |
994 if (fontset >= 0) | |
995 font_info = FS_LOAD_FONT (f, FRAME_X_FONT_TABLE (f), CHARSET_ASCII, | |
996 NULL, fontset); | |
997 else if (font_name) | |
998 font_info = FS_LOAD_FONT (f, FRAME_X_FONT_TABLE (f), face->charset, | |
999 font_name, -1); | |
1000 UNBLOCK_INPUT; | |
1001 | |
1002 if (font_info) | |
1003 { | |
1004 char *s; | |
1005 int i; | |
1006 | |
1007 face->font_info_id = FONT_INFO_ID (f, font_info); | |
1008 face->font = font_info->font; | |
1009 face->font_name = font_info->full_name; | |
1010 | |
1011 /* Make the registry part of the font name readily accessible. | |
1012 The registry is used to find suitable faces for unibyte text. */ | |
1013 s = font_info->full_name + strlen (font_info->full_name); | |
1014 i = 0; | |
1015 while (i < 2 && --s >= font_info->full_name) | |
1016 if (*s == '-') | |
1017 ++i; | |
1018 | |
1019 if (!STRINGP (face->registry) | |
1020 || xstricmp (XSTRING (face->registry)->data, s + 1) != 0) | |
1021 { | |
1022 if (STRINGP (Vface_default_registry) | |
1023 && !xstricmp (XSTRING (Vface_default_registry)->data, s + 1)) | |
1024 face->registry = Vface_default_registry; | |
1025 else | |
1026 face->registry = build_string (s + 1); | |
1027 } | |
1028 } | |
1029 else if (fontset >= 0) | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
1030 add_to_log ("Unable to load ASCII font of fontset %d", |
25301
2042c4a224ad
(add_to_log): Renamed from display_message.
Gerd Moellmann <gerd@gnu.org>
parents:
25270
diff
changeset
|
1031 make_number (fontset), Qnil); |
24995 | 1032 else if (font_name) |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
1033 add_to_log ("Unable to load font %s", |
25301
2042c4a224ad
(add_to_log): Renamed from display_message.
Gerd Moellmann <gerd@gnu.org>
parents:
25270
diff
changeset
|
1034 build_string (font_name), Qnil); |
24995 | 1035 } |
1036 | |
1037 #endif /* HAVE_X_WINDOWS */ | |
1038 | |
1039 | |
1040 | |
1041 /*********************************************************************** | |
1042 X Colors | |
1043 ***********************************************************************/ | |
1044 | |
1045 #ifdef HAVE_X_WINDOWS | |
1046 | |
1047 /* Return non-zero if COLOR_NAME is a shade of gray (or white or | |
1048 black) on frame F. The algorithm is taken from 20.2 faces.el. */ | |
1049 | |
1050 static int | |
1051 face_color_gray_p (f, color_name) | |
1052 struct frame *f; | |
1053 char *color_name; | |
1054 { | |
1055 XColor color; | |
1056 int gray_p; | |
1057 | |
1058 if (defined_color (f, color_name, &color, 0)) | |
1059 gray_p = ((abs (color.red - color.green) | |
1060 < max (color.red, color.green) / 20) | |
1061 && (abs (color.green - color.blue) | |
1062 < max (color.green, color.blue) / 20) | |
1063 && (abs (color.blue - color.red) | |
1064 < max (color.blue, color.red) / 20)); | |
1065 else | |
1066 gray_p = 0; | |
1067 | |
1068 return gray_p; | |
1069 } | |
1070 | |
1071 | |
1072 /* Return non-zero if color COLOR_NAME can be displayed on frame F. | |
1073 BACKGROUND_P non-zero means the color will be used as background | |
1074 color. */ | |
1075 | |
1076 static int | |
1077 face_color_supported_p (f, color_name, background_p) | |
1078 struct frame *f; | |
1079 char *color_name; | |
1080 int background_p; | |
1081 { | |
1082 Lisp_Object frame; | |
1083 | |
1084 XSETFRAME (frame, f); | |
1085 return (!NILP (Vwindow_system) | |
1086 && (!NILP (Fx_display_color_p (frame)) | |
1087 || xstricmp (color_name, "black") == 0 | |
1088 || xstricmp (color_name, "white") == 0 | |
1089 || (background_p | |
1090 && face_color_gray_p (f, color_name)) | |
1091 || (!NILP (Fx_display_grayscale_p (frame)) | |
1092 && face_color_gray_p (f, color_name)))); | |
1093 } | |
1094 | |
1095 | |
1096 DEFUN ("face-color-gray-p", Fface_color_gray_p, Sface_color_gray_p, 1, 2, 0, | |
1097 "Return non-nil if COLOR is a shade of gray (or white or black).\n\ | |
1098 FRAME specifies the frame and thus the display for interpreting COLOR.\n\ | |
1099 If FRAME is nil or omitted, use the selected frame.") | |
1100 (color, frame) | |
1101 Lisp_Object color, frame; | |
1102 { | |
1103 struct frame *f = check_x_frame (frame); | |
1104 CHECK_STRING (color, 0); | |
1105 return face_color_gray_p (f, XSTRING (color)->data) ? Qt : Qnil; | |
1106 } | |
1107 | |
1108 | |
1109 DEFUN ("face-color-supported-p", Fface_color_supported_p, | |
1110 Sface_color_supported_p, 2, 3, 0, | |
1111 "Return non-nil if COLOR can be displayed on FRAME.\n\ | |
1112 BACKGROUND-P non-nil means COLOR is used as a background.\n\ | |
1113 If FRAME is nil or omitted, use the selected frame.\n\ | |
1114 COLOR must be a valid color name.") | |
1115 (frame, color, background_p) | |
1116 Lisp_Object frame, color, background_p; | |
1117 { | |
1118 struct frame *f = check_x_frame (frame); | |
1119 CHECK_STRING (color, 0); | |
1120 if (face_color_supported_p (f, XSTRING (color)->data, !NILP (background_p))) | |
1121 return Qt; | |
1122 return Qnil; | |
1123 } | |
1124 | |
1125 /* Load color with name NAME for use by face FACE on frame F. | |
1126 TARGET_INDEX must be one of LFACE_FOREGROUND_INDEX, | |
1127 LFACE_BACKGROUND_INDEX, LFACE_UNDERLINE_INDEX, LFACE_OVERLINE_INDEX, | |
1128 LFACE_STRIKE_THROUGH_INDEX, or LFACE_BOX_INDEX. Value is the | |
1129 pixel color. If color cannot be loaded, display a message, and | |
1130 return the foreground, background or underline color of F, but | |
1131 record that fact in flags of the face so that we don't try to free | |
1132 these colors. */ | |
1133 | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1134 unsigned long |
24995 | 1135 load_color (f, face, name, target_index) |
1136 struct frame *f; | |
1137 struct face *face; | |
1138 Lisp_Object name; | |
1139 enum lface_attribute_index target_index; | |
1140 { | |
1141 XColor color; | |
1142 | |
1143 xassert (STRINGP (name)); | |
1144 xassert (target_index == LFACE_FOREGROUND_INDEX | |
1145 || target_index == LFACE_BACKGROUND_INDEX | |
1146 || target_index == LFACE_UNDERLINE_INDEX | |
1147 || target_index == LFACE_OVERLINE_INDEX | |
1148 || target_index == LFACE_STRIKE_THROUGH_INDEX | |
1149 || target_index == LFACE_BOX_INDEX); | |
1150 | |
1151 /* if the color map is full, defined_color will return a best match | |
1152 to the values in an existing cell. */ | |
1153 if (!defined_color (f, XSTRING (name)->data, &color, 1)) | |
1154 { | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
1155 add_to_log ("Unable to load color %s", name, Qnil); |
24995 | 1156 |
1157 switch (target_index) | |
1158 { | |
1159 case LFACE_FOREGROUND_INDEX: | |
1160 face->foreground_defaulted_p = 1; | |
1161 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1162 break; | |
1163 | |
1164 case LFACE_BACKGROUND_INDEX: | |
1165 face->background_defaulted_p = 1; | |
1166 color.pixel = FRAME_BACKGROUND_PIXEL (f); | |
1167 break; | |
1168 | |
1169 case LFACE_UNDERLINE_INDEX: | |
1170 face->underline_defaulted_p = 1; | |
1171 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1172 break; | |
1173 | |
1174 case LFACE_OVERLINE_INDEX: | |
1175 face->overline_color_defaulted_p = 1; | |
1176 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1177 break; | |
1178 | |
1179 case LFACE_STRIKE_THROUGH_INDEX: | |
1180 face->strike_through_color_defaulted_p = 1; | |
1181 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1182 break; | |
1183 | |
1184 case LFACE_BOX_INDEX: | |
1185 face->box_color_defaulted_p = 1; | |
1186 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1187 break; | |
1188 | |
1189 default: | |
1190 abort (); | |
1191 } | |
1192 } | |
1193 #if GLYPH_DEBUG | |
1194 else | |
1195 ++ncolors_allocated; | |
1196 #endif | |
1197 | |
1198 return color.pixel; | |
1199 } | |
1200 | |
1201 | |
1202 /* Load colors for face FACE which is used on frame F. Colors are | |
1203 specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX | |
1204 of ATTRS. If the background color specified is not supported on F, | |
1205 try to emulate gray colors with a stipple from Vface_default_stipple. */ | |
1206 | |
1207 static void | |
1208 load_face_colors (f, face, attrs) | |
1209 struct frame *f; | |
1210 struct face *face; | |
1211 Lisp_Object *attrs; | |
1212 { | |
1213 Lisp_Object fg, bg; | |
1214 | |
1215 bg = attrs[LFACE_BACKGROUND_INDEX]; | |
1216 fg = attrs[LFACE_FOREGROUND_INDEX]; | |
1217 | |
1218 /* Swap colors if face is inverse-video. */ | |
1219 if (EQ (attrs[LFACE_INVERSE_INDEX], Qt)) | |
1220 { | |
1221 Lisp_Object tmp; | |
1222 tmp = fg; | |
1223 fg = bg; | |
1224 bg = tmp; | |
1225 } | |
1226 | |
1227 /* Check for support for foreground, not for background because | |
1228 face_color_supported_p is smart enough to know that grays are | |
1229 "supported" as background because we are supposed to use stipple | |
1230 for them. */ | |
1231 if (!face_color_supported_p (f, XSTRING (bg)->data, 0) | |
1232 && !NILP (Fpixmap_spec_p (Vface_default_stipple))) | |
1233 { | |
1234 x_destroy_bitmap (f, face->stipple); | |
1235 face->stipple = load_pixmap (f, Vface_default_stipple, | |
1236 &face->pixmap_w, &face->pixmap_h); | |
1237 } | |
25092
79a5a567bdb0
(prepare_face_for_display): Use FillOpaqueStippled instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25062
diff
changeset
|
1238 |
79a5a567bdb0
(prepare_face_for_display): Use FillOpaqueStippled instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25062
diff
changeset
|
1239 face->background = load_color (f, face, bg, LFACE_BACKGROUND_INDEX); |
24995 | 1240 face->foreground = load_color (f, face, fg, LFACE_FOREGROUND_INDEX); |
1241 } | |
1242 | |
1243 | |
1244 /* Free color PIXEL on frame F. */ | |
1245 | |
1246 void | |
1247 unload_color (f, pixel) | |
1248 struct frame *f; | |
1249 unsigned long pixel; | |
1250 { | |
1251 Display *dpy = FRAME_X_DISPLAY (f); | |
1252 int class = FRAME_X_DISPLAY_INFO (f)->visual->class; | |
1253 | |
1254 if (pixel == BLACK_PIX_DEFAULT (f) | |
1255 || pixel == WHITE_PIX_DEFAULT (f)) | |
1256 return; | |
1257 | |
1258 BLOCK_INPUT; | |
1259 | |
1260 /* If display has an immutable color map, freeing colors is not | |
1261 necessary and some servers don't allow it. So don't do it. */ | |
1262 if (! (class == StaticColor || class == StaticGray || class == TrueColor)) | |
1263 { | |
1264 Colormap cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | |
1265 XFreeColors (dpy, cmap, &pixel, 1, 0); | |
1266 } | |
1267 | |
1268 UNBLOCK_INPUT; | |
1269 } | |
1270 | |
1271 | |
1272 /* Free colors allocated for FACE. */ | |
1273 | |
1274 static void | |
1275 free_face_colors (f, face) | |
1276 struct frame *f; | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
1277 struct face *face; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
1278 { |
24995 | 1279 int class = FRAME_X_DISPLAY_INFO (f)->visual->class; |
1280 | |
1281 /* If display has an immutable color map, freeing colors is not | |
1282 necessary and some servers don't allow it. So don't do it. */ | |
1283 if (class != StaticColor | |
1284 && class != StaticGray | |
1285 && class != TrueColor) | |
1286 { | |
1287 Display *dpy; | |
1288 Colormap cmap; | |
1289 | |
1290 BLOCK_INPUT; | |
1291 dpy = FRAME_X_DISPLAY (f); | |
1292 cmap = DefaultColormapOfScreen (FRAME_X_SCREEN (f)); | |
1293 | |
1294 if (face->foreground != BLACK_PIX_DEFAULT (f) | |
1295 && face->foreground != WHITE_PIX_DEFAULT (f) | |
1296 && !face->foreground_defaulted_p) | |
1297 { | |
1298 XFreeColors (dpy, cmap, &face->foreground, 1, 0); | |
1299 IF_DEBUG (--ncolors_allocated); | |
1300 } | |
1301 | |
1302 if (face->background != BLACK_PIX_DEFAULT (f) | |
1303 && face->background != WHITE_PIX_DEFAULT (f) | |
1304 && !face->background_defaulted_p) | |
1305 { | |
1306 XFreeColors (dpy, cmap, &face->background, 1, 0); | |
1307 IF_DEBUG (--ncolors_allocated); | |
1308 } | |
1309 | |
1310 if (face->underline_p | |
1311 && !face->underline_defaulted_p | |
1312 && face->underline_color != BLACK_PIX_DEFAULT (f) | |
1313 && face->underline_color != WHITE_PIX_DEFAULT (f)) | |
1314 { | |
1315 XFreeColors (dpy, cmap, &face->underline_color, 1, 0); | |
1316 IF_DEBUG (--ncolors_allocated); | |
1317 } | |
1318 | |
1319 if (face->overline_p | |
1320 && !face->overline_color_defaulted_p | |
1321 && face->overline_color != BLACK_PIX_DEFAULT (f) | |
1322 && face->overline_color != WHITE_PIX_DEFAULT (f)) | |
1323 { | |
1324 XFreeColors (dpy, cmap, &face->overline_color, 1, 0); | |
1325 IF_DEBUG (--ncolors_allocated); | |
1326 } | |
1327 | |
1328 if (face->strike_through_p | |
1329 && !face->strike_through_color_defaulted_p | |
1330 && face->strike_through_color != BLACK_PIX_DEFAULT (f) | |
1331 && face->strike_through_color != WHITE_PIX_DEFAULT (f)) | |
1332 { | |
1333 XFreeColors (dpy, cmap, &face->strike_through_color, 1, 0); | |
1334 IF_DEBUG (--ncolors_allocated); | |
1335 } | |
1336 | |
1337 if (face->box != FACE_NO_BOX | |
1338 && !face->box_color_defaulted_p | |
1339 && face->box_color != BLACK_PIX_DEFAULT (f) | |
1340 && face->box_color != WHITE_PIX_DEFAULT (f)) | |
1341 { | |
1342 XFreeColors (dpy, cmap, &face->box_color, 1, 0); | |
1343 IF_DEBUG (--ncolors_allocated); | |
1344 } | |
1345 | |
1346 UNBLOCK_INPUT; | |
1347 } | |
1348 } | |
1349 | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1350 #else /* ! HAVE_X_WINDOWS */ |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1351 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1352 #ifdef MSDOS |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1353 unsigned long |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1354 load_color (f, face, name, target_index) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1355 struct frame *f; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1356 struct face *face; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1357 Lisp_Object name; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1358 enum lface_attribute_index target_index; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1359 { |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1360 Lisp_Object color; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1361 int color_idx = FACE_TTY_DEFAULT_COLOR; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1362 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1363 if (NILP (name)) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1364 return (unsigned long)FACE_TTY_DEFAULT_COLOR; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1365 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1366 CHECK_STRING (name, 0); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1367 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1368 color = Qnil; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1369 if (XSTRING (name)->size && !NILP (Ffboundp (Qmsdos_color_translate))) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1370 { |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1371 color = call1 (Qmsdos_color_translate, name); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1372 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1373 if (INTEGERP (color)) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1374 return (unsigned long)XINT (color); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1375 |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
1376 add_to_log ("Unable to load color %s", name, Qnil); |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1377 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1378 switch (target_index) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1379 { |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1380 case LFACE_FOREGROUND_INDEX: |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1381 face->foreground_defaulted_p = 1; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1382 color_idx = FRAME_FOREGROUND_PIXEL (f); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1383 break; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1384 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1385 case LFACE_BACKGROUND_INDEX: |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1386 face->background_defaulted_p = 1; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1387 color_idx = FRAME_BACKGROUND_PIXEL (f); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1388 break; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1389 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1390 case LFACE_UNDERLINE_INDEX: |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1391 face->underline_defaulted_p = 1; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1392 color_idx = FRAME_FOREGROUND_PIXEL (f); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1393 break; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1394 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1395 case LFACE_OVERLINE_INDEX: |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1396 face->overline_color_defaulted_p = 1; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1397 color_idx = FRAME_FOREGROUND_PIXEL (f); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1398 break; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1399 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1400 case LFACE_STRIKE_THROUGH_INDEX: |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1401 face->strike_through_color_defaulted_p = 1; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1402 color_idx = FRAME_FOREGROUND_PIXEL (f); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1403 break; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1404 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1405 case LFACE_BOX_INDEX: |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1406 face->box_color_defaulted_p = 1; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1407 color_idx = FRAME_FOREGROUND_PIXEL (f); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1408 break; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1409 } |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1410 } |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1411 else |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1412 color_idx = msdos_stdcolor_idx (XSTRING (name)->data); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1413 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1414 return (unsigned long)color_idx; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1415 } |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1416 #endif /* MSDOS */ |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1417 #endif /* ! HAVE_X_WINDOWS */ |
24995 | 1418 |
1419 | |
1420 | |
1421 /*********************************************************************** | |
1422 XLFD Font Names | |
1423 ***********************************************************************/ | |
1424 | |
1425 /* An enumerator for each field of an XLFD font name. */ | |
1426 | |
1427 enum xlfd_field | |
1428 { | |
1429 XLFD_FOUNDRY, | |
1430 XLFD_FAMILY, | |
1431 XLFD_WEIGHT, | |
1432 XLFD_SLANT, | |
1433 XLFD_SWIDTH, | |
1434 XLFD_ADSTYLE, | |
1435 XLFD_PIXEL_SIZE, | |
1436 XLFD_POINT_SIZE, | |
1437 XLFD_RESX, | |
1438 XLFD_RESY, | |
1439 XLFD_SPACING, | |
1440 XLFD_AVGWIDTH, | |
1441 XLFD_REGISTRY, | |
1442 XLFD_ENCODING, | |
1443 XLFD_LAST | |
1444 }; | |
1445 | |
1446 /* An enumerator for each possible slant value of a font. Taken from | |
1447 the XLFD specification. */ | |
1448 | |
1449 enum xlfd_slant | |
1450 { | |
1451 XLFD_SLANT_UNKNOWN, | |
1452 XLFD_SLANT_ROMAN, | |
1453 XLFD_SLANT_ITALIC, | |
1454 XLFD_SLANT_OBLIQUE, | |
1455 XLFD_SLANT_REVERSE_ITALIC, | |
1456 XLFD_SLANT_REVERSE_OBLIQUE, | |
1457 XLFD_SLANT_OTHER | |
1458 }; | |
1459 | |
1460 /* Relative font weight according to XLFD documentation. */ | |
1461 | |
1462 enum xlfd_weight | |
1463 { | |
1464 XLFD_WEIGHT_UNKNOWN, | |
1465 XLFD_WEIGHT_ULTRA_LIGHT, /* 10 */ | |
1466 XLFD_WEIGHT_EXTRA_LIGHT, /* 20 */ | |
1467 XLFD_WEIGHT_LIGHT, /* 30 */ | |
1468 XLFD_WEIGHT_SEMI_LIGHT, /* 40: SemiLight, Book, ... */ | |
1469 XLFD_WEIGHT_MEDIUM, /* 50: Medium, Normal, Regular, ... */ | |
1470 XLFD_WEIGHT_SEMI_BOLD, /* 60: SemiBold, DemiBold, ... */ | |
1471 XLFD_WEIGHT_BOLD, /* 70: Bold, ... */ | |
1472 XLFD_WEIGHT_EXTRA_BOLD, /* 80: ExtraBold, Heavy, ... */ | |
1473 XLFD_WEIGHT_ULTRA_BOLD /* 90: UltraBold, Black, ... */ | |
1474 }; | |
1475 | |
1476 /* Relative proportionate width. */ | |
1477 | |
1478 enum xlfd_swidth | |
1479 { | |
1480 XLFD_SWIDTH_UNKNOWN, | |
1481 XLFD_SWIDTH_ULTRA_CONDENSED, /* 10 */ | |
1482 XLFD_SWIDTH_EXTRA_CONDENSED, /* 20 */ | |
1483 XLFD_SWIDTH_CONDENSED, /* 30: Condensed, Narrow, Compressed, ... */ | |
1484 XLFD_SWIDTH_SEMI_CONDENSED, /* 40: semicondensed */ | |
1485 XLFD_SWIDTH_MEDIUM, /* 50: Medium, Normal, Regular, ... */ | |
1486 XLFD_SWIDTH_SEMI_EXPANDED, /* 60: SemiExpanded, DemiExpanded, ... */ | |
1487 XLFD_SWIDTH_EXPANDED, /* 70: Expanded... */ | |
1488 XLFD_SWIDTH_EXTRA_EXPANDED, /* 80: ExtraExpanded, Wide... */ | |
1489 XLFD_SWIDTH_ULTRA_EXPANDED /* 90: UltraExpanded... */ | |
1490 }; | |
1491 | |
1492 /* Structure used for tables mapping XLFD weight, slant, and width | |
1493 names to numeric and symbolic values. */ | |
1494 | |
1495 struct table_entry | |
1496 { | |
1497 char *name; | |
1498 int numeric; | |
1499 Lisp_Object *symbol; | |
1500 }; | |
1501 | |
1502 /* Table of XLFD slant names and their numeric and symbolic | |
1503 representations. This table must be sorted by slant names in | |
1504 ascending order. */ | |
1505 | |
1506 static struct table_entry slant_table[] = | |
1507 { | |
1508 {"i", XLFD_SLANT_ITALIC, &Qitalic}, | |
1509 {"o", XLFD_SLANT_OBLIQUE, &Qoblique}, | |
1510 {"ot", XLFD_SLANT_OTHER, &Qitalic}, | |
1511 {"r", XLFD_SLANT_ROMAN, &Qnormal}, | |
1512 {"ri", XLFD_SLANT_REVERSE_ITALIC, &Qreverse_italic}, | |
1513 {"ro", XLFD_SLANT_REVERSE_OBLIQUE, &Qreverse_oblique} | |
1514 }; | |
1515 | |
1516 /* Table of XLFD weight names. This table must be sorted by weight | |
1517 names in ascending order. */ | |
1518 | |
1519 static struct table_entry weight_table[] = | |
1520 { | |
1521 {"black", XLFD_WEIGHT_ULTRA_BOLD, &Qultra_bold}, | |
1522 {"bold", XLFD_WEIGHT_BOLD, &Qbold}, | |
1523 {"book", XLFD_WEIGHT_SEMI_LIGHT, &Qsemi_light}, | |
1524 {"demibold", XLFD_WEIGHT_SEMI_BOLD, &Qsemi_bold}, | |
1525 {"extralight", XLFD_WEIGHT_EXTRA_LIGHT, &Qextra_light}, | |
1526 {"extrabold", XLFD_WEIGHT_EXTRA_BOLD, &Qextra_bold}, | |
1527 {"heavy", XLFD_WEIGHT_EXTRA_BOLD, &Qextra_bold}, | |
1528 {"light", XLFD_WEIGHT_LIGHT, &Qlight}, | |
1529 {"medium", XLFD_WEIGHT_MEDIUM, &Qnormal}, | |
1530 {"normal", XLFD_WEIGHT_MEDIUM, &Qnormal}, | |
1531 {"regular", XLFD_WEIGHT_MEDIUM, &Qnormal}, | |
1532 {"semibold", XLFD_WEIGHT_SEMI_BOLD, &Qsemi_bold}, | |
1533 {"semilight", XLFD_WEIGHT_SEMI_LIGHT, &Qsemi_light}, | |
1534 {"ultralight", XLFD_WEIGHT_ULTRA_LIGHT, &Qultra_light}, | |
1535 {"ultrabold", XLFD_WEIGHT_ULTRA_BOLD, &Qultra_bold} | |
1536 }; | |
1537 | |
1538 /* Table of XLFD width names. This table must be sorted by width | |
1539 names in ascending order. */ | |
1540 | |
1541 static struct table_entry swidth_table[] = | |
1542 { | |
1543 {"compressed", XLFD_SWIDTH_CONDENSED, &Qcondensed}, | |
1544 {"condensed", XLFD_SWIDTH_CONDENSED, &Qcondensed}, | |
1545 {"demiexpanded", XLFD_SWIDTH_SEMI_EXPANDED, &Qsemi_expanded}, | |
1546 {"expanded", XLFD_SWIDTH_EXPANDED, &Qexpanded}, | |
1547 {"extracondensed", XLFD_SWIDTH_EXTRA_CONDENSED, &Qextra_condensed}, | |
1548 {"extraexpanded", XLFD_SWIDTH_EXTRA_EXPANDED, &Qextra_expanded}, | |
1549 {"medium", XLFD_SWIDTH_MEDIUM, &Qnormal}, | |
1550 {"narrow", XLFD_SWIDTH_CONDENSED, &Qcondensed}, | |
1551 {"normal", XLFD_SWIDTH_MEDIUM, &Qnormal}, | |
1552 {"regular", XLFD_SWIDTH_MEDIUM, &Qnormal}, | |
1553 {"semicondensed", XLFD_SWIDTH_SEMI_CONDENSED, &Qsemi_condensed}, | |
1554 {"semiexpanded", XLFD_SWIDTH_SEMI_EXPANDED, &Qsemi_expanded}, | |
1555 {"ultracondensed", XLFD_SWIDTH_ULTRA_CONDENSED, &Qultra_condensed}, | |
1556 {"ultraexpanded", XLFD_SWIDTH_ULTRA_EXPANDED, &Qultra_expanded}, | |
1557 {"wide", XLFD_SWIDTH_EXTRA_EXPANDED, &Qextra_expanded} | |
1558 }; | |
1559 | |
1560 /* Structure used to hold the result of splitting font names in XLFD | |
1561 format into their fields. */ | |
1562 | |
1563 struct font_name | |
1564 { | |
1565 /* The original name which is modified destructively by | |
1566 split_font_name. The pointer is kept here to be able to free it | |
1567 if it was allocated from the heap. */ | |
1568 char *name; | |
1569 | |
1570 /* Font name fields. Each vector element points into `name' above. | |
1571 Fields are NUL-terminated. */ | |
1572 char *fields[XLFD_LAST]; | |
1573 | |
1574 /* Numeric values for those fields that interest us. See | |
1575 split_font_name for which these are. */ | |
1576 int numeric[XLFD_LAST]; | |
1577 }; | |
1578 | |
1579 /* The frame in effect when sorting font names. Set temporarily in | |
1580 sort_fonts so that it is available in font comparison functions. */ | |
1581 | |
1582 static struct frame *font_frame; | |
1583 | |
1584 /* Order by which font selection chooses fonts. The default values | |
1585 mean `first, find a best match for the font width, then for the | |
1586 font height, then for weight, then for slant.' This variable can be | |
1587 set via set-face-font-sort-order. */ | |
1588 | |
1589 static int font_sort_order[4]; | |
1590 | |
1591 | |
1592 /* Look up FONT.fields[FIELD_INDEX] in TABLE which has DIM entries. | |
1593 TABLE must be sorted by TABLE[i]->name in ascending order. Value | |
1594 is a pointer to the matching table entry or null if no table entry | |
1595 matches. */ | |
1596 | |
1597 static struct table_entry * | |
1598 xlfd_lookup_field_contents (table, dim, font, field_index) | |
1599 struct table_entry *table; | |
1600 int dim; | |
1601 struct font_name *font; | |
1602 int field_index; | |
1603 { | |
1604 /* Function split_font_name converts fields to lower-case, so there | |
1605 is no need to use xstrlwr or xstricmp here. */ | |
1606 char *s = font->fields[field_index]; | |
1607 int low, mid, high, cmp; | |
1608 | |
1609 low = 0; | |
1610 high = dim - 1; | |
1611 | |
1612 while (low <= high) | |
1613 { | |
1614 mid = (low + high) / 2; | |
1615 cmp = strcmp (table[mid].name, s); | |
1616 | |
1617 if (cmp < 0) | |
1618 low = mid + 1; | |
1619 else if (cmp > 0) | |
1620 high = mid - 1; | |
1621 else | |
1622 return table + mid; | |
1623 } | |
1624 | |
1625 return NULL; | |
1626 } | |
1627 | |
1628 | |
1629 /* Return a numeric representation for font name field | |
1630 FONT.fields[FIELD_INDEX]. The field is looked up in TABLE which | |
1631 has DIM entries. Value is the numeric value found or DFLT if no | |
1632 table entry matches. This function is used to translate weight, | |
1633 slant, and swidth names of XLFD font names to numeric values. */ | |
1634 | |
1635 static INLINE int | |
1636 xlfd_numeric_value (table, dim, font, field_index, dflt) | |
1637 struct table_entry *table; | |
1638 int dim; | |
1639 struct font_name *font; | |
1640 int field_index; | |
1641 int dflt; | |
1642 { | |
1643 struct table_entry *p; | |
1644 p = xlfd_lookup_field_contents (table, dim, font, field_index); | |
1645 return p ? p->numeric : dflt; | |
1646 } | |
1647 | |
1648 | |
1649 /* Return a symbolic representation for font name field | |
1650 FONT.fields[FIELD_INDEX]. The field is looked up in TABLE which | |
1651 has DIM entries. Value is the symbolic value found or DFLT if no | |
1652 table entry matches. This function is used to translate weight, | |
1653 slant, and swidth names of XLFD font names to symbols. */ | |
1654 | |
1655 static INLINE Lisp_Object | |
1656 xlfd_symbolic_value (table, dim, font, field_index, dflt) | |
1657 struct table_entry *table; | |
1658 int dim; | |
1659 struct font_name *font; | |
1660 int field_index; | |
1661 int dflt; | |
1662 { | |
1663 struct table_entry *p; | |
1664 p = xlfd_lookup_field_contents (table, dim, font, field_index); | |
1665 return p ? *p->symbol : dflt; | |
1666 } | |
1667 | |
1668 | |
1669 /* Return a numeric value for the slant of the font given by FONT. */ | |
1670 | |
1671 static INLINE int | |
1672 xlfd_numeric_slant (font) | |
1673 struct font_name *font; | |
1674 { | |
1675 return xlfd_numeric_value (slant_table, DIM (slant_table), | |
1676 font, XLFD_SLANT, XLFD_SLANT_ROMAN); | |
1677 } | |
1678 | |
1679 | |
1680 /* Return a symbol representing the weight of the font given by FONT. */ | |
1681 | |
1682 static INLINE Lisp_Object | |
1683 xlfd_symbolic_slant (font) | |
1684 struct font_name *font; | |
1685 { | |
1686 return xlfd_symbolic_value (slant_table, DIM (slant_table), | |
1687 font, XLFD_SLANT, Qnormal); | |
1688 } | |
1689 | |
1690 | |
1691 /* Return a numeric value for the weight of the font given by FONT. */ | |
1692 | |
1693 static INLINE int | |
1694 xlfd_numeric_weight (font) | |
1695 struct font_name *font; | |
1696 { | |
1697 return xlfd_numeric_value (weight_table, DIM (weight_table), | |
1698 font, XLFD_WEIGHT, XLFD_WEIGHT_MEDIUM); | |
1699 } | |
1700 | |
1701 | |
1702 /* Return a symbol representing the slant of the font given by FONT. */ | |
1703 | |
1704 static INLINE Lisp_Object | |
1705 xlfd_symbolic_weight (font) | |
1706 struct font_name *font; | |
1707 { | |
1708 return xlfd_symbolic_value (weight_table, DIM (weight_table), | |
1709 font, XLFD_WEIGHT, Qnormal); | |
1710 } | |
1711 | |
1712 | |
1713 /* Return a numeric value for the swidth of the font whose XLFD font | |
1714 name fields are found in FONT. */ | |
1715 | |
1716 static INLINE int | |
1717 xlfd_numeric_swidth (font) | |
1718 struct font_name *font; | |
1719 { | |
1720 return xlfd_numeric_value (swidth_table, DIM (swidth_table), | |
1721 font, XLFD_SWIDTH, XLFD_SWIDTH_MEDIUM); | |
1722 } | |
1723 | |
1724 | |
1725 /* Return a symbolic value for the swidth of FONT. */ | |
1726 | |
1727 static INLINE Lisp_Object | |
1728 xlfd_symbolic_swidth (font) | |
1729 struct font_name *font; | |
1730 { | |
1731 return xlfd_symbolic_value (swidth_table, DIM (swidth_table), | |
1732 font, XLFD_SWIDTH, Qnormal); | |
1733 } | |
1734 | |
1735 | |
1736 /* Look up the entry of SYMBOL in the vector TABLE which has DIM | |
1737 entries. Value is a pointer to the matching table entry or null if | |
1738 no element of TABLE contains SYMBOL. */ | |
1739 | |
1740 static struct table_entry * | |
1741 face_value (table, dim, symbol) | |
1742 struct table_entry *table; | |
1743 int dim; | |
1744 Lisp_Object symbol; | |
1745 { | |
1746 int i; | |
1747 | |
1748 xassert (SYMBOLP (symbol)); | |
1749 | |
1750 for (i = 0; i < dim; ++i) | |
1751 if (EQ (*table[i].symbol, symbol)) | |
1752 break; | |
1753 | |
1754 return i < dim ? table + i : NULL; | |
1755 } | |
1756 | |
1757 | |
1758 /* Return a numeric value for SYMBOL in the vector TABLE which has DIM | |
1759 entries. Value is -1 if SYMBOL is not found in TABLE. */ | |
1760 | |
1761 static INLINE int | |
1762 face_numeric_value (table, dim, symbol) | |
1763 struct table_entry *table; | |
1764 int dim; | |
1765 Lisp_Object symbol; | |
1766 { | |
1767 struct table_entry *p = face_value (table, dim, symbol); | |
1768 return p ? p->numeric : -1; | |
1769 } | |
1770 | |
1771 | |
1772 /* Return a numeric value representing the weight specified by Lisp | |
1773 symbol WEIGHT. Value is one of the enumerators of enum | |
1774 xlfd_weight. */ | |
1775 | |
1776 static INLINE int | |
1777 face_numeric_weight (weight) | |
1778 Lisp_Object weight; | |
1779 { | |
1780 return face_numeric_value (weight_table, DIM (weight_table), weight); | |
1781 } | |
1782 | |
1783 | |
1784 /* Return a numeric value representing the slant specified by Lisp | |
1785 symbol SLANT. Value is one of the enumerators of enum xlfd_slant. */ | |
1786 | |
1787 static INLINE int | |
1788 face_numeric_slant (slant) | |
1789 Lisp_Object slant; | |
1790 { | |
1791 return face_numeric_value (slant_table, DIM (slant_table), slant); | |
1792 } | |
1793 | |
1794 | |
1795 /* Return a numeric value representing the swidth specified by Lisp | |
1796 symbol WIDTH. Value is one of the enumerators of enum xlfd_swidth. */ | |
1797 | |
1798 static int | |
1799 face_numeric_swidth (width) | |
1800 Lisp_Object width; | |
1801 { | |
1802 return face_numeric_value (swidth_table, DIM (swidth_table), width); | |
1803 } | |
1804 | |
1805 | |
1806 #ifdef HAVE_X_WINDOWS | |
1807 | |
1808 /* Return non-zero if FONT is the name of a fixed-pitch font. */ | |
1809 | |
1810 static INLINE int | |
1811 xlfd_fixed_p (font) | |
1812 struct font_name *font; | |
1813 { | |
1814 /* Function split_font_name converts fields to lower-case, so there | |
1815 is no need to use tolower here. */ | |
1816 return *font->fields[XLFD_SPACING] != 'p'; | |
1817 } | |
1818 | |
1819 | |
1820 /* Return the point size of FONT on frame F, measured in 1/10 pt. | |
1821 | |
1822 The actual height of the font when displayed on F depends on the | |
1823 resolution of both the font and frame. For example, a 10pt font | |
1824 designed for a 100dpi display will display larger than 10pt on a | |
1825 75dpi display. (It's not unusual to use fonts not designed for the | |
1826 display one is using. For example, some intlfonts are available in | |
1827 72dpi versions, only.) | |
1828 | |
1829 Value is the real point size of FONT on frame F, or 0 if it cannot | |
1830 be determined. */ | |
1831 | |
1832 static INLINE int | |
1833 xlfd_point_size (f, font) | |
1834 struct frame *f; | |
1835 struct font_name *font; | |
1836 { | |
1837 double resy = FRAME_X_DISPLAY_INFO (f)->resy; | |
1838 double font_resy = atoi (font->fields[XLFD_RESY]); | |
1839 double font_pt = atoi (font->fields[XLFD_POINT_SIZE]); | |
1840 int real_pt; | |
1841 | |
1842 if (font_resy == 0 || font_pt == 0) | |
1843 real_pt = 0; | |
1844 else | |
1845 real_pt = (font_resy / resy) * font_pt + 0.5; | |
1846 | |
1847 return real_pt; | |
1848 } | |
1849 | |
1850 | |
1851 /* Split XLFD font name FONT->name destructively into NUL-terminated, | |
1852 lower-case fields in FONT->fields. NUMERIC_P non-zero means | |
1853 compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH, | |
1854 XLFD_RESY, XLFD_SLANT, and XLFD_WEIGHT in FONT->numeric. Value is | |
1855 zero if the font name doesn't have the format we expect. The | |
1856 expected format is a font name that starts with a `-' and has | |
1857 XLFD_LAST fields separated by `-'. (The XLFD specification allows | |
1858 forms of font names where certain field contents are enclosed in | |
1859 square brackets. We don't support that, for now. */ | |
1860 | |
1861 static int | |
1862 split_font_name (f, font, numeric_p) | |
1863 struct frame *f; | |
1864 struct font_name *font; | |
1865 int numeric_p; | |
1866 { | |
1867 int i = 0; | |
1868 int success_p; | |
1869 | |
1870 if (*font->name == '-') | |
1871 { | |
1872 char *p = xstrlwr (font->name) + 1; | |
1873 | |
1874 while (i < XLFD_LAST) | |
1875 { | |
1876 font->fields[i] = p; | |
1877 ++i; | |
1878 | |
1879 while (*p && *p != '-') | |
1880 ++p; | |
1881 | |
1882 if (*p != '-') | |
1883 break; | |
1884 | |
1885 *p++ = 0; | |
1886 } | |
1887 } | |
1888 | |
1889 success_p = i == XLFD_LAST; | |
1890 | |
1891 /* If requested, and font name was in the expected format, | |
1892 compute numeric values for some fields. */ | |
1893 if (numeric_p && success_p) | |
1894 { | |
1895 font->numeric[XLFD_POINT_SIZE] = xlfd_point_size (f, font); | |
1896 font->numeric[XLFD_RESY] = atoi (font->fields[XLFD_RESY]); | |
1897 font->numeric[XLFD_SLANT] = xlfd_numeric_slant (font); | |
1898 font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font); | |
1899 font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); | |
1900 } | |
1901 | |
1902 return success_p; | |
1903 } | |
1904 | |
1905 | |
1906 /* Build an XLFD font name from font name fields in FONT. Value is a | |
1907 pointer to the font name, which is allocated via xmalloc. */ | |
1908 | |
1909 static char * | |
1910 build_font_name (font) | |
1911 struct font_name *font; | |
1912 { | |
1913 int i; | |
1914 int size = 100; | |
1915 char *font_name = (char *) xmalloc (size); | |
1916 int total_length = 0; | |
1917 | |
1918 for (i = 0; i < XLFD_LAST; ++i) | |
1919 { | |
1920 /* Add 1 because of the leading `-'. */ | |
1921 int len = strlen (font->fields[i]) + 1; | |
1922 | |
1923 /* Reallocate font_name if necessary. Add 1 for the final | |
1924 NUL-byte. */ | |
1925 if (total_length + len + 1 >= size) | |
1926 { | |
1927 int new_size = max (2 * size, size + len + 1); | |
1928 int sz = new_size * sizeof *font_name; | |
1929 font_name = (char *) xrealloc (font_name, sz); | |
1930 size = new_size; | |
1931 } | |
1932 | |
1933 font_name[total_length] = '-'; | |
1934 bcopy (font->fields[i], font_name + total_length + 1, len - 1); | |
1935 total_length += len; | |
1936 } | |
1937 | |
1938 font_name[total_length] = 0; | |
1939 return font_name; | |
1940 } | |
1941 | |
1942 | |
1943 /* Free an array FONTS of N font_name structures. This frees FONTS | |
1944 itself and all `name' fields in its elements. */ | |
1945 | |
1946 static INLINE void | |
1947 free_font_names (fonts, n) | |
1948 struct font_name *fonts; | |
1949 int n; | |
1950 { | |
1951 while (n) | |
1952 xfree (fonts[--n].name); | |
1953 xfree (fonts); | |
1954 } | |
1955 | |
1956 | |
1957 /* Sort vector FONTS of font_name structures which contains NFONTS | |
1958 elements using qsort and comparison function CMPFN. F is the frame | |
1959 on which the fonts will be used. The global variable font_frame | |
1960 is temporarily set to F to make it available in CMPFN. */ | |
1961 | |
1962 static INLINE void | |
1963 sort_fonts (f, fonts, nfonts, cmpfn) | |
1964 struct frame *f; | |
1965 struct font_name *fonts; | |
1966 int nfonts; | |
1967 int (*cmpfn) P_ ((const void *, const void *)); | |
1968 { | |
1969 font_frame = f; | |
1970 qsort (fonts, nfonts, sizeof *fonts, cmpfn); | |
1971 font_frame = NULL; | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
1972 } |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
1973 |
24995 | 1974 |
1975 /* Get fonts matching PATTERN on frame F. If F is null, use the first | |
1976 display in x_display_list. FONTS is a pointer to a vector of | |
1977 NFONTS font_name structures. TRY_ALTERNATIVES_P non-zero means try | |
1978 alternative patterns from Valternate_fontname_alist if no fonts are | |
1979 found matching PATTERN. SCALABLE_FONTS_P non-zero means include | |
1980 scalable fonts. | |
1981 | |
1982 For all fonts found, set FONTS[i].name to the name of the font, | |
1983 allocated via xmalloc, and split font names into fields. Ignore | |
1984 fonts that we can't parse. Value is the number of fonts found. | |
1985 | |
1986 This is similar to x_list_fonts. The differences are: | |
1987 | |
1988 1. It avoids consing. | |
1989 2. It never calls XLoadQueryFont. */ | |
1990 | |
1991 static int | |
1992 x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, | |
1993 scalable_fonts_p) | |
1994 struct frame *f; | |
1995 char *pattern; | |
1996 struct font_name *fonts; | |
1997 int nfonts, try_alternatives_p; | |
1998 int scalable_fonts_p; | |
1999 { | |
2000 Display *dpy = f ? FRAME_X_DISPLAY (f) : x_display_list->display; | |
2001 int n, i, j; | |
2002 char **names; | |
2003 | |
2004 /* Get the list of fonts matching PATTERN from the X server. */ | |
2005 BLOCK_INPUT; | |
2006 names = XListFonts (dpy, pattern, nfonts, &n); | |
2007 UNBLOCK_INPUT; | |
2008 | |
2009 if (names) | |
2010 { | |
2011 /* Make a copy of the font names we got from X, and | |
2012 split them into fields. */ | |
2013 for (i = j = 0; i < n; ++i) | |
2014 { | |
2015 /* Make a copy of the font name. */ | |
2016 fonts[j].name = xstrdup (names[i]); | |
2017 | |
2018 /* Ignore fonts having a name that we can't parse. */ | |
2019 if (!split_font_name (f, fonts + j, 1)) | |
2020 xfree (fonts[j].name); | |
2021 else if (font_scalable_p (fonts + j)) | |
2022 { | |
2023 #if SCALABLE_FONTS | |
2024 if (!scalable_fonts_p | |
2025 || !may_use_scalable_font_p (fonts + j, names[i])) | |
2026 xfree (fonts[j].name); | |
2027 else | |
2028 ++j; | |
2029 #else /* !SCALABLE_FONTS */ | |
2030 /* Always ignore scalable fonts. */ | |
2031 xfree (fonts[j].name); | |
2032 #endif /* !SCALABLE_FONTS */ | |
2033 } | |
2034 else | |
2035 ++j; | |
2036 } | |
2037 | |
2038 n = j; | |
2039 | |
2040 /* Free font names. */ | |
2041 BLOCK_INPUT; | |
2042 XFreeFontNames (names); | |
2043 UNBLOCK_INPUT; | |
2044 } | |
2045 | |
2046 | |
2047 /* If no fonts found, try patterns from Valternate_fontname_alist. */ | |
2048 if (n == 0 && try_alternatives_p) | |
2049 { | |
2050 Lisp_Object list = Valternate_fontname_alist; | |
2051 | |
2052 while (CONSP (list)) | |
2053 { | |
2054 Lisp_Object entry = XCAR (list); | |
2055 if (CONSP (entry) | |
2056 && STRINGP (XCAR (entry)) | |
2057 && strcmp (XSTRING (XCAR (entry))->data, pattern) == 0) | |
2058 break; | |
2059 list = XCDR (list); | |
2060 } | |
2061 | |
2062 if (CONSP (list)) | |
2063 { | |
2064 Lisp_Object patterns = XCAR (list); | |
2065 Lisp_Object name; | |
2066 | |
2067 while (CONSP (patterns) | |
2068 /* If list is screwed up, give up. */ | |
2069 && (name = XCAR (patterns), | |
2070 STRINGP (name)) | |
2071 /* Ignore patterns equal to PATTERN because we tried that | |
2072 already with no success. */ | |
2073 && (strcmp (XSTRING (name)->data, pattern) == 0 | |
2074 || (n = x_face_list_fonts (f, XSTRING (name)->data, | |
2075 fonts, nfonts, 0, | |
2076 scalable_fonts_p), | |
2077 n == 0))) | |
2078 patterns = XCDR (patterns); | |
2079 } | |
2080 } | |
2081 | |
2082 return n; | |
2083 } | |
2084 | |
2085 | |
2086 /* Determine the first font matching PATTERN on frame F. Return in | |
2087 *FONT the matching font name, split into fields. Value is non-zero | |
2088 if a match was found. */ | |
2089 | |
2090 static int | |
2091 first_font_matching (f, pattern, font) | |
2092 struct frame *f; | |
2093 char *pattern; | |
2094 struct font_name *font; | |
2095 { | |
2096 int nfonts = 100; | |
2097 struct font_name *fonts; | |
2098 | |
2099 fonts = (struct font_name *) xmalloc (nfonts * sizeof *fonts); | |
2100 nfonts = x_face_list_fonts (f, pattern, fonts, nfonts, 1, 0); | |
2101 | |
2102 if (nfonts > 0) | |
2103 { | |
2104 bcopy (&fonts[0], font, sizeof *font); | |
2105 | |
2106 fonts[0].name = NULL; | |
2107 free_font_names (fonts, nfonts); | |
2108 } | |
2109 | |
2110 return nfonts > 0; | |
2111 } | |
2112 | |
2113 | |
2114 /* Determine fonts matching PATTERN on frame F. Sort resulting fonts | |
2115 using comparison function CMPFN. Value is the number of fonts | |
2116 found. If value is non-zero, *FONTS is set to a vector of | |
2117 font_name structures allocated from the heap containing matching | |
2118 fonts. Each element of *FONTS contains a name member that is also | |
2119 allocated from the heap. Font names in these structures are split | |
2120 into fields. Use free_font_names to free such an array. */ | |
2121 | |
2122 static int | |
2123 sorted_font_list (f, pattern, cmpfn, fonts) | |
2124 struct frame *f; | |
2125 char *pattern; | |
2126 int (*cmpfn) P_ ((const void *, const void *)); | |
2127 struct font_name **fonts; | |
2128 { | |
2129 int nfonts; | |
2130 | |
2131 /* Get the list of fonts matching pattern. 100 should suffice. */ | |
25270 | 2132 nfonts = DEFAULT_FONT_LIST_LIMIT; |
2133 if (INTEGERP (Vfont_list_limit) && XINT (Vfont_list_limit) > 0) | |
2134 nfonts = XFASTINT (Vfont_list_limit); | |
2135 | |
24995 | 2136 *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts); |
2137 #if SCALABLE_FONTS | |
2138 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 1); | |
2139 #else | |
2140 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 0); | |
2141 #endif | |
2142 | |
2143 /* Sort the resulting array and return it in *FONTS. If no | |
2144 fonts were found, make sure to set *FONTS to null. */ | |
2145 if (nfonts) | |
2146 sort_fonts (f, *fonts, nfonts, cmpfn); | |
2147 else | |
2148 { | |
2149 xfree (*fonts); | |
2150 *fonts = NULL; | |
2151 } | |
2152 | |
2153 return nfonts; | |
2154 } | |
2155 | |
2156 | |
2157 /* Compare two font_name structures *A and *B. Value is analogous to | |
2158 strcmp. Sort order is given by the global variable | |
2159 font_sort_order. Font names are sorted so that, everything else | |
2160 being equal, fonts with a resolution closer to that of the frame on | |
2161 which they are used are listed first. The global variable | |
2162 font_frame is the frame on which we operate. */ | |
2163 | |
2164 static int | |
2165 cmp_font_names (a, b) | |
2166 const void *a, *b; | |
2167 { | |
2168 struct font_name *x = (struct font_name *) a; | |
2169 struct font_name *y = (struct font_name *) b; | |
2170 int cmp; | |
2171 | |
2172 /* All strings have been converted to lower-case by split_font_name, | |
2173 so we can use strcmp here. */ | |
2174 cmp = strcmp (x->fields[XLFD_FAMILY], y->fields[XLFD_FAMILY]); | |
2175 if (cmp == 0) | |
2176 { | |
2177 int i; | |
2178 | |
2179 for (i = 0; i < DIM (font_sort_order) && cmp == 0; ++i) | |
2180 { | |
2181 int j = font_sort_order[i]; | |
2182 cmp = x->numeric[j] - y->numeric[j]; | |
2183 } | |
2184 | |
2185 if (cmp == 0) | |
2186 { | |
2187 /* Everything else being equal, we prefer fonts with an | |
2188 y-resolution closer to that of the frame. */ | |
2189 int resy = FRAME_X_DISPLAY_INFO (font_frame)->resy; | |
2190 int x_resy = x->numeric[XLFD_RESY]; | |
2191 int y_resy = y->numeric[XLFD_RESY]; | |
2192 cmp = abs (resy - x_resy) - abs (resy - y_resy); | |
2193 } | |
2194 } | |
2195 | |
2196 return cmp; | |
2197 } | |
2198 | |
2199 | |
2200 /* Get a sorted list of fonts of family FAMILY on frame F. If PATTERN | |
2201 is non-null list fonts matching that pattern. Otherwise, if | |
2202 REGISTRY_AND_ENCODING is non-null return only fonts with that | |
2203 registry and encoding, otherwise return fonts of any registry and | |
2204 encoding. Set *FONTS to a vector of font_name structures allocated | |
2205 from the heap containing the fonts found. Value is the number of | |
2206 fonts found. */ | |
2207 | |
2208 static int | |
2209 font_list (f, pattern, family, registry_and_encoding, fonts) | |
2210 struct frame *f; | |
2211 char *pattern; | |
2212 char *family; | |
2213 char *registry_and_encoding; | |
2214 struct font_name **fonts; | |
2215 { | |
2216 if (pattern == NULL) | |
2217 { | |
2218 if (family == NULL) | |
2219 family = "*"; | |
2220 | |
2221 if (registry_and_encoding == NULL) | |
2222 registry_and_encoding = "*"; | |
2223 | |
2224 pattern = (char *) alloca (strlen (family) | |
2225 + strlen (registry_and_encoding) | |
2226 + 10); | |
2227 if (index (family, '-')) | |
2228 sprintf (pattern, "-%s-*-%s", family, registry_and_encoding); | |
2229 else | |
2230 sprintf (pattern, "-*-%s-*-%s", family, registry_and_encoding); | |
2231 } | |
2232 | |
2233 return sorted_font_list (f, pattern, cmp_font_names, fonts); | |
2234 } | |
2235 | |
2236 | |
2237 /* Remove elements from LIST whose cars are `equal'. Called from | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2238 x-family-fonts and x-font-family-list to remove duplicate font |
24995 | 2239 entries. */ |
2240 | |
2241 static void | |
2242 remove_duplicates (list) | |
2243 Lisp_Object list; | |
2244 { | |
2245 Lisp_Object tail = list; | |
2246 | |
2247 while (!NILP (tail) && !NILP (XCDR (tail))) | |
2248 { | |
2249 Lisp_Object next = XCDR (tail); | |
2250 if (!NILP (Fequal (XCAR (next), XCAR (tail)))) | |
2251 XCDR (tail) = XCDR (next); | |
2252 else | |
2253 tail = XCDR (tail); | |
2254 } | |
2255 } | |
2256 | |
2257 | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2258 DEFUN ("x-family-fonts", Fx_family_fonts, Sx_family_fonts, 0, 2, 0, |
24995 | 2259 "Return a list of available fonts of family FAMILY on FRAME.\n\ |
2260 If FAMILY is omitted or nil, list all families.\n\ | |
2261 Otherwise, FAMILY must be a string, possibly containing wildcards\n\ | |
2262 `?' and `*'.\n\ | |
2263 If FRAME is omitted or nil, use the selected frame.\n\ | |
2264 Each element of the result is a vector [FAMILY WIDTH POINT-SIZE WEIGHT\n\ | |
25270 | 2265 SLANT FIXED-P FULL REGISTRY-AND-ENCODING].\n\ |
24995 | 2266 FAMILY is the font family name. POINT-SIZE is the size of the\n\ |
2267 font in 1/10 pt. WIDTH, WEIGHT, and SLANT are symbols describing the\n\ | |
2268 width, weight and slant of the font. These symbols are the same as for\n\ | |
2269 face attributes. FIXED-P is non-nil if the font is fixed-pitch.\n\ | |
25270 | 2270 FULL is the full name of the font, and REGISTRY-AND-ENCODING is a string\n\ |
2271 giving the registry and encoding of the font.\n\ | |
24995 | 2272 The result list is sorted according to the current setting of\n\ |
2273 the face font sort order.") | |
2274 (family, frame) | |
2275 Lisp_Object family, frame; | |
2276 { | |
2277 struct frame *f = check_x_frame (frame); | |
2278 struct font_name *fonts; | |
2279 int i, nfonts; | |
2280 Lisp_Object result; | |
2281 struct gcpro gcpro1; | |
2282 char *family_pattern; | |
2283 | |
2284 if (NILP (family)) | |
2285 family_pattern = "*"; | |
2286 else | |
2287 { | |
2288 CHECK_STRING (family, 1); | |
2289 family_pattern = LSTRDUPA (family); | |
2290 } | |
2291 | |
2292 result = Qnil; | |
2293 GCPRO1 (result); | |
2294 nfonts = font_list (f, NULL, family_pattern, NULL, &fonts); | |
2295 for (i = nfonts - 1; i >= 0; --i) | |
2296 { | |
25270 | 2297 Lisp_Object v = Fmake_vector (make_number (8), Qnil); |
2298 char *tem; | |
24995 | 2299 |
2300 #define ASET(VECTOR, IDX, VAL) (XVECTOR (VECTOR)->contents[IDX] = (VAL)) | |
2301 | |
2302 ASET (v, 0, build_string (fonts[i].fields[XLFD_FAMILY])); | |
2303 ASET (v, 1, xlfd_symbolic_swidth (fonts + i)); | |
2304 ASET (v, 2, make_number (xlfd_point_size (f, fonts + i))); | |
2305 ASET (v, 3, xlfd_symbolic_weight (fonts + i)); | |
2306 ASET (v, 4, xlfd_symbolic_slant (fonts + i)); | |
2307 ASET (v, 5, xlfd_fixed_p (fonts + i) ? Qt : Qnil); | |
25270 | 2308 tem = build_font_name (fonts + i); |
2309 ASET (v, 6, build_string (tem)); | |
2310 sprintf (tem, "%s-%s", fonts[i].fields[XLFD_REGISTRY], | |
2311 fonts[i].fields[XLFD_ENCODING]); | |
2312 ASET (v, 7, build_string (tem)); | |
2313 xfree (tem); | |
2314 | |
24995 | 2315 result = Fcons (v, result); |
2316 | |
2317 #undef ASET | |
2318 } | |
2319 | |
2320 remove_duplicates (result); | |
2321 free_font_names (fonts, nfonts); | |
2322 UNGCPRO; | |
2323 return result; | |
2324 } | |
2325 | |
2326 | |
2327 DEFUN ("x-font-family-list", Fx_font_family_list, Sx_font_family_list, | |
2328 0, 1, 0, | |
2329 "Return a list of available font families on FRAME.\n\ | |
2330 If FRAME is omitted or nil, use the selected frame.\n\ | |
2331 Value is a list of conses (FAMILY . FIXED-P) where FAMILY\n\ | |
2332 is a font family, and FIXED-P is non-nil if fonts of that family\n\ | |
2333 are fixed-pitch.") | |
2334 (frame) | |
2335 Lisp_Object frame; | |
2336 { | |
2337 struct frame *f = check_x_frame (frame); | |
2338 int nfonts, i; | |
2339 struct font_name *fonts; | |
2340 Lisp_Object result; | |
2341 struct gcpro gcpro1; | |
25270 | 2342 int count = specpdl_ptr - specpdl; |
2343 int limit; | |
2344 | |
2345 /* Let's consider all fonts. Increase the limit for matching | |
2346 fonts until we have them all. */ | |
2347 for (limit = 500;;) | |
2348 { | |
2349 specbind (intern ("font-list-limit"), make_number (limit)); | |
2350 nfonts = font_list (f, NULL, "*", NULL, &fonts); | |
2351 | |
2352 if (nfonts == limit) | |
2353 { | |
2354 free_font_names (fonts, nfonts); | |
2355 limit *= 2; | |
2356 } | |
2357 else | |
2358 break; | |
2359 } | |
24995 | 2360 |
2361 result = Qnil; | |
2362 GCPRO1 (result); | |
2363 for (i = nfonts - 1; i >= 0; --i) | |
2364 result = Fcons (Fcons (build_string (fonts[i].fields[XLFD_FAMILY]), | |
2365 xlfd_fixed_p (fonts + i) ? Qt : Qnil), | |
2366 result); | |
2367 | |
2368 remove_duplicates (result); | |
2369 free_font_names (fonts, nfonts); | |
2370 UNGCPRO; | |
25270 | 2371 return unbind_to (count, result); |
24995 | 2372 } |
2373 | |
2374 | |
2375 DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 5, 0, | |
2376 "Return a list of the names of available fonts matching PATTERN.\n\ | |
2377 If optional arguments FACE and FRAME are specified, return only fonts\n\ | |
2378 the same size as FACE on FRAME.\n\ | |
2379 PATTERN is a string, perhaps with wildcard characters;\n\ | |
2380 the * character matches any substring, and\n\ | |
2381 the ? character matches any single character.\n\ | |
2382 PATTERN is case-insensitive.\n\ | |
2383 FACE is a face name--a symbol.\n\ | |
2384 \n\ | |
2385 The return value is a list of strings, suitable as arguments to\n\ | |
2386 set-face-font.\n\ | |
2387 \n\ | |
2388 Fonts Emacs can't use may or may not be excluded\n\ | |
2389 even if they match PATTERN and FACE.\n\ | |
2390 The optional fourth argument MAXIMUM sets a limit on how many\n\ | |
2391 fonts to match. The first MAXIMUM fonts are reported.\n\ | |
2392 The optional fifth argument WIDTH, if specified, is a number of columns\n\ | |
2393 occupied by a character of a font. In that case, return only fonts\n\ | |
2394 the WIDTH times as wide as FACE on FRAME.") | |
2395 (pattern, face, frame, maximum, width) | |
2396 Lisp_Object pattern, face, frame, maximum, width; | |
2397 { | |
2398 struct frame *f; | |
2399 int size; | |
2400 int maxnames; | |
2401 | |
2402 check_x (); | |
2403 CHECK_STRING (pattern, 0); | |
2404 | |
2405 if (NILP (maximum)) | |
2406 maxnames = 2000; | |
2407 else | |
2408 { | |
2409 CHECK_NATNUM (maximum, 0); | |
2410 maxnames = XINT (maximum); | |
2411 } | |
2412 | |
2413 if (!NILP (width)) | |
2414 CHECK_NUMBER (width, 4); | |
2415 | |
2416 /* We can't simply call check_x_frame because this function may be | |
2417 called before any frame is created. */ | |
2418 f = frame_or_selected_frame (frame, 2); | |
2419 if (!FRAME_X_P (f)) | |
2420 { | |
2421 /* Perhaps we have not yet created any frame. */ | |
2422 f = NULL; | |
2423 face = Qnil; | |
2424 } | |
2425 | |
2426 /* Determine the width standard for comparison with the fonts we find. */ | |
2427 | |
2428 if (NILP (face)) | |
2429 size = 0; | |
2430 else | |
2431 { | |
2432 /* This is of limited utility since it works with character | |
2433 widths. Keep it for compatibility. --gerd. */ | |
2434 int face_id = lookup_named_face (f, face, CHARSET_ASCII); | |
2435 struct face *face = FACE_FROM_ID (f, face_id); | |
2436 | |
2437 if (face->font) | |
2438 size = face->font->max_bounds.width; | |
2439 else | |
2440 size = FRAME_FONT (f)->max_bounds.width; | |
2441 | |
2442 if (!NILP (width)) | |
2443 size *= XINT (width); | |
2444 } | |
2445 | |
2446 { | |
2447 Lisp_Object args[2]; | |
2448 | |
2449 args[0] = x_list_fonts (f, pattern, size, maxnames); | |
2450 if (f == NULL) | |
2451 /* We don't have to check fontsets. */ | |
2452 return args[0]; | |
2453 args[1] = list_fontsets (f, pattern, size); | |
2454 return Fnconc (2, args); | |
2455 } | |
2456 } | |
2457 | |
2458 #endif /* HAVE_X_WINDOWS */ | |
2459 | |
2460 | |
2461 | |
2462 /*********************************************************************** | |
2463 Lisp Faces | |
2464 ***********************************************************************/ | |
2465 | |
2466 /* Access face attributes of face FACE, a Lisp vector. */ | |
2467 | |
2468 #define LFACE_FAMILY(LFACE) \ | |
2469 XVECTOR (LFACE)->contents[LFACE_FAMILY_INDEX] | |
2470 #define LFACE_HEIGHT(LFACE) \ | |
2471 XVECTOR (LFACE)->contents[LFACE_HEIGHT_INDEX] | |
2472 #define LFACE_WEIGHT(LFACE) \ | |
2473 XVECTOR (LFACE)->contents[LFACE_WEIGHT_INDEX] | |
2474 #define LFACE_SLANT(LFACE) \ | |
2475 XVECTOR (LFACE)->contents[LFACE_SLANT_INDEX] | |
2476 #define LFACE_UNDERLINE(LFACE) \ | |
2477 XVECTOR (LFACE)->contents[LFACE_UNDERLINE_INDEX] | |
2478 #define LFACE_INVERSE(LFACE) \ | |
2479 XVECTOR (LFACE)->contents[LFACE_INVERSE_INDEX] | |
2480 #define LFACE_FOREGROUND(LFACE) \ | |
2481 XVECTOR (LFACE)->contents[LFACE_FOREGROUND_INDEX] | |
2482 #define LFACE_BACKGROUND(LFACE) \ | |
2483 XVECTOR (LFACE)->contents[LFACE_BACKGROUND_INDEX] | |
2484 #define LFACE_STIPPLE(LFACE) \ | |
2485 XVECTOR (LFACE)->contents[LFACE_STIPPLE_INDEX] | |
2486 #define LFACE_SWIDTH(LFACE) \ | |
2487 XVECTOR (LFACE)->contents[LFACE_SWIDTH_INDEX] | |
2488 #define LFACE_OVERLINE(LFACE) \ | |
2489 XVECTOR (LFACE)->contents[LFACE_OVERLINE_INDEX] | |
2490 #define LFACE_STRIKE_THROUGH(LFACE) \ | |
2491 XVECTOR (LFACE)->contents[LFACE_STRIKE_THROUGH_INDEX] | |
2492 #define LFACE_BOX(LFACE) \ | |
2493 XVECTOR (LFACE)->contents[LFACE_BOX_INDEX] | |
2494 | |
2495 /* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size | |
2496 LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */ | |
2497 | |
2498 #define LFACEP(LFACE) \ | |
2499 (VECTORP (LFACE) \ | |
2500 && XVECTOR (LFACE)->size == LFACE_VECTOR_SIZE \ | |
2501 && EQ (XVECTOR (LFACE)->contents[0], Qface)) | |
2502 | |
2503 | |
2504 #if GLYPH_DEBUG | |
2505 | |
2506 /* Check consistency of Lisp face attribute vector ATTRS. */ | |
2507 | |
2508 static void | |
2509 check_lface_attrs (attrs) | |
2510 Lisp_Object *attrs; | |
2511 { | |
2512 xassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX]) | |
2513 || STRINGP (attrs[LFACE_FAMILY_INDEX])); | |
2514 xassert (UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX]) | |
2515 || SYMBOLP (attrs[LFACE_SWIDTH_INDEX])); | |
2516 xassert (UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX]) | |
2517 || INTEGERP (attrs[LFACE_HEIGHT_INDEX])); | |
2518 xassert (UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX]) | |
2519 || SYMBOLP (attrs[LFACE_WEIGHT_INDEX])); | |
2520 xassert (UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX]) | |
2521 || SYMBOLP (attrs[LFACE_SLANT_INDEX])); | |
2522 xassert (UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX]) | |
2523 || SYMBOLP (attrs[LFACE_UNDERLINE_INDEX]) | |
2524 || STRINGP (attrs[LFACE_UNDERLINE_INDEX])); | |
2525 xassert (UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX]) | |
2526 || SYMBOLP (attrs[LFACE_OVERLINE_INDEX]) | |
2527 || STRINGP (attrs[LFACE_OVERLINE_INDEX])); | |
2528 xassert (UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX]) | |
2529 || SYMBOLP (attrs[LFACE_STRIKE_THROUGH_INDEX]) | |
2530 || STRINGP (attrs[LFACE_STRIKE_THROUGH_INDEX])); | |
2531 xassert (UNSPECIFIEDP (attrs[LFACE_BOX_INDEX]) | |
2532 || SYMBOLP (attrs[LFACE_BOX_INDEX]) | |
2533 || STRINGP (attrs[LFACE_BOX_INDEX]) | |
2534 || INTEGERP (attrs[LFACE_BOX_INDEX]) | |
2535 || CONSP (attrs[LFACE_BOX_INDEX])); | |
2536 xassert (UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX]) | |
2537 || SYMBOLP (attrs[LFACE_INVERSE_INDEX])); | |
2538 xassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX]) | |
2539 || STRINGP (attrs[LFACE_FOREGROUND_INDEX])); | |
2540 xassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX]) | |
2541 || STRINGP (attrs[LFACE_BACKGROUND_INDEX])); | |
2542 #ifdef HAVE_WINDOW_SYSTEM | |
2543 xassert (UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX]) | |
2544 || SYMBOLP (attrs[LFACE_STIPPLE_INDEX]) | |
2545 || !NILP (Fpixmap_spec_p (attrs[LFACE_STIPPLE_INDEX]))); | |
2546 #endif | |
2547 } | |
2548 | |
2549 | |
2550 /* Check consistency of attributes of Lisp face LFACE (a Lisp vector). */ | |
2551 | |
2552 static void | |
2553 check_lface (lface) | |
2554 Lisp_Object lface; | |
2555 { | |
2556 if (!NILP (lface)) | |
2557 { | |
2558 xassert (LFACEP (lface)); | |
2559 check_lface_attrs (XVECTOR (lface)->contents); | |
2560 } | |
2561 } | |
2562 | |
2563 #else /* GLYPH_DEBUG == 0 */ | |
2564 | |
2565 #define check_lface_attrs(attrs) (void) 0 | |
2566 #define check_lface(lface) (void) 0 | |
2567 | |
2568 #endif /* GLYPH_DEBUG == 0 */ | |
2569 | |
2570 | |
2571 /* Return the face definition of FACE_NAME on frame F. F null means | |
2572 return the global definition. FACE_NAME may be a string or a | |
2573 symbol (apparently Emacs 20.2 allows strings as face names in face | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2574 text properties; ediff uses that). If FACE_NAME is an alias for |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2575 another face, return that face's definition. If SIGNAL_P is |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2576 non-zero, signal an error if FACE_NAME is not a valid face name. |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2577 If SIGNAL_P is zero, value is nil if FACE_NAME is not a valid face |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2578 name. */ |
24995 | 2579 |
2580 static INLINE Lisp_Object | |
2581 lface_from_face_name (f, face_name, signal_p) | |
2582 struct frame *f; | |
2583 Lisp_Object face_name; | |
2584 int signal_p; | |
2585 { | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2586 Lisp_Object lface, alias; |
24995 | 2587 |
2588 if (STRINGP (face_name)) | |
2589 face_name = intern (XSTRING (face_name)->data); | |
2590 | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2591 /* If FACE_NAME is an alias for another face, return the definition |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2592 of the aliased face. */ |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2593 alias = Fget (face_name, Qface_alias); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2594 if (!NILP (alias)) |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2595 face_name = alias; |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2596 |
24995 | 2597 if (f) |
2598 lface = assq_no_quit (face_name, f->face_alist); | |
2599 else | |
2600 lface = assq_no_quit (face_name, Vface_new_frame_defaults); | |
2601 | |
2602 if (CONSP (lface)) | |
2603 lface = XCDR (lface); | |
2604 else if (signal_p) | |
2605 signal_error ("Invalid face", face_name); | |
2606 | |
2607 check_lface (lface); | |
2608 return lface; | |
2609 } | |
2610 | |
2611 | |
2612 /* Get face attributes of face FACE_NAME from frame-local faces on | |
2613 frame F. Store the resulting attributes in ATTRS which must point | |
2614 to a vector of Lisp_Objects of size LFACE_VECTOR_SIZE. If SIGNAL_P | |
2615 is non-zero, signal an error if FACE_NAME does not name a face. | |
2616 Otherwise, value is zero if FACE_NAME is not a face. */ | |
2617 | |
2618 static INLINE int | |
2619 get_lface_attributes (f, face_name, attrs, signal_p) | |
2620 struct frame *f; | |
2621 Lisp_Object face_name; | |
2622 Lisp_Object *attrs; | |
2623 int signal_p; | |
2624 { | |
2625 Lisp_Object lface; | |
2626 int success_p; | |
2627 | |
2628 lface = lface_from_face_name (f, face_name, signal_p); | |
2629 if (!NILP (lface)) | |
2630 { | |
2631 bcopy (XVECTOR (lface)->contents, attrs, | |
2632 LFACE_VECTOR_SIZE * sizeof *attrs); | |
2633 success_p = 1; | |
2634 } | |
2635 else | |
2636 success_p = 0; | |
2637 | |
2638 return success_p; | |
2639 } | |
2640 | |
2641 | |
2642 /* Non-zero if all attributes in face attribute vector ATTRS are | |
2643 specified, i.e. are non-nil. */ | |
2644 | |
2645 static int | |
2646 lface_fully_specified_p (attrs) | |
2647 Lisp_Object *attrs; | |
2648 { | |
2649 int i; | |
2650 | |
2651 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
2652 if (UNSPECIFIEDP (attrs[i])) | |
2653 break; | |
2654 | |
2655 return i == LFACE_VECTOR_SIZE; | |
2656 } | |
2657 | |
2658 | |
2659 #ifdef HAVE_X_WINDOWS | |
2660 | |
2661 /* Set font-related attributes of Lisp face LFACE from XLFD font name | |
2662 FONT_NAME. If FORCE_P is zero, set only unspecified attributes of | |
2663 LFACE. Ignore fields of FONT_NAME containing wildcards. Value is | |
2664 zero if not successful because FONT_NAME was not in a valid format. | |
2665 A valid format is one that is suitable for split_font_name, see the | |
2666 comment there. */ | |
2667 | |
2668 static int | |
2669 set_lface_from_font_name (f, lface, font_name, force_p) | |
6784
d41c216ccd27
(frame_update_line_height): Check param_faces[i] not null.
Richard M. Stallman <rms@gnu.org>
parents:
6768
diff
changeset
|
2670 struct frame *f; |
24995 | 2671 Lisp_Object lface; |
2672 char *font_name; | |
2673 int force_p; | |
2674 { | |
2675 struct font_name font; | |
2676 char *buffer; | |
2677 int pt; | |
2678 int free_font_name_p = 0; | |
2679 | |
2680 /* If FONT_NAME contains wildcards, use the first matching font. */ | |
2681 if (index (font_name, '*') || index (font_name, '?')) | |
2682 { | |
2683 if (!first_font_matching (f, font_name, &font)) | |
2684 return 0; | |
2685 free_font_name_p = 1; | |
2686 } | |
2687 else | |
2688 { | |
2689 font.name = STRDUPA (font_name); | |
2690 if (!split_font_name (f, &font, 1)) | |
2691 { | |
2692 /* The font name may be something like `6x13'. Make | |
2693 sure we use the full name. */ | |
2694 struct font_info *font_info; | |
2695 | |
2696 BLOCK_INPUT; | |
2697 font_info = fs_load_font (f, FRAME_X_FONT_TABLE (f), | |
2698 CHARSET_ASCII, font_name, -1); | |
2699 UNBLOCK_INPUT; | |
2700 | |
2701 if (!font_info) | |
2702 return 0; | |
2703 | |
2704 font.name = STRDUPA (font_info->full_name); | |
2705 split_font_name (f, &font, 1); | |
2706 } | |
2707 | |
2708 /* FONT_NAME should not be a fontset name, here. */ | |
2709 xassert (xstricmp (font.fields[XLFD_REGISTRY], "fontset") != 0); | |
2710 } | |
2711 | |
2712 /* Set attributes only if unspecified, otherwise face defaults for | |
2713 new frames would never take effect. */ | |
2714 | |
2715 if (force_p || UNSPECIFIEDP (LFACE_FAMILY (lface))) | |
2716 { | |
2717 buffer = (char *) alloca (strlen (font.fields[XLFD_FAMILY]) | |
2718 + strlen (font.fields[XLFD_FOUNDRY]) | |
2719 + 2); | |
2720 sprintf (buffer, "%s-%s", font.fields[XLFD_FOUNDRY], | |
2721 font.fields[XLFD_FAMILY]); | |
2722 LFACE_FAMILY (lface) = build_string (buffer); | |
2723 } | |
2724 | |
2725 if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface))) | |
2726 { | |
2727 pt = xlfd_point_size (f, &font); | |
2728 xassert (pt > 0); | |
2729 LFACE_HEIGHT (lface) = make_number (pt); | |
2730 } | |
2731 | |
2732 if (force_p || UNSPECIFIEDP (LFACE_SWIDTH (lface))) | |
2733 LFACE_SWIDTH (lface) = xlfd_symbolic_swidth (&font); | |
2734 | |
2735 if (force_p || UNSPECIFIEDP (LFACE_WEIGHT (lface))) | |
2736 LFACE_WEIGHT (lface) = xlfd_symbolic_weight (&font); | |
2737 | |
2738 if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface))) | |
2739 LFACE_SLANT (lface) = xlfd_symbolic_slant (&font); | |
2740 | |
2741 if (free_font_name_p) | |
2742 xfree (font.name); | |
2743 | |
2744 return 1; | |
2745 } | |
2746 | |
2747 #endif /* HAVE_X_WINDOWS */ | |
2748 | |
2749 | |
2750 /* Merge two Lisp face attribute vectors FROM and TO and store the | |
2751 resulting attributes in TO. Every non-nil attribute of FROM | |
2752 overrides the corresponding attribute of TO. */ | |
2753 | |
2754 static INLINE void | |
2755 merge_face_vectors (from, to) | |
2756 Lisp_Object *from, *to; | |
2757 { | |
2758 int i; | |
2759 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
2760 if (!UNSPECIFIEDP (from[i])) | |
2761 to[i] = from[i]; | |
2762 } | |
2763 | |
2764 | |
2765 /* Given a Lisp face attribute vector TO and a Lisp object PROP that | |
2766 is a face property, determine the resulting face attributes on | |
2767 frame F, and store them in TO. PROP may be a single face | |
2768 specification or a list of such specifications. Each face | |
2769 specification can be | |
2770 | |
2771 1. A symbol or string naming a Lisp face. | |
2772 | |
2773 2. A property list of the form (KEYWORD VALUE ...) where each | |
2774 KEYWORD is a face attribute name, and value is an appropriate value | |
2775 for that attribute. | |
2776 | |
2777 3. Conses or the form (FOREGROUND-COLOR . COLOR) or | |
2778 (BACKGROUND-COLOR . COLOR) where COLOR is a color name. This is | |
2779 for compatibility with 20.2. | |
2780 | |
2781 Face specifications earlier in lists take precedence over later | |
2782 specifications. */ | |
2783 | |
2784 static void | |
2785 merge_face_vector_with_property (f, to, prop) | |
2786 struct frame *f; | |
2787 Lisp_Object *to; | |
2788 Lisp_Object prop; | |
2789 { | |
2790 if (CONSP (prop)) | |
2791 { | |
2792 Lisp_Object first = XCAR (prop); | |
2793 | |
2794 if (EQ (first, Qforeground_color) | |
2795 || EQ (first, Qbackground_color)) | |
2796 { | |
2797 /* One of (FOREGROUND-COLOR . COLOR) or (BACKGROUND-COLOR | |
2798 . COLOR). COLOR must be a string. */ | |
2799 Lisp_Object color_name = XCDR (prop); | |
2800 Lisp_Object color = first; | |
2801 | |
2802 if (STRINGP (color_name)) | |
2803 { | |
2804 if (EQ (color, Qforeground_color)) | |
2805 to[LFACE_FOREGROUND_INDEX] = color_name; | |
2806 else | |
2807 to[LFACE_BACKGROUND_INDEX] = color_name; | |
2808 } | |
2809 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2810 add_to_log ("Invalid face color", color_name, Qnil); |
24995 | 2811 } |
2812 else if (SYMBOLP (first) | |
2813 && *XSYMBOL (first)->name->data == ':') | |
2814 { | |
2815 /* Assume this is the property list form. */ | |
2816 while (CONSP (prop) && CONSP (XCDR (prop))) | |
2817 { | |
2818 Lisp_Object keyword = XCAR (prop); | |
2819 Lisp_Object value = XCAR (XCDR (prop)); | |
2820 | |
2821 if (EQ (keyword, QCfamily)) | |
2822 { | |
2823 if (STRINGP (value)) | |
2824 to[LFACE_FAMILY_INDEX] = value; | |
2825 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2826 add_to_log ("Illegal face font family", value, Qnil); |
24995 | 2827 } |
2828 else if (EQ (keyword, QCheight)) | |
2829 { | |
2830 if (INTEGERP (value)) | |
2831 to[LFACE_HEIGHT_INDEX] = value; | |
2832 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2833 add_to_log ("Illegal face font height", value, Qnil); |
24995 | 2834 } |
2835 else if (EQ (keyword, QCweight)) | |
2836 { | |
2837 if (SYMBOLP (value) | |
2838 && face_numeric_weight (value) >= 0) | |
2839 to[LFACE_WEIGHT_INDEX] = value; | |
2840 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2841 add_to_log ("Illegal face weight", value, Qnil); |
24995 | 2842 } |
2843 else if (EQ (keyword, QCslant)) | |
2844 { | |
2845 if (SYMBOLP (value) | |
2846 && face_numeric_slant (value) >= 0) | |
2847 to[LFACE_SLANT_INDEX] = value; | |
2848 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2849 add_to_log ("Illegal face slant", value, Qnil); |
24995 | 2850 } |
2851 else if (EQ (keyword, QCunderline)) | |
2852 { | |
2853 if (EQ (value, Qt) | |
2854 || NILP (value) | |
2855 || STRINGP (value)) | |
2856 to[LFACE_UNDERLINE_INDEX] = value; | |
2857 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2858 add_to_log ("Illegal face underline", value, Qnil); |
24995 | 2859 } |
2860 else if (EQ (keyword, QCoverline)) | |
2861 { | |
2862 if (EQ (value, Qt) | |
2863 || NILP (value) | |
2864 || STRINGP (value)) | |
2865 to[LFACE_OVERLINE_INDEX] = value; | |
2866 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2867 add_to_log ("Illegal face overline", value, Qnil); |
24995 | 2868 } |
2869 else if (EQ (keyword, QCstrike_through)) | |
2870 { | |
2871 if (EQ (value, Qt) | |
2872 || NILP (value) | |
2873 || STRINGP (value)) | |
2874 to[LFACE_STRIKE_THROUGH_INDEX] = value; | |
2875 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2876 add_to_log ("Illegal face strike-through", value, Qnil); |
24995 | 2877 } |
2878 else if (EQ (keyword, QCbox)) | |
2879 { | |
2880 if (EQ (value, Qt)) | |
2881 value = make_number (1); | |
2882 if (INTEGERP (value) | |
2883 || STRINGP (value) | |
2884 || CONSP (value) | |
2885 || NILP (value)) | |
2886 to[LFACE_BOX_INDEX] = value; | |
2887 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2888 add_to_log ("Illegal face box", value, Qnil); |
24995 | 2889 } |
2890 else if (EQ (keyword, QCinverse_video) | |
2891 || EQ (keyword, QCreverse_video)) | |
2892 { | |
2893 if (EQ (value, Qt) || NILP (value)) | |
2894 to[LFACE_INVERSE_INDEX] = value; | |
2895 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2896 add_to_log ("Illegal face inverse-video", value, Qnil); |
24995 | 2897 } |
2898 else if (EQ (keyword, QCforeground)) | |
2899 { | |
2900 if (STRINGP (value)) | |
2901 to[LFACE_FOREGROUND_INDEX] = value; | |
2902 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2903 add_to_log ("Illegal face foreground", value, Qnil); |
24995 | 2904 } |
2905 else if (EQ (keyword, QCbackground)) | |
2906 { | |
2907 if (STRINGP (value)) | |
2908 to[LFACE_BACKGROUND_INDEX] = value; | |
2909 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2910 add_to_log ("Illegal face background", value, Qnil); |
24995 | 2911 } |
2912 else if (EQ (keyword, QCstipple)) | |
2913 { | |
2914 #ifdef HAVE_X_WINDOWS | |
2915 Lisp_Object pixmap_p = Fpixmap_spec_p (value); | |
2916 if (!NILP (pixmap_p)) | |
2917 to[LFACE_STIPPLE_INDEX] = value; | |
2918 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2919 add_to_log ("Illegal face stipple", value, Qnil); |
24995 | 2920 #endif |
2921 } | |
2922 else if (EQ (keyword, QCwidth)) | |
2923 { | |
2924 if (SYMBOLP (value) | |
2925 && face_numeric_swidth (value) >= 0) | |
2926 to[LFACE_SWIDTH_INDEX] = value; | |
2927 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2928 add_to_log ("Illegal face width", value, Qnil); |
24995 | 2929 } |
2930 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2931 add_to_log ("Invalid attribute %s in face property", |
25301
2042c4a224ad
(add_to_log): Renamed from display_message.
Gerd Moellmann <gerd@gnu.org>
parents:
25270
diff
changeset
|
2932 keyword, Qnil); |
24995 | 2933 |
2934 prop = XCDR (XCDR (prop)); | |
2935 } | |
2936 } | |
2937 else | |
2938 { | |
2939 /* This is a list of face specs. Specifications at the | |
2940 beginning of the list take precedence over later | |
2941 specifications, so we have to merge starting with the | |
2942 last specification. */ | |
2943 Lisp_Object next = XCDR (prop); | |
2944 if (!NILP (next)) | |
2945 merge_face_vector_with_property (f, to, next); | |
2946 merge_face_vector_with_property (f, to, first); | |
2947 } | |
2948 } | |
2949 else | |
2950 { | |
2951 /* PROP ought to be a face name. */ | |
2952 Lisp_Object lface = lface_from_face_name (f, prop, 0); | |
2953 if (NILP (lface)) | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
2954 add_to_log ("Invalid face text property value: %s", prop, Qnil); |
24995 | 2955 else |
2956 merge_face_vectors (XVECTOR (lface)->contents, to); | |
2957 } | |
2958 } | |
2959 | |
2960 | |
2961 DEFUN ("internal-make-lisp-face", Finternal_make_lisp_face, | |
2962 Sinternal_make_lisp_face, 1, 2, 0, | |
2963 "Make FACE, a symbol, a Lisp face with all attributes nil.\n\ | |
2964 If FACE was not known as a face before, create a new one.\n\ | |
2965 If optional argument FRAME is specified, make a frame-local face\n\ | |
2966 for that frame. Otherwise operate on the global face definition.\n\ | |
2967 Value is a vector of face attributes.") | |
2968 (face, frame) | |
2969 Lisp_Object face, frame; | |
2970 { | |
2971 Lisp_Object global_lface, lface; | |
2972 struct frame *f; | |
2973 int i; | |
2974 | |
2975 CHECK_SYMBOL (face, 0); | |
2976 global_lface = lface_from_face_name (NULL, face, 0); | |
2977 | |
2978 if (!NILP (frame)) | |
2979 { | |
2980 CHECK_LIVE_FRAME (frame, 1); | |
2981 f = XFRAME (frame); | |
2982 lface = lface_from_face_name (f, face, 0); | |
2983 } | |
2984 else | |
2985 f = NULL, lface = Qnil; | |
2986 | |
2987 /* Add a global definition if there is none. */ | |
2988 if (NILP (global_lface)) | |
2989 { | |
2990 global_lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), | |
2991 Qunspecified); | |
2992 XVECTOR (global_lface)->contents[0] = Qface; | |
2993 Vface_new_frame_defaults = Fcons (Fcons (face, global_lface), | |
2994 Vface_new_frame_defaults); | |
2995 | |
2996 /* Assign the new Lisp face a unique ID. The mapping from Lisp | |
2997 face id to Lisp face is given by the vector lface_id_to_name. | |
2998 The mapping from Lisp face to Lisp face id is given by the | |
2999 property `face' of the Lisp face name. */ | |
3000 if (next_lface_id == lface_id_to_name_size) | |
3001 { | |
3002 int new_size = max (50, 2 * lface_id_to_name_size); | |
3003 int sz = new_size * sizeof *lface_id_to_name; | |
3004 lface_id_to_name = (Lisp_Object *) xrealloc (lface_id_to_name, sz); | |
3005 lface_id_to_name_size = new_size; | |
3006 } | |
3007 | |
3008 lface_id_to_name[next_lface_id] = face; | |
3009 Fput (face, Qface, make_number (next_lface_id)); | |
3010 ++next_lface_id; | |
3011 } | |
3012 else if (f == NULL) | |
3013 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
3014 XVECTOR (global_lface)->contents[i] = Qunspecified; | |
3015 | |
3016 /* Add a frame-local definition. */ | |
3017 if (f) | |
3018 { | |
3019 if (NILP (lface)) | |
3020 { | |
3021 lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), | |
3022 Qunspecified); | |
3023 XVECTOR (lface)->contents[0] = Qface; | |
3024 f->face_alist = Fcons (Fcons (face, lface), f->face_alist); | |
3025 } | |
3026 else | |
3027 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
3028 XVECTOR (lface)->contents[i] = Qunspecified; | |
3029 } | |
3030 else | |
3031 lface = global_lface; | |
3032 | |
3033 xassert (LFACEP (lface)); | |
3034 check_lface (lface); | |
3035 return lface; | |
3036 } | |
3037 | |
3038 | |
3039 DEFUN ("internal-lisp-face-p", Finternal_lisp_face_p, | |
3040 Sinternal_lisp_face_p, 1, 2, 0, | |
3041 "Return non-nil if FACE names a face.\n\ | |
3042 If optional second parameter FRAME is non-nil, check for the\n\ | |
3043 existence of a frame-local face with name FACE on that frame.\n\ | |
3044 Otherwise check for the existence of a global face.") | |
3045 (face, frame) | |
3046 Lisp_Object face, frame; | |
3047 { | |
3048 Lisp_Object lface; | |
3049 | |
3050 if (!NILP (frame)) | |
3051 { | |
3052 CHECK_LIVE_FRAME (frame, 1); | |
3053 lface = lface_from_face_name (XFRAME (frame), face, 0); | |
3054 } | |
3055 else | |
3056 lface = lface_from_face_name (NULL, face, 0); | |
3057 | |
3058 return lface; | |
3059 } | |
3060 | |
3061 | |
3062 DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face, | |
3063 Sinternal_copy_lisp_face, 4, 4, 0, | |
3064 "Copy face FROM to TO.\n\ | |
3065 If FRAME it t, copy the global face definition of FROM to the\n\ | |
3066 global face definition of TO. Otherwise, copy the frame-local\n\ | |
3067 definition of FROM on FRAME to the frame-local definition of TO\n\ | |
3068 on NEW-FRAME, or FRAME if NEW-FRAME is nil.\n\ | |
3069 \n\ | |
3070 Value is TO.") | |
3071 (from, to, frame, new_frame) | |
3072 Lisp_Object from, to, frame, new_frame; | |
3073 { | |
3074 Lisp_Object lface, copy; | |
3075 | |
3076 CHECK_SYMBOL (from, 0); | |
3077 CHECK_SYMBOL (to, 1); | |
3078 if (NILP (new_frame)) | |
3079 new_frame = frame; | |
3080 | |
3081 if (EQ (frame, Qt)) | |
3082 { | |
3083 /* Copy global definition of FROM. We don't make copies of | |
3084 strings etc. because 20.2 didn't do it either. */ | |
3085 lface = lface_from_face_name (NULL, from, 1); | |
3086 copy = Finternal_make_lisp_face (to, Qnil); | |
3087 } | |
3088 else | |
3089 { | |
3090 /* Copy frame-local definition of FROM. */ | |
3091 CHECK_LIVE_FRAME (frame, 2); | |
3092 CHECK_LIVE_FRAME (new_frame, 3); | |
3093 lface = lface_from_face_name (XFRAME (frame), from, 1); | |
3094 copy = Finternal_make_lisp_face (to, new_frame); | |
3095 } | |
3096 | |
3097 bcopy (XVECTOR (lface)->contents, XVECTOR (copy)->contents, | |
3098 LFACE_VECTOR_SIZE * sizeof (Lisp_Object)); | |
3099 | |
3100 return to; | |
3101 } | |
3102 | |
3103 | |
3104 DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute, | |
3105 Sinternal_set_lisp_face_attribute, 3, 4, 0, | |
3106 "Set attribute ATTR of FACE to VALUE.\n\ | |
3107 If optional argument FRAME is given, set the face attribute of face FACE\n\ | |
3108 on that frame. If FRAME is t, set the attribute of the default for face\n\ | |
3109 FACE (for new frames). If FRAME is omitted or nil, use the selected\n\ | |
3110 frame.") | |
3111 (face, attr, value, frame) | |
3112 Lisp_Object face, attr, value, frame; | |
6784
d41c216ccd27
(frame_update_line_height): Check param_faces[i] not null.
Richard M. Stallman <rms@gnu.org>
parents:
6768
diff
changeset
|
3113 { |
24995 | 3114 Lisp_Object lface; |
3115 Lisp_Object old_value = Qnil; | |
3116 int font_related_attr_p = 0; | |
3117 | |
3118 CHECK_SYMBOL (face, 0); | |
3119 CHECK_SYMBOL (attr, 1); | |
3120 | |
3121 /* Set lface to the Lisp attribute vector of FACE. */ | |
3122 if (EQ (frame, Qt)) | |
3123 lface = lface_from_face_name (NULL, face, 1); | |
3124 else | |
3125 { | |
3126 if (NILP (frame)) | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
3127 frame = selected_frame; |
24995 | 3128 |
3129 CHECK_LIVE_FRAME (frame, 3); | |
3130 lface = lface_from_face_name (XFRAME (frame), face, 0); | |
3131 | |
3132 /* If a frame-local face doesn't exist yet, create one. */ | |
3133 if (NILP (lface)) | |
3134 lface = Finternal_make_lisp_face (face, frame); | |
3135 } | |
3136 | |
3137 if (EQ (attr, QCfamily)) | |
3138 { | |
3139 if (!UNSPECIFIEDP (value)) | |
3140 { | |
3141 CHECK_STRING (value, 3); | |
3142 if (XSTRING (value)->size == 0) | |
3143 signal_error ("Invalid face family", value); | |
3144 } | |
3145 old_value = LFACE_FAMILY (lface); | |
3146 LFACE_FAMILY (lface) = value; | |
3147 font_related_attr_p = 1; | |
3148 } | |
3149 else if (EQ (attr, QCheight)) | |
3150 { | |
3151 if (!UNSPECIFIEDP (value)) | |
3152 { | |
3153 CHECK_NUMBER (value, 3); | |
3154 if (XINT (value) <= 0) | |
3155 signal_error ("Invalid face height", value); | |
3156 } | |
3157 old_value = LFACE_HEIGHT (lface); | |
3158 LFACE_HEIGHT (lface) = value; | |
3159 font_related_attr_p = 1; | |
3160 } | |
3161 else if (EQ (attr, QCweight)) | |
3162 { | |
3163 if (!UNSPECIFIEDP (value)) | |
3164 { | |
3165 CHECK_SYMBOL (value, 3); | |
3166 if (face_numeric_weight (value) < 0) | |
3167 signal_error ("Invalid face weight", value); | |
3168 } | |
3169 old_value = LFACE_WEIGHT (lface); | |
3170 LFACE_WEIGHT (lface) = value; | |
3171 font_related_attr_p = 1; | |
3172 } | |
3173 else if (EQ (attr, QCslant)) | |
3174 { | |
3175 if (!UNSPECIFIEDP (value)) | |
3176 { | |
3177 CHECK_SYMBOL (value, 3); | |
3178 if (face_numeric_slant (value) < 0) | |
3179 signal_error ("Invalid face slant", value); | |
3180 } | |
3181 old_value = LFACE_SLANT (lface); | |
3182 LFACE_SLANT (lface) = value; | |
3183 font_related_attr_p = 1; | |
3184 } | |
3185 else if (EQ (attr, QCunderline)) | |
3186 { | |
3187 if (!UNSPECIFIEDP (value)) | |
3188 if ((SYMBOLP (value) | |
3189 && !EQ (value, Qt) | |
3190 && !EQ (value, Qnil)) | |
3191 /* Underline color. */ | |
3192 || (STRINGP (value) | |
3193 && XSTRING (value)->size == 0)) | |
3194 signal_error ("Invalid face underline", value); | |
3195 | |
3196 old_value = LFACE_UNDERLINE (lface); | |
3197 LFACE_UNDERLINE (lface) = value; | |
3198 } | |
3199 else if (EQ (attr, QCoverline)) | |
3200 { | |
3201 if (!UNSPECIFIEDP (value)) | |
3202 if ((SYMBOLP (value) | |
3203 && !EQ (value, Qt) | |
3204 && !EQ (value, Qnil)) | |
3205 /* Overline color. */ | |
3206 || (STRINGP (value) | |
3207 && XSTRING (value)->size == 0)) | |
3208 signal_error ("Invalid face overline", value); | |
3209 | |
3210 old_value = LFACE_OVERLINE (lface); | |
3211 LFACE_OVERLINE (lface) = value; | |
3212 } | |
3213 else if (EQ (attr, QCstrike_through)) | |
3214 { | |
3215 if (!UNSPECIFIEDP (value)) | |
3216 if ((SYMBOLP (value) | |
3217 && !EQ (value, Qt) | |
3218 && !EQ (value, Qnil)) | |
3219 /* Strike-through color. */ | |
3220 || (STRINGP (value) | |
3221 && XSTRING (value)->size == 0)) | |
3222 signal_error ("Invalid face strike-through", value); | |
3223 | |
3224 old_value = LFACE_STRIKE_THROUGH (lface); | |
3225 LFACE_STRIKE_THROUGH (lface) = value; | |
3226 } | |
3227 else if (EQ (attr, QCbox)) | |
3228 { | |
3229 int valid_p; | |
3230 | |
3231 /* Allow t meaning a simple box of width 1 in foreground color | |
3232 of the face. */ | |
3233 if (EQ (value, Qt)) | |
3234 value = make_number (1); | |
3235 | |
3236 if (UNSPECIFIEDP (value)) | |
3237 valid_p = 1; | |
3238 else if (NILP (value)) | |
3239 valid_p = 1; | |
3240 else if (INTEGERP (value)) | |
3241 valid_p = XINT (value) > 0; | |
3242 else if (STRINGP (value)) | |
3243 valid_p = XSTRING (value)->size > 0; | |
3244 else if (CONSP (value)) | |
3245 { | |
3246 Lisp_Object tem; | |
3247 | |
3248 tem = value; | |
3249 while (CONSP (tem)) | |
3250 { | |
3251 Lisp_Object k, v; | |
3252 | |
3253 k = XCAR (tem); | |
3254 tem = XCDR (tem); | |
3255 if (!CONSP (tem)) | |
3256 break; | |
3257 v = XCAR (tem); | |
3258 tem = XCDR (tem); | |
3259 | |
3260 if (EQ (k, QCline_width)) | |
3261 { | |
3262 if (!INTEGERP (v) || XINT (v) <= 0) | |
3263 break; | |
3264 } | |
3265 else if (EQ (k, QCcolor)) | |
3266 { | |
3267 if (!STRINGP (v) || XSTRING (v)->size == 0) | |
3268 break; | |
3269 } | |
3270 else if (EQ (k, QCstyle)) | |
3271 { | |
3272 if (!EQ (v, Qpressed_button) && !EQ (v, Qreleased_button)) | |
3273 break; | |
3274 } | |
3275 else | |
3276 break; | |
3277 } | |
3278 | |
3279 valid_p = NILP (tem); | |
3280 } | |
3281 else | |
3282 valid_p = 0; | |
3283 | |
3284 if (!valid_p) | |
3285 signal_error ("Invalid face box", value); | |
3286 | |
3287 old_value = LFACE_BOX (lface); | |
3288 LFACE_BOX (lface) = value; | |
3289 } | |
3290 else if (EQ (attr, QCinverse_video) | |
3291 || EQ (attr, QCreverse_video)) | |
3292 { | |
3293 if (!UNSPECIFIEDP (value)) | |
3294 { | |
3295 CHECK_SYMBOL (value, 3); | |
3296 if (!EQ (value, Qt) && !NILP (value)) | |
3297 signal_error ("Invalid inverse-video face attribute value", value); | |
3298 } | |
3299 old_value = LFACE_INVERSE (lface); | |
3300 LFACE_INVERSE (lface) = value; | |
3301 } | |
3302 else if (EQ (attr, QCforeground)) | |
3303 { | |
3304 if (!UNSPECIFIEDP (value)) | |
3305 { | |
3306 /* Don't check for valid color names here because it depends | |
3307 on the frame (display) whether the color will be valid | |
3308 when the face is realized. */ | |
3309 CHECK_STRING (value, 3); | |
3310 if (XSTRING (value)->size == 0) | |
3311 signal_error ("Empty foreground color value", value); | |
3312 } | |
3313 old_value = LFACE_FOREGROUND (lface); | |
3314 LFACE_FOREGROUND (lface) = value; | |
3315 } | |
3316 else if (EQ (attr, QCbackground)) | |
3317 { | |
3318 if (!UNSPECIFIEDP (value)) | |
3319 { | |
3320 /* Don't check for valid color names here because it depends | |
3321 on the frame (display) whether the color will be valid | |
3322 when the face is realized. */ | |
3323 CHECK_STRING (value, 3); | |
3324 if (XSTRING (value)->size == 0) | |
3325 signal_error ("Empty background color value", value); | |
3326 } | |
3327 old_value = LFACE_BACKGROUND (lface); | |
3328 LFACE_BACKGROUND (lface) = value; | |
3329 } | |
3330 else if (EQ (attr, QCstipple)) | |
3331 { | |
3332 #ifdef HAVE_X_WINDOWS | |
3333 if (!UNSPECIFIEDP (value) | |
3334 && !NILP (value) | |
3335 && NILP (Fpixmap_spec_p (value))) | |
3336 signal_error ("Invalid stipple attribute", value); | |
3337 old_value = LFACE_STIPPLE (lface); | |
3338 LFACE_STIPPLE (lface) = value; | |
3339 #endif /* HAVE_X_WINDOWS */ | |
3340 } | |
3341 else if (EQ (attr, QCwidth)) | |
3342 { | |
3343 if (!UNSPECIFIEDP (value)) | |
3344 { | |
3345 CHECK_SYMBOL (value, 3); | |
3346 if (face_numeric_swidth (value) < 0) | |
3347 signal_error ("Invalid face width", value); | |
3348 } | |
3349 old_value = LFACE_SWIDTH (lface); | |
3350 LFACE_SWIDTH (lface) = value; | |
3351 font_related_attr_p = 1; | |
3352 } | |
3353 else if (EQ (attr, QCfont)) | |
3354 { | |
3355 #ifdef HAVE_X_WINDOWS | |
3356 /* Set font-related attributes of the Lisp face from an | |
3357 XLFD font name. */ | |
3358 struct frame *f; | |
3359 | |
3360 CHECK_STRING (value, 3); | |
3361 if (EQ (frame, Qt)) | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
3362 f = SELECTED_FRAME (); |
24995 | 3363 else |
3364 f = check_x_frame (frame); | |
3365 | |
3366 if (!set_lface_from_font_name (f, lface, XSTRING (value)->data, 1)) | |
3367 signal_error ("Invalid font name", value); | |
3368 | |
3369 font_related_attr_p = 1; | |
3370 #endif /* HAVE_X_WINDOWS */ | |
3371 } | |
3372 else if (EQ (attr, QCbold)) | |
3373 { | |
3374 old_value = LFACE_WEIGHT (lface); | |
3375 LFACE_WEIGHT (lface) = NILP (value) ? Qnormal : Qbold; | |
3376 font_related_attr_p = 1; | |
3377 } | |
3378 else if (EQ (attr, QCitalic)) | |
3379 { | |
3380 old_value = LFACE_SLANT (lface); | |
3381 LFACE_SLANT (lface) = NILP (value) ? Qnormal : Qitalic; | |
3382 font_related_attr_p = 1; | |
3383 } | |
3384 else | |
3385 signal_error ("Invalid face attribute name", attr); | |
3386 | |
3387 /* Changing a named face means that all realized faces depending on | |
3388 that face are invalid. Since we cannot tell which realized faces | |
3389 depend on the face, make sure they are all removed. This is done | |
3390 by incrementing face_change_count. The next call to | |
3391 init_iterator will then free realized faces. */ | |
3392 if (!EQ (frame, Qt) | |
3393 && (EQ (attr, QCfont) | |
3394 || NILP (Fequal (old_value, value)))) | |
3395 { | |
3396 ++face_change_count; | |
3397 ++windows_or_buffers_changed; | |
3398 } | |
3399 | |
3400 #ifdef HAVE_X_WINDOWS | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3401 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3402 if (!EQ (frame, Qt) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3403 && !UNSPECIFIEDP (value) |
24995 | 3404 && NILP (Fequal (old_value, value))) |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3405 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3406 Lisp_Object param; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3407 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3408 param = Qnil; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3409 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3410 if (EQ (face, Qdefault)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3411 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3412 /* Changed font-related attributes of the `default' face are |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3413 reflected in changed `font' frame parameters. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3414 if (font_related_attr_p |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3415 && lface_fully_specified_p (XVECTOR (lface)->contents)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3416 set_font_frame_param (frame, lface); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3417 else if (EQ (attr, QCforeground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3418 param = Qforeground_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3419 else if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3420 param = Qbackground_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3421 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3422 else if (EQ (face, Qscroll_bar)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3423 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3424 /* Changing the colors of `scroll-bar' sets frame parameters |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3425 `scroll-bar-foreground' and `scroll-bar-background'. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3426 if (EQ (attr, QCforeground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3427 param = Qscroll_bar_foreground; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3428 else if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3429 param = Qscroll_bar_background; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3430 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3431 else if (EQ (face, Qborder)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3432 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3433 /* Changing background color of `border' sets frame parameter |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3434 `border-color'. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3435 if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3436 param = Qborder_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3437 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3438 else if (EQ (face, Qcursor)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3439 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3440 /* Changing background color of `cursor' sets frame parameter |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3441 `cursor-color'. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3442 if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3443 param = Qcursor_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3444 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3445 else if (EQ (face, Qmouse)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3446 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3447 /* Changing background color of `mouse' sets frame parameter |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3448 `mouse-color'. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3449 if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3450 param = Qmouse_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3451 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3452 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3453 if (SYMBOLP (param)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3454 Fmodify_frame_parameters (frame, Fcons (Fcons (param, value), Qnil)); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3455 } |
24995 | 3456 |
3457 #endif /* HAVE_X_WINDOWS */ | |
3458 | |
3459 return face; | |
3460 } | |
3461 | |
3462 | |
3463 #ifdef HAVE_X_WINDOWS | |
3464 | |
3465 /* Set the `font' frame parameter of FRAME according to `default' face | |
3466 attributes LFACE. */ | |
3467 | |
3468 static void | |
3469 set_font_frame_param (frame, lface) | |
3470 Lisp_Object frame, lface; | |
3471 { | |
3472 struct frame *f = XFRAME (frame); | |
3473 Lisp_Object frame_font; | |
3474 int fontset; | |
3475 char *font; | |
3476 | |
3477 /* Get FRAME's font parameter. */ | |
3478 frame_font = Fassq (Qfont, f->param_alist); | |
3479 xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font))); | |
3480 frame_font = XCDR (frame_font); | |
3481 | |
3482 fontset = fs_query_fontset (f, XSTRING (frame_font)->data); | |
3483 if (fontset >= 0) | |
3484 { | |
3485 /* Frame parameter is a fontset name. Modify the fontset so | |
3486 that all its fonts reflect face attributes LFACE. */ | |
3487 int charset; | |
3488 struct fontset_info *fontset_info; | |
3489 | |
3490 fontset_info = FRAME_FONTSET_DATA (f)->fontset_table[fontset]; | |
3491 | |
3492 for (charset = 0; charset < MAX_CHARSET; ++charset) | |
3493 if (fontset_info->fontname[charset]) | |
3494 { | |
3495 font = choose_face_fontset_font (f, XVECTOR (lface)->contents, | |
3496 fontset, charset); | |
3497 Fset_fontset_font (frame_font, CHARSET_SYMBOL (charset), | |
3498 build_string (font), frame); | |
3499 xfree (font); | |
3500 } | |
3501 } | |
3502 else | |
3503 { | |
3504 /* Frame parameter is an X font name. I believe this can | |
3505 only happen in unibyte mode. */ | |
3506 font = choose_face_font (f, XVECTOR (lface)->contents, | |
3507 -1, Vface_default_registry); | |
3508 if (font) | |
3509 { | |
3510 store_frame_param (f, Qfont, build_string (font)); | |
3511 xfree (font); | |
3512 } | |
3513 } | |
3514 } | |
3515 | |
3516 | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3517 /* Update the corresponding face when frame parameter PARAM on frame F |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3518 has been assigned the value NEW_VALUE. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3519 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3520 void |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3521 update_face_from_frame_parameter (f, param, new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3522 struct frame *f; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3523 Lisp_Object param, new_value; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3524 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3525 Lisp_Object lface; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3526 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3527 /* If there are no faces yet, give up. This is the case when called |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3528 from Fx_create_frame, and we do the necessary things later in |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3529 face-set-after-frame-defaults. */ |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3530 if (NILP (f->face_alist)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3531 return; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3532 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3533 if (EQ (param, Qforeground_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3534 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3535 lface = lface_from_face_name (f, Qdefault, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3536 LFACE_FOREGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3537 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3538 realize_basic_faces (f); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3539 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3540 else if (EQ (param, Qbackground_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3541 { |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3542 Lisp_Object frame; |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3543 |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3544 /* Changing the background color might change the background |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3545 mode, so that we have to load new defface specs. Call |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3546 frame-update-face-colors to do that. */ |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3547 XSETFRAME (frame, f); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3548 call1 (Qframe_update_face_colors, frame); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3549 |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3550 lface = lface_from_face_name (f, Qdefault, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3551 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3552 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3553 realize_basic_faces (f); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3554 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3555 if (EQ (param, Qborder_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3556 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3557 lface = lface_from_face_name (f, Qborder, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3558 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3559 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3560 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3561 else if (EQ (param, Qcursor_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3562 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3563 lface = lface_from_face_name (f, Qcursor, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3564 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3565 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3566 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3567 else if (EQ (param, Qmouse_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3568 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3569 lface = lface_from_face_name (f, Qmouse, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3570 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3571 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3572 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3573 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3574 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3575 |
24995 | 3576 /* Get the value of X resource RESOURCE, class CLASS for the display |
3577 of frame FRAME. This is here because ordinary `x-get-resource' | |
3578 doesn't take a frame argument. */ | |
3579 | |
3580 DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource, | |
3581 Sinternal_face_x_get_resource, 3, 3, 0, "") | |
3582 (resource, class, frame) | |
3583 Lisp_Object resource, class, frame; | |
3584 { | |
3585 Lisp_Object value; | |
3586 CHECK_STRING (resource, 0); | |
3587 CHECK_STRING (class, 1); | |
3588 CHECK_LIVE_FRAME (frame, 2); | |
3589 BLOCK_INPUT; | |
3590 value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)), | |
3591 resource, class, Qnil, Qnil); | |
3592 UNBLOCK_INPUT; | |
3593 return value; | |
3594 } | |
3595 | |
3596 | |
3597 /* Return resource string VALUE as a boolean value, i.e. nil, or t. | |
3598 If VALUE is "on" or "true", return t. If VALUE is "off" or | |
3599 "false", return nil. Otherwise, if SIGNAL_P is non-zero, signal an | |
3600 error; if SIGNAL_P is zero, return 0. */ | |
3601 | |
3602 static Lisp_Object | |
3603 face_boolean_x_resource_value (value, signal_p) | |
3604 Lisp_Object value; | |
3605 int signal_p; | |
3606 { | |
3607 Lisp_Object result = make_number (0); | |
3608 | |
3609 xassert (STRINGP (value)); | |
3610 | |
3611 if (xstricmp (XSTRING (value)->data, "on") == 0 | |
3612 || xstricmp (XSTRING (value)->data, "true") == 0) | |
3613 result = Qt; | |
3614 else if (xstricmp (XSTRING (value)->data, "off") == 0 | |
3615 || xstricmp (XSTRING (value)->data, "false") == 0) | |
3616 result = Qnil; | |
3617 else if (xstricmp (XSTRING (value)->data, "unspecified") == 0) | |
3618 result = Qunspecified; | |
3619 else if (signal_p) | |
3620 signal_error ("Invalid face attribute value from X resource", value); | |
3621 | |
3622 return result; | |
3623 } | |
3624 | |
3625 | |
3626 DEFUN ("internal-set-lisp-face-attribute-from-resource", | |
3627 Finternal_set_lisp_face_attribute_from_resource, | |
3628 Sinternal_set_lisp_face_attribute_from_resource, | |
3629 3, 4, 0, "") | |
3630 (face, attr, value, frame) | |
3631 Lisp_Object face, attr, value, frame; | |
3632 { | |
3633 CHECK_SYMBOL (face, 0); | |
3634 CHECK_SYMBOL (attr, 1); | |
3635 CHECK_STRING (value, 2); | |
3636 | |
3637 if (xstricmp (XSTRING (value)->data, "unspecified") == 0) | |
3638 value = Qunspecified; | |
3639 else if (EQ (attr, QCheight)) | |
3640 { | |
3641 value = Fstring_to_number (value, make_number (10)); | |
3642 if (XINT (value) <= 0) | |
3643 signal_error ("Invalid face height from X resource", value); | |
3644 } | |
3645 else if (EQ (attr, QCbold) || EQ (attr, QCitalic)) | |
3646 value = face_boolean_x_resource_value (value, 1); | |
3647 else if (EQ (attr, QCweight) || EQ (attr, QCslant) || EQ (attr, QCwidth)) | |
3648 value = intern (XSTRING (value)->data); | |
3649 else if (EQ (attr, QCreverse_video) || EQ (attr, QCinverse_video)) | |
3650 value = face_boolean_x_resource_value (value, 1); | |
3651 else if (EQ (attr, QCunderline) | |
3652 || EQ (attr, QCoverline) | |
3653 || EQ (attr, QCstrike_through) | |
3654 || EQ (attr, QCbox)) | |
3655 { | |
3656 Lisp_Object boolean_value; | |
3657 | |
3658 /* If the result of face_boolean_x_resource_value is t or nil, | |
3659 VALUE does NOT specify a color. */ | |
3660 boolean_value = face_boolean_x_resource_value (value, 0); | |
3661 if (SYMBOLP (boolean_value)) | |
3662 value = boolean_value; | |
3663 } | |
3664 | |
3665 return Finternal_set_lisp_face_attribute (face, attr, value, frame); | |
6784
d41c216ccd27
(frame_update_line_height): Check param_faces[i] not null.
Richard M. Stallman <rms@gnu.org>
parents:
6768
diff
changeset
|
3666 } |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
3667 |
24995 | 3668 |
3669 #endif /* HAVE_X_WINDOWS */ | |
3670 | |
3671 | |
3672 | |
3673 DEFUN ("internal-get-lisp-face-attribute", Finternal_get_lisp_face_attribute, | |
3674 Sinternal_get_lisp_face_attribute, | |
3675 2, 3, 0, | |
3676 "Return face attribute KEYWORD of face SYMBOL.\n\ | |
3677 If SYMBOL does not name a valid Lisp face or KEYWORD isn't a valid\n\ | |
3678 face attribute name, signal an error.\n\ | |
3679 If the optional argument FRAME is given, report on face FACE in that\n\ | |
3680 frame. If FRAME is t, report on the defaults for face FACE (for new\n\ | |
3681 frames). If FRAME is omitted or nil, use the selected frame.") | |
3682 (symbol, keyword, frame) | |
3683 Lisp_Object symbol, keyword, frame; | |
3684 { | |
3685 Lisp_Object lface, value = Qnil; | |
3686 | |
3687 CHECK_SYMBOL (symbol, 0); | |
3688 CHECK_SYMBOL (keyword, 1); | |
3689 | |
3690 if (EQ (frame, Qt)) | |
3691 lface = lface_from_face_name (NULL, symbol, 1); | |
3692 else | |
3693 { | |
3694 if (NILP (frame)) | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
3695 frame = selected_frame; |
24995 | 3696 CHECK_LIVE_FRAME (frame, 2); |
3697 lface = lface_from_face_name (XFRAME (frame), symbol, 1); | |
3698 } | |
3699 | |
3700 if (EQ (keyword, QCfamily)) | |
3701 value = LFACE_FAMILY (lface); | |
3702 else if (EQ (keyword, QCheight)) | |
3703 value = LFACE_HEIGHT (lface); | |
3704 else if (EQ (keyword, QCweight)) | |
3705 value = LFACE_WEIGHT (lface); | |
3706 else if (EQ (keyword, QCslant)) | |
3707 value = LFACE_SLANT (lface); | |
3708 else if (EQ (keyword, QCunderline)) | |
3709 value = LFACE_UNDERLINE (lface); | |
3710 else if (EQ (keyword, QCoverline)) | |
3711 value = LFACE_OVERLINE (lface); | |
3712 else if (EQ (keyword, QCstrike_through)) | |
3713 value = LFACE_STRIKE_THROUGH (lface); | |
3714 else if (EQ (keyword, QCbox)) | |
3715 value = LFACE_BOX (lface); | |
3716 else if (EQ (keyword, QCinverse_video) | |
3717 || EQ (keyword, QCreverse_video)) | |
3718 value = LFACE_INVERSE (lface); | |
3719 else if (EQ (keyword, QCforeground)) | |
3720 value = LFACE_FOREGROUND (lface); | |
3721 else if (EQ (keyword, QCbackground)) | |
3722 value = LFACE_BACKGROUND (lface); | |
3723 else if (EQ (keyword, QCstipple)) | |
3724 value = LFACE_STIPPLE (lface); | |
3725 else if (EQ (keyword, QCwidth)) | |
3726 value = LFACE_SWIDTH (lface); | |
3727 else | |
3728 signal_error ("Invalid face attribute name", keyword); | |
3729 | |
3730 return value; | |
3731 } | |
3732 | |
3733 | |
3734 DEFUN ("internal-lisp-face-attribute-values", | |
3735 Finternal_lisp_face_attribute_values, | |
3736 Sinternal_lisp_face_attribute_values, 1, 1, 0, | |
3737 "Return a list of valid discrete values for face attribute ATTR.\n\ | |
3738 Value is nil if ATTR doesn't have a discrete set of valid values.") | |
3739 (attr) | |
3740 Lisp_Object attr; | |
3741 { | |
3742 Lisp_Object result = Qnil; | |
3743 | |
3744 CHECK_SYMBOL (attr, 0); | |
3745 | |
3746 if (EQ (attr, QCweight) | |
3747 || EQ (attr, QCslant) | |
3748 || EQ (attr, QCwidth)) | |
3749 { | |
3750 /* Extract permissible symbols from tables. */ | |
3751 struct table_entry *table; | |
3752 int i, dim; | |
3753 | |
3754 if (EQ (attr, QCweight)) | |
3755 table = weight_table, dim = DIM (weight_table); | |
3756 else if (EQ (attr, QCslant)) | |
3757 table = slant_table, dim = DIM (slant_table); | |
3758 else | |
3759 table = swidth_table, dim = DIM (swidth_table); | |
3760 | |
3761 for (i = 0; i < dim; ++i) | |
3762 { | |
3763 Lisp_Object symbol = *table[i].symbol; | |
3764 Lisp_Object tail = result; | |
3765 | |
3766 while (!NILP (tail) | |
3767 && !EQ (XCAR (tail), symbol)) | |
3768 tail = XCDR (tail); | |
3769 | |
3770 if (NILP (tail)) | |
3771 result = Fcons (symbol, result); | |
3772 } | |
3773 } | |
3774 else if (EQ (attr, QCunderline)) | |
3775 result = Fcons (Qt, Fcons (Qnil, Qnil)); | |
3776 else if (EQ (attr, QCoverline)) | |
3777 result = Fcons (Qt, Fcons (Qnil, Qnil)); | |
3778 else if (EQ (attr, QCstrike_through)) | |
3779 result = Fcons (Qt, Fcons (Qnil, Qnil)); | |
3780 else if (EQ (attr, QCinverse_video) || EQ (attr, QCreverse_video)) | |
3781 result = Fcons (Qt, Fcons (Qnil, Qnil)); | |
3782 | |
3783 return result; | |
3784 } | |
3785 | |
3786 | |
3787 DEFUN ("internal-merge-in-global-face", Finternal_merge_in_global_face, | |
3788 Sinternal_merge_in_global_face, 2, 2, 0, | |
3789 "Add attributes from frame-default definition of FACE to FACE on FRAME.") | |
3790 (face, frame) | |
3791 Lisp_Object face, frame; | |
3792 { | |
3793 Lisp_Object global_lface, local_lface; | |
3794 CHECK_LIVE_FRAME (frame, 1); | |
3795 global_lface = lface_from_face_name (NULL, face, 1); | |
3796 local_lface = lface_from_face_name (XFRAME (frame), face, 0); | |
3797 if (NILP (local_lface)) | |
3798 local_lface = Finternal_make_lisp_face (face, frame); | |
3799 merge_face_vectors (XVECTOR (global_lface)->contents, | |
3800 XVECTOR (local_lface)->contents); | |
3801 return face; | |
3802 } | |
3803 | |
3804 | |
3805 /* The following function is implemented for compatibility with 20.2. | |
3806 The function is used in x-resolve-fonts when it is asked to | |
3807 return fonts with the same size as the font of a face. This is | |
3808 done in fontset.el. */ | |
3809 | |
3810 DEFUN ("face-font", Fface_font, Sface_font, 1, 2, 0, | |
3811 "Return the font name of face FACE, or nil if it is unspecified.\n\ | |
3812 If the optional argument FRAME is given, report on face FACE in that frame.\n\ | |
3813 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ | |
3814 The font default for a face is either nil, or a list\n\ | |
3815 of the form (bold), (italic) or (bold italic).\n\ | |
3816 If FRAME is omitted or nil, use the selected frame.") | |
3817 (face, frame) | |
3818 Lisp_Object face, frame; | |
3819 { | |
3820 if (EQ (frame, Qt)) | |
3821 { | |
3822 Lisp_Object result = Qnil; | |
3823 Lisp_Object lface = lface_from_face_name (NULL, face, 1); | |
3824 | |
3825 if (!UNSPECIFIEDP (LFACE_WEIGHT (lface)) | |
3826 && !EQ (LFACE_WEIGHT (lface), Qnormal)) | |
3827 result = Fcons (Qbold, result); | |
3828 | |
3829 if (!NILP (LFACE_SLANT (lface)) | |
3830 && !EQ (LFACE_SLANT (lface), Qnormal)) | |
3831 result = Fcons (Qitalic, result); | |
3832 | |
3833 return result; | |
3834 } | |
3835 else | |
3836 { | |
3837 struct frame *f = frame_or_selected_frame (frame, 1); | |
3838 int face_id = lookup_named_face (f, face, CHARSET_ASCII); | |
3839 struct face *face = FACE_FROM_ID (f, face_id); | |
3840 return build_string (face->font_name); | |
3841 } | |
3842 } | |
3843 | |
3844 | |
3845 /* Compare face vectors V1 and V2 for equality. Value is non-zero if | |
3846 all attributes are `equal'. Tries to be fast because this function | |
3847 is called quite often. */ | |
3848 | |
3849 static INLINE int | |
3850 lface_equal_p (v1, v2) | |
3851 Lisp_Object *v1, *v2; | |
3852 { | |
3853 int i, equal_p = 1; | |
3854 | |
3855 for (i = 1; i < LFACE_VECTOR_SIZE && equal_p; ++i) | |
3856 { | |
3857 Lisp_Object a = v1[i]; | |
3858 Lisp_Object b = v2[i]; | |
3859 | |
3860 /* Type can differ, e.g. when one attribute is unspecified, i.e. nil, | |
3861 and the other is specified. */ | |
3862 equal_p = XTYPE (a) == XTYPE (b); | |
3863 if (!equal_p) | |
3864 break; | |
3865 | |
3866 if (!EQ (a, b)) | |
3867 { | |
3868 switch (XTYPE (a)) | |
3869 { | |
3870 case Lisp_String: | |
3871 equal_p = (XSTRING (a)->size == XSTRING (b)->size | |
3872 && bcmp (XSTRING (a)->data, XSTRING (b)->data, | |
3873 XSTRING (a)->size) == 0); | |
3874 break; | |
3875 | |
3876 case Lisp_Int: | |
3877 case Lisp_Symbol: | |
3878 equal_p = 0; | |
3879 break; | |
3880 | |
3881 default: | |
3882 equal_p = !NILP (Fequal (a, b)); | |
3883 break; | |
3884 } | |
3885 } | |
3886 } | |
3887 | |
3888 return equal_p; | |
3889 } | |
3890 | |
3891 | |
3892 DEFUN ("internal-lisp-face-equal-p", Finternal_lisp_face_equal_p, | |
3893 Sinternal_lisp_face_equal_p, 2, 3, 0, | |
3894 "True if FACE1 and FACE2 are equal.\n\ | |
3895 If the optional argument FRAME is given, report on face FACE in that frame.\n\ | |
3896 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ | |
3897 If FRAME is omitted or nil, use the selected frame.") | |
3898 (face1, face2, frame) | |
3899 Lisp_Object face1, face2, frame; | |
3900 { | |
3901 int equal_p; | |
3902 struct frame *f; | |
3903 Lisp_Object lface1, lface2; | |
3904 | |
3905 if (EQ (frame, Qt)) | |
3906 f = NULL; | |
3907 else | |
3908 /* Don't use check_x_frame here because this function is called | |
3909 before X frames exist. At that time, if FRAME is nil, | |
3910 selected_frame will be used which is the frame dumped with | |
3911 Emacs. That frame is not an X frame. */ | |
3912 f = frame_or_selected_frame (frame, 2); | |
3913 | |
3914 lface1 = lface_from_face_name (NULL, face1, 1); | |
3915 lface2 = lface_from_face_name (NULL, face2, 1); | |
3916 equal_p = lface_equal_p (XVECTOR (lface1)->contents, | |
3917 XVECTOR (lface2)->contents); | |
3918 return equal_p ? Qt : Qnil; | |
3919 } | |
3920 | |
3921 | |
3922 DEFUN ("internal-lisp-face-empty-p", Finternal_lisp_face_empty_p, | |
3923 Sinternal_lisp_face_empty_p, 1, 2, 0, | |
3924 "True if FACE has no attribute specified.\n\ | |
3925 If the optional argument FRAME is given, report on face FACE in that frame.\n\ | |
3926 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ | |
3927 If FRAME is omitted or nil, use the selected frame.") | |
3928 (face, frame) | |
3929 Lisp_Object face, frame; | |
3930 { | |
3931 struct frame *f; | |
3932 Lisp_Object lface; | |
3933 int i; | |
3934 | |
3935 if (NILP (frame)) | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
3936 frame = selected_frame; |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
3937 CHECK_LIVE_FRAME (frame, 0); |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
3938 f = XFRAME (frame); |
24995 | 3939 |
3940 if (EQ (frame, Qt)) | |
3941 lface = lface_from_face_name (NULL, face, 1); | |
3942 else | |
3943 lface = lface_from_face_name (f, face, 1); | |
3944 | |
3945 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
3946 if (!UNSPECIFIEDP (XVECTOR (lface)->contents[i])) | |
3947 break; | |
3948 | |
3949 return i == LFACE_VECTOR_SIZE ? Qt : Qnil; | |
3950 } | |
3951 | |
3952 | |
3953 DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist, | |
3954 0, 1, 0, | |
3955 "Return an alist of frame-local faces defined on FRAME.\n\ | |
3956 For internal use only.") | |
3957 (frame) | |
3958 Lisp_Object frame; | |
3959 { | |
3960 struct frame *f = frame_or_selected_frame (frame, 0); | |
3961 return f->face_alist; | |
3962 } | |
3963 | |
3964 | |
3965 /* Return a hash code for Lisp string STRING with case ignored. Used | |
3966 below in computing a hash value for a Lisp face. */ | |
3967 | |
3968 static INLINE unsigned | |
3969 hash_string_case_insensitive (string) | |
3970 Lisp_Object string; | |
3971 { | |
3972 unsigned char *s; | |
3973 unsigned hash = 0; | |
3974 xassert (STRINGP (string)); | |
3975 for (s = XSTRING (string)->data; *s; ++s) | |
3976 hash = (hash << 1) ^ tolower (*s); | |
3977 return hash; | |
3978 } | |
3979 | |
3980 | |
3981 /* Return a hash code for face attribute vector V. */ | |
3982 | |
3983 static INLINE unsigned | |
3984 lface_hash (v) | |
3985 Lisp_Object *v; | |
3986 { | |
3987 return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX]) | |
3988 ^ hash_string_case_insensitive (v[LFACE_FOREGROUND_INDEX]) | |
3989 ^ hash_string_case_insensitive (v[LFACE_BACKGROUND_INDEX]) | |
3990 ^ (unsigned) v[LFACE_WEIGHT_INDEX] | |
3991 ^ (unsigned) v[LFACE_SLANT_INDEX] | |
3992 ^ (unsigned) v[LFACE_SWIDTH_INDEX] | |
3993 ^ XFASTINT (v[LFACE_HEIGHT_INDEX])); | |
3994 } | |
3995 | |
3996 | |
3997 /* Return non-zero if LFACE1 and LFACE2 specify the same font (without | |
3998 considering charsets/registries). They do if they specify the same | |
3999 family, point size, weight, width and slant. Both LFACE1 and | |
4000 LFACE2 must be fully-specified. */ | |
4001 | |
4002 static INLINE int | |
4003 lface_same_font_attributes_p (lface1, lface2) | |
4004 Lisp_Object *lface1, *lface2; | |
4005 { | |
4006 xassert (lface_fully_specified_p (lface1) | |
4007 && lface_fully_specified_p (lface2)); | |
4008 return (xstricmp (XSTRING (lface1[LFACE_FAMILY_INDEX])->data, | |
4009 XSTRING (lface2[LFACE_FAMILY_INDEX])->data) == 0 | |
4010 && (XFASTINT (lface1[LFACE_HEIGHT_INDEX]) | |
4011 == XFASTINT (lface2[LFACE_HEIGHT_INDEX])) | |
4012 && EQ (lface1[LFACE_SWIDTH_INDEX], lface2[LFACE_SWIDTH_INDEX]) | |
4013 && EQ (lface1[LFACE_WEIGHT_INDEX], lface2[LFACE_WEIGHT_INDEX]) | |
4014 && EQ (lface1[LFACE_SLANT_INDEX], lface2[LFACE_SLANT_INDEX])); | |
4015 } | |
4016 | |
4017 | |
4018 | |
4019 /*********************************************************************** | |
4020 Realized Faces | |
4021 ***********************************************************************/ | |
4022 | |
4023 /* Allocate and return a new realized face for Lisp face attribute | |
4024 vector ATTR, charset CHARSET, and registry REGISTRY. */ | |
4025 | |
4026 static struct face * | |
4027 make_realized_face (attr, charset, registry) | |
4028 Lisp_Object *attr; | |
4029 int charset; | |
4030 Lisp_Object registry; | |
4031 { | |
4032 struct face *face = (struct face *) xmalloc (sizeof *face); | |
4033 bzero (face, sizeof *face); | |
4034 face->charset = charset; | |
4035 face->registry = registry; | |
4036 bcopy (attr, face->lface, sizeof face->lface); | |
4037 return face; | |
4038 } | |
4039 | |
4040 | |
4041 /* Free realized face FACE, including its X resources. FACE may | |
4042 be null. */ | |
4043 | |
4044 static void | |
4045 free_realized_face (f, face) | |
4046 struct frame *f; | |
4047 struct face *face; | |
4048 { | |
4049 if (face) | |
4050 { | |
4051 #ifdef HAVE_X_WINDOWS | |
4052 if (FRAME_X_P (f)) | |
4053 { | |
4054 if (face->gc) | |
4055 { | |
4056 x_free_gc (f, face->gc); | |
4057 face->gc = 0; | |
4058 } | |
4059 | |
4060 free_face_colors (f, face); | |
4061 x_destroy_bitmap (f, face->stipple); | |
4062 } | |
4063 #endif /* HAVE_X_WINDOWS */ | |
4064 | |
4065 xfree (face); | |
4066 } | |
4067 } | |
4068 | |
4069 | |
4070 /* Prepare face FACE for subsequent display on frame F. This | |
4071 allocated GCs if they haven't been allocated yet or have been freed | |
4072 by clearing the face cache. */ | |
4073 | |
4074 void | |
4075 prepare_face_for_display (f, face) | |
4076 struct frame *f; | |
4077 struct face *face; | |
4078 { | |
4079 #ifdef HAVE_X_WINDOWS | |
4080 xassert (FRAME_X_P (f)); | |
4081 | |
4082 if (face->gc == 0) | |
4083 { | |
4084 XGCValues xgcv; | |
4085 unsigned long mask = GCForeground | GCBackground | GCGraphicsExposures; | |
4086 | |
4087 xgcv.foreground = face->foreground; | |
4088 xgcv.background = face->background; | |
4089 xgcv.graphics_exposures = False; | |
4090 | |
4091 /* The font of FACE may be null if we couldn't load it. */ | |
4092 if (face->font) | |
4093 { | |
4094 xgcv.font = face->font->fid; | |
4095 mask |= GCFont; | |
4096 } | |
4097 | |
4098 BLOCK_INPUT; | |
4099 if (face->stipple) | |
4100 { | |
25092
79a5a567bdb0
(prepare_face_for_display): Use FillOpaqueStippled instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25062
diff
changeset
|
4101 xgcv.fill_style = FillOpaqueStippled; |
24995 | 4102 xgcv.stipple = x_bitmap_pixmap (f, face->stipple); |
4103 mask |= GCFillStyle | GCStipple; | |
4104 } | |
4105 | |
4106 face->gc = x_create_gc (f, mask, &xgcv); | |
4107 UNBLOCK_INPUT; | |
4108 } | |
4109 #endif | |
4110 } | |
4111 | |
4112 | |
4113 /* Non-zero if FACE is suitable for displaying ISO8859-1. Used in | |
4114 macro FACE_SUITABLE_FOR_CHARSET_P to avoid realizing a new face for | |
4115 ISO8859-1 if the ASCII face suffices. */ | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4116 |
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4117 int |
24995 | 4118 face_suitable_for_iso8859_1_p (face) |
4119 struct face *face; | |
4120 { | |
4121 int len = strlen (face->font_name); | |
4122 return len >= 9 && xstricmp (face->font_name + len - 9, "iso8859-1") == 0; | |
4123 } | |
4124 | |
4125 | |
4126 /* Value is non-zero if FACE is suitable for displaying characters | |
4127 of CHARSET. CHARSET < 0 means unibyte text. */ | |
4128 | |
4129 INLINE int | |
4130 face_suitable_for_charset_p (face, charset) | |
4131 struct face *face; | |
4132 int charset; | |
4133 { | |
4134 int suitable_p = 0; | |
4135 | |
4136 if (charset < 0) | |
4137 { | |
4138 if (EQ (face->registry, Vface_default_registry) | |
4139 || !NILP (Fequal (face->registry, Vface_default_registry))) | |
4140 suitable_p = 1; | |
4141 } | |
4142 else if (face->charset == charset) | |
4143 suitable_p = 1; | |
4144 else if (face->charset == CHARSET_ASCII | |
4145 && charset == charset_latin_iso8859_1) | |
4146 suitable_p = face_suitable_for_iso8859_1_p (face); | |
4147 else if (face->charset == charset_latin_iso8859_1 | |
4148 && charset == CHARSET_ASCII) | |
4149 suitable_p = 1; | |
4150 | |
4151 return suitable_p; | |
4152 } | |
4153 | |
4154 | |
4155 | |
4156 /*********************************************************************** | |
4157 Face Cache | |
4158 ***********************************************************************/ | |
4159 | |
4160 /* Return a new face cache for frame F. */ | |
4161 | |
4162 static struct face_cache * | |
4163 make_face_cache (f) | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4164 struct frame *f; |
24995 | 4165 { |
4166 struct face_cache *c; | |
4167 int size; | |
4168 | |
4169 c = (struct face_cache *) xmalloc (sizeof *c); | |
4170 bzero (c, sizeof *c); | |
4171 size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | |
4172 c->buckets = (struct face **) xmalloc (size); | |
4173 bzero (c->buckets, size); | |
4174 c->size = 50; | |
4175 c->faces_by_id = (struct face **) xmalloc (c->size * sizeof *c->faces_by_id); | |
4176 c->f = f; | |
4177 return c; | |
4178 } | |
4179 | |
4180 | |
4181 /* Clear out all graphics contexts for all realized faces, except for | |
4182 the basic faces. This should be done from time to time just to avoid | |
4183 keeping too many graphics contexts that are no longer needed. */ | |
4184 | |
4185 static void | |
4186 clear_face_gcs (c) | |
4187 struct face_cache *c; | |
4188 { | |
4189 if (c && FRAME_X_P (c->f)) | |
4190 { | |
4191 #ifdef HAVE_X_WINDOWS | |
4192 int i; | |
4193 for (i = BASIC_FACE_ID_SENTINEL; i < c->used; ++i) | |
4194 { | |
4195 struct face *face = c->faces_by_id[i]; | |
4196 if (face && face->gc) | |
4197 { | |
4198 x_free_gc (c->f, face->gc); | |
4199 face->gc = 0; | |
4200 } | |
4201 } | |
4202 #endif /* HAVE_X_WINDOWS */ | |
4203 } | |
4204 } | |
4205 | |
4206 | |
4207 /* Free all realized faces in face cache C, including basic faces. C | |
4208 may be null. If faces are freed, make sure the frame's current | |
4209 matrix is marked invalid, so that a display caused by an expose | |
4210 event doesn't try to use faces we destroyed. */ | |
4211 | |
4212 static void | |
4213 free_realized_faces (c) | |
4214 struct face_cache *c; | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4215 { |
24995 | 4216 if (c && c->used) |
4217 { | |
4218 int i, size; | |
4219 struct frame *f = c->f; | |
4220 | |
4221 for (i = 0; i < c->used; ++i) | |
4222 { | |
4223 free_realized_face (f, c->faces_by_id[i]); | |
4224 c->faces_by_id[i] = NULL; | |
4225 } | |
4226 | |
4227 c->used = 0; | |
4228 size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | |
4229 bzero (c->buckets, size); | |
4230 | |
4231 /* Must do a thorough redisplay the next time. Mark current | |
4232 matrices as invalid because they will reference faces freed | |
4233 above. This function is also called when a frame is | |
4234 destroyed. In this case, the root window of F is nil. */ | |
4235 if (WINDOWP (f->root_window)) | |
4236 { | |
4237 clear_current_matrices (f); | |
4238 ++windows_or_buffers_changed; | |
4239 } | |
4240 } | |
4241 } | |
4242 | |
4243 | |
4244 /* Free all realized faces on FRAME or on all frames if FRAME is nil. | |
4245 This is done after attributes of a named face have been changed, | |
4246 because we can't tell which realized faces depend on that face. */ | |
4247 | |
4248 void | |
4249 free_all_realized_faces (frame) | |
4250 Lisp_Object frame; | |
4251 { | |
4252 if (NILP (frame)) | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4253 { |
24995 | 4254 Lisp_Object rest; |
4255 FOR_EACH_FRAME (rest, frame) | |
4256 free_realized_faces (FRAME_FACE_CACHE (XFRAME (frame))); | |
4257 } | |
4258 else | |
4259 free_realized_faces (FRAME_FACE_CACHE (XFRAME (frame))); | |
4260 } | |
4261 | |
4262 | |
4263 /* Free face cache C and faces in it, including their X resources. */ | |
4264 | |
4265 static void | |
4266 free_face_cache (c) | |
4267 struct face_cache *c; | |
4268 { | |
4269 if (c) | |
4270 { | |
4271 free_realized_faces (c); | |
4272 xfree (c->buckets); | |
4273 xfree (c->faces_by_id); | |
4274 xfree (c); | |
4275 } | |
4276 } | |
4277 | |
4278 | |
4279 /* Cache realized face FACE in face cache C. HASH is the hash value | |
4280 of FACE. If FACE->fontset >= 0, add the new face to the end of the | |
4281 collision list of the face hash table of C. This is done because | |
4282 otherwise lookup_face would find FACE for every charset, even if | |
4283 faces with the same attributes but for specific charsets exist. */ | |
4284 | |
4285 static void | |
4286 cache_face (c, face, hash) | |
4287 struct face_cache *c; | |
4288 struct face *face; | |
4289 unsigned hash; | |
4290 { | |
4291 int i = hash % FACE_CACHE_BUCKETS_SIZE; | |
4292 | |
4293 face->hash = hash; | |
4294 | |
4295 if (face->fontset >= 0) | |
4296 { | |
4297 struct face *last = c->buckets[i]; | |
4298 if (last) | |
4299 { | |
4300 while (last->next) | |
4301 last = last->next; | |
4302 last->next = face; | |
4303 face->prev = last; | |
4304 face->next = NULL; | |
4305 } | |
4306 else | |
4307 { | |
4308 c->buckets[i] = face; | |
4309 face->prev = face->next = NULL; | |
4310 } | |
4311 } | |
4312 else | |
4313 { | |
4314 face->prev = NULL; | |
4315 face->next = c->buckets[i]; | |
4316 if (face->next) | |
4317 face->next->prev = face; | |
4318 c->buckets[i] = face; | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4319 } |
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4320 |
24995 | 4321 /* Find a free slot in C->faces_by_id and use the index of the free |
4322 slot as FACE->id. */ | |
4323 for (i = 0; i < c->used; ++i) | |
4324 if (c->faces_by_id[i] == NULL) | |
4325 break; | |
4326 face->id = i; | |
4327 | |
4328 /* Maybe enlarge C->faces_by_id. */ | |
4329 if (i == c->used && c->used == c->size) | |
4330 { | |
4331 int new_size = 2 * c->size; | |
4332 int sz = new_size * sizeof *c->faces_by_id; | |
4333 c->faces_by_id = (struct face **) xrealloc (c->faces_by_id, sz); | |
4334 c->size = new_size; | |
4335 } | |
4336 | |
4337 #if GLYPH_DEBUG | |
4338 /* Check that FACE got a unique id. */ | |
4339 { | |
4340 int j, n; | |
4341 struct face *face; | |
4342 | |
4343 for (j = n = 0; j < FACE_CACHE_BUCKETS_SIZE; ++j) | |
4344 for (face = c->buckets[j]; face; face = face->next) | |
4345 if (face->id == i) | |
4346 ++n; | |
4347 | |
4348 xassert (n == 1); | |
4349 } | |
4350 #endif /* GLYPH_DEBUG */ | |
4351 | |
4352 c->faces_by_id[i] = face; | |
4353 if (i == c->used) | |
4354 ++c->used; | |
4355 } | |
4356 | |
4357 | |
4358 /* Remove face FACE from cache C. */ | |
4359 | |
4360 static void | |
4361 uncache_face (c, face) | |
4362 struct face_cache *c; | |
4363 struct face *face; | |
4364 { | |
4365 int i = face->hash % FACE_CACHE_BUCKETS_SIZE; | |
4366 | |
4367 if (face->prev) | |
4368 face->prev->next = face->next; | |
4369 else | |
4370 c->buckets[i] = face->next; | |
4371 | |
4372 if (face->next) | |
4373 face->next->prev = face->prev; | |
4374 | |
4375 c->faces_by_id[face->id] = NULL; | |
4376 if (face->id == c->used) | |
4377 --c->used; | |
4378 } | |
4379 | |
4380 | |
4381 /* Look up a realized face with face attributes ATTR in the face cache | |
4382 of frame F. The face will be used to display characters of | |
4383 CHARSET. CHARSET < 0 means the face will be used to display | |
4384 unibyte text. The value of face-default-registry is used to choose | |
4385 a font for the face in that case. Value is the ID of the face | |
4386 found. If no suitable face is found, realize a new one. */ | |
4387 | |
4388 INLINE int | |
4389 lookup_face (f, attr, charset) | |
4390 struct frame *f; | |
4391 Lisp_Object *attr; | |
4392 int charset; | |
4393 { | |
4394 struct face_cache *c = FRAME_FACE_CACHE (f); | |
4395 unsigned hash; | |
4396 int i; | |
4397 struct face *face; | |
4398 | |
4399 xassert (c != NULL); | |
4400 check_lface_attrs (attr); | |
4401 | |
4402 /* Look up ATTR in the face cache. */ | |
4403 hash = lface_hash (attr); | |
4404 i = hash % FACE_CACHE_BUCKETS_SIZE; | |
4405 | |
4406 for (face = c->buckets[i]; face; face = face->next) | |
4407 if (face->hash == hash | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4408 && (!FRAME_WINDOW_P (f) |
24995 | 4409 || FACE_SUITABLE_FOR_CHARSET_P (face, charset)) |
4410 && lface_equal_p (face->lface, attr)) | |
4411 break; | |
4412 | |
4413 /* If not found, realize a new face. */ | |
4414 if (face == NULL) | |
4415 { | |
4416 face = realize_face (c, attr, charset); | |
4417 cache_face (c, face, hash); | |
4418 } | |
4419 | |
4420 #if GLYPH_DEBUG | |
4421 xassert (face == FACE_FROM_ID (f, face->id)); | |
4422 if (FRAME_X_P (f)) | |
4423 xassert (charset < 0 || FACE_SUITABLE_FOR_CHARSET_P (face, charset)); | |
4424 #endif /* GLYPH_DEBUG */ | |
4425 | |
4426 return face->id; | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4427 } |
24995 | 4428 |
4429 | |
4430 /* Return the face id of the realized face for named face SYMBOL on | |
4431 frame F suitable for displaying characters from CHARSET. CHARSET < | |
4432 0 means unibyte text. */ | |
4433 | |
4434 int | |
4435 lookup_named_face (f, symbol, charset) | |
4436 struct frame *f; | |
4437 Lisp_Object symbol; | |
4438 int charset; | |
4439 { | |
4440 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
4441 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; | |
4442 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
4443 | |
4444 get_lface_attributes (f, symbol, symbol_attrs, 1); | |
4445 bcopy (default_face->lface, attrs, sizeof attrs); | |
4446 merge_face_vectors (symbol_attrs, attrs); | |
4447 return lookup_face (f, attrs, charset); | |
4448 } | |
4449 | |
4450 | |
4451 /* Return the ID of the realized ASCII face of Lisp face with ID | |
4452 LFACE_ID on frame F. Value is -1 if LFACE_ID isn't valid. */ | |
4453 | |
4454 int | |
4455 ascii_face_of_lisp_face (f, lface_id) | |
4456 struct frame *f; | |
4457 int lface_id; | |
4458 { | |
4459 int face_id; | |
4460 | |
4461 if (lface_id >= 0 && lface_id < lface_id_to_name_size) | |
4462 { | |
4463 Lisp_Object face_name = lface_id_to_name[lface_id]; | |
4464 face_id = lookup_named_face (f, face_name, CHARSET_ASCII); | |
4465 } | |
4466 else | |
4467 face_id = -1; | |
4468 | |
4469 return face_id; | |
4470 } | |
4471 | |
4472 | |
4473 /* Return a face for charset ASCII that is like the face with id | |
4474 FACE_ID on frame F, but has a font that is STEPS steps smaller. | |
4475 STEPS < 0 means larger. Value is the id of the face. */ | |
4476 | |
4477 int | |
4478 smaller_face (f, face_id, steps) | |
4479 struct frame *f; | |
4480 int face_id, steps; | |
4481 { | |
4482 #ifdef HAVE_X_WINDOWS | |
4483 struct face *face; | |
4484 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
4485 int pt, last_pt, last_height; | |
4486 int delta; | |
4487 int new_face_id; | |
4488 struct face *new_face; | |
4489 | |
4490 /* If not called for an X frame, just return the original face. */ | |
4491 if (FRAME_TERMCAP_P (f)) | |
4492 return face_id; | |
4493 | |
4494 /* Try in increments of 1/2 pt. */ | |
4495 delta = steps < 0 ? 5 : -5; | |
4496 steps = abs (steps); | |
4497 | |
4498 face = FACE_FROM_ID (f, face_id); | |
4499 bcopy (face->lface, attrs, sizeof attrs); | |
4500 pt = last_pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]); | |
4501 new_face_id = face_id; | |
4502 last_height = FONT_HEIGHT (face->font); | |
4503 | |
4504 while (steps | |
4505 && pt + delta > 0 | |
4506 /* Give up if we cannot find a font within 10pt. */ | |
4507 && abs (last_pt - pt) < 100) | |
4508 { | |
4509 /* Look up a face for a slightly smaller/larger font. */ | |
4510 pt += delta; | |
4511 attrs[LFACE_HEIGHT_INDEX] = make_number (pt); | |
4512 new_face_id = lookup_face (f, attrs, CHARSET_ASCII); | |
4513 new_face = FACE_FROM_ID (f, new_face_id); | |
4514 | |
4515 /* If height changes, count that as one step. */ | |
4516 if (FONT_HEIGHT (new_face->font) != last_height) | |
4517 { | |
4518 --steps; | |
4519 last_height = FONT_HEIGHT (new_face->font); | |
4520 last_pt = pt; | |
4521 } | |
4522 } | |
4523 | |
4524 return new_face_id; | |
4525 | |
4526 #else /* not HAVE_X_WINDOWS */ | |
4527 | |
4528 return face_id; | |
4529 | |
4530 #endif /* not HAVE_X_WINDOWS */ | |
4531 } | |
4532 | |
4533 | |
4534 /* Return a face for charset ASCII that is like the face with id | |
4535 FACE_ID on frame F, but has height HEIGHT. */ | |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
4536 |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
4537 int |
24995 | 4538 face_with_height (f, face_id, height) |
4539 struct frame *f; | |
4540 int face_id; | |
4541 int height; | |
4542 { | |
4543 #ifdef HAVE_X_WINDOWS | |
4544 struct face *face; | |
4545 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
4546 | |
4547 if (FRAME_TERMCAP_P (f) | |
4548 || height <= 0) | |
4549 return face_id; | |
4550 | |
4551 face = FACE_FROM_ID (f, face_id); | |
4552 bcopy (face->lface, attrs, sizeof attrs); | |
4553 attrs[LFACE_HEIGHT_INDEX] = make_number (height); | |
4554 face_id = lookup_face (f, attrs, CHARSET_ASCII); | |
4555 #endif /* HAVE_X_WINDOWS */ | |
4556 | |
4557 return face_id; | |
4558 } | |
4559 | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4560 /* Return the face id of the realized face for named face SYMBOL on |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4561 frame F suitable for displaying characters from CHARSET (CHARSET < |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4562 0 means unibyte text), and use attributes of the face FACE_ID for |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4563 attributes that aren't completely specified by SYMBOL. This is |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4564 like lookup_named_face, except that the default attributes come |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4565 from FACE_ID, not from the default face. FACE_ID is assumed to |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4566 be already realized. */ |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4567 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4568 int |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4569 lookup_derived_face (f, symbol, charset, face_id) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4570 struct frame *f; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4571 Lisp_Object symbol; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4572 int charset; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4573 int face_id; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4574 { |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4575 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4576 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4577 struct face *default_face = FACE_FROM_ID (f, face_id); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4578 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4579 if (!default_face) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4580 abort (); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4581 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4582 get_lface_attributes (f, symbol, symbol_attrs, 1); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4583 bcopy (default_face->lface, attrs, sizeof attrs); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4584 merge_face_vectors (symbol_attrs, attrs); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4585 return lookup_face (f, attrs, charset); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4586 } |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4587 |
24995 | 4588 |
4589 | |
4590 /*********************************************************************** | |
4591 Font selection | |
4592 ***********************************************************************/ | |
4593 | |
4594 DEFUN ("internal-set-font-selection-order", | |
4595 Finternal_set_font_selection_order, | |
4596 Sinternal_set_font_selection_order, 1, 1, 0, | |
4597 "Set font selection order for face font selection to ORDER.\n\ | |
4598 ORDER must be a list of length 4 containing the symbols `:width',\n\ | |
4599 `:height', `:weight', and `:slant'. Face attributes appearing\n\ | |
4600 first in ORDER are matched first, e.g. if `:height' appears before\n\ | |
4601 `:weight' in ORDER, font selection first tries to find a font with\n\ | |
4602 a suitable height, and then tries to match the font weight.\n\ | |
4603 Value is ORDER.") | |
4604 (order) | |
4605 Lisp_Object order; | |
4606 { | |
4607 Lisp_Object list; | |
4608 int i; | |
4609 int indices[4]; | |
4610 | |
4611 CHECK_LIST (order, 0); | |
4612 bzero (indices, sizeof indices); | |
4613 i = 0; | |
4614 | |
4615 for (list = order; | |
4616 CONSP (list) && i < DIM (indices); | |
4617 list = XCDR (list), ++i) | |
4618 { | |
4619 Lisp_Object attr = XCAR (list); | |
4620 int xlfd; | |
4621 | |
4622 if (EQ (attr, QCwidth)) | |
4623 xlfd = XLFD_SWIDTH; | |
4624 else if (EQ (attr, QCheight)) | |
4625 xlfd = XLFD_POINT_SIZE; | |
4626 else if (EQ (attr, QCweight)) | |
4627 xlfd = XLFD_WEIGHT; | |
4628 else if (EQ (attr, QCslant)) | |
4629 xlfd = XLFD_SLANT; | |
4630 else | |
4631 break; | |
4632 | |
4633 if (indices[i] != 0) | |
4634 break; | |
4635 indices[i] = xlfd; | |
4636 } | |
4637 | |
4638 if (!NILP (list) | |
4639 || i != DIM (indices) | |
4640 || indices[0] == 0 | |
4641 || indices[1] == 0 | |
4642 || indices[2] == 0 | |
4643 || indices[3] == 0) | |
4644 signal_error ("Invalid font sort order", order); | |
4645 | |
4646 if (bcmp (indices, font_sort_order, sizeof indices) != 0) | |
4647 { | |
4648 bcopy (indices, font_sort_order, sizeof font_sort_order); | |
4649 free_all_realized_faces (Qnil); | |
4650 } | |
4651 | |
4652 return Qnil; | |
4653 } | |
4654 | |
4655 | |
4656 DEFUN ("internal-set-alternative-font-family-alist", | |
4657 Finternal_set_alternative_font_family_alist, | |
4658 Sinternal_set_alternative_font_family_alist, 1, 1, 0, | |
4659 "Define alternative font families to try in face font selection.\n\ | |
4660 ALIST is an alist of (FAMILY ALTERNATIVE1 ALTERNATIVE2 ...) entries.\n\ | |
4661 Each ALTERNATIVE is tried in order if no fonts of font family FAMILY can\n\ | |
4662 be found. Value is ALIST.") | |
4663 (alist) | |
4664 Lisp_Object alist; | |
4665 { | |
4666 CHECK_LIST (alist, 0); | |
4667 Vface_alternative_font_family_alist = alist; | |
4668 free_all_realized_faces (Qnil); | |
4669 return alist; | |
4670 } | |
4671 | |
4672 | |
4673 #ifdef HAVE_X_WINDOWS | |
4674 | |
4675 /* Return the X registry and encoding of font name FONT_NAME on frame F. | |
4676 Value is nil if not successful. */ | |
4677 | |
4678 static Lisp_Object | |
4679 deduce_unibyte_registry (f, font_name) | |
4680 struct frame *f; | |
4681 char *font_name; | |
4682 { | |
4683 struct font_name font; | |
4684 Lisp_Object registry = Qnil; | |
4685 | |
4686 font.name = STRDUPA (font_name); | |
4687 if (split_font_name (f, &font, 0)) | |
4688 { | |
4689 char *buffer; | |
4690 | |
4691 /* Extract registry and encoding. */ | |
4692 buffer = (char *) alloca (strlen (font.fields[XLFD_REGISTRY]) | |
4693 + strlen (font.fields[XLFD_ENCODING]) | |
4694 + 10); | |
4695 strcpy (buffer, font.fields[XLFD_REGISTRY]); | |
4696 strcat (buffer, "-"); | |
4697 strcat (buffer, font.fields[XLFD_ENCODING]); | |
4698 registry = build_string (buffer); | |
4699 } | |
4700 | |
4701 return registry; | |
4702 } | |
4703 | |
4704 | |
4705 /* Value is non-zero if FONT is the name of a scalable font. The | |
4706 X11R6 XLFD spec says that point size, pixel size, and average width | |
4707 are zero for scalable fonts. Intlfonts contain at least one | |
4708 scalable font ("*-muleindian-1") for which this isn't true, so we | |
4709 just test average width. */ | |
4710 | |
4711 static int | |
4712 font_scalable_p (font) | |
4713 struct font_name *font; | |
4714 { | |
4715 char *s = font->fields[XLFD_AVGWIDTH]; | |
4716 return *s == '0' && *(s + 1) == '\0'; | |
4717 } | |
4718 | |
4719 | |
4720 /* Value is non-zero if FONT1 is a better match for font attributes | |
4721 VALUES than FONT2. VALUES is an array of face attribute values in | |
4722 font sort order. COMPARE_PT_P zero means don't compare point | |
4723 sizes. */ | |
4724 | |
4725 static int | |
4726 better_font_p (values, font1, font2, compare_pt_p) | |
4727 int *values; | |
4728 struct font_name *font1, *font2; | |
4729 int compare_pt_p; | |
4730 { | |
4731 int i; | |
4732 | |
4733 for (i = 0; i < 4; ++i) | |
4734 { | |
4735 int xlfd_idx = font_sort_order[i]; | |
4736 | |
4737 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) | |
4738 { | |
4739 int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); | |
4740 int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); | |
4741 | |
4742 if (delta1 > delta2) | |
4743 return 0; | |
4744 else if (delta1 < delta2) | |
4745 return 1; | |
4746 else | |
4747 { | |
4748 /* The difference may be equal because, e.g., the face | |
4749 specifies `italic' but we have only `regular' and | |
4750 `oblique'. Prefer `oblique' in this case. */ | |
4751 if ((xlfd_idx == XLFD_WEIGHT || xlfd_idx == XLFD_SLANT) | |
4752 && font1->numeric[xlfd_idx] > values[i] | |
4753 && font2->numeric[xlfd_idx] < values[i]) | |
4754 return 1; | |
4755 } | |
4756 } | |
4757 } | |
4758 | |
4759 return 0; | |
4760 } | |
4761 | |
4762 | |
4763 #if SCALABLE_FONTS | |
4764 | |
4765 /* Value is non-zero if FONT is an exact match for face attributes in | |
4766 SPECIFIED. SPECIFIED is an array of face attribute values in font | |
4767 sort order. */ | |
4768 | |
4769 static int | |
4770 exact_face_match_p (specified, font) | |
4771 int *specified; | |
4772 struct font_name *font; | |
4773 { | |
4774 int i; | |
4775 | |
4776 for (i = 0; i < 4; ++i) | |
4777 if (specified[i] != font->numeric[font_sort_order[i]]) | |
4778 break; | |
4779 | |
4780 return i == 4; | |
4781 } | |
4782 | |
4783 | |
4784 /* Value is the name of a scaled font, generated from scalable font | |
4785 FONT on frame F. SPECIFIED_PT is the point-size to scale FONT to. | |
4786 Value is allocated from heap. */ | |
4787 | |
4788 static char * | |
4789 build_scalable_font_name (f, font, specified_pt) | |
4790 struct frame *f; | |
4791 struct font_name *font; | |
4792 int specified_pt; | |
4793 { | |
4794 char point_size[20], pixel_size[20]; | |
4795 int pixel_value; | |
4796 double resy = FRAME_X_DISPLAY_INFO (f)->resy; | |
4797 double pt; | |
4798 | |
4799 /* If scalable font is for a specific resolution, compute | |
4800 the point size we must specify from the resolution of | |
4801 the display and the specified resolution of the font. */ | |
4802 if (font->numeric[XLFD_RESY] != 0) | |
4803 { | |
4804 pt = resy / font->numeric[XLFD_RESY] * specified_pt + 0.5; | |
4805 pixel_value = font->numeric[XLFD_RESY] / 720.0 * pt; | |
4806 } | |
4807 else | |
4808 { | |
4809 pt = specified_pt; | |
4810 pixel_value = resy / 720.0 * pt; | |
4811 } | |
4812 | |
4813 /* Set point size of the font. */ | |
4814 sprintf (point_size, "%d", (int) pt); | |
4815 font->fields[XLFD_POINT_SIZE] = point_size; | |
4816 font->numeric[XLFD_POINT_SIZE] = pt; | |
4817 | |
4818 /* Set pixel size. */ | |
4819 sprintf (pixel_size, "%d", pixel_value); | |
4820 font->fields[XLFD_PIXEL_SIZE] = pixel_size; | |
4821 font->numeric[XLFD_PIXEL_SIZE] = pixel_value; | |
4822 | |
4823 /* If font doesn't specify its resolution, use the | |
4824 resolution of the display. */ | |
4825 if (font->numeric[XLFD_RESY] == 0) | |
4826 { | |
4827 char buffer[20]; | |
4828 sprintf (buffer, "%d", (int) resy); | |
4829 font->fields[XLFD_RESY] = buffer; | |
4830 font->numeric[XLFD_RESY] = resy; | |
4831 } | |
4832 | |
4833 if (strcmp (font->fields[XLFD_RESX], "0") == 0) | |
4834 { | |
4835 char buffer[20]; | |
4836 int resx = FRAME_X_DISPLAY_INFO (f)->resx; | |
4837 sprintf (buffer, "%d", resx); | |
4838 font->fields[XLFD_RESX] = buffer; | |
4839 font->numeric[XLFD_RESX] = resx; | |
4840 } | |
4841 | |
4842 return build_font_name (font); | |
4843 } | |
4844 | |
4845 | |
4846 /* Value is non-zero if we are allowed to use scalable font FONT. We | |
4847 can't run a Lisp function here since this function may be called | |
4848 with input blocked. */ | |
4849 | |
4850 static int | |
4851 may_use_scalable_font_p (font, name) | |
4852 struct font_name *font; | |
4853 char *name; | |
4854 { | |
4855 if (EQ (Vscalable_fonts_allowed, Qt)) | |
4856 return 1; | |
4857 else if (CONSP (Vscalable_fonts_allowed)) | |
4858 { | |
4859 Lisp_Object tail, regexp; | |
4860 | |
4861 for (tail = Vscalable_fonts_allowed; CONSP (tail); tail = XCDR (tail)) | |
4862 { | |
4863 regexp = XCAR (tail); | |
4864 if (STRINGP (regexp) | |
4865 && fast_c_string_match_ignore_case (regexp, name) >= 0) | |
4866 return 1; | |
4867 } | |
4868 } | |
4869 | |
4870 return 0; | |
4871 } | |
4872 | |
4873 #endif /* SCALABLE_FONTS != 0 */ | |
4874 | |
4875 | |
4876 /* Return the name of the best matching font for face attributes | |
4877 ATTRS in the array of font_name structures FONTS which contains | |
4878 NFONTS elements. Value is a font name which is allocated from | |
4879 the heap. FONTS is freed by this function. */ | |
4880 | |
4881 static char * | |
4882 best_matching_font (f, attrs, fonts, nfonts) | |
4883 struct frame *f; | |
4884 Lisp_Object *attrs; | |
4885 struct font_name *fonts; | |
4886 int nfonts; | |
4887 { | |
4888 char *font_name; | |
4889 struct font_name *best; | |
4890 int i, pt; | |
4891 int specified[4]; | |
4892 int exact_p; | |
4893 | |
4894 if (nfonts == 0) | |
4895 return NULL; | |
4896 | |
4897 /* Make specified font attributes available in `specified', | |
4898 indexed by sort order. */ | |
4899 for (i = 0; i < DIM (font_sort_order); ++i) | |
4900 { | |
4901 int xlfd_idx = font_sort_order[i]; | |
4902 | |
4903 if (xlfd_idx == XLFD_SWIDTH) | |
4904 specified[i] = face_numeric_swidth (attrs[LFACE_SWIDTH_INDEX]); | |
4905 else if (xlfd_idx == XLFD_POINT_SIZE) | |
4906 specified[i] = pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]); | |
4907 else if (xlfd_idx == XLFD_WEIGHT) | |
4908 specified[i] = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]); | |
4909 else if (xlfd_idx == XLFD_SLANT) | |
4910 specified[i] = face_numeric_slant (attrs[LFACE_SLANT_INDEX]); | |
4911 else | |
4912 abort (); | |
4913 } | |
4914 | |
4915 #if SCALABLE_FONTS | |
4916 | |
4917 /* Set to 1 */ | |
4918 exact_p = 0; | |
4919 | |
4920 /* Start with the first non-scalable font in the list. */ | |
4921 for (i = 0; i < nfonts; ++i) | |
4922 if (!font_scalable_p (fonts + i)) | |
4923 break; | |
4924 | |
4925 /* Find the best match among the non-scalable fonts. */ | |
4926 if (i < nfonts) | |
4927 { | |
4928 best = fonts + i; | |
4929 | |
4930 for (i = 1; i < nfonts; ++i) | |
4931 if (!font_scalable_p (fonts + i) | |
4932 && better_font_p (specified, fonts + i, best, 1)) | |
4933 { | |
4934 best = fonts + i; | |
4935 | |
4936 exact_p = exact_face_match_p (specified, best); | |
4937 if (exact_p) | |
4938 break; | |
4939 } | |
4940 | |
4941 } | |
4942 else | |
4943 best = NULL; | |
4944 | |
4945 /* Unless we found an exact match among non-scalable fonts, see if | |
4946 we can find a better match among scalable fonts. */ | |
4947 if (!exact_p) | |
4948 { | |
4949 /* A scalable font is better if | |
4950 | |
4951 1. its weight, slant, swidth attributes are better, or. | |
4952 | |
4953 2. the best non-scalable font doesn't have the required | |
4954 point size, and the scalable fonts weight, slant, swidth | |
4955 isn't worse. */ | |
4956 | |
4957 int non_scalable_has_exact_height_p; | |
4958 | |
4959 if (best && best->numeric[XLFD_POINT_SIZE] == pt) | |
4960 non_scalable_has_exact_height_p = 1; | |
4961 else | |
4962 non_scalable_has_exact_height_p = 0; | |
4963 | |
4964 for (i = 0; i < nfonts; ++i) | |
4965 if (font_scalable_p (fonts + i)) | |
4966 { | |
4967 if (best == NULL | |
4968 || better_font_p (specified, fonts + i, best, 0) | |
4969 || (!non_scalable_has_exact_height_p | |
4970 && !better_font_p (specified, best, fonts + i, 0))) | |
4971 best = fonts + i; | |
4972 } | |
4973 } | |
4974 | |
4975 if (font_scalable_p (best)) | |
4976 font_name = build_scalable_font_name (f, best, pt); | |
4977 else | |
4978 font_name = build_font_name (best); | |
4979 | |
4980 #else /* !SCALABLE_FONTS */ | |
4981 | |
4982 /* Find the best non-scalable font. */ | |
4983 best = fonts; | |
4984 | |
4985 for (i = 1; i < nfonts; ++i) | |
4986 { | |
4987 xassert (!font_scalable_p (fonts + i)); | |
4988 if (better_font_p (specified, fonts + i, best, 1)) | |
4989 best = fonts + i; | |
4990 } | |
4991 | |
4992 font_name = build_font_name (best); | |
4993 | |
4994 #endif /* !SCALABLE_FONTS */ | |
4995 | |
4996 /* Free font_name structures. */ | |
4997 free_font_names (fonts, nfonts); | |
4998 | |
4999 return font_name; | |
5000 } | |
5001 | |
5002 | |
5003 /* Try to get a list of fonts on frame F with font family FAMILY and | |
5004 registry/encoding REGISTRY. Return in *FONTS a pointer to a vector | |
5005 of font_name structures for the fonts matched. Value is the number | |
5006 of fonts found. */ | |
5007 | |
5008 static int | |
5009 try_font_list (f, attrs, pattern, family, registry, fonts) | |
5010 struct frame *f; | |
5011 Lisp_Object *attrs; | |
5012 char *pattern, *family, *registry; | |
5013 struct font_name **fonts; | |
5014 { | |
5015 int nfonts; | |
5016 | |
5017 if (family == NULL) | |
5018 family = LSTRDUPA (attrs[LFACE_FAMILY_INDEX]); | |
5019 | |
5020 nfonts = font_list (f, pattern, family, registry, fonts); | |
5021 | |
5022 if (nfonts == 0) | |
5023 { | |
5024 Lisp_Object alter; | |
5025 | |
5026 /* Try alternative font families from | |
5027 Vface_alternative_font_family_alist. */ | |
5028 alter = Fassoc (build_string (family), | |
5029 Vface_alternative_font_family_alist); | |
5030 if (CONSP (alter)) | |
5031 for (alter = XCDR (alter); | |
5032 CONSP (alter) && nfonts == 0; | |
5033 alter = XCDR (alter)) | |
5034 { | |
5035 if (STRINGP (XCAR (alter))) | |
5036 { | |
5037 family = LSTRDUPA (XCAR (alter)); | |
5038 nfonts = font_list (f, NULL, family, registry, fonts); | |
5039 } | |
5040 } | |
5041 | |
5042 /* Try font family of the default face or "fixed". */ | |
5043 if (nfonts == 0) | |
5044 { | |
5045 struct face *dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
5046 if (dflt) | |
5047 family = LSTRDUPA (dflt->lface[LFACE_FAMILY_INDEX]); | |
5048 else | |
5049 family = "fixed"; | |
5050 nfonts = font_list (f, NULL, family, registry, fonts); | |
5051 } | |
5052 | |
5053 /* Try any family with the given registry. */ | |
5054 if (nfonts == 0) | |
5055 nfonts = font_list (f, NULL, "*", registry, fonts); | |
5056 } | |
5057 | |
5058 return nfonts; | |
5059 } | |
5060 | |
5061 | |
5062 /* Return the registry and encoding pattern that fonts for CHARSET | |
5063 should match. Value is allocated from the heap. */ | |
5064 | |
5065 char * | |
5066 x_charset_registry (charset) | |
5067 int charset; | |
5068 { | |
5069 Lisp_Object prop, charset_plist; | |
5070 char *registry; | |
5071 | |
5072 /* Get registry and encoding from the charset's plist. */ | |
5073 charset_plist = CHARSET_TABLE_INFO (charset, CHARSET_PLIST_IDX); | |
5074 prop = Fplist_get (charset_plist, Qx_charset_registry); | |
5075 | |
5076 if (STRINGP (prop)) | |
5077 { | |
5078 if (index (XSTRING (prop)->data, '-')) | |
5079 registry = xstrdup (XSTRING (prop)->data); | |
5080 else | |
5081 { | |
5082 /* If registry doesn't contain a `-', make it a pattern. */ | |
5083 registry = (char *) xmalloc (STRING_BYTES (XSTRING (prop)) + 5); | |
5084 strcpy (registry, XSTRING (prop)->data); | |
5085 strcat (registry, "*-*"); | |
5086 } | |
5087 } | |
5088 else if (STRINGP (Vface_default_registry)) | |
5089 registry = xstrdup (XSTRING (Vface_default_registry)->data); | |
5090 else | |
5091 registry = xstrdup ("iso8859-1"); | |
5092 | |
5093 return registry; | |
5094 } | |
5095 | |
5096 | |
5097 /* Return the fontset id of the fontset name or alias name given by | |
5098 the family attribute of ATTRS on frame F. Value is -1 if the | |
5099 family attribute of ATTRS doesn't name a fontset. */ | |
5100 | |
5101 static int | |
5102 face_fontset (f, attrs) | |
5103 struct frame *f; | |
5104 Lisp_Object *attrs; | |
5105 { | |
5106 Lisp_Object name = attrs[LFACE_FAMILY_INDEX]; | |
5107 int fontset; | |
5108 | |
5109 name = Fquery_fontset (name, Qnil); | |
5110 if (NILP (name)) | |
5111 fontset = -1; | |
5112 else | |
5113 fontset = fs_query_fontset (f, XSTRING (name)->data); | |
5114 | |
5115 return fontset; | |
5116 } | |
5117 | |
5118 | |
5119 /* Get the font to use for the face realizing the fully-specified Lisp | |
5120 face ATTRS for charset CHARSET on frame F. CHARSET < 0 means | |
5121 unibyte text; UNIBYTE_REGISTRY is the registry and encoding to use | |
5122 in this case. Value is the font name which is allocated from the | |
5123 heap (which means that it must be freed eventually). */ | |
5124 | |
5125 static char * | |
5126 choose_face_font (f, attrs, charset, unibyte_registry) | |
5127 struct frame *f; | |
5128 Lisp_Object *attrs; | |
5129 int charset; | |
5130 Lisp_Object unibyte_registry; | |
5131 { | |
5132 struct font_name *fonts; | |
5133 int nfonts; | |
5134 char *registry; | |
5135 | |
5136 /* ATTRS must be fully-specified. */ | |
5137 xassert (lface_fully_specified_p (attrs)); | |
5138 | |
5139 if (STRINGP (unibyte_registry)) | |
5140 registry = xstrdup (XSTRING (unibyte_registry)->data); | |
5141 else | |
5142 registry = x_charset_registry (charset); | |
5143 | |
5144 nfonts = try_font_list (f, attrs, NULL, NULL, registry, &fonts); | |
5145 xfree (registry); | |
5146 return best_matching_font (f, attrs, fonts, nfonts); | |
5147 } | |
5148 | |
5149 | |
5150 /* Choose a font to use on frame F to display CHARSET using FONTSET | |
5151 with Lisp face attributes specified by ATTRS. CHARSET may be any | |
5152 valid charset except CHARSET_COMPOSITION. CHARSET < 0 means | |
5153 unibyte text. If the fontset doesn't contain a font pattern for | |
5154 charset, use the pattern for CHARSET_ASCII. Value is the font name | |
5155 which is allocated from the heap and must be freed by the caller. */ | |
5156 | |
5157 static char * | |
5158 choose_face_fontset_font (f, attrs, fontset, charset) | |
5159 struct frame *f; | |
5160 Lisp_Object *attrs; | |
5161 int fontset, charset; | |
5162 { | |
5163 char *pattern; | |
5164 char *font_name = NULL; | |
5165 struct fontset_info *fontset_info; | |
5166 struct font_name *fonts; | |
5167 int nfonts; | |
5168 | |
5169 xassert (charset != CHARSET_COMPOSITION); | |
5170 xassert (fontset >= 0 && fontset < FRAME_FONTSET_DATA (f)->n_fontsets); | |
5171 | |
5172 /* For unibyte text, use the ASCII font of the fontset. Using the | |
5173 ASCII font seems to be the most reasonable thing we can do in | |
5174 this case. */ | |
5175 if (charset < 0) | |
5176 charset = CHARSET_ASCII; | |
5177 | |
5178 /* Get the font name pattern to use for CHARSET from the fontset. */ | |
5179 fontset_info = FRAME_FONTSET_DATA (f)->fontset_table[fontset]; | |
5180 pattern = fontset_info->fontname[charset]; | |
5181 if (!pattern) | |
5182 pattern = fontset_info->fontname[CHARSET_ASCII]; | |
5183 xassert (pattern); | |
5184 | |
5185 /* Get a list of fonts matching that pattern and choose the | |
5186 best match for the specified face attributes from it. */ | |
5187 nfonts = try_font_list (f, attrs, pattern, NULL, NULL, &fonts); | |
5188 font_name = best_matching_font (f, attrs, fonts, nfonts); | |
5189 return font_name; | |
5190 } | |
5191 | |
5192 #endif /* HAVE_X_WINDOWS */ | |
5193 | |
5194 | |
5195 | |
5196 /*********************************************************************** | |
5197 Face Realization | |
5198 ***********************************************************************/ | |
5199 | |
5200 /* Realize basic faces on frame F. Value is zero if frame parameters | |
5201 of F don't contain enough information needed to realize the default | |
5202 face. */ | |
5203 | |
5204 static int | |
5205 realize_basic_faces (f) | |
2342 | 5206 struct frame *f; |
24995 | 5207 { |
5208 int success_p = 0; | |
5209 | |
5210 if (realize_default_face (f)) | |
5211 { | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
5212 realize_named_face (f, Qmode_line, MODE_LINE_FACE_ID); |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25389
diff
changeset
|
5213 realize_named_face (f, Qtool_bar, TOOL_BAR_FACE_ID); |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
5214 realize_named_face (f, Qfringe, BITMAP_AREA_FACE_ID); |
25546 | 5215 realize_named_face (f, Qheader_line, HEADER_LINE_FACE_ID); |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
5216 realize_named_face (f, Qscroll_bar, SCROLL_BAR_FACE_ID); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
5217 realize_named_face (f, Qborder, BORDER_FACE_ID); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
5218 realize_named_face (f, Qcursor, CURSOR_FACE_ID); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
5219 realize_named_face (f, Qmouse, MOUSE_FACE_ID); |
24995 | 5220 success_p = 1; |
5221 } | |
5222 | |
5223 return success_p; | |
5224 } | |
5225 | |
5226 | |
5227 /* Realize the default face on frame F. If the face is not fully | |
5228 specified, make it fully-specified. Attributes of the default face | |
5229 that are not explicitly specified are taken from frame parameters. */ | |
5230 | |
5231 static int | |
5232 realize_default_face (f) | |
5233 struct frame *f; | |
5234 { | |
5235 struct face_cache *c = FRAME_FACE_CACHE (f); | |
5236 Lisp_Object lface; | |
5237 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
5238 Lisp_Object unibyte_registry; | |
5239 Lisp_Object frame_font; | |
5240 struct face *face; | |
5241 int fontset; | |
5242 | |
5243 /* If the `default' face is not yet known, create it. */ | |
5244 lface = lface_from_face_name (f, Qdefault, 0); | |
5245 if (NILP (lface)) | |
5246 { | |
5247 Lisp_Object frame; | |
5248 XSETFRAME (frame, f); | |
5249 lface = Finternal_make_lisp_face (Qdefault, frame); | |
5250 } | |
5251 | |
5252 #ifdef HAVE_X_WINDOWS | |
5253 if (FRAME_X_P (f)) | |
5254 { | |
5255 /* Set frame_font to the value of the `font' frame parameter. */ | |
5256 frame_font = Fassq (Qfont, f->param_alist); | |
5257 xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font))); | |
5258 frame_font = XCDR (frame_font); | |
5259 | |
5260 fontset = fs_query_fontset (f, XSTRING (frame_font)->data); | |
5261 if (fontset >= 0) | |
5262 { | |
5263 /* If frame_font is a fontset name, don't use that for | |
5264 determining font-related attributes of the default face | |
5265 because it is just an artificial name. Use the ASCII font of | |
5266 the fontset, instead. */ | |
5267 struct font_info *font_info; | |
5268 struct font_name font; | |
5269 | |
5270 BLOCK_INPUT; | |
5271 font_info = FS_LOAD_FONT (f, FRAME_X_FONT_TABLE (f), CHARSET_ASCII, | |
5272 NULL, fontset); | |
5273 UNBLOCK_INPUT; | |
5274 | |
5275 /* Set weight etc. from the ASCII font. */ | |
5276 if (!set_lface_from_font_name (f, lface, font_info->full_name, 0)) | |
5277 return 0; | |
5278 | |
5279 /* Remember registry and encoding of the frame font. */ | |
5280 unibyte_registry = deduce_unibyte_registry (f, font_info->full_name); | |
5281 if (STRINGP (unibyte_registry)) | |
5282 Vface_default_registry = unibyte_registry; | |
5283 else | |
5284 Vface_default_registry = build_string ("iso8859-1"); | |
5285 | |
5286 /* But set the family to the fontset alias name. Implementation | |
5287 note: When a font is passed to Emacs via `-fn FONT', a | |
5288 fontset is created in `x-win.el' whose name ends in | |
5289 `fontset-startup'. This fontset has an alias name that is | |
5290 equal to frame_font. */ | |
5291 xassert (STRINGP (frame_font)); | |
5292 font.name = LSTRDUPA (frame_font); | |
5293 | |
5294 if (!split_font_name (f, &font, 1) | |
5295 || xstricmp (font.fields[XLFD_REGISTRY], "fontset") != 0 | |
5296 || xstricmp (font.fields[XLFD_ENCODING], "startup") != 0) | |
5297 LFACE_FAMILY (lface) = frame_font; | |
5298 } | |
5299 else | |
5300 { | |
5301 /* Frame parameters contain a real font. Fill default face | |
5302 attributes from that font. */ | |
5303 if (!set_lface_from_font_name (f, lface, | |
5304 XSTRING (frame_font)->data, 0)) | |
5305 return 0; | |
5306 | |
5307 /* Remember registry and encoding of the frame font. */ | |
5308 unibyte_registry | |
5309 = deduce_unibyte_registry (f, XSTRING (frame_font)->data); | |
5310 if (STRINGP (unibyte_registry)) | |
5311 Vface_default_registry = unibyte_registry; | |
5312 else | |
5313 Vface_default_registry = build_string ("iso8859-1"); | |
5314 } | |
5315 } | |
5316 #endif /* HAVE_X_WINDOWS */ | |
5317 | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5318 if (!FRAME_WINDOW_P (f)) |
24995 | 5319 { |
5320 LFACE_FAMILY (lface) = build_string ("default"); | |
5321 LFACE_SWIDTH (lface) = Qnormal; | |
5322 LFACE_HEIGHT (lface) = make_number (1); | |
5323 LFACE_WEIGHT (lface) = Qnormal; | |
5324 LFACE_SLANT (lface) = Qnormal; | |
5325 } | |
5326 | |
5327 if (UNSPECIFIEDP (LFACE_UNDERLINE (lface))) | |
5328 LFACE_UNDERLINE (lface) = Qnil; | |
5329 | |
5330 if (UNSPECIFIEDP (LFACE_OVERLINE (lface))) | |
5331 LFACE_OVERLINE (lface) = Qnil; | |
5332 | |
5333 if (UNSPECIFIEDP (LFACE_STRIKE_THROUGH (lface))) | |
5334 LFACE_STRIKE_THROUGH (lface) = Qnil; | |
5335 | |
5336 if (UNSPECIFIEDP (LFACE_BOX (lface))) | |
5337 LFACE_BOX (lface) = Qnil; | |
5338 | |
5339 if (UNSPECIFIEDP (LFACE_INVERSE (lface))) | |
5340 LFACE_INVERSE (lface) = Qnil; | |
5341 | |
5342 if (UNSPECIFIEDP (LFACE_FOREGROUND (lface))) | |
5343 { | |
5344 /* This function is called so early that colors are not yet | |
5345 set in the frame parameter list. */ | |
5346 Lisp_Object color = Fassq (Qforeground_color, f->param_alist); | |
5347 | |
5348 if (CONSP (color) && STRINGP (XCDR (color))) | |
5349 LFACE_FOREGROUND (lface) = XCDR (color); | |
5350 else if (FRAME_X_P (f)) | |
5351 return 0; | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5352 else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) |
24995 | 5353 /* Frame parameters for terminal frames usually don't contain |
5354 a color. Use an empty string to indicate that the face | |
5355 should use the (unknown) default color of the terminal. */ | |
5356 LFACE_FOREGROUND (lface) = build_string (""); | |
5357 else | |
5358 abort (); | |
5359 } | |
5360 | |
5361 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface))) | |
5362 { | |
5363 /* This function is called so early that colors are not yet | |
5364 set in the frame parameter list. */ | |
5365 Lisp_Object color = Fassq (Qbackground_color, f->param_alist); | |
5366 if (CONSP (color) && STRINGP (XCDR (color))) | |
5367 LFACE_BACKGROUND (lface) = XCDR (color); | |
5368 else if (FRAME_X_P (f)) | |
5369 return 0; | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5370 else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) |
24995 | 5371 /* Frame parameters for terminal frames usually don't contain |
5372 a color. Use an empty string to indicate that the face | |
5373 should use the (unknown) default color of the terminal. */ | |
5374 LFACE_BACKGROUND (lface) = build_string (""); | |
5375 else | |
5376 abort (); | |
5377 } | |
5378 | |
5379 if (UNSPECIFIEDP (LFACE_STIPPLE (lface))) | |
5380 LFACE_STIPPLE (lface) = Qnil; | |
5381 | |
5382 /* Realize the face; it must be fully-specified now. */ | |
5383 xassert (lface_fully_specified_p (XVECTOR (lface)->contents)); | |
5384 check_lface (lface); | |
5385 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); | |
5386 face = realize_face (c, attrs, CHARSET_ASCII); | |
5387 | |
5388 /* Remove the former default face. */ | |
5389 if (c->used > DEFAULT_FACE_ID) | |
5390 { | |
5391 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
5392 uncache_face (c, default_face); | |
5393 free_realized_face (f, default_face); | |
5394 } | |
5395 | |
5396 /* Insert the new default face. */ | |
5397 cache_face (c, face, lface_hash (attrs)); | |
5398 xassert (face->id == DEFAULT_FACE_ID); | |
5399 return 1; | |
5400 } | |
5401 | |
5402 | |
5403 /* Realize basic faces other than the default face in face cache C. | |
5404 SYMBOL is the face name, ID is the face id the realized face must | |
5405 have. The default face must have been realized already. */ | |
5406 | |
5407 static void | |
5408 realize_named_face (f, symbol, id) | |
5409 struct frame *f; | |
5410 Lisp_Object symbol; | |
5411 int id; | |
5412 { | |
5413 struct face_cache *c = FRAME_FACE_CACHE (f); | |
5414 Lisp_Object lface = lface_from_face_name (f, symbol, 0); | |
5415 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
5416 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; | |
5417 struct face *new_face; | |
5418 | |
5419 /* The default face must exist and be fully specified. */ | |
5420 get_lface_attributes (f, Qdefault, attrs, 1); | |
5421 check_lface_attrs (attrs); | |
5422 xassert (lface_fully_specified_p (attrs)); | |
5423 | |
5424 /* If SYMBOL isn't know as a face, create it. */ | |
5425 if (NILP (lface)) | |
5426 { | |
5427 Lisp_Object frame; | |
5428 XSETFRAME (frame, f); | |
5429 lface = Finternal_make_lisp_face (symbol, frame); | |
5430 } | |
5431 | |
5432 /* Merge SYMBOL's face with the default face. */ | |
5433 get_lface_attributes (f, symbol, symbol_attrs, 1); | |
5434 merge_face_vectors (symbol_attrs, attrs); | |
5435 | |
5436 /* Realize the face. */ | |
5437 new_face = realize_face (c, attrs, CHARSET_ASCII); | |
5438 | |
5439 /* Remove the former face. */ | |
5440 if (c->used > id) | |
5441 { | |
5442 struct face *old_face = c->faces_by_id[id]; | |
5443 uncache_face (c, old_face); | |
5444 free_realized_face (f, old_face); | |
5445 } | |
5446 | |
5447 /* Insert the new face. */ | |
5448 cache_face (c, new_face, lface_hash (attrs)); | |
5449 xassert (new_face->id == id); | |
5450 } | |
5451 | |
5452 | |
5453 /* Realize the fully-specified face with attributes ATTRS in face | |
5454 cache C for character set CHARSET or for unibyte text if CHARSET < | |
5455 0. Value is a pointer to the newly created realized face. */ | |
5456 | |
5457 static struct face * | |
5458 realize_face (c, attrs, charset) | |
5459 struct face_cache *c; | |
5460 Lisp_Object *attrs; | |
5461 int charset; | |
5462 { | |
5463 struct face *face; | |
5464 | |
5465 /* LFACE must be fully specified. */ | |
5466 xassert (c != NULL); | |
5467 check_lface_attrs (attrs); | |
5468 | |
5469 if (FRAME_X_P (c->f)) | |
5470 face = realize_x_face (c, attrs, charset); | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5471 else if (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f)) |
24995 | 5472 face = realize_tty_face (c, attrs, charset); |
5473 else | |
5474 abort (); | |
5475 | |
5476 return face; | |
5477 } | |
5478 | |
5479 | |
5480 /* Realize the fully-specified face with attributes ATTRS in face | |
5481 cache C for character set CHARSET or for unibyte text if CHARSET < | |
5482 0. Do it for X frame C->f. Value is a pointer to the newly | |
5483 created realized face. */ | |
5484 | |
5485 static struct face * | |
5486 realize_x_face (c, attrs, charset) | |
5487 struct face_cache *c; | |
5488 Lisp_Object *attrs; | |
5489 int charset; | |
5490 { | |
5491 #ifdef HAVE_X_WINDOWS | |
5492 struct face *face, *default_face; | |
5493 struct frame *f = c->f; | |
5494 Lisp_Object stipple, overline, strike_through, box; | |
5495 Lisp_Object unibyte_registry; | |
5496 struct gcpro gcpro1; | |
5497 | |
5498 xassert (FRAME_X_P (f)); | |
5499 | |
5500 /* If realizing a face for use in unibyte text, get the X registry | |
5501 and encoding to use from Vface_default_registry. */ | |
5502 if (charset < 0) | |
5503 unibyte_registry = (STRINGP (Vface_default_registry) | |
5504 ? Vface_default_registry | |
5505 : build_string ("iso8859-1")); | |
5506 else | |
5507 unibyte_registry = Qnil; | |
5508 GCPRO1 (unibyte_registry); | |
5509 | |
5510 /* Allocate a new realized face. */ | |
5511 face = make_realized_face (attrs, charset, unibyte_registry); | |
5512 | |
5513 /* Determine the font to use. Most of the time, the font will be | |
5514 the same as the font of the default face, so try that first. */ | |
5515 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
5516 if (default_face | |
5517 && FACE_SUITABLE_FOR_CHARSET_P (default_face, charset) | |
5518 && lface_same_font_attributes_p (default_face->lface, attrs)) | |
5519 { | |
5520 face->font = default_face->font; | |
5521 face->fontset = default_face->fontset; | |
5522 face->font_info_id = default_face->font_info_id; | |
5523 face->font_name = default_face->font_name; | |
5524 face->registry = default_face->registry; | |
5525 } | |
5526 else if (charset >= 0) | |
5527 { | |
5528 /* For all charsets except CHARSET_COMPOSITION, we use our own | |
5529 font selection functions to choose a best matching font for | |
5530 the specified face attributes. If the face specifies a | |
5531 fontset alias name, the fontset determines the font name | |
5532 pattern, otherwise we construct a font pattern from face | |
5533 attributes and charset. | |
5534 | |
5535 If charset is CHARSET_COMPOSITION, we always construct a face | |
5536 with a fontset, even if the face doesn't specify a fontset alias | |
5537 (we use fontset-standard in that case). When the composite | |
5538 character is displayed in xterm.c, a suitable concrete font is | |
5539 loaded in x_get_char_font_and_encoding. */ | |
5540 | |
5541 char *font_name = NULL; | |
5542 int fontset = face_fontset (f, attrs); | |
5543 | |
5544 if (charset == CHARSET_COMPOSITION) | |
5545 fontset = max (0, fontset); | |
5546 else if (fontset < 0) | |
5547 font_name = choose_face_font (f, attrs, charset, Qnil); | |
5548 else | |
5549 { | |
5550 font_name = choose_face_fontset_font (f, attrs, fontset, charset); | |
5551 fontset = -1; | |
5552 } | |
5553 | |
5554 load_face_font_or_fontset (f, face, font_name, fontset); | |
5555 xfree (font_name); | |
5556 } | |
5557 else | |
5558 { | |
5559 /* Unibyte case, and font is not equal to that of the default | |
5560 face. UNIBYTE_REGISTRY is the X registry and encoding the | |
5561 font should have. What is a reasonable thing to do if the | |
5562 user specified a fontset alias name for the face in this | |
5563 case? We choose a font by taking the ASCII font of the | |
5564 fontset, but using UNIBYTE_REGISTRY for its registry and | |
5565 encoding. */ | |
5566 | |
5567 char *font_name = NULL; | |
5568 int fontset = face_fontset (f, attrs); | |
5569 | |
5570 if (fontset < 0) | |
5571 font_name = choose_face_font (f, attrs, charset, unibyte_registry); | |
5572 else | |
5573 font_name = choose_face_fontset_font (f, attrs, fontset, charset); | |
5574 | |
5575 load_face_font_or_fontset (f, face, font_name, -1); | |
5576 xfree (font_name); | |
5577 } | |
5578 | |
5579 /* Load colors, and set remaining attributes. */ | |
5580 | |
5581 load_face_colors (f, face, attrs); | |
5582 | |
5583 /* Set up box. */ | |
5584 box = attrs[LFACE_BOX_INDEX]; | |
5585 if (STRINGP (box)) | |
5586 { | |
5587 /* A simple box of line width 1 drawn in color given by | |
5588 the string. */ | |
5589 face->box_color = load_color (f, face, attrs[LFACE_BOX_INDEX], | |
5590 LFACE_BOX_INDEX); | |
5591 face->box = FACE_SIMPLE_BOX; | |
5592 face->box_line_width = 1; | |
5593 } | |
5594 else if (INTEGERP (box)) | |
5595 { | |
5596 /* Simple box of specified line width in foreground color of the | |
5597 face. */ | |
5598 xassert (XINT (box) > 0); | |
5599 face->box = FACE_SIMPLE_BOX; | |
5600 face->box_line_width = XFASTINT (box); | |
5601 face->box_color = face->foreground; | |
5602 face->box_color_defaulted_p = 1; | |
5603 } | |
5604 else if (CONSP (box)) | |
5605 { | |
5606 /* `(:width WIDTH :color COLOR :shadow SHADOW)'. SHADOW | |
5607 being one of `raised' or `sunken'. */ | |
5608 face->box = FACE_SIMPLE_BOX; | |
5609 face->box_color = face->foreground; | |
5610 face->box_color_defaulted_p = 1; | |
5611 face->box_line_width = 1; | |
5612 | |
5613 while (CONSP (box)) | |
5614 { | |
5615 Lisp_Object keyword, value; | |
5616 | |
5617 keyword = XCAR (box); | |
5618 box = XCDR (box); | |
5619 | |
5620 if (!CONSP (box)) | |
5621 break; | |
5622 value = XCAR (box); | |
5623 box = XCDR (box); | |
5624 | |
5625 if (EQ (keyword, QCline_width)) | |
5626 { | |
5627 if (INTEGERP (value) && XINT (value) > 0) | |
5628 face->box_line_width = XFASTINT (value); | |
5629 } | |
5630 else if (EQ (keyword, QCcolor)) | |
5631 { | |
5632 if (STRINGP (value)) | |
5633 { | |
5634 face->box_color = load_color (f, face, value, | |
5635 LFACE_BOX_INDEX); | |
5636 face->use_box_color_for_shadows_p = 1; | |
5637 } | |
5638 } | |
5639 else if (EQ (keyword, QCstyle)) | |
5640 { | |
5641 if (EQ (value, Qreleased_button)) | |
5642 face->box = FACE_RAISED_BOX; | |
5643 else if (EQ (value, Qpressed_button)) | |
5644 face->box = FACE_SUNKEN_BOX; | |
5645 } | |
5646 } | |
5647 } | |
5648 | |
5649 /* Text underline, overline, strike-through. */ | |
5650 | |
5651 if (EQ (attrs[LFACE_UNDERLINE_INDEX], Qt)) | |
5652 { | |
5653 /* Use default color (same as foreground color). */ | |
5654 face->underline_p = 1; | |
5655 face->underline_defaulted_p = 1; | |
5656 face->underline_color = 0; | |
5657 } | |
5658 else if (STRINGP (attrs[LFACE_UNDERLINE_INDEX])) | |
5659 { | |
5660 /* Use specified color. */ | |
5661 face->underline_p = 1; | |
5662 face->underline_defaulted_p = 0; | |
5663 face->underline_color | |
5664 = load_color (f, face, attrs[LFACE_UNDERLINE_INDEX], | |
5665 LFACE_UNDERLINE_INDEX); | |
5666 } | |
5667 else if (NILP (attrs[LFACE_UNDERLINE_INDEX])) | |
5668 { | |
5669 face->underline_p = 0; | |
5670 face->underline_defaulted_p = 0; | |
5671 face->underline_color = 0; | |
5672 } | |
5673 | |
5674 overline = attrs[LFACE_OVERLINE_INDEX]; | |
5675 if (STRINGP (overline)) | |
5676 { | |
5677 face->overline_color | |
5678 = load_color (f, face, attrs[LFACE_OVERLINE_INDEX], | |
5679 LFACE_OVERLINE_INDEX); | |
5680 face->overline_p = 1; | |
5681 } | |
5682 else if (EQ (overline, Qt)) | |
5683 { | |
5684 face->overline_color = face->foreground; | |
5685 face->overline_color_defaulted_p = 1; | |
5686 face->overline_p = 1; | |
5687 } | |
5688 | |
5689 strike_through = attrs[LFACE_STRIKE_THROUGH_INDEX]; | |
5690 if (STRINGP (strike_through)) | |
5691 { | |
5692 face->strike_through_color | |
5693 = load_color (f, face, attrs[LFACE_STRIKE_THROUGH_INDEX], | |
5694 LFACE_STRIKE_THROUGH_INDEX); | |
5695 face->strike_through_p = 1; | |
5696 } | |
5697 else if (EQ (strike_through, Qt)) | |
5698 { | |
5699 face->strike_through_color = face->foreground; | |
5700 face->strike_through_color_defaulted_p = 1; | |
5701 face->strike_through_p = 1; | |
5702 } | |
5703 | |
5704 stipple = attrs[LFACE_STIPPLE_INDEX]; | |
5705 if (!NILP (stipple)) | |
5706 face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h); | |
5707 | |
5708 UNGCPRO; | |
5709 xassert (face->fontset < 0 || face->charset == CHARSET_COMPOSITION); | |
5710 xassert (FACE_SUITABLE_FOR_CHARSET_P (face, charset)); | |
5711 return face; | |
5712 #endif /* HAVE_X_WINDOWS */ | |
5713 } | |
5714 | |
5715 | |
5716 /* Realize the fully-specified face with attributes ATTRS in face | |
5717 cache C for character set CHARSET or for unibyte text if CHARSET < | |
5718 0. Do it for TTY frame C->f. Value is a pointer to the newly | |
5719 created realized face. */ | |
5720 | |
5721 static struct face * | |
5722 realize_tty_face (c, attrs, charset) | |
5723 struct face_cache *c; | |
5724 Lisp_Object *attrs; | |
5725 int charset; | |
5726 { | |
5727 struct face *face; | |
5728 int weight, slant; | |
5729 Lisp_Object color; | |
5730 | |
5731 /* Frame must be a termcap frame. */ | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5732 xassert (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f)); |
24995 | 5733 |
5734 /* Allocate a new realized face. */ | |
5735 face = make_realized_face (attrs, charset, Qnil); | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5736 face->font_name = FRAME_MSDOS_P (c->f) ? "ms-dos" : "tty"; |
24995 | 5737 |
5738 /* Map face attributes to TTY appearances. We map slant to | |
5739 dimmed text because we want italic text to appear differently | |
5740 and because dimmed text is probably used infrequently. */ | |
5741 weight = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]); | |
5742 slant = face_numeric_slant (attrs[LFACE_SLANT_INDEX]); | |
5743 | |
5744 if (weight > XLFD_WEIGHT_MEDIUM) | |
5745 face->tty_bold_p = 1; | |
5746 if (weight < XLFD_WEIGHT_MEDIUM || slant != XLFD_SLANT_ROMAN) | |
5747 face->tty_dim_p = 1; | |
5748 if (!NILP (attrs[LFACE_UNDERLINE_INDEX])) | |
5749 face->tty_underline_p = 1; | |
5750 if (!NILP (attrs[LFACE_INVERSE_INDEX])) | |
5751 face->tty_reverse_p = 1; | |
5752 | |
5753 /* Map color names to color indices. */ | |
5754 face->foreground = face->background = FACE_TTY_DEFAULT_COLOR; | |
5755 | |
5756 color = attrs[LFACE_FOREGROUND_INDEX]; | |
5757 if (XSTRING (color)->size | |
5758 && (color = Fassoc (color, Vface_tty_color_alist), | |
5759 CONSP (color))) | |
5760 face->foreground = XINT (XCDR (color)); | |
5761 | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5762 #ifdef MSDOS |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5763 if (FRAME_MSDOS_P (c->f) && face->foreground == FACE_TTY_DEFAULT_COLOR) |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5764 { |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5765 face->foreground = load_color (c->f, face, |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5766 attrs[LFACE_FOREGROUND_INDEX], |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5767 LFACE_FOREGROUND_INDEX); |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5768 /* If the foreground of the default face is the default color, |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5769 use the foreground color defined by the frame. */ |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5770 if (face->foreground == FACE_TTY_DEFAULT_COLOR) |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5771 { |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5772 face->foreground = FRAME_FOREGROUND_PIXEL (f); |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5773 attrs[LFACE_FOREGROUND_INDEX] = |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5774 build_string (msdos_stdcolor_name (face->foreground)); |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5775 } |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5776 } |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5777 #endif |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5778 |
24995 | 5779 color = attrs[LFACE_BACKGROUND_INDEX]; |
5780 if (XSTRING (color)->size | |
5781 && (color = Fassoc (color, Vface_tty_color_alist), | |
5782 CONSP (color))) | |
5783 face->background = XINT (XCDR (color)); | |
5784 | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5785 #ifdef MSDOS |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5786 if (FRAME_MSDOS_P (c->f) && face->background == FACE_TTY_DEFAULT_COLOR) |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5787 { |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5788 face->background = load_color (c->f, face, |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5789 attrs[LFACE_BACKGROUND_INDEX], |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5790 LFACE_BACKGROUND_INDEX); |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5791 /* If the background of the default face is the default color, |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5792 use the background color defined by the frame. */ |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5793 if (face->background == FACE_TTY_DEFAULT_COLOR) |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5794 { |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5795 face->background = FRAME_BACKGROUND_PIXEL (f); |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5796 attrs[LFACE_BACKGROUND_INDEX] = |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5797 build_string (msdos_stdcolor_name (face->background)); |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5798 } |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
5799 } |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5800 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5801 /* Swap colors if face is inverse-video. */ |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5802 if (face->tty_reverse_p) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5803 { |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5804 unsigned long tem = face->foreground; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5805 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5806 face->foreground = face->background; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5807 face->background = tem; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5808 } |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5809 #endif |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5810 |
24995 | 5811 return face; |
5812 } | |
5813 | |
5814 | |
5815 DEFUN ("face-register-tty-color", Fface_register_tty_color, | |
5816 Sface_register_tty_color, 2, 2, 0, | |
5817 "Say that COLOR is color number NUMBER on the terminal.\n\ | |
5818 COLOR is a string, the color name. Value is COLOR.") | |
5819 (color, number) | |
5820 Lisp_Object color, number; | |
5821 { | |
5822 Lisp_Object entry; | |
5823 | |
5824 CHECK_STRING (color, 0); | |
5825 CHECK_NUMBER (number, 1); | |
5826 entry = Fassoc (color, Vface_tty_color_alist); | |
5827 if (NILP (entry)) | |
5828 Vface_tty_color_alist = Fcons (Fcons (color, number), | |
5829 Vface_tty_color_alist); | |
5830 else | |
5831 Fsetcdr (entry, number); | |
5832 return color; | |
5833 } | |
5834 | |
5835 | |
5836 DEFUN ("face-clear-tty-colors", Fface_clear_tty_colors, | |
5837 Sface_clear_tty_colors, 0, 0, 0, | |
5838 "Unregister all registered tty colors.") | |
5839 () | |
5840 { | |
5841 return Vface_tty_color_alist = Qnil; | |
5842 } | |
5843 | |
5844 | |
5845 DEFUN ("tty-defined-colors", Ftty_defined_colors, | |
5846 Stty_defined_colors, 0, 0, 0, | |
5847 "Return a list of registered tty colors.") | |
5848 () | |
5849 { | |
5850 Lisp_Object list, colors; | |
5851 | |
5852 colors = Qnil; | |
5853 for (list = Vface_tty_color_alist; CONSP (list); list = XCDR (list)) | |
5854 colors = Fcons (XCAR (XCAR (list)), colors); | |
5855 | |
5856 return colors; | |
5857 } | |
5858 | |
5859 | |
5860 | |
5861 /*********************************************************************** | |
5862 Computing Faces | |
5863 ***********************************************************************/ | |
5864 | |
5865 /* Return the ID of the face to use to display character CH with face | |
5866 property PROP on frame F in current_buffer. */ | |
5867 | |
5868 int | |
5869 compute_char_face (f, ch, prop) | |
5870 struct frame *f; | |
5871 int ch; | |
5872 Lisp_Object prop; | |
5873 { | |
5874 int face_id; | |
5875 int charset = (NILP (current_buffer->enable_multibyte_characters) | |
5876 ? -1 | |
5877 : CHAR_CHARSET (ch)); | |
5878 | |
5879 if (NILP (prop)) | |
5880 face_id = FACE_FOR_CHARSET (f, DEFAULT_FACE_ID, charset); | |
5881 else | |
5882 { | |
5883 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
5884 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
5885 bcopy (default_face->lface, attrs, sizeof attrs); | |
5886 merge_face_vector_with_property (f, attrs, prop); | |
5887 face_id = lookup_face (f, attrs, charset); | |
5888 } | |
5889 | |
5890 return face_id; | |
5891 } | |
5892 | |
5893 | |
5894 /* Return the face ID associated with buffer position POS for | |
5895 displaying ASCII characters. Return in *ENDPTR the position at | |
5896 which a different face is needed, as far as text properties and | |
5897 overlays are concerned. W is a window displaying current_buffer. | |
5898 | |
5899 REGION_BEG, REGION_END delimit the region, so it can be | |
5900 highlighted. | |
5901 | |
5902 LIMIT is a position not to scan beyond. That is to limit the time | |
5903 this function can take. | |
5904 | |
5905 If MOUSE is non-zero, use the character's mouse-face, not its face. | |
5906 | |
5907 The face returned is suitable for displaying CHARSET_ASCII if | |
5908 current_buffer->enable_multibyte_characters is non-nil. Otherwise, | |
5909 the face is suitable for displaying unibyte text. */ | |
5910 | |
5911 int | |
5912 face_at_buffer_position (w, pos, region_beg, region_end, | |
5913 endptr, limit, mouse) | |
2391 | 5914 struct window *w; |
2342 | 5915 int pos; |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
5916 int region_beg, region_end; |
2342 | 5917 int *endptr; |
5084
863e092a5891
(compute_char_face): Accept new arg LIMIT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
5918 int limit; |
6615
96ddf85642d1
(compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents:
5858
diff
changeset
|
5919 int mouse; |
2342 | 5920 { |
24995 | 5921 struct frame *f = XFRAME (w->frame); |
5922 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
5923 Lisp_Object prop, position; |
24995 | 5924 int i, noverlays; |
2342 | 5925 Lisp_Object *overlay_vec; |
2391 | 5926 Lisp_Object frame; |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5927 int endpos; |
24995 | 5928 Lisp_Object propname = mouse ? Qmouse_face : Qface; |
5929 Lisp_Object limit1, end; | |
5930 struct face *default_face; | |
5931 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); | |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5932 |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5933 /* W must display the current buffer. We could write this function |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5934 to use the frame and buffer of W, but right now it doesn't. */ |
25359
14135aa647e2
(face_at_buffer_position): Don't xassert that
Gerd Moellmann <gerd@gnu.org>
parents:
25301
diff
changeset
|
5935 /* xassert (XBUFFER (w->buffer) == current_buffer); */ |
2391 | 5936 |
9284
a969e0eefaf5
(compute_char_face): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents:
9186
diff
changeset
|
5937 XSETFRAME (frame, f); |
24995 | 5938 XSETFASTINT (position, pos); |
2342 | 5939 |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5940 endpos = ZV; |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
5941 if (pos < region_beg && region_beg < endpos) |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
5942 endpos = region_beg; |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5943 |
24995 | 5944 /* Get the `face' or `mouse_face' text property at POS, and |
5945 determine the next position at which the property changes. */ | |
6615
96ddf85642d1
(compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents:
5858
diff
changeset
|
5946 prop = Fget_text_property (position, propname, w->buffer); |
24995 | 5947 XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); |
5948 end = Fnext_single_property_change (position, propname, w->buffer, limit1); | |
5949 if (INTEGERP (end)) | |
5950 endpos = XINT (end); | |
5951 | |
5952 /* Look at properties from overlays. */ | |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
5953 { |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5954 int next_overlay; |
2838
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5955 int len; |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
5956 |
2838
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5957 /* First try with room for 40 overlays. */ |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5958 len = 40; |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5959 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
11420
8ab99c3646a7
(compute_char_face): Don't use NULL.
Richard M. Stallman <rms@gnu.org>
parents:
11416
diff
changeset
|
5960 noverlays = overlays_at (pos, 0, &overlay_vec, &len, |
24995 | 5961 &next_overlay, NULL); |
5962 | |
5963 /* If there are more than 40, make enough space for all, and try | |
5964 again. */ | |
2838
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5965 if (noverlays > len) |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5966 { |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5967 len = noverlays; |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5968 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); |
8965
a7947f88d558
(compute_char_face): Pass new arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
8848
diff
changeset
|
5969 noverlays = overlays_at (pos, 0, &overlay_vec, &len, |
24995 | 5970 &next_overlay, NULL); |
2838
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5971 } |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
5972 |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5973 if (next_overlay < endpos) |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
5974 endpos = next_overlay; |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
5975 } |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
5976 |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
5977 *endptr = endpos; |
2342 | 5978 |
24995 | 5979 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
5980 | |
5981 /* Optimize common cases where we can use the default face. */ | |
5982 if (noverlays == 0 | |
5983 && NILP (prop) | |
5984 && !(pos >= region_beg && pos < region_end) | |
5985 && (multibyte_p | |
5986 || !FRAME_WINDOW_P (f) | |
5987 || FACE_SUITABLE_FOR_CHARSET_P (default_face, -1))) | |
5988 return DEFAULT_FACE_ID; | |
5989 | |
5990 /* Begin with attributes from the default face. */ | |
5991 bcopy (default_face->lface, attrs, sizeof attrs); | |
5992 | |
5993 /* Merge in attributes specified via text properties. */ | |
5994 if (!NILP (prop)) | |
5995 merge_face_vector_with_property (f, attrs, prop); | |
5996 | |
5997 /* Now merge the overlay data. */ | |
5858
021e58905963
(compute_char_face): Extract overlay-sorting code as a separate function,
Karl Heuer <kwzh@gnu.org>
parents:
5801
diff
changeset
|
5998 noverlays = sort_overlays (overlay_vec, noverlays, w); |
2342 | 5999 for (i = 0; i < noverlays; i++) |
6000 { | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6001 Lisp_Object oend; |
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6002 int oendpos; |
9186
45bac5feb065
(compute_char_face): Handle list as overlay face property.
Richard M. Stallman <rms@gnu.org>
parents:
9184
diff
changeset
|
6003 |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6004 prop = Foverlay_get (overlay_vec[i], propname); |
24995 | 6005 if (!NILP (prop)) |
6006 merge_face_vector_with_property (f, attrs, prop); | |
2342 | 6007 |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6008 oend = OVERLAY_END (overlay_vec[i]); |
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6009 oendpos = OVERLAY_POSITION (oend); |
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6010 if (oendpos < endpos) |
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6011 endpos = oendpos; |
2342 | 6012 } |
6013 | |
24995 | 6014 /* If in the region, merge in the region face. */ |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6015 if (pos >= region_beg && pos < region_end) |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6016 { |
24995 | 6017 Lisp_Object region_face = lface_from_face_name (f, Qregion, 0); |
6018 merge_face_vectors (XVECTOR (region_face)->contents, attrs); | |
6019 | |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6020 if (region_end < endpos) |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6021 endpos = region_end; |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6022 } |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6023 |
2342 | 6024 *endptr = endpos; |
6025 | |
24995 | 6026 /* Look up a realized face with the given face attributes, |
6027 or realize a new one. Charset is ignored for tty frames. */ | |
6028 return lookup_face (f, attrs, multibyte_p ? CHARSET_ASCII : -1); | |
2342 | 6029 } |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6030 |
24995 | 6031 |
6032 /* Compute the face at character position POS in Lisp string STRING on | |
6033 window W, for charset CHARSET_ASCII. | |
6034 | |
6035 If STRING is an overlay string, it comes from position BUFPOS in | |
6036 current_buffer, otherwise BUFPOS is zero to indicate that STRING is | |
6037 not an overlay string. W must display the current buffer. | |
6038 REGION_BEG and REGION_END give the start and end positions of the | |
6039 region; both are -1 if no region is visible. BASE_FACE_ID is the | |
6040 id of the basic face to merge with. It is usually equal to | |
25546 | 6041 DEFAULT_FACE_ID but can be MODE_LINE_FACE_ID or HEADER_LINE_FACE_ID |
24995 | 6042 for strings displayed in the mode or top line. |
6043 | |
6044 Set *ENDPTR to the next position where to check for faces in | |
6045 STRING; -1 if the face is constant from POS to the end of the | |
6046 string. | |
6047 | |
6048 Value is the id of the face to use. The face returned is suitable | |
6049 for displaying CHARSET_ASCII if STRING is multibyte. Otherwise, | |
6050 the face is suitable for displaying unibyte text. */ | |
6051 | |
6052 int | |
6053 face_at_string_position (w, string, pos, bufpos, region_beg, | |
6054 region_end, endptr, base_face_id) | |
6055 struct window *w; | |
6056 Lisp_Object string; | |
6057 int pos, bufpos; | |
6058 int region_beg, region_end; | |
6059 int *endptr; | |
6060 enum face_id base_face_id; | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6061 { |
24995 | 6062 Lisp_Object prop, position, end, limit; |
6063 struct frame *f = XFRAME (WINDOW_FRAME (w)); | |
6064 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
6065 struct face *base_face; | |
6066 int multibyte_p = STRING_MULTIBYTE (string); | |
6067 | |
6068 /* Get the value of the face property at the current position within | |
6069 STRING. Value is nil if there is no face property. */ | |
6070 XSETFASTINT (position, pos); | |
6071 prop = Fget_text_property (position, Qface, string); | |
6072 | |
6073 /* Get the next position at which to check for faces. Value of end | |
6074 is nil if face is constant all the way to the end of the string. | |
6075 Otherwise it is a string position where to check faces next. | |
6076 Limit is the maximum position up to which to check for property | |
6077 changes in Fnext_single_property_change. Strings are usually | |
6078 short, so set the limit to the end of the string. */ | |
6079 XSETFASTINT (limit, XSTRING (string)->size); | |
6080 end = Fnext_single_property_change (position, Qface, string, limit); | |
6081 if (INTEGERP (end)) | |
6082 *endptr = XFASTINT (end); | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6083 else |
24995 | 6084 *endptr = -1; |
6085 | |
6086 base_face = FACE_FROM_ID (f, base_face_id); | |
6087 xassert (base_face); | |
6088 | |
6089 /* Optimize the default case that there is no face property and we | |
6090 are not in the region. */ | |
6091 if (NILP (prop) | |
6092 && (base_face_id != DEFAULT_FACE_ID | |
6093 /* BUFPOS <= 0 means STRING is not an overlay string, so | |
6094 that the region doesn't have to be taken into account. */ | |
6095 || bufpos <= 0 | |
6096 || bufpos < region_beg | |
6097 || bufpos >= region_end) | |
6098 && (multibyte_p | |
6099 /* We can't realize faces for different charsets differently | |
6100 if we don't have fonts, so we can stop here if not working | |
6101 on a window-system frame. */ | |
6102 || !FRAME_WINDOW_P (f) | |
6103 || FACE_SUITABLE_FOR_CHARSET_P (base_face, -1))) | |
6104 return base_face->id; | |
6105 | |
6106 /* Begin with attributes from the base face. */ | |
6107 bcopy (base_face->lface, attrs, sizeof attrs); | |
6108 | |
6109 /* Merge in attributes specified via text properties. */ | |
6110 if (!NILP (prop)) | |
6111 merge_face_vector_with_property (f, attrs, prop); | |
6112 | |
6113 /* If in the region, merge in the region face. */ | |
6114 if (bufpos | |
6115 && bufpos >= region_beg | |
6116 && bufpos < region_end) | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6117 { |
24995 | 6118 Lisp_Object region_face = lface_from_face_name (f, Qregion, 0); |
6119 merge_face_vectors (XVECTOR (region_face)->contents, attrs); | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6120 } |
24995 | 6121 |
6122 /* Look up a realized face with the given face attributes, | |
6123 or realize a new one. */ | |
6124 return lookup_face (f, attrs, multibyte_p ? CHARSET_ASCII : -1); | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
6125 } |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
6126 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
6127 |
2336 | 6128 |
24995 | 6129 /*********************************************************************** |
6130 Tests | |
6131 ***********************************************************************/ | |
6132 | |
6133 #if GLYPH_DEBUG | |
6134 | |
6135 /* Print the contents of the realized face FACE to stderr. */ | |
6136 | |
6137 static void | |
6138 dump_realized_face (face) | |
6139 struct face *face; | |
2336 | 6140 { |
24995 | 6141 fprintf (stderr, "ID: %d\n", face->id); |
6142 #ifdef HAVE_X_WINDOWS | |
6143 fprintf (stderr, "gc: %d\n", (int) face->gc); | |
6144 #endif | |
6145 fprintf (stderr, "foreground: 0x%lx (%s)\n", | |
6146 face->foreground, | |
6147 XSTRING (face->lface[LFACE_FOREGROUND_INDEX])->data); | |
6148 fprintf (stderr, "background: 0x%lx (%s)\n", | |
6149 face->background, | |
6150 XSTRING (face->lface[LFACE_BACKGROUND_INDEX])->data); | |
6151 fprintf (stderr, "font_name: %s (%s)\n", | |
6152 face->font_name, | |
6153 XSTRING (face->lface[LFACE_FAMILY_INDEX])->data); | |
6154 #ifdef HAVE_X_WINDOWS | |
6155 fprintf (stderr, "font = %p\n", face->font); | |
6156 #endif | |
6157 fprintf (stderr, "font_info_id = %d\n", face->font_info_id); | |
6158 fprintf (stderr, "fontset: %d\n", face->fontset); | |
6159 fprintf (stderr, "underline: %d (%s)\n", | |
6160 face->underline_p, | |
6161 XSTRING (Fsymbol_name (face->lface[LFACE_UNDERLINE_INDEX]))->data); | |
6162 fprintf (stderr, "hash: %d\n", face->hash); | |
6163 fprintf (stderr, "charset: %d\n", face->charset); | |
6164 } | |
6165 | |
6166 | |
6167 DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, "") | |
6168 (n) | |
6169 Lisp_Object n; | |
6170 { | |
6171 if (NILP (n)) | |
2336 | 6172 { |
24995 | 6173 int i; |
6174 | |
6175 fprintf (stderr, "font selection order: "); | |
6176 for (i = 0; i < DIM (font_sort_order); ++i) | |
6177 fprintf (stderr, "%d ", font_sort_order[i]); | |
6178 fprintf (stderr, "\n"); | |
6179 | |
6180 fprintf (stderr, "alternative fonts: "); | |
6181 debug_print (Vface_alternative_font_family_alist); | |
6182 fprintf (stderr, "\n"); | |
6183 | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
6184 for (i = 0; i < FRAME_FACE_CACHE (SELECTED_FRAME ())->used; ++i) |
24995 | 6185 Fdump_face (make_number (i)); |
2336 | 6186 } |
24995 | 6187 else |
6188 { | |
6189 struct face *face; | |
6190 CHECK_NUMBER (n, 0); | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
6191 face = FACE_FROM_ID (SELECTED_FRAME (), XINT (n)); |
24995 | 6192 if (face == NULL) |
6193 error ("Not a valid face"); | |
6194 dump_realized_face (face); | |
6195 } | |
6196 | |
2336 | 6197 return Qnil; |
6198 } | |
6199 | |
6200 | |
24995 | 6201 DEFUN ("show-face-resources", Fshow_face_resources, Sshow_face_resources, |
6202 0, 0, 0, "") | |
6203 () | |
2336 | 6204 { |
24995 | 6205 fprintf (stderr, "number of colors = %d\n", ncolors_allocated); |
6206 fprintf (stderr, "number of pixmaps = %d\n", npixmaps_allocated); | |
6207 fprintf (stderr, "number of GCs = %d\n", ngcs); | |
2336 | 6208 return Qnil; |
6209 } | |
24995 | 6210 |
6211 #endif /* GLYPH_DEBUG != 0 */ | |
6212 | |
18083
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
6213 |
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
6214 |
24995 | 6215 /*********************************************************************** |
6216 Initialization | |
6217 ***********************************************************************/ | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
6218 |
2336 | 6219 void |
2391 | 6220 syms_of_xfaces () |
2336 | 6221 { |
2391 | 6222 Qface = intern ("face"); |
6223 staticpro (&Qface); | |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
6224 Qpixmap_spec_p = intern ("pixmap-spec-p"); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
6225 staticpro (&Qpixmap_spec_p); |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6226 Qframe_update_face_colors = intern ("frame-update-face-colors"); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6227 staticpro (&Qframe_update_face_colors); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6228 |
24995 | 6229 /* Lisp face attribute keywords. */ |
6230 QCfamily = intern (":family"); | |
6231 staticpro (&QCfamily); | |
6232 QCheight = intern (":height"); | |
6233 staticpro (&QCheight); | |
6234 QCweight = intern (":weight"); | |
6235 staticpro (&QCweight); | |
6236 QCslant = intern (":slant"); | |
6237 staticpro (&QCslant); | |
6238 QCunderline = intern (":underline"); | |
6239 staticpro (&QCunderline); | |
6240 QCinverse_video = intern (":inverse-video"); | |
6241 staticpro (&QCinverse_video); | |
6242 QCreverse_video = intern (":reverse-video"); | |
6243 staticpro (&QCreverse_video); | |
6244 QCforeground = intern (":foreground"); | |
6245 staticpro (&QCforeground); | |
6246 QCbackground = intern (":background"); | |
6247 staticpro (&QCbackground); | |
6248 QCstipple = intern (":stipple");; | |
6249 staticpro (&QCstipple); | |
6250 QCwidth = intern (":width"); | |
6251 staticpro (&QCwidth); | |
6252 QCfont = intern (":font"); | |
6253 staticpro (&QCfont); | |
6254 QCbold = intern (":bold"); | |
6255 staticpro (&QCbold); | |
6256 QCitalic = intern (":italic"); | |
6257 staticpro (&QCitalic); | |
6258 QCoverline = intern (":overline"); | |
6259 staticpro (&QCoverline); | |
6260 QCstrike_through = intern (":strike-through"); | |
6261 staticpro (&QCstrike_through); | |
6262 QCbox = intern (":box"); | |
6263 staticpro (&QCbox); | |
6264 | |
6265 /* Symbols used for Lisp face attribute values. */ | |
6266 QCcolor = intern (":color"); | |
6267 staticpro (&QCcolor); | |
6268 QCline_width = intern (":line-width"); | |
6269 staticpro (&QCline_width); | |
6270 QCstyle = intern (":style"); | |
6271 staticpro (&QCstyle); | |
6272 Qreleased_button = intern ("released-button"); | |
6273 staticpro (&Qreleased_button); | |
6274 Qpressed_button = intern ("pressed-button"); | |
6275 staticpro (&Qpressed_button); | |
6276 Qnormal = intern ("normal"); | |
6277 staticpro (&Qnormal); | |
6278 Qultra_light = intern ("ultra-light"); | |
6279 staticpro (&Qultra_light); | |
6280 Qextra_light = intern ("extra-light"); | |
6281 staticpro (&Qextra_light); | |
6282 Qlight = intern ("light"); | |
6283 staticpro (&Qlight); | |
6284 Qsemi_light = intern ("semi-light"); | |
6285 staticpro (&Qsemi_light); | |
6286 Qsemi_bold = intern ("semi-bold"); | |
6287 staticpro (&Qsemi_bold); | |
6288 Qbold = intern ("bold"); | |
6289 staticpro (&Qbold); | |
6290 Qextra_bold = intern ("extra-bold"); | |
6291 staticpro (&Qextra_bold); | |
6292 Qultra_bold = intern ("ultra-bold"); | |
6293 staticpro (&Qultra_bold); | |
6294 Qoblique = intern ("oblique"); | |
6295 staticpro (&Qoblique); | |
6296 Qitalic = intern ("italic"); | |
6297 staticpro (&Qitalic); | |
6298 Qreverse_oblique = intern ("reverse-oblique"); | |
6299 staticpro (&Qreverse_oblique); | |
6300 Qreverse_italic = intern ("reverse-italic"); | |
6301 staticpro (&Qreverse_italic); | |
6302 Qultra_condensed = intern ("ultra-condensed"); | |
6303 staticpro (&Qultra_condensed); | |
6304 Qextra_condensed = intern ("extra-condensed"); | |
6305 staticpro (&Qextra_condensed); | |
6306 Qcondensed = intern ("condensed"); | |
6307 staticpro (&Qcondensed); | |
6308 Qsemi_condensed = intern ("semi-condensed"); | |
6309 staticpro (&Qsemi_condensed); | |
6310 Qsemi_expanded = intern ("semi-expanded"); | |
6311 staticpro (&Qsemi_expanded); | |
6312 Qexpanded = intern ("expanded"); | |
6313 staticpro (&Qexpanded); | |
6314 Qextra_expanded = intern ("extra-expanded"); | |
6315 staticpro (&Qextra_expanded); | |
6316 Qultra_expanded = intern ("ultra-expanded"); | |
6317 staticpro (&Qultra_expanded); | |
6318 Qbackground_color = intern ("background-color"); | |
6319 staticpro (&Qbackground_color); | |
6320 Qforeground_color = intern ("foreground-color"); | |
6321 staticpro (&Qforeground_color); | |
6322 Qunspecified = intern ("unspecified"); | |
6323 staticpro (&Qunspecified); | |
6324 | |
6325 Qx_charset_registry = intern ("x-charset-registry"); | |
6326 staticpro (&Qx_charset_registry); | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6327 Qface_alias = intern ("face-alias"); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6328 staticpro (&Qface_alias); |
24995 | 6329 Qdefault = intern ("default"); |
6330 staticpro (&Qdefault); | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6331 Qmode_line = intern ("mode-line"); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6332 staticpro (&Qmode_line); |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25389
diff
changeset
|
6333 Qtool_bar = intern ("tool-bar"); |
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25389
diff
changeset
|
6334 staticpro (&Qtool_bar); |
24995 | 6335 Qregion = intern ("region"); |
6336 staticpro (&Qregion); | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6337 Qfringe = intern ("fringe"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6338 staticpro (&Qfringe); |
25546 | 6339 Qheader_line = intern ("header-line"); |
6340 staticpro (&Qheader_line); | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6341 Qscroll_bar = intern ("scroll-bar"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6342 staticpro (&Qscroll_bar); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6343 Qcursor = intern ("cursor"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6344 staticpro (&Qcursor); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6345 Qborder = intern ("border"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6346 staticpro (&Qborder); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6347 Qmouse = intern ("mouse"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6348 staticpro (&Qmouse); |
24995 | 6349 |
6350 defsubr (&Sinternal_make_lisp_face); | |
6351 defsubr (&Sinternal_lisp_face_p); | |
6352 defsubr (&Sinternal_set_lisp_face_attribute); | |
6353 #ifdef HAVE_X_WINDOWS | |
6354 defsubr (&Sinternal_set_lisp_face_attribute_from_resource); | |
6355 defsubr (&Sface_color_gray_p); | |
6356 defsubr (&Sface_color_supported_p); | |
6357 #endif | |
6358 defsubr (&Sinternal_get_lisp_face_attribute); | |
6359 defsubr (&Sinternal_lisp_face_attribute_values); | |
6360 defsubr (&Sinternal_lisp_face_equal_p); | |
6361 defsubr (&Sinternal_lisp_face_empty_p); | |
6362 defsubr (&Sinternal_copy_lisp_face); | |
6363 defsubr (&Sinternal_merge_in_global_face); | |
6364 defsubr (&Sface_font); | |
6365 defsubr (&Sframe_face_alist); | |
6366 defsubr (&Sinternal_set_font_selection_order); | |
6367 defsubr (&Sinternal_set_alternative_font_family_alist); | |
6368 #if GLYPH_DEBUG | |
6369 defsubr (&Sdump_face); | |
6370 defsubr (&Sshow_face_resources); | |
6371 #endif /* GLYPH_DEBUG */ | |
6372 defsubr (&Sclear_face_cache); | |
6373 | |
25270 | 6374 DEFVAR_LISP ("font-list-limit", &Vfont_list_limit, |
6375 "*Limit for font matching.\n\ | |
6376 If an integer > 0, font matching functions won't load more than\n\ | |
6377 that number of fonts when searching for a matching font."); | |
6378 Vfont_list_limit = make_number (DEFAULT_FONT_LIST_LIMIT); | |
6379 | |
24995 | 6380 DEFVAR_LISP ("face-new-frame-defaults", &Vface_new_frame_defaults, |
6381 "List of global face definitions (for internal use only.)"); | |
6382 Vface_new_frame_defaults = Qnil; | |
6383 | |
6384 DEFVAR_LISP ("face-default-stipple", &Vface_default_stipple, | |
6385 "*Default stipple pattern used on monochrome displays.\n\ | |
6386 This stipple pattern is used on monochrome displays\n\ | |
6387 instead of shades of gray for a face background color.\n\ | |
6388 See `set-face-stipple' for possible values for this variable."); | |
6389 Vface_default_stipple = build_string ("gray3"); | |
6390 | |
6391 DEFVAR_LISP ("face-default-registry", &Vface_default_registry, | |
6392 "Default registry and encoding to use.\n\ | |
6393 This registry and encoding is used for unibyte text. It is set up\n\ | |
6394 from the specified frame font when Emacs starts. (For internal use only.)"); | |
6395 Vface_default_registry = Qnil; | |
6396 | |
6397 DEFVAR_LISP ("face-alternative-font-family-alist", | |
6398 &Vface_alternative_font_family_alist, ""); | |
6399 Vface_alternative_font_family_alist = Qnil; | |
6400 | |
6401 #if SCALABLE_FONTS | |
6402 | |
6403 DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed, | |
6404 "Allowed scalable fonts.\n\ | |
6405 A value of nil means don't allow any scalable fonts.\n\ | |
6406 A value of t means allow any scalable font.\n\ | |
6407 Otherwise, value must be a list of regular expressions. A font may be\n\ | |
6408 scaled if its name matches a regular expression in the list."); | |
6409 Vscalable_fonts_allowed = Qnil; | |
6410 | |
6411 #endif /* SCALABLE_FONTS */ | |
18083
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
6412 |
9572 | 6413 #ifdef HAVE_X_WINDOWS |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
6414 defsubr (&Spixmap_spec_p); |
24995 | 6415 defsubr (&Sx_list_fonts); |
6416 defsubr (&Sinternal_face_x_get_resource); | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6417 defsubr (&Sx_family_fonts); |
24995 | 6418 defsubr (&Sx_font_family_list); |
6419 #endif /* HAVE_X_WINDOWS */ | |
6420 | |
6421 /* TTY face support. */ | |
6422 defsubr (&Sface_register_tty_color); | |
6423 defsubr (&Sface_clear_tty_colors); | |
6424 defsubr (&Stty_defined_colors); | |
6425 Vface_tty_color_alist = Qnil; | |
6426 staticpro (&Vface_tty_color_alist); | |
2336 | 6427 } |