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