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