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