Mercurial > emacs
annotate src/xfaces.c @ 28441:a7b3ff772283
(byte-compile-file-form-autoload): Re-enable new code.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Fri, 31 Mar 2000 11:28:14 +0000 |
parents | 1a817fd04b31 |
children | b6b552188c57 |
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 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
29 1. Font family name. |
24995 | 30 |
31 2. Relative proportionate width, aka character set width or set | |
32 width (swidth), e.g. `semi-compressed'. | |
33 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
34 3. Font height in 1/10pt. |
24995 | 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 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
58 14. Font or fontset pattern, or nil. This is a special attribute. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
59 When this attribyte is specified, the face uses a font opened by |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
60 that pattern as is. In addition, all the other font-related |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
61 attributes (1st thru 5th) are generated from the opened font name. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
62 On the other hand, if one of the other font-related attributes are |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
63 specified, this attribute is set to nil. In that case, the face |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
64 doesn't inherit this attribute from the `default' face, and uses a |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
65 font determined by the other attributes (those may be inherited |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
66 from the `default' face). |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
67 |
24995 | 68 Faces are frame-local by nature because Emacs allows to define the |
69 same named face (face names are symbols) differently for different | |
70 frames. Each frame has an alist of face definitions for all named | |
71 faces. The value of a named face in such an alist is a Lisp vector | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
72 with the symbol `face' in slot 0, and a slot for each of the face |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
73 attributes mentioned above. |
24995 | 74 |
75 There is also a global face alist `Vface_new_frame_defaults'. Face | |
76 definitions from this list are used to initialize faces of newly | |
77 created frames. | |
78 | |
79 A face doesn't have to specify all attributes. Those not specified | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
80 have a value of `unspecified'. Faces specifying all attributes but |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
81 the 14th are called `fully-specified'. |
24995 | 82 |
83 | |
84 Face merging. | |
85 | |
86 The display style of a given character in the text is determined by | |
87 combining several faces. This process is called `face merging'. | |
88 Any aspect of the display style that isn't specified by overlays or | |
89 text properties is taken from the `default' face. Since it is made | |
90 sure that the default face is always fully-specified, face merging | |
91 always results in a fully-specified face. | |
92 | |
93 | |
94 Face realization. | |
95 | |
96 After all face attributes for a character have been determined by | |
97 merging faces of that character, that face is `realized'. The | |
98 realization process maps face attributes to what is physically | |
99 available on the system where Emacs runs. The result is a | |
100 `realized face' in form of a struct face which is stored in the | |
101 face cache of the frame on which it was realized. | |
102 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
103 Face realization is done in the context of the character to display |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
104 because different fonts may be used for different characters. In |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
105 other words, for characters that have different font |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
106 specifications, different realized faces are needed to display |
24995 | 107 them. |
108 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
109 Font specification is done by fontsets. See the comment in |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
110 fontset.c for the details. In the current implementation, all ASCII |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
111 characters share the same font in a fontset. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
112 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
113 Faces are at first realized for ASCII characters, and, at that |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
114 time, assigned a specific realized fontset. Hereafter, we call |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
115 such a face as `ASCII face'. When a face for a multibyte character |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
116 is realized, it inherits (thus shares) a fontset of an ASCII face |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
117 that has the same attributes other than font-related ones. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
118 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
119 Thus, all realzied face have a realized fontset. |
24995 | 120 |
121 | |
122 Unibyte text. | |
123 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
124 Unibyte text (i.e. raw 8-bit characters) is displayed with the same |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
125 font as ASCII characters. That is because it is expected that |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
126 unibyte text users specify a font that is suitable both for ASCII |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
127 and raw 8-bit characters. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
128 |
24995 | 129 |
130 Font selection. | |
131 | |
132 Font selection tries to find the best available matching font for a | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
133 given (character, face) combination. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
134 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
135 If the face specifies a fontset name, that fontset determines a |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
136 pattern for fonts of the given character. If the face specifies a |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
137 font name or the other font-related attributes, a fontset is |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
138 realized from the default fontset. In that case, that |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
139 specification determines a pattern for ASCII characters and the |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
140 default fontset determines a pattern for multibyte characters. |
24995 | 141 |
142 Available fonts on the system on which Emacs runs are then matched | |
143 against the font pattern. The result of font selection is the best | |
144 match for the given face attributes in this font list. | |
145 | |
146 Font selection can be influenced by the user. | |
147 | |
148 1. The user can specify the relative importance he gives the face | |
149 attributes width, height, weight, and slant by setting | |
150 face-font-selection-order (faces.el) to a list of face attribute | |
151 names. The default is '(:width :height :weight :slant), and means | |
152 that font selection first tries to find a good match for the font | |
153 width specified by a face, then---within fonts with that | |
154 width---tries to find a best match for the specified font height, | |
155 etc. | |
156 | |
157 2. Setting face-alternative-font-family-alist allows the user to | |
158 specify alternative font families to try if a family specified by a | |
159 face doesn't exist. | |
160 | |
161 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
162 Character compositition. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
163 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
164 Usually, the realization process is already finished when Emacs |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
165 actually reflects the desired glyph matrix on the screen. However, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
166 on displaying a composition (sequence of characters to be composed |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
167 on the screen), a suitable font for the components of the |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
168 composition is selected and realized while drawing them on the |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
169 screen, i.e. the realization process is delayed but in principle |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
170 the same. |
24995 | 171 |
172 | |
173 Initialization of basic faces. | |
174 | |
175 The faces `default', `modeline' are considered `basic faces'. | |
176 When redisplay happens the first time for a newly created frame, | |
177 basic faces are realized for CHARSET_ASCII. Frame parameters are | |
178 used to fill in unspecified attributes of the default face. */ | |
179 | |
180 /* Define SCALABLE_FONTS to a non-zero value to enable scalable | |
181 font use. Define it to zero to disable scalable font use. | |
182 | |
183 Use of too many or too large scalable fonts can crash XFree86 | |
184 servers. That's why I've put the code dealing with scalable fonts | |
185 in #if's. */ | |
186 | |
187 #define SCALABLE_FONTS 1 | |
2342 | 188 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25890
diff
changeset
|
189 #include <config.h> |
2336 | 190 #include <sys/types.h> |
191 #include <sys/stat.h> | |
192 #include "lisp.h" | |
17047 | 193 #include "charset.h" |
18083
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
194 #include "frame.h" |
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
195 |
9572 | 196 #ifdef HAVE_X_WINDOWS |
2336 | 197 #include "xterm.h" |
17047 | 198 #include "fontset.h" |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
199 #ifdef USE_MOTIF |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
200 #include <Xm/Xm.h> |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
201 #include <Xm/XmStrDefs.h> |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
202 #endif /* USE_MOTIF */ |
9572 | 203 #endif |
24995 | 204 |
9572 | 205 #ifdef MSDOS |
206 #include "dosfns.h" | |
207 #endif | |
24995 | 208 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
209 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
210 #include "w32term.h" |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
211 #include "fontset.h" |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
212 /* 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
|
213 code with #ifdef blocks. */ |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
214 #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
|
215 #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
|
216 #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
|
217 #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
|
218 #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
|
219 #define GCGraphicsExposures 0 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
220 /* 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
|
221 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
|
222 #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
|
223 #endif |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
224 |
2336 | 225 #include "buffer.h" |
2391 | 226 #include "dispextern.h" |
2438 | 227 #include "blockinput.h" |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
228 #include "window.h" |
8848 | 229 #include "intervals.h" |
2336 | 230 |
9572 | 231 #ifdef HAVE_X_WINDOWS |
24995 | 232 |
233 /* 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
|
234 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
|
235 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
|
236 #included. */ |
24995 | 237 |
3436
291f28da7ea1
Test XOS_NEEDS_TIME_H, not HPUX, for including time.hj.
Richard M. Stallman <rms@gnu.org>
parents:
3401
diff
changeset
|
238 #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
|
239 #include <time.h> |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
240 #undef USG |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
241 #include <X11/Xos.h> |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
242 #define USG |
d968bcba16af
* xfaces.c [XOS_NEEDS_TIME_H]: #undef USG while #including
Jim Blandy <jimb@redhat.com>
parents:
3882
diff
changeset
|
243 #define __TIMEVAL__ |
24995 | 244 #else /* not XOS_NEEDS_TIME_H */ |
2336 | 245 #include <X11/Xos.h> |
24995 | 246 #endif /* not XOS_NEEDS_TIME_H */ |
247 | |
9572 | 248 #endif /* HAVE_X_WINDOWS */ |
24995 | 249 |
250 #include <stdio.h> | |
251 #include <ctype.h> | |
252 #include "keyboard.h" | |
253 | |
254 #ifndef max | |
255 #define max(A, B) ((A) > (B) ? (A) : (B)) | |
256 #define min(A, B) ((A) < (B) ? (A) : (B)) | |
257 #define abs(X) ((X) < 0 ? -(X) : (X)) | |
258 #endif | |
259 | |
260 /* Non-zero if face attribute ATTR is unspecified. */ | |
261 | |
262 #define UNSPECIFIEDP(ATTR) EQ ((ATTR), Qunspecified) | |
263 | |
264 /* Value is the number of elements of VECTOR. */ | |
265 | |
266 #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR)) | |
267 | |
268 /* Make a copy of string S on the stack using alloca. Value is a pointer | |
269 to the copy. */ | |
270 | |
271 #define STRDUPA(S) strcpy ((char *) alloca (strlen ((S)) + 1), (S)) | |
272 | |
273 /* Make a copy of the contents of Lisp string S on the stack using | |
274 alloca. Value is a pointer to the copy. */ | |
275 | |
276 #define LSTRDUPA(S) STRDUPA (XSTRING ((S))->data) | |
277 | |
278 /* Size of hash table of realized faces in face caches (should be a | |
279 prime number). */ | |
280 | |
281 #define FACE_CACHE_BUCKETS_SIZE 1001 | |
282 | |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
283 /* 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
|
284 #ifndef HAVE_X_WINDOWS |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
285 typedef struct { |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
286 unsigned long pixel; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
287 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
|
288 char flags; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
289 char pad; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
290 } XColor; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
291 #endif |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
292 |
24995 | 293 /* Keyword symbols used for face attribute names. */ |
294 | |
295 Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline; | |
296 Lisp_Object QCinverse_video, QCforeground, QCbackground, QCstipple; | |
297 Lisp_Object QCwidth, QCfont, QCbold, QCitalic; | |
298 Lisp_Object QCreverse_video; | |
299 Lisp_Object QCoverline, QCstrike_through, QCbox; | |
300 | |
301 /* Symbols used for attribute values. */ | |
302 | |
303 Lisp_Object Qnormal, Qbold, Qultra_light, Qextra_light, Qlight; | |
304 Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold; | |
305 Lisp_Object Qoblique, Qitalic, Qreverse_oblique, Qreverse_italic; | |
306 Lisp_Object Qultra_condensed, Qextra_condensed, Qcondensed; | |
307 Lisp_Object Qsemi_condensed, Qsemi_expanded, Qexpanded, Qextra_expanded; | |
308 Lisp_Object Qultra_expanded; | |
309 Lisp_Object Qreleased_button, Qpressed_button; | |
310 Lisp_Object QCstyle, QCcolor, QCline_width; | |
27114
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
311 Lisp_Object Qunspecified; |
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
312 |
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
313 char unspecified_fg[] = "unspecified-fg", unspecified_bg[] = "unspecified-bg"; |
24995 | 314 |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
315 /* 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
|
316 has changed, frame_update_face_colors. */ |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
317 |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
318 Lisp_Object Qframe_update_face_colors; |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
319 |
24995 | 320 /* Names of basic faces. */ |
321 | |
26574
5510d0cc07c3
Don't duplicate Qmode_line definition done elsewhere.
Dave Love <fx@gnu.org>
parents:
26088
diff
changeset
|
322 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
|
323 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
|
324 extern Lisp_Object Qmode_line; |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
325 |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
326 /* 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
|
327 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
|
328 the aliased face. */ |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
329 |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
330 Lisp_Object Qface_alias; |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
331 |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
332 /* Names of frame parameters related to faces. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
333 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
334 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
|
335 extern Lisp_Object Qborder_color, Qcursor_color, Qmouse_color; |
24995 | 336 |
337 /* Default stipple pattern used on monochrome displays. This stipple | |
338 pattern is used on monochrome displays instead of shades of gray | |
339 for a face background color. See `set-face-stipple' for possible | |
340 values for this variable. */ | |
341 | |
342 Lisp_Object Vface_default_stipple; | |
343 | |
344 /* Alist of alternative font families. Each element is of the form | |
345 (FAMILY FAMILY1 FAMILY2 ...). If fonts of FAMILY can't be loaded, | |
346 try FAMILY1, then FAMILY2, ... */ | |
347 | |
348 Lisp_Object Vface_alternative_font_family_alist; | |
349 | |
350 /* Allowed scalable fonts. A value of nil means don't allow any | |
351 scalable fonts. A value of t means allow the use of any scalable | |
352 font. Otherwise, value must be a list of regular expressions. A | |
353 font may be scaled if its name matches a regular expression in the | |
354 list. */ | |
355 | |
356 #if SCALABLE_FONTS | |
357 Lisp_Object Vscalable_fonts_allowed; | |
358 #endif | |
359 | |
25270 | 360 /* Maximum number of fonts to consider in font_list. If not an |
361 integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */ | |
362 | |
363 Lisp_Object Vfont_list_limit; | |
364 #define DEFAULT_FONT_LIST_LIMIT 100 | |
365 | |
24995 | 366 /* The symbols `foreground-color' and `background-color' which can be |
367 used as part of a `face' property. This is for compatibility with | |
368 Emacs 20.2. */ | |
369 | |
370 Lisp_Object Qforeground_color, Qbackground_color; | |
371 | |
372 /* The symbols `face' and `mouse-face' used as text properties. */ | |
2342 | 373 |
23730
c71c3ac4b80a
(Qmouse_face): Replace definition with extern decl.
Richard M. Stallman <rms@gnu.org>
parents:
21766
diff
changeset
|
374 Lisp_Object Qface; |
24995 | 375 extern Lisp_Object Qmouse_face; |
376 | |
377 /* Error symbol for wrong_type_argument in load_pixmap. */ | |
378 | |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
379 Lisp_Object Qbitmap_spec_p; |
2391 | 380 |
24995 | 381 /* Alist of global face definitions. Each element is of the form |
382 (FACE . LFACE) where FACE is a symbol naming a face and LFACE | |
383 is a Lisp vector of face attributes. These faces are used | |
384 to initialize faces for new frames. */ | |
385 | |
386 Lisp_Object Vface_new_frame_defaults; | |
387 | |
388 /* The next ID to assign to Lisp faces. */ | |
389 | |
390 static int next_lface_id; | |
391 | |
392 /* A vector mapping Lisp face Id's to face names. */ | |
393 | |
394 static Lisp_Object *lface_id_to_name; | |
395 static int lface_id_to_name_size; | |
396 | |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
397 /* 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
|
398 Lisp_Object Qtty_color_desc, Qtty_color_by_index; |
24995 | 399 |
400 /* Counter for calls to clear_face_cache. If this counter reaches | |
401 CLEAR_FONT_TABLE_COUNT, and a frame has more than | |
402 CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed. */ | |
403 | |
404 static int clear_font_table_count; | |
405 #define CLEAR_FONT_TABLE_COUNT 100 | |
406 #define CLEAR_FONT_TABLE_NFONTS 10 | |
407 | |
408 /* Non-zero means face attributes have been changed since the last | |
409 redisplay. Used in redisplay_internal. */ | |
410 | |
411 int face_change_count; | |
412 | |
413 /* The total number of colors currently allocated. */ | |
414 | |
415 #if GLYPH_DEBUG | |
416 static int ncolors_allocated; | |
417 static int npixmaps_allocated; | |
418 static int ngcs; | |
419 #endif | |
420 | |
421 | |
2336 | 422 |
24995 | 423 /* Function prototypes. */ |
424 | |
425 struct font_name; | |
426 struct table_entry; | |
427 | |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
428 static Lisp_Object resolve_face_name P_ ((Lisp_Object)); |
24995 | 429 static int may_use_scalable_font_p P_ ((struct font_name *, char *)); |
430 static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); | |
431 static int better_font_p P_ ((int *, struct font_name *, struct font_name *, | |
432 int)); | |
433 static int first_font_matching P_ ((struct frame *f, char *, | |
434 struct font_name *)); | |
435 static int x_face_list_fonts P_ ((struct frame *, char *, | |
436 struct font_name *, int, int, int)); | |
437 static int font_scalable_p P_ ((struct font_name *)); | |
438 static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int)); | |
439 static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); | |
440 static unsigned char *xstrlwr P_ ((unsigned char *)); | |
441 static void signal_error P_ ((char *, Lisp_Object)); | |
442 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
443 static void load_face_font P_ ((struct frame *, struct face *, int)); |
24995 | 444 static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); |
445 static void free_face_colors P_ ((struct frame *, struct face *)); | |
446 static int face_color_gray_p P_ ((struct frame *, char *)); | |
447 static char *build_font_name P_ ((struct font_name *)); | |
448 static void free_font_names P_ ((struct font_name *, int)); | |
449 static int sorted_font_list P_ ((struct frame *, char *, | |
450 int (*cmpfn) P_ ((const void *, const void *)), | |
451 struct font_name **)); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
452 static int font_list P_ ((struct frame *, Lisp_Object, Lisp_Object, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
453 Lisp_Object, struct font_name **)); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
454 static int try_font_list P_ ((struct frame *, Lisp_Object *, Lisp_Object, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
455 Lisp_Object, Lisp_Object, struct font_name **)); |
24995 | 456 static int cmp_font_names P_ ((const void *, const void *)); |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
457 static struct face *realize_face P_ ((struct face_cache *, Lisp_Object *, int, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
458 struct face *, int)); |
24995 | 459 static struct face *realize_x_face P_ ((struct face_cache *, |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
460 Lisp_Object *, int, struct face *)); |
24995 | 461 static struct face *realize_tty_face P_ ((struct face_cache *, |
462 Lisp_Object *, int)); | |
463 static int realize_basic_faces P_ ((struct frame *)); | |
464 static int realize_default_face P_ ((struct frame *)); | |
465 static void realize_named_face P_ ((struct frame *, Lisp_Object, int)); | |
466 static int lface_fully_specified_p P_ ((Lisp_Object *)); | |
467 static int lface_equal_p P_ ((Lisp_Object *, Lisp_Object *)); | |
468 static unsigned hash_string_case_insensitive P_ ((Lisp_Object)); | |
469 static unsigned lface_hash P_ ((Lisp_Object *)); | |
470 static int lface_same_font_attributes_p P_ ((Lisp_Object *, Lisp_Object *)); | |
471 static struct face_cache *make_face_cache P_ ((struct frame *)); | |
472 static void free_realized_face P_ ((struct frame *, struct face *)); | |
473 static void clear_face_gcs P_ ((struct face_cache *)); | |
474 static void free_face_cache P_ ((struct face_cache *)); | |
475 static int face_numeric_weight P_ ((Lisp_Object)); | |
476 static int face_numeric_slant P_ ((Lisp_Object)); | |
477 static int face_numeric_swidth P_ ((Lisp_Object)); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
478 static int face_fontset P_ ((Lisp_Object *)); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
479 static char *choose_face_font P_ ((struct frame *, Lisp_Object *, int, int)); |
24995 | 480 static void merge_face_vectors P_ ((Lisp_Object *from, Lisp_Object *)); |
481 static void merge_face_vector_with_property P_ ((struct frame *, Lisp_Object *, | |
482 Lisp_Object)); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
483 static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
484 Lisp_Object, int, int)); |
24995 | 485 static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
486 static struct face *make_realized_face P_ ((Lisp_Object *)); |
24995 | 487 static void free_realized_faces P_ ((struct face_cache *)); |
488 static char *best_matching_font P_ ((struct frame *, Lisp_Object *, | |
489 struct font_name *, int)); | |
490 static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); | |
491 static void uncache_face P_ ((struct face_cache *, struct face *)); | |
492 static int xlfd_numeric_slant P_ ((struct font_name *)); | |
493 static int xlfd_numeric_weight P_ ((struct font_name *)); | |
494 static int xlfd_numeric_swidth P_ ((struct font_name *)); | |
495 static Lisp_Object xlfd_symbolic_slant P_ ((struct font_name *)); | |
496 static Lisp_Object xlfd_symbolic_weight P_ ((struct font_name *)); | |
497 static Lisp_Object xlfd_symbolic_swidth P_ ((struct font_name *)); | |
498 static int xlfd_fixed_p P_ ((struct font_name *)); | |
499 static int xlfd_numeric_value P_ ((struct table_entry *, int, struct font_name *, | |
500 int, int)); | |
501 static Lisp_Object xlfd_symbolic_value P_ ((struct table_entry *, int, | |
502 struct font_name *, int, int)); | |
503 static struct table_entry *xlfd_lookup_field_contents P_ ((struct table_entry *, int, | |
504 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
|
505 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
506 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 507 |
508 static int split_font_name P_ ((struct frame *, struct font_name *, int)); | |
509 static int xlfd_point_size P_ ((struct frame *, struct font_name *)); | |
510 static void sort_fonts P_ ((struct frame *, struct font_name *, int, | |
511 int (*cmpfn) P_ ((const void *, const void *)))); | |
512 static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *)); | |
513 static void x_free_gc P_ ((struct frame *, GC)); | |
514 static void clear_font_table P_ ((struct frame *)); | |
515 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
516 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
517 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
|
518 #endif /* WINDOWSNT */ |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
519 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
520 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 521 |
522 | |
523 /*********************************************************************** | |
524 Utilities | |
525 ***********************************************************************/ | |
526 | |
527 #ifdef HAVE_X_WINDOWS | |
528 | |
28354
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
529 #ifdef DEBUG_X_COLORS |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
530 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
531 /* The following is a poor mans infrastructure for debugging X color |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
532 allocation problems on displays with PseudoColor-8. Some X servers |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
533 like 3.3.5 XF86_SVGA with Matrox cards apparently don't implement |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
534 color reference counts completely so that they don't signal an |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
535 error when a color is freed whose reference count is already 0. |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
536 Other X servers do. To help me debug this, the following code |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
537 implements a simple reference counting schema of its own, for a |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
538 single display/screen. --gerd. */ |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
539 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
540 /* Reference counts for pixel colors. */ |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
541 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
542 int color_count[256]; |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
543 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
544 /* Register color PIXEL as allocated. */ |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
545 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
546 void |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
547 register_color (pixel) |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
548 unsigned long pixel; |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
549 { |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
550 xassert (pixel < 256); |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
551 ++color_count[pixel]; |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
552 } |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
553 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
554 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
555 /* Register color PIXEL as deallocated. */ |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
556 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
557 void |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
558 unregister_color (pixel) |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
559 unsigned long pixel; |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
560 { |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
561 xassert (pixel < 256); |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
562 if (color_count[pixel] > 0) |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
563 --color_count[pixel]; |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
564 else |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
565 abort (); |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
566 } |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
567 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
568 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
569 /* Register N colors from PIXELS as deallocated. */ |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
570 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
571 void |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
572 unregister_colors (pixels, n) |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
573 unsigned long *pixels; |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
574 int n; |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
575 { |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
576 int i; |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
577 for (i = 0; i < n; ++i) |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
578 unregister_color (pixels[i]); |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
579 } |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
580 |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
581 #endif /* DEBUG_X_COLORS */ |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
582 |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
583 /* 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
|
584 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
|
585 is called. */ |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
586 |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
587 void |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
588 x_free_colors (f, pixels, npixels) |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
589 struct frame *f; |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
590 unsigned long *pixels; |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
591 int npixels; |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
592 { |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
593 int class = FRAME_X_DISPLAY_INFO (f)->visual->class; |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
594 |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
595 /* 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
|
596 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
|
597 if (class != StaticColor && class != StaticGray && class != TrueColor) |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
598 { |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
599 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
|
600 Colormap cmap = FRAME_X_COLORMAP (f); |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
601 Screen *screen = FRAME_X_SCREEN (f); |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
602 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
|
603 |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
604 if (default_cmap_p) |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
605 { |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
606 /* 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
|
607 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
|
608 int screen_no = XScreenNumberOfScreen (screen); |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
609 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
|
610 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
|
611 unsigned long *px; |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
612 int i, j; |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
613 |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
614 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
|
615 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
|
616 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
|
617 px[j++] = pixels[i]; |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
618 |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
619 if (j) |
28354
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
620 { |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
621 XFreeColors (dpy, cmap, px, j, 0); |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
622 #ifdef DEBUG_X_COLORS |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
623 unregister_colors (px, j); |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
624 #endif |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
625 } |
27984
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
626 } |
574e0b398168
(x_free_colors): Access colormap of frame using
Gerd Moellmann <gerd@gnu.org>
parents:
27982
diff
changeset
|
627 else |
28354
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
628 { |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
629 XFreeColors (dpy, cmap, pixels, npixels, 0); |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
630 #ifdef DEBUG_X_COLORS |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
631 unregister_colors (pixels, npixels); |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
632 #endif |
d6ae8188fa58
(register_color, unregister_colors, unregister_colors)
Gerd Moellmann <gerd@gnu.org>
parents:
28349
diff
changeset
|
633 } |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
634 } |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
635 } |
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
636 |
24995 | 637 /* Create and return a GC for use on frame F. GC values and mask |
638 are given by XGCV and MASK. */ | |
639 | |
640 static INLINE GC | |
641 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
|
642 struct frame *f; |
24995 | 643 unsigned long mask; |
644 XGCValues *xgcv; | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
645 { |
2336 | 646 GC gc; |
24995 | 647 BLOCK_INPUT; |
648 gc = XCreateGC (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), mask, xgcv); | |
649 UNBLOCK_INPUT; | |
650 IF_DEBUG (++ngcs); | |
651 return gc; | |
652 } | |
653 | |
654 | |
655 /* Free GC which was used on frame F. */ | |
656 | |
657 static INLINE void | |
658 x_free_gc (f, gc) | |
659 struct frame *f; | |
660 GC gc; | |
661 { | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
662 BLOCK_INPUT; |
24995 | 663 xassert (--ngcs >= 0); |
664 XFreeGC (FRAME_X_DISPLAY (f), gc); | |
665 UNBLOCK_INPUT; | |
666 } | |
667 | |
668 #endif /* HAVE_X_WINDOWS */ | |
669 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
670 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
671 /* W32 emulation of GCs */ |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
672 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
673 static INLINE GC |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
674 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
|
675 struct frame *f; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
676 unsigned long mask; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
677 XGCValues *xgcv; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
678 { |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
679 GC gc; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
680 BLOCK_INPUT; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
681 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
|
682 UNBLOCK_INPUT; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
683 IF_DEBUG (++ngcs); |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
684 return gc; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
685 } |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
686 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
687 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
688 /* 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
|
689 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
690 static INLINE void |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
691 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
|
692 struct frame *f; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
693 GC gc; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
694 { |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
695 BLOCK_INPUT; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
696 xassert (--ngcs >= 0); |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
697 xfree (gc); |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
698 UNBLOCK_INPUT; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
699 } |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
700 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
701 #endif /* WINDOWSNT */ |
24995 | 702 |
703 /* Like stricmp. Used to compare parts of font names which are in | |
704 ISO8859-1. */ | |
705 | |
706 int | |
707 xstricmp (s1, s2) | |
708 unsigned char *s1, *s2; | |
709 { | |
710 while (*s1 && *s2) | |
711 { | |
712 unsigned char c1 = tolower (*s1); | |
713 unsigned char c2 = tolower (*s2); | |
714 if (c1 != c2) | |
715 return c1 < c2 ? -1 : 1; | |
716 ++s1, ++s2; | |
717 } | |
718 | |
719 if (*s1 == 0) | |
720 return *s2 == 0 ? 0 : -1; | |
721 return 1; | |
722 } | |
723 | |
724 | |
725 /* Like strlwr, which might not always be available. */ | |
726 | |
727 static unsigned char * | |
728 xstrlwr (s) | |
729 unsigned char *s; | |
730 { | |
731 unsigned char *p = s; | |
732 | |
733 for (p = s; *p; ++p) | |
734 *p = tolower (*p); | |
735 | |
736 return s; | |
737 } | |
738 | |
739 | |
740 /* Signal `error' with message S, and additional argument ARG. */ | |
741 | |
742 static void | |
743 signal_error (s, arg) | |
744 char *s; | |
745 Lisp_Object arg; | |
746 { | |
747 Fsignal (Qerror, Fcons (build_string (s), Fcons (arg, Qnil))); | |
748 } | |
749 | |
750 | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
751 /* 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
|
752 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
|
753 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
|
754 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
|
755 Lisp function definitions. */ |
24995 | 756 |
757 static INLINE struct frame * | |
758 frame_or_selected_frame (frame, nparam) | |
759 Lisp_Object frame; | |
760 int nparam; | |
761 { | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
762 if (NILP (frame)) |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
763 frame = selected_frame; |
24995 | 764 |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
765 CHECK_LIVE_FRAME (frame, nparam); |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
766 return XFRAME (frame); |
24995 | 767 } |
768 | |
769 | |
770 /*********************************************************************** | |
771 Frames and faces | |
772 ***********************************************************************/ | |
773 | |
774 /* 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
|
775 |
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
776 void |
24995 | 777 init_frame_faces (f) |
778 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
|
779 { |
24995 | 780 /* Make a face cache, if F doesn't have one. */ |
781 if (FRAME_FACE_CACHE (f) == NULL) | |
782 FRAME_FACE_CACHE (f) = make_face_cache (f); | |
783 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
784 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 785 /* 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
|
786 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
|
787 { |
24995 | 788 if (FRAME_X_IMAGE_CACHE (f) == NULL) |
789 FRAME_X_IMAGE_CACHE (f) = make_image_cache (); | |
790 ++FRAME_X_IMAGE_CACHE (f)->refcount; | |
791 } | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
792 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 793 |
794 /* Realize basic faces. Must have enough information in frame | |
795 parameters to realize basic faces at this point. */ | |
796 #ifdef HAVE_X_WINDOWS | |
797 if (!FRAME_X_P (f) || FRAME_X_WINDOW (f)) | |
798 #endif | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
799 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
800 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
|
801 #endif |
24995 | 802 if (!realize_basic_faces (f)) |
803 abort (); | |
804 } | |
805 | |
806 | |
807 /* Free face cache of frame F. Called from Fdelete_frame. */ | |
808 | |
809 void | |
810 free_frame_faces (f) | |
811 struct frame *f; | |
812 { | |
813 struct face_cache *face_cache = FRAME_FACE_CACHE (f); | |
814 | |
815 if (face_cache) | |
816 { | |
817 free_face_cache (face_cache); | |
818 FRAME_FACE_CACHE (f) = NULL; | |
819 } | |
820 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
821 #ifdef HAVE_WINDOW_SYSTEM |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
822 if (FRAME_WINDOW_P (f)) |
24995 | 823 { |
824 struct image_cache *image_cache = FRAME_X_IMAGE_CACHE (f); | |
825 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
|
826 { |
24995 | 827 --image_cache->refcount; |
828 if (image_cache->refcount == 0) | |
829 free_image_cache (f); | |
830 } | |
831 } | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
832 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 833 } |
834 | |
835 | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
836 /* 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
|
837 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
|
838 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
|
839 of named faces. */ |
24995 | 840 |
841 void | |
842 recompute_basic_faces (f) | |
843 struct frame *f; | |
844 { | |
845 if (FRAME_FACE_CACHE (f)) | |
846 { | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
847 clear_face_cache (0); |
26601
e23e3120d84f
(set_lface_from_font_name): Fix previous change.
Gerd Moellmann <gerd@gnu.org>
parents:
26594
diff
changeset
|
848 if (!realize_basic_faces (f)) |
e23e3120d84f
(set_lface_from_font_name): Fix previous change.
Gerd Moellmann <gerd@gnu.org>
parents:
26594
diff
changeset
|
849 abort (); |
24995 | 850 } |
851 } | |
852 | |
853 | |
854 /* Clear the face caches of all frames. CLEAR_FONTS_P non-zero means | |
855 try to free unused fonts, too. */ | |
856 | |
857 void | |
858 clear_face_cache (clear_fonts_p) | |
859 int clear_fonts_p; | |
860 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
861 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 862 Lisp_Object tail, frame; |
863 struct frame *f; | |
864 | |
865 if (clear_fonts_p | |
866 || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT) | |
867 { | |
868 /* From time to time see if we can unload some fonts. This also | |
869 frees all realized faces on all frames. Fonts needed by | |
870 faces will be loaded again when faces are realized again. */ | |
871 clear_font_table_count = 0; | |
872 | |
873 FOR_EACH_FRAME (tail, frame) | |
874 { | |
875 f = XFRAME (frame); | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
876 if (FRAME_WINDOW_P (f) |
24995 | 877 && 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
|
878 { |
24995 | 879 free_all_realized_faces (frame); |
880 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
|
881 } |
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
882 } |
8e610355cb29
Eliminate the "display faces"; store GCs in the "computed faces".
Richard M. Stallman <rms@gnu.org>
parents:
9326
diff
changeset
|
883 } |
24995 | 884 else |
13460
5513606156bc
(unload_font): Invalidate computed faces.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
885 { |
24995 | 886 /* Clear GCs of realized faces. */ |
887 FOR_EACH_FRAME (tail, frame) | |
13460
5513606156bc
(unload_font): Invalidate computed faces.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
888 { |
24995 | 889 f = XFRAME (frame); |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
890 if (FRAME_WINDOW_P (f)) |
24995 | 891 { |
892 clear_face_gcs (FRAME_FACE_CACHE (f)); | |
893 clear_image_cache (f, 0); | |
894 } | |
13460
5513606156bc
(unload_font): Invalidate computed faces.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
895 } |
5513606156bc
(unload_font): Invalidate computed faces.
Richard M. Stallman <rms@gnu.org>
parents:
13363
diff
changeset
|
896 } |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
897 #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
|
898 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
899 |
24995 | 900 |
901 DEFUN ("clear-face-cache", Fclear_face_cache, Sclear_face_cache, 0, 1, 0, | |
902 "Clear face caches on all frames.\n\ | |
903 Optional THOROUGHLY non-nil means try to free unused fonts, too.") | |
904 (thorougly) | |
905 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
|
906 { |
24995 | 907 clear_face_cache (!NILP (thorougly)); |
908 return Qnil; | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
909 } |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
910 |
24995 | 911 |
912 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
913 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 914 |
915 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
916 /* Remove those fonts from the font table of frame F exept for the |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
917 default ASCII font for the frame. Called from clear_face_cache |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
918 from time to time. */ |
24995 | 919 |
920 static void | |
921 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
|
922 struct frame *f; |
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
923 { |
24995 | 924 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); |
925 Lisp_Object rest, frame; | |
926 int i; | |
927 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
928 xassert (FRAME_WINDOW_P (f)); |
24995 | 929 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
930 /* Free those fonts that are not used by the frame F as the default. */ |
24995 | 931 for (i = 0; i < dpyinfo->n_fonts; ++i) |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
932 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
933 struct font_info *font_info = dpyinfo->font_table + i; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
934 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
935 if (!font_info->name |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
936 || font_info->font == FRAME_FONT (f)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
937 continue; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
938 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
939 /* Free names. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
940 if (font_info->full_name != font_info->name) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
941 xfree (font_info->full_name); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
942 xfree (font_info->name); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
943 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
944 /* Free the font. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
945 BLOCK_INPUT; |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
946 #ifdef HAVE_X_WINDOWS |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
947 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
|
948 #endif |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
949 #ifdef WINDOWSNT |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
950 w32_unload_font (dpyinfo, font_info->font); |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
951 #endif |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
952 UNBLOCK_INPUT; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
953 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
954 /* Mark font table slot free. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
955 font_info->font = NULL; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
956 font_info->name = font_info->full_name = NULL; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
957 } |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
958 } |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
959 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
960 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 961 |
962 | |
963 | |
964 /*********************************************************************** | |
965 X Pixmaps | |
966 ***********************************************************************/ | |
967 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
968 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 969 |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
970 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
|
971 "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
|
972 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
|
973 (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
|
974 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
|
975 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
|
976 (WIDTH + 7)/8 bytes.") |
14090
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
977 (object) |
24b93860d392
(Fpixmap_spec_p): Harmonize arguments with documentation.
Erik Naggum <erik@naggum.no>
parents:
14036
diff
changeset
|
978 Lisp_Object object; |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
979 { |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
980 int pixmap_p = 0; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
981 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
982 if (STRINGP (object)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
983 /* 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
|
984 pixmap_p = 1; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
985 else if (CONSP (object)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
986 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
987 /* 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
|
988 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
|
989 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
|
990 Lisp_Object width, height, 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 height = width = data = Qnil; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
993 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
994 if (CONSP (object)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
995 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
996 width = XCAR (object); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
997 object = XCDR (object); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
998 if (CONSP (object)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
999 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1000 height = XCAR (object); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1001 object = XCDR (object); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1002 if (CONSP (object)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1003 data = XCAR (object); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1004 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1005 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1006 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1007 if (NATNUMP (width) && NATNUMP (height) && STRINGP (data)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1008 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1009 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
|
1010 / BITS_PER_CHAR); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1011 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
|
1012 pixmap_p = 1; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1013 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1014 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1015 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
1016 return pixmap_p ? Qt : Qnil; |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1017 } |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1018 |
24995 | 1019 |
1020 /* Load a bitmap according to NAME (which is either a file name or a | |
1021 pixmap spec) for use on frame F. Value is the bitmap_id (see | |
1022 xfns.c). If NAME is nil, return with a bitmap id of zero. If | |
1023 bitmap cannot be loaded, display a message saying so, and return | |
1024 zero. Store the bitmap width in *W_PTR and its height in *H_PTR, | |
1025 if these pointers are not null. */ | |
1026 | |
1027 static int | |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1028 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
|
1029 FRAME_PTR f; |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1030 Lisp_Object name; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1031 unsigned int *w_ptr, *h_ptr; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1032 { |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1033 int bitmap_id; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1034 Lisp_Object tem; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1035 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1036 if (NILP (name)) |
24995 | 1037 return 0; |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1038 |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
1039 tem = Fbitmap_spec_p (name); |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1040 if (NILP (tem)) |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
1041 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
|
1042 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1043 BLOCK_INPUT; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1044 if (CONSP (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 /* Decode a bitmap spec into a bitmap. */ |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1047 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1048 int h, w; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1049 Lisp_Object bits; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1050 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1051 w = XINT (Fcar (name)); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1052 h = XINT (Fcar (Fcdr (name))); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1053 bits = Fcar (Fcdr (Fcdr (name))); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1054 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1055 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
|
1056 w, h); |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1057 } |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1058 else |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1059 { |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1060 /* 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
|
1061 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
|
1062 } |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1063 UNBLOCK_INPUT; |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1064 |
9902
32ed712a45a3
(load_pixmap): Handle bitmap_id < 0. F is a FRAME_PTR.
Richard M. Stallman <rms@gnu.org>
parents:
9671
diff
changeset
|
1065 if (bitmap_id < 0) |
24995 | 1066 { |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
1067 add_to_log ("Invalid or undefined bitmap %s", name, Qnil); |
24995 | 1068 bitmap_id = 0; |
1069 | |
1070 if (w_ptr) | |
1071 *w_ptr = 0; | |
1072 if (h_ptr) | |
1073 *h_ptr = 0; | |
1074 } | |
1075 else | |
1076 { | |
1077 #if GLYPH_DEBUG | |
1078 ++npixmaps_allocated; | |
1079 #endif | |
1080 if (w_ptr) | |
1081 *w_ptr = x_bitmap_width (f, bitmap_id); | |
1082 | |
1083 if (h_ptr) | |
1084 *h_ptr = x_bitmap_height (f, bitmap_id); | |
1085 } | |
9564
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1086 |
1bfb920ab23e
(intern_face): Set the fill_style.
Richard M. Stallman <rms@gnu.org>
parents:
9529
diff
changeset
|
1087 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
|
1088 } |
9572 | 1089 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1090 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 1091 |
9572 | 1092 |
2336 | 1093 |
24995 | 1094 /*********************************************************************** |
1095 Minimum font bounds | |
1096 ***********************************************************************/ | |
1097 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1098 #ifdef HAVE_WINDOW_SYSTEM |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
1099 |
25062
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
1100 /* 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
|
1101 changes. */ |
6768
0b61d2b74e64
(frame_update_line_height): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6615
diff
changeset
|
1102 |
6879
471aebc1b151
(frame_update_line_height): Don't call x_set_window_size.
Richard M. Stallman <rms@gnu.org>
parents:
6784
diff
changeset
|
1103 int |
6768
0b61d2b74e64
(frame_update_line_height): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6615
diff
changeset
|
1104 frame_update_line_height (f) |
24995 | 1105 struct frame *f; |
6768
0b61d2b74e64
(frame_update_line_height): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6615
diff
changeset
|
1106 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1107 int line_height, changed_p; |
25062
050561b336aa
(load_face_colors): Load background color if setting
Gerd Moellmann <gerd@gnu.org>
parents:
24995
diff
changeset
|
1108 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1109 line_height = FONT_HEIGHT (FRAME_FONT (f)); |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1110 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
|
1111 FRAME_LINE_HEIGHT (f) = line_height; |
24995 | 1112 return changed_p; |
6768
0b61d2b74e64
(frame_update_line_height): New function.
Richard M. Stallman <rms@gnu.org>
parents:
6615
diff
changeset
|
1113 } |
24995 | 1114 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1115 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 1116 |
6784
d41c216ccd27
(frame_update_line_height): Check param_faces[i] not null.
Richard M. Stallman <rms@gnu.org>
parents:
6768
diff
changeset
|
1117 |
24995 | 1118 /*********************************************************************** |
1119 Fonts | |
1120 ***********************************************************************/ | |
1121 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1122 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 1123 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1124 /* Load font of face FACE which is used on frame F to display |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1125 character C. The name of the font to load is determined by lface |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1126 and fontset of FACE. */ |
6784
d41c216ccd27
(frame_update_line_height): Check param_faces[i] not null.
Richard M. Stallman <rms@gnu.org>
parents:
6768
diff
changeset
|
1127 |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
1128 static void |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1129 load_face_font (f, face, c) |
24995 | 1130 struct frame *f; |
1131 struct face *face; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1132 int c; |
24995 | 1133 { |
1134 struct font_info *font_info = NULL; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1135 char *font_name; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1136 |
24995 | 1137 face->font_info_id = -1; |
1138 face->font = NULL; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1139 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1140 font_name = choose_face_font (f, face->lface, face->fontset, c); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1141 if (!font_name) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1142 return; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1143 |
24995 | 1144 BLOCK_INPUT; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1145 font_info = FS_LOAD_FACE_FONT (f, c, font_name, face); |
24995 | 1146 UNBLOCK_INPUT; |
1147 | |
1148 if (font_info) | |
1149 { | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1150 face->font_info_id = font_info->font_idx; |
24995 | 1151 face->font = font_info->font; |
1152 face->font_name = font_info->full_name; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1153 if (face->gc) |
24995 | 1154 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1155 x_free_gc (f, face->gc); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1156 face->gc = 0; |
24995 | 1157 } |
1158 } | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1159 else |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
1160 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
|
1161 build_string (font_name), Qnil); |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
1162 xfree (font_name); |
24995 | 1163 } |
1164 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1165 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 1166 |
1167 | |
1168 | |
1169 /*********************************************************************** | |
1170 X Colors | |
1171 ***********************************************************************/ | |
1172 | |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1173 /* 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
|
1174 int |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1175 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
|
1176 struct frame *f; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1177 char *color_name; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1178 XColor *color_def; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1179 int alloc; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1180 { |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1181 Lisp_Object color_desc; |
27695
68feb13f9572
(tty_defined_color): Declare color_idx unsigned long.
Dave Love <fx@gnu.org>
parents:
27137
diff
changeset
|
1182 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
|
1183 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
|
1184 int status = 1; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1185 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1186 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
|
1187 { |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1188 Lisp_Object frame; |
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1189 |
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1190 XSETFRAME (frame, f); |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1191 status = 0; |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1192 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
|
1193 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
|
1194 { |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1195 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
|
1196 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
|
1197 { |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1198 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
|
1199 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
|
1200 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
|
1201 } |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1202 status = 1; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1203 } |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1204 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
|
1205 /* 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
|
1206 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
|
1207 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
|
1208 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
|
1209 status = 1; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1210 } |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
1211 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
|
1212 { |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
1213 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
|
1214 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
|
1215 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
|
1216 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
|
1217 } |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
1218 |
27743
2e020ab026b8
(tty_defined_color): Don't return faulire indication
Eli Zaretskii <eliz@gnu.org>
parents:
27695
diff
changeset
|
1219 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
|
1220 status = 1; |
2e020ab026b8
(tty_defined_color): Don't return faulire indication
Eli Zaretskii <eliz@gnu.org>
parents:
27695
diff
changeset
|
1221 |
27695
68feb13f9572
(tty_defined_color): Declare color_idx unsigned long.
Dave Love <fx@gnu.org>
parents:
27137
diff
changeset
|
1222 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
|
1223 color_def->red = red; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1224 color_def->green = green; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1225 color_def->blue = blue; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1226 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1227 return status; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1228 } |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1229 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1230 /* 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
|
1231 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
|
1232 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
|
1233 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1234 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
|
1235 int |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1236 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
|
1237 struct frame *f; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1238 char *color_name; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1239 XColor *color_def; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1240 int alloc; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1241 { |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1242 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
|
1243 return tty_defined_color (f, color_name, color_def, alloc); |
24995 | 1244 #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
|
1245 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
|
1246 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
|
1247 #endif |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1248 #ifdef WINDOWSNT |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1249 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
|
1250 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
|
1251 #endif |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1252 #ifdef macintosh |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1253 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
|
1254 /* 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
|
1255 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
|
1256 #endif |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1257 else |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1258 abort (); |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1259 } |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1260 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1261 /* 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
|
1262 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1263 Lisp_Object |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1264 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
|
1265 struct frame *f; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1266 int idx; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1267 { |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1268 char *color; |
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 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
|
1271 { |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1272 Lisp_Object frame; |
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1273 Lisp_Object coldesc; |
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1274 |
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1275 XSETFRAME (frame, f); |
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
1276 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
|
1277 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1278 if (!NILP (coldesc)) |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1279 return XCAR (coldesc); |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1280 } |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1281 #ifdef MSDOS |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1282 /* 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
|
1283 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
|
1284 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
|
1285 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
|
1286 #endif |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1287 |
27114
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
1288 if (idx == FACE_TTY_DEFAULT_FG_COLOR) |
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
1289 return build_string (unspecified_fg); |
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
1290 if (idx == FACE_TTY_DEFAULT_BG_COLOR) |
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
1291 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
|
1292 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1293 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1294 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
|
1295 #endif |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1296 |
27114
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
1297 return Qunspecified; |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1298 } |
24995 | 1299 |
1300 /* Return non-zero if COLOR_NAME is a shade of gray (or white or | |
1301 black) on frame F. The algorithm is taken from 20.2 faces.el. */ | |
1302 | |
1303 static int | |
1304 face_color_gray_p (f, color_name) | |
1305 struct frame *f; | |
1306 char *color_name; | |
1307 { | |
1308 XColor color; | |
1309 int gray_p; | |
1310 | |
1311 if (defined_color (f, color_name, &color, 0)) | |
1312 gray_p = ((abs (color.red - color.green) | |
1313 < max (color.red, color.green) / 20) | |
1314 && (abs (color.green - color.blue) | |
1315 < max (color.green, color.blue) / 20) | |
1316 && (abs (color.blue - color.red) | |
1317 < max (color.blue, color.red) / 20)); | |
1318 else | |
1319 gray_p = 0; | |
1320 | |
1321 return gray_p; | |
1322 } | |
1323 | |
1324 | |
1325 /* Return non-zero if color COLOR_NAME can be displayed on frame F. | |
1326 BACKGROUND_P non-zero means the color will be used as background | |
1327 color. */ | |
1328 | |
1329 static int | |
1330 face_color_supported_p (f, color_name, background_p) | |
1331 struct frame *f; | |
1332 char *color_name; | |
1333 int background_p; | |
1334 { | |
1335 Lisp_Object frame; | |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1336 XColor not_used; |
24995 | 1337 |
1338 XSETFRAME (frame, f); | |
26972
68a3d8530f6c
(face_color_supported_p): Check by tty_defined_color
Kenichi Handa <handa@m17n.org>
parents:
26913
diff
changeset
|
1339 return (FRAME_WINDOW_P (f) |
68a3d8530f6c
(face_color_supported_p): Check by tty_defined_color
Kenichi Handa <handa@m17n.org>
parents:
26913
diff
changeset
|
1340 ? (!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
|
1341 || xstricmp (color_name, "black") == 0 |
68a3d8530f6c
(face_color_supported_p): Check by tty_defined_color
Kenichi Handa <handa@m17n.org>
parents:
26913
diff
changeset
|
1342 || xstricmp (color_name, "white") == 0 |
68a3d8530f6c
(face_color_supported_p): Check by tty_defined_color
Kenichi Handa <handa@m17n.org>
parents:
26913
diff
changeset
|
1343 || (background_p |
68a3d8530f6c
(face_color_supported_p): Check by tty_defined_color
Kenichi Handa <handa@m17n.org>
parents:
26913
diff
changeset
|
1344 && 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
|
1345 || (!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
|
1346 && 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
|
1347 : 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
|
1348 } |
24995 | 1349 |
1350 | |
27100
9a0d8503806e
(Fcolor_gray_p): Renamed from face-color-gray-p.
Eli Zaretskii <eliz@gnu.org>
parents:
27088
diff
changeset
|
1351 DEFUN ("color-gray-p", Fcolor_gray_p, Scolor_gray_p, 1, 2, 0, |
24995 | 1352 "Return non-nil if COLOR is a shade of gray (or white or black).\n\ |
1353 FRAME specifies the frame and thus the display for interpreting COLOR.\n\ | |
1354 If FRAME is nil or omitted, use the selected frame.") | |
1355 (color, frame) | |
1356 Lisp_Object color, frame; | |
1357 { | |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1358 struct frame *f; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1359 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1360 CHECK_FRAME (frame, 0); |
24995 | 1361 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
|
1362 f = XFRAME (frame); |
24995 | 1363 return face_color_gray_p (f, XSTRING (color)->data) ? Qt : Qnil; |
1364 } | |
1365 | |
1366 | |
27100
9a0d8503806e
(Fcolor_gray_p): Renamed from face-color-gray-p.
Eli Zaretskii <eliz@gnu.org>
parents:
27088
diff
changeset
|
1367 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
|
1368 Scolor_supported_p, 2, 3, 0, |
24995 | 1369 "Return non-nil if COLOR can be displayed on FRAME.\n\ |
1370 BACKGROUND-P non-nil means COLOR is used as a background.\n\ | |
1371 If FRAME is nil or omitted, use the selected frame.\n\ | |
1372 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
|
1373 (color, frame, background_p) |
24995 | 1374 Lisp_Object frame, color, background_p; |
1375 { | |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1376 struct frame *f; |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1377 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1378 CHECK_FRAME (frame, 0); |
24995 | 1379 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
|
1380 f = XFRAME (frame); |
24995 | 1381 if (face_color_supported_p (f, XSTRING (color)->data, !NILP (background_p))) |
1382 return Qt; | |
1383 return Qnil; | |
1384 } | |
1385 | |
1386 /* Load color with name NAME for use by face FACE on frame F. | |
1387 TARGET_INDEX must be one of LFACE_FOREGROUND_INDEX, | |
1388 LFACE_BACKGROUND_INDEX, LFACE_UNDERLINE_INDEX, LFACE_OVERLINE_INDEX, | |
1389 LFACE_STRIKE_THROUGH_INDEX, or LFACE_BOX_INDEX. Value is the | |
1390 pixel color. If color cannot be loaded, display a message, and | |
1391 return the foreground, background or underline color of F, but | |
1392 record that fact in flags of the face so that we don't try to free | |
1393 these colors. */ | |
1394 | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
1395 unsigned long |
24995 | 1396 load_color (f, face, name, target_index) |
1397 struct frame *f; | |
1398 struct face *face; | |
1399 Lisp_Object name; | |
1400 enum lface_attribute_index target_index; | |
1401 { | |
1402 XColor color; | |
1403 | |
1404 xassert (STRINGP (name)); | |
1405 xassert (target_index == LFACE_FOREGROUND_INDEX | |
1406 || target_index == LFACE_BACKGROUND_INDEX | |
1407 || target_index == LFACE_UNDERLINE_INDEX | |
1408 || target_index == LFACE_OVERLINE_INDEX | |
1409 || target_index == LFACE_STRIKE_THROUGH_INDEX | |
1410 || target_index == LFACE_BOX_INDEX); | |
1411 | |
1412 /* if the color map is full, defined_color will return a best match | |
1413 to the values in an existing cell. */ | |
1414 if (!defined_color (f, XSTRING (name)->data, &color, 1)) | |
1415 { | |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
1416 add_to_log ("Unable to load color \"%s\"", name, Qnil); |
24995 | 1417 |
1418 switch (target_index) | |
1419 { | |
1420 case LFACE_FOREGROUND_INDEX: | |
1421 face->foreground_defaulted_p = 1; | |
1422 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1423 break; | |
1424 | |
1425 case LFACE_BACKGROUND_INDEX: | |
1426 face->background_defaulted_p = 1; | |
1427 color.pixel = FRAME_BACKGROUND_PIXEL (f); | |
1428 break; | |
1429 | |
1430 case LFACE_UNDERLINE_INDEX: | |
1431 face->underline_defaulted_p = 1; | |
1432 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1433 break; | |
1434 | |
1435 case LFACE_OVERLINE_INDEX: | |
1436 face->overline_color_defaulted_p = 1; | |
1437 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1438 break; | |
1439 | |
1440 case LFACE_STRIKE_THROUGH_INDEX: | |
1441 face->strike_through_color_defaulted_p = 1; | |
1442 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1443 break; | |
1444 | |
1445 case LFACE_BOX_INDEX: | |
1446 face->box_color_defaulted_p = 1; | |
1447 color.pixel = FRAME_FOREGROUND_PIXEL (f); | |
1448 break; | |
1449 | |
1450 default: | |
1451 abort (); | |
1452 } | |
1453 } | |
1454 #if GLYPH_DEBUG | |
1455 else | |
1456 ++ncolors_allocated; | |
1457 #endif | |
1458 | |
1459 return color.pixel; | |
1460 } | |
1461 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1462 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 1463 |
1464 /* Load colors for face FACE which is used on frame F. Colors are | |
1465 specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX | |
1466 of ATTRS. If the background color specified is not supported on F, | |
1467 try to emulate gray colors with a stipple from Vface_default_stipple. */ | |
1468 | |
1469 static void | |
1470 load_face_colors (f, face, attrs) | |
1471 struct frame *f; | |
1472 struct face *face; | |
1473 Lisp_Object *attrs; | |
1474 { | |
1475 Lisp_Object fg, bg; | |
1476 | |
1477 bg = attrs[LFACE_BACKGROUND_INDEX]; | |
1478 fg = attrs[LFACE_FOREGROUND_INDEX]; | |
1479 | |
1480 /* Swap colors if face is inverse-video. */ | |
1481 if (EQ (attrs[LFACE_INVERSE_INDEX], Qt)) | |
1482 { | |
1483 Lisp_Object tmp; | |
1484 tmp = fg; | |
1485 fg = bg; | |
1486 bg = tmp; | |
1487 } | |
1488 | |
1489 /* Check for support for foreground, not for background because | |
1490 face_color_supported_p is smart enough to know that grays are | |
1491 "supported" as background because we are supposed to use stipple | |
1492 for them. */ | |
1493 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
|
1494 && !NILP (Fbitmap_spec_p (Vface_default_stipple))) |
24995 | 1495 { |
1496 x_destroy_bitmap (f, face->stipple); | |
1497 face->stipple = load_pixmap (f, Vface_default_stipple, | |
1498 &face->pixmap_w, &face->pixmap_h); | |
1499 } | |
25092
79a5a567bdb0
(prepare_face_for_display): Use FillOpaqueStippled instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25062
diff
changeset
|
1500 |
79a5a567bdb0
(prepare_face_for_display): Use FillOpaqueStippled instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25062
diff
changeset
|
1501 face->background = load_color (f, face, bg, LFACE_BACKGROUND_INDEX); |
24995 | 1502 face->foreground = load_color (f, face, fg, LFACE_FOREGROUND_INDEX); |
1503 } | |
1504 | |
1505 | |
1506 /* Free color PIXEL on frame F. */ | |
1507 | |
1508 void | |
1509 unload_color (f, pixel) | |
1510 struct frame *f; | |
1511 unsigned long pixel; | |
1512 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1513 #ifdef HAVE_X_WINDOWS |
24995 | 1514 BLOCK_INPUT; |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1515 x_free_colors (f, &pixel, 1); |
24995 | 1516 UNBLOCK_INPUT; |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1517 #endif |
24995 | 1518 } |
1519 | |
1520 | |
1521 /* Free colors allocated for FACE. */ | |
1522 | |
1523 static void | |
1524 free_face_colors (f, face) | |
1525 struct frame *f; | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
1526 struct face *face; |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
1527 { |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1528 #ifdef HAVE_X_WINDOWS |
24995 | 1529 int class = FRAME_X_DISPLAY_INFO (f)->visual->class; |
1530 | |
1531 /* If display has an immutable color map, freeing colors is not | |
1532 necessary and some servers don't allow it. So don't do it. */ | |
1533 if (class != StaticColor | |
1534 && class != StaticGray | |
1535 && class != TrueColor) | |
1536 { | |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1537 BLOCK_INPUT; |
24995 | 1538 |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1539 if (!face->foreground_defaulted_p) |
24995 | 1540 { |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1541 x_free_colors (f, &face->foreground, 1); |
24995 | 1542 IF_DEBUG (--ncolors_allocated); |
1543 } | |
1544 | |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1545 if (!face->background_defaulted_p) |
24995 | 1546 { |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1547 x_free_colors (f, &face->background, 1); |
24995 | 1548 IF_DEBUG (--ncolors_allocated); |
1549 } | |
1550 | |
1551 if (face->underline_p | |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1552 && !face->underline_defaulted_p) |
24995 | 1553 { |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1554 x_free_colors (f, &face->underline_color, 1); |
24995 | 1555 IF_DEBUG (--ncolors_allocated); |
1556 } | |
1557 | |
1558 if (face->overline_p | |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1559 && !face->overline_color_defaulted_p) |
24995 | 1560 { |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1561 x_free_colors (f, &face->overline_color, 1); |
24995 | 1562 IF_DEBUG (--ncolors_allocated); |
1563 } | |
1564 | |
1565 if (face->strike_through_p | |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1566 && !face->strike_through_color_defaulted_p) |
24995 | 1567 { |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1568 x_free_colors (f, &face->strike_through_color, 1); |
24995 | 1569 IF_DEBUG (--ncolors_allocated); |
1570 } | |
1571 | |
1572 if (face->box != FACE_NO_BOX | |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1573 && !face->box_color_defaulted_p) |
24995 | 1574 { |
27960
25a04100858d
(x_free_colors): New function.
Gerd Moellmann <gerd@gnu.org>
parents:
27743
diff
changeset
|
1575 x_free_colors (f, &face->box_color, 1); |
24995 | 1576 IF_DEBUG (--ncolors_allocated); |
1577 } | |
1578 | |
1579 UNBLOCK_INPUT; | |
1580 } | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1581 #endif /* HAVE_X_WINDOWS */ |
24995 | 1582 } |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1583 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 1584 |
1585 | |
1586 | |
1587 /*********************************************************************** | |
1588 XLFD Font Names | |
1589 ***********************************************************************/ | |
1590 | |
1591 /* An enumerator for each field of an XLFD font name. */ | |
1592 | |
1593 enum xlfd_field | |
1594 { | |
1595 XLFD_FOUNDRY, | |
1596 XLFD_FAMILY, | |
1597 XLFD_WEIGHT, | |
1598 XLFD_SLANT, | |
1599 XLFD_SWIDTH, | |
1600 XLFD_ADSTYLE, | |
1601 XLFD_PIXEL_SIZE, | |
1602 XLFD_POINT_SIZE, | |
1603 XLFD_RESX, | |
1604 XLFD_RESY, | |
1605 XLFD_SPACING, | |
1606 XLFD_AVGWIDTH, | |
1607 XLFD_REGISTRY, | |
1608 XLFD_ENCODING, | |
1609 XLFD_LAST | |
1610 }; | |
1611 | |
1612 /* An enumerator for each possible slant value of a font. Taken from | |
1613 the XLFD specification. */ | |
1614 | |
1615 enum xlfd_slant | |
1616 { | |
1617 XLFD_SLANT_UNKNOWN, | |
1618 XLFD_SLANT_ROMAN, | |
1619 XLFD_SLANT_ITALIC, | |
1620 XLFD_SLANT_OBLIQUE, | |
1621 XLFD_SLANT_REVERSE_ITALIC, | |
1622 XLFD_SLANT_REVERSE_OBLIQUE, | |
1623 XLFD_SLANT_OTHER | |
1624 }; | |
1625 | |
1626 /* Relative font weight according to XLFD documentation. */ | |
1627 | |
1628 enum xlfd_weight | |
1629 { | |
1630 XLFD_WEIGHT_UNKNOWN, | |
1631 XLFD_WEIGHT_ULTRA_LIGHT, /* 10 */ | |
1632 XLFD_WEIGHT_EXTRA_LIGHT, /* 20 */ | |
1633 XLFD_WEIGHT_LIGHT, /* 30 */ | |
1634 XLFD_WEIGHT_SEMI_LIGHT, /* 40: SemiLight, Book, ... */ | |
1635 XLFD_WEIGHT_MEDIUM, /* 50: Medium, Normal, Regular, ... */ | |
1636 XLFD_WEIGHT_SEMI_BOLD, /* 60: SemiBold, DemiBold, ... */ | |
1637 XLFD_WEIGHT_BOLD, /* 70: Bold, ... */ | |
1638 XLFD_WEIGHT_EXTRA_BOLD, /* 80: ExtraBold, Heavy, ... */ | |
1639 XLFD_WEIGHT_ULTRA_BOLD /* 90: UltraBold, Black, ... */ | |
1640 }; | |
1641 | |
1642 /* Relative proportionate width. */ | |
1643 | |
1644 enum xlfd_swidth | |
1645 { | |
1646 XLFD_SWIDTH_UNKNOWN, | |
1647 XLFD_SWIDTH_ULTRA_CONDENSED, /* 10 */ | |
1648 XLFD_SWIDTH_EXTRA_CONDENSED, /* 20 */ | |
1649 XLFD_SWIDTH_CONDENSED, /* 30: Condensed, Narrow, Compressed, ... */ | |
1650 XLFD_SWIDTH_SEMI_CONDENSED, /* 40: semicondensed */ | |
1651 XLFD_SWIDTH_MEDIUM, /* 50: Medium, Normal, Regular, ... */ | |
1652 XLFD_SWIDTH_SEMI_EXPANDED, /* 60: SemiExpanded, DemiExpanded, ... */ | |
1653 XLFD_SWIDTH_EXPANDED, /* 70: Expanded... */ | |
1654 XLFD_SWIDTH_EXTRA_EXPANDED, /* 80: ExtraExpanded, Wide... */ | |
1655 XLFD_SWIDTH_ULTRA_EXPANDED /* 90: UltraExpanded... */ | |
1656 }; | |
1657 | |
1658 /* Structure used for tables mapping XLFD weight, slant, and width | |
1659 names to numeric and symbolic values. */ | |
1660 | |
1661 struct table_entry | |
1662 { | |
1663 char *name; | |
1664 int numeric; | |
1665 Lisp_Object *symbol; | |
1666 }; | |
1667 | |
1668 /* Table of XLFD slant names and their numeric and symbolic | |
1669 representations. This table must be sorted by slant names in | |
1670 ascending order. */ | |
1671 | |
1672 static struct table_entry slant_table[] = | |
1673 { | |
1674 {"i", XLFD_SLANT_ITALIC, &Qitalic}, | |
1675 {"o", XLFD_SLANT_OBLIQUE, &Qoblique}, | |
1676 {"ot", XLFD_SLANT_OTHER, &Qitalic}, | |
1677 {"r", XLFD_SLANT_ROMAN, &Qnormal}, | |
1678 {"ri", XLFD_SLANT_REVERSE_ITALIC, &Qreverse_italic}, | |
1679 {"ro", XLFD_SLANT_REVERSE_OBLIQUE, &Qreverse_oblique} | |
1680 }; | |
1681 | |
1682 /* Table of XLFD weight names. This table must be sorted by weight | |
1683 names in ascending order. */ | |
1684 | |
1685 static struct table_entry weight_table[] = | |
1686 { | |
1687 {"black", XLFD_WEIGHT_ULTRA_BOLD, &Qultra_bold}, | |
1688 {"bold", XLFD_WEIGHT_BOLD, &Qbold}, | |
1689 {"book", XLFD_WEIGHT_SEMI_LIGHT, &Qsemi_light}, | |
1690 {"demibold", XLFD_WEIGHT_SEMI_BOLD, &Qsemi_bold}, | |
1691 {"extralight", XLFD_WEIGHT_EXTRA_LIGHT, &Qextra_light}, | |
1692 {"extrabold", XLFD_WEIGHT_EXTRA_BOLD, &Qextra_bold}, | |
1693 {"heavy", XLFD_WEIGHT_EXTRA_BOLD, &Qextra_bold}, | |
1694 {"light", XLFD_WEIGHT_LIGHT, &Qlight}, | |
1695 {"medium", XLFD_WEIGHT_MEDIUM, &Qnormal}, | |
1696 {"normal", XLFD_WEIGHT_MEDIUM, &Qnormal}, | |
1697 {"regular", XLFD_WEIGHT_MEDIUM, &Qnormal}, | |
1698 {"semibold", XLFD_WEIGHT_SEMI_BOLD, &Qsemi_bold}, | |
1699 {"semilight", XLFD_WEIGHT_SEMI_LIGHT, &Qsemi_light}, | |
1700 {"ultralight", XLFD_WEIGHT_ULTRA_LIGHT, &Qultra_light}, | |
1701 {"ultrabold", XLFD_WEIGHT_ULTRA_BOLD, &Qultra_bold} | |
1702 }; | |
1703 | |
1704 /* Table of XLFD width names. This table must be sorted by width | |
1705 names in ascending order. */ | |
1706 | |
1707 static struct table_entry swidth_table[] = | |
1708 { | |
1709 {"compressed", XLFD_SWIDTH_CONDENSED, &Qcondensed}, | |
1710 {"condensed", XLFD_SWIDTH_CONDENSED, &Qcondensed}, | |
1711 {"demiexpanded", XLFD_SWIDTH_SEMI_EXPANDED, &Qsemi_expanded}, | |
1712 {"expanded", XLFD_SWIDTH_EXPANDED, &Qexpanded}, | |
1713 {"extracondensed", XLFD_SWIDTH_EXTRA_CONDENSED, &Qextra_condensed}, | |
1714 {"extraexpanded", XLFD_SWIDTH_EXTRA_EXPANDED, &Qextra_expanded}, | |
1715 {"medium", XLFD_SWIDTH_MEDIUM, &Qnormal}, | |
1716 {"narrow", XLFD_SWIDTH_CONDENSED, &Qcondensed}, | |
1717 {"normal", XLFD_SWIDTH_MEDIUM, &Qnormal}, | |
1718 {"regular", XLFD_SWIDTH_MEDIUM, &Qnormal}, | |
1719 {"semicondensed", XLFD_SWIDTH_SEMI_CONDENSED, &Qsemi_condensed}, | |
1720 {"semiexpanded", XLFD_SWIDTH_SEMI_EXPANDED, &Qsemi_expanded}, | |
1721 {"ultracondensed", XLFD_SWIDTH_ULTRA_CONDENSED, &Qultra_condensed}, | |
1722 {"ultraexpanded", XLFD_SWIDTH_ULTRA_EXPANDED, &Qultra_expanded}, | |
1723 {"wide", XLFD_SWIDTH_EXTRA_EXPANDED, &Qextra_expanded} | |
1724 }; | |
1725 | |
1726 /* Structure used to hold the result of splitting font names in XLFD | |
1727 format into their fields. */ | |
1728 | |
1729 struct font_name | |
1730 { | |
1731 /* The original name which is modified destructively by | |
1732 split_font_name. The pointer is kept here to be able to free it | |
1733 if it was allocated from the heap. */ | |
1734 char *name; | |
1735 | |
1736 /* Font name fields. Each vector element points into `name' above. | |
1737 Fields are NUL-terminated. */ | |
1738 char *fields[XLFD_LAST]; | |
1739 | |
1740 /* Numeric values for those fields that interest us. See | |
1741 split_font_name for which these are. */ | |
1742 int numeric[XLFD_LAST]; | |
1743 }; | |
1744 | |
1745 /* The frame in effect when sorting font names. Set temporarily in | |
1746 sort_fonts so that it is available in font comparison functions. */ | |
1747 | |
1748 static struct frame *font_frame; | |
1749 | |
1750 /* Order by which font selection chooses fonts. The default values | |
1751 mean `first, find a best match for the font width, then for the | |
1752 font height, then for weight, then for slant.' This variable can be | |
1753 set via set-face-font-sort-order. */ | |
1754 | |
1755 static int font_sort_order[4]; | |
1756 | |
1757 | |
1758 /* Look up FONT.fields[FIELD_INDEX] in TABLE which has DIM entries. | |
1759 TABLE must be sorted by TABLE[i]->name in ascending order. Value | |
1760 is a pointer to the matching table entry or null if no table entry | |
1761 matches. */ | |
1762 | |
1763 static struct table_entry * | |
1764 xlfd_lookup_field_contents (table, dim, font, field_index) | |
1765 struct table_entry *table; | |
1766 int dim; | |
1767 struct font_name *font; | |
1768 int field_index; | |
1769 { | |
1770 /* Function split_font_name converts fields to lower-case, so there | |
1771 is no need to use xstrlwr or xstricmp here. */ | |
1772 char *s = font->fields[field_index]; | |
1773 int low, mid, high, cmp; | |
1774 | |
1775 low = 0; | |
1776 high = dim - 1; | |
1777 | |
1778 while (low <= high) | |
1779 { | |
1780 mid = (low + high) / 2; | |
1781 cmp = strcmp (table[mid].name, s); | |
1782 | |
1783 if (cmp < 0) | |
1784 low = mid + 1; | |
1785 else if (cmp > 0) | |
1786 high = mid - 1; | |
1787 else | |
1788 return table + mid; | |
1789 } | |
1790 | |
1791 return NULL; | |
1792 } | |
1793 | |
1794 | |
1795 /* Return a numeric representation for font name field | |
1796 FONT.fields[FIELD_INDEX]. The field is looked up in TABLE which | |
1797 has DIM entries. Value is the numeric value found or DFLT if no | |
1798 table entry matches. This function is used to translate weight, | |
1799 slant, and swidth names of XLFD font names to numeric values. */ | |
1800 | |
1801 static INLINE int | |
1802 xlfd_numeric_value (table, dim, font, field_index, dflt) | |
1803 struct table_entry *table; | |
1804 int dim; | |
1805 struct font_name *font; | |
1806 int field_index; | |
1807 int dflt; | |
1808 { | |
1809 struct table_entry *p; | |
1810 p = xlfd_lookup_field_contents (table, dim, font, field_index); | |
1811 return p ? p->numeric : dflt; | |
1812 } | |
1813 | |
1814 | |
1815 /* Return a symbolic representation for font name field | |
1816 FONT.fields[FIELD_INDEX]. The field is looked up in TABLE which | |
1817 has DIM entries. Value is the symbolic value found or DFLT if no | |
1818 table entry matches. This function is used to translate weight, | |
1819 slant, and swidth names of XLFD font names to symbols. */ | |
1820 | |
1821 static INLINE Lisp_Object | |
1822 xlfd_symbolic_value (table, dim, font, field_index, dflt) | |
1823 struct table_entry *table; | |
1824 int dim; | |
1825 struct font_name *font; | |
1826 int field_index; | |
1827 int dflt; | |
1828 { | |
1829 struct table_entry *p; | |
1830 p = xlfd_lookup_field_contents (table, dim, font, field_index); | |
1831 return p ? *p->symbol : dflt; | |
1832 } | |
1833 | |
1834 | |
1835 /* Return a numeric value for the slant of the font given by FONT. */ | |
1836 | |
1837 static INLINE int | |
1838 xlfd_numeric_slant (font) | |
1839 struct font_name *font; | |
1840 { | |
1841 return xlfd_numeric_value (slant_table, DIM (slant_table), | |
1842 font, XLFD_SLANT, XLFD_SLANT_ROMAN); | |
1843 } | |
1844 | |
1845 | |
1846 /* Return a symbol representing the weight of the font given by FONT. */ | |
1847 | |
1848 static INLINE Lisp_Object | |
1849 xlfd_symbolic_slant (font) | |
1850 struct font_name *font; | |
1851 { | |
1852 return xlfd_symbolic_value (slant_table, DIM (slant_table), | |
1853 font, XLFD_SLANT, Qnormal); | |
1854 } | |
1855 | |
1856 | |
1857 /* Return a numeric value for the weight of the font given by FONT. */ | |
1858 | |
1859 static INLINE int | |
1860 xlfd_numeric_weight (font) | |
1861 struct font_name *font; | |
1862 { | |
1863 return xlfd_numeric_value (weight_table, DIM (weight_table), | |
1864 font, XLFD_WEIGHT, XLFD_WEIGHT_MEDIUM); | |
1865 } | |
1866 | |
1867 | |
1868 /* Return a symbol representing the slant of the font given by FONT. */ | |
1869 | |
1870 static INLINE Lisp_Object | |
1871 xlfd_symbolic_weight (font) | |
1872 struct font_name *font; | |
1873 { | |
1874 return xlfd_symbolic_value (weight_table, DIM (weight_table), | |
1875 font, XLFD_WEIGHT, Qnormal); | |
1876 } | |
1877 | |
1878 | |
1879 /* Return a numeric value for the swidth of the font whose XLFD font | |
1880 name fields are found in FONT. */ | |
1881 | |
1882 static INLINE int | |
1883 xlfd_numeric_swidth (font) | |
1884 struct font_name *font; | |
1885 { | |
1886 return xlfd_numeric_value (swidth_table, DIM (swidth_table), | |
1887 font, XLFD_SWIDTH, XLFD_SWIDTH_MEDIUM); | |
1888 } | |
1889 | |
1890 | |
1891 /* Return a symbolic value for the swidth of FONT. */ | |
1892 | |
1893 static INLINE Lisp_Object | |
1894 xlfd_symbolic_swidth (font) | |
1895 struct font_name *font; | |
1896 { | |
1897 return xlfd_symbolic_value (swidth_table, DIM (swidth_table), | |
1898 font, XLFD_SWIDTH, Qnormal); | |
1899 } | |
1900 | |
1901 | |
1902 /* Look up the entry of SYMBOL in the vector TABLE which has DIM | |
1903 entries. Value is a pointer to the matching table entry or null if | |
1904 no element of TABLE contains SYMBOL. */ | |
1905 | |
1906 static struct table_entry * | |
1907 face_value (table, dim, symbol) | |
1908 struct table_entry *table; | |
1909 int dim; | |
1910 Lisp_Object symbol; | |
1911 { | |
1912 int i; | |
1913 | |
1914 xassert (SYMBOLP (symbol)); | |
1915 | |
1916 for (i = 0; i < dim; ++i) | |
1917 if (EQ (*table[i].symbol, symbol)) | |
1918 break; | |
1919 | |
1920 return i < dim ? table + i : NULL; | |
1921 } | |
1922 | |
1923 | |
1924 /* Return a numeric value for SYMBOL in the vector TABLE which has DIM | |
1925 entries. Value is -1 if SYMBOL is not found in TABLE. */ | |
1926 | |
1927 static INLINE int | |
1928 face_numeric_value (table, dim, symbol) | |
1929 struct table_entry *table; | |
1930 int dim; | |
1931 Lisp_Object symbol; | |
1932 { | |
1933 struct table_entry *p = face_value (table, dim, symbol); | |
1934 return p ? p->numeric : -1; | |
1935 } | |
1936 | |
1937 | |
1938 /* Return a numeric value representing the weight specified by Lisp | |
1939 symbol WEIGHT. Value is one of the enumerators of enum | |
1940 xlfd_weight. */ | |
1941 | |
1942 static INLINE int | |
1943 face_numeric_weight (weight) | |
1944 Lisp_Object weight; | |
1945 { | |
1946 return face_numeric_value (weight_table, DIM (weight_table), weight); | |
1947 } | |
1948 | |
1949 | |
1950 /* Return a numeric value representing the slant specified by Lisp | |
1951 symbol SLANT. Value is one of the enumerators of enum xlfd_slant. */ | |
1952 | |
1953 static INLINE int | |
1954 face_numeric_slant (slant) | |
1955 Lisp_Object slant; | |
1956 { | |
1957 return face_numeric_value (slant_table, DIM (slant_table), slant); | |
1958 } | |
1959 | |
1960 | |
1961 /* Return a numeric value representing the swidth specified by Lisp | |
1962 symbol WIDTH. Value is one of the enumerators of enum xlfd_swidth. */ | |
1963 | |
1964 static int | |
1965 face_numeric_swidth (width) | |
1966 Lisp_Object width; | |
1967 { | |
1968 return face_numeric_value (swidth_table, DIM (swidth_table), width); | |
1969 } | |
1970 | |
1971 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
1972 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 1973 |
1974 /* Return non-zero if FONT is the name of a fixed-pitch font. */ | |
1975 | |
1976 static INLINE int | |
1977 xlfd_fixed_p (font) | |
1978 struct font_name *font; | |
1979 { | |
1980 /* Function split_font_name converts fields to lower-case, so there | |
1981 is no need to use tolower here. */ | |
1982 return *font->fields[XLFD_SPACING] != 'p'; | |
1983 } | |
1984 | |
1985 | |
1986 /* Return the point size of FONT on frame F, measured in 1/10 pt. | |
1987 | |
1988 The actual height of the font when displayed on F depends on the | |
1989 resolution of both the font and frame. For example, a 10pt font | |
1990 designed for a 100dpi display will display larger than 10pt on a | |
1991 75dpi display. (It's not unusual to use fonts not designed for the | |
1992 display one is using. For example, some intlfonts are available in | |
1993 72dpi versions, only.) | |
1994 | |
1995 Value is the real point size of FONT on frame F, or 0 if it cannot | |
1996 be determined. */ | |
1997 | |
1998 static INLINE int | |
1999 xlfd_point_size (f, font) | |
2000 struct frame *f; | |
2001 struct font_name *font; | |
2002 { | |
2003 double resy = FRAME_X_DISPLAY_INFO (f)->resy; | |
2004 double font_resy = atoi (font->fields[XLFD_RESY]); | |
2005 double font_pt = atoi (font->fields[XLFD_POINT_SIZE]); | |
2006 int real_pt; | |
2007 | |
2008 if (font_resy == 0 || font_pt == 0) | |
2009 real_pt = 0; | |
2010 else | |
2011 real_pt = (font_resy / resy) * font_pt + 0.5; | |
2012 | |
2013 return real_pt; | |
2014 } | |
2015 | |
2016 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2017 /* Return point size of PIXEL dots while considering Y-resultion (DPI) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2018 of frame F. This function is used to guess a point size of font |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2019 when only the pixel height of the font is available. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2020 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2021 static INLINE int |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2022 pixel_point_size (f, pixel) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2023 struct frame *f; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2024 int pixel; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2025 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2026 double resy = FRAME_X_DISPLAY_INFO (f)->resy; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2027 double real_pt; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2028 int int_pt; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2029 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2030 /* As one inch is 72 points, 72/RESY gives the point size of one dot. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2031 real_pt = pixel * 72 / resy; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2032 int_pt = real_pt + 0.5; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2033 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2034 return int_pt; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2035 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2036 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2037 |
24995 | 2038 /* Split XLFD font name FONT->name destructively into NUL-terminated, |
2039 lower-case fields in FONT->fields. NUMERIC_P non-zero means | |
2040 compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH, | |
2041 XLFD_RESY, XLFD_SLANT, and XLFD_WEIGHT in FONT->numeric. Value is | |
2042 zero if the font name doesn't have the format we expect. The | |
2043 expected format is a font name that starts with a `-' and has | |
2044 XLFD_LAST fields separated by `-'. (The XLFD specification allows | |
2045 forms of font names where certain field contents are enclosed in | |
2046 square brackets. We don't support that, for now. */ | |
2047 | |
2048 static int | |
2049 split_font_name (f, font, numeric_p) | |
2050 struct frame *f; | |
2051 struct font_name *font; | |
2052 int numeric_p; | |
2053 { | |
2054 int i = 0; | |
2055 int success_p; | |
2056 | |
2057 if (*font->name == '-') | |
2058 { | |
2059 char *p = xstrlwr (font->name) + 1; | |
2060 | |
2061 while (i < XLFD_LAST) | |
2062 { | |
2063 font->fields[i] = p; | |
2064 ++i; | |
2065 | |
2066 while (*p && *p != '-') | |
2067 ++p; | |
2068 | |
2069 if (*p != '-') | |
2070 break; | |
2071 | |
2072 *p++ = 0; | |
2073 } | |
2074 } | |
2075 | |
2076 success_p = i == XLFD_LAST; | |
2077 | |
2078 /* If requested, and font name was in the expected format, | |
2079 compute numeric values for some fields. */ | |
2080 if (numeric_p && success_p) | |
2081 { | |
2082 font->numeric[XLFD_POINT_SIZE] = xlfd_point_size (f, font); | |
2083 font->numeric[XLFD_RESY] = atoi (font->fields[XLFD_RESY]); | |
2084 font->numeric[XLFD_SLANT] = xlfd_numeric_slant (font); | |
2085 font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font); | |
2086 font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); | |
2087 } | |
2088 | |
2089 return success_p; | |
2090 } | |
2091 | |
2092 | |
2093 /* Build an XLFD font name from font name fields in FONT. Value is a | |
2094 pointer to the font name, which is allocated via xmalloc. */ | |
2095 | |
2096 static char * | |
2097 build_font_name (font) | |
2098 struct font_name *font; | |
2099 { | |
2100 int i; | |
2101 int size = 100; | |
2102 char *font_name = (char *) xmalloc (size); | |
2103 int total_length = 0; | |
2104 | |
2105 for (i = 0; i < XLFD_LAST; ++i) | |
2106 { | |
2107 /* Add 1 because of the leading `-'. */ | |
2108 int len = strlen (font->fields[i]) + 1; | |
2109 | |
2110 /* Reallocate font_name if necessary. Add 1 for the final | |
2111 NUL-byte. */ | |
2112 if (total_length + len + 1 >= size) | |
2113 { | |
2114 int new_size = max (2 * size, size + len + 1); | |
2115 int sz = new_size * sizeof *font_name; | |
2116 font_name = (char *) xrealloc (font_name, sz); | |
2117 size = new_size; | |
2118 } | |
2119 | |
2120 font_name[total_length] = '-'; | |
2121 bcopy (font->fields[i], font_name + total_length + 1, len - 1); | |
2122 total_length += len; | |
2123 } | |
2124 | |
2125 font_name[total_length] = 0; | |
2126 return font_name; | |
2127 } | |
2128 | |
2129 | |
2130 /* Free an array FONTS of N font_name structures. This frees FONTS | |
2131 itself and all `name' fields in its elements. */ | |
2132 | |
2133 static INLINE void | |
2134 free_font_names (fonts, n) | |
2135 struct font_name *fonts; | |
2136 int n; | |
2137 { | |
2138 while (n) | |
2139 xfree (fonts[--n].name); | |
2140 xfree (fonts); | |
2141 } | |
2142 | |
2143 | |
2144 /* Sort vector FONTS of font_name structures which contains NFONTS | |
2145 elements using qsort and comparison function CMPFN. F is the frame | |
2146 on which the fonts will be used. The global variable font_frame | |
2147 is temporarily set to F to make it available in CMPFN. */ | |
2148 | |
2149 static INLINE void | |
2150 sort_fonts (f, fonts, nfonts, cmpfn) | |
2151 struct frame *f; | |
2152 struct font_name *fonts; | |
2153 int nfonts; | |
2154 int (*cmpfn) P_ ((const void *, const void *)); | |
2155 { | |
2156 font_frame = f; | |
2157 qsort (fonts, nfonts, sizeof *fonts, cmpfn); | |
2158 font_frame = NULL; | |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
2159 } |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
2160 |
24995 | 2161 |
2162 /* Get fonts matching PATTERN on frame F. If F is null, use the first | |
2163 display in x_display_list. FONTS is a pointer to a vector of | |
2164 NFONTS font_name structures. TRY_ALTERNATIVES_P non-zero means try | |
2165 alternative patterns from Valternate_fontname_alist if no fonts are | |
2166 found matching PATTERN. SCALABLE_FONTS_P non-zero means include | |
2167 scalable fonts. | |
2168 | |
2169 For all fonts found, set FONTS[i].name to the name of the font, | |
2170 allocated via xmalloc, and split font names into fields. Ignore | |
2171 fonts that we can't parse. Value is the number of fonts found. | |
2172 | |
2173 This is similar to x_list_fonts. The differences are: | |
2174 | |
2175 1. It avoids consing. | |
2176 2. It never calls XLoadQueryFont. */ | |
2177 | |
2178 static int | |
2179 x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, | |
2180 scalable_fonts_p) | |
2181 struct frame *f; | |
2182 char *pattern; | |
2183 struct font_name *fonts; | |
2184 int nfonts, try_alternatives_p; | |
2185 int scalable_fonts_p; | |
2186 { | |
2187 int n, i, j; | |
2188 char **names; | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2189 #ifdef HAVE_X_WINDOWS |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2190 Display *dpy = f ? FRAME_X_DISPLAY (f) : x_display_list->display; |
24995 | 2191 |
2192 /* Get the list of fonts matching PATTERN from the X server. */ | |
2193 BLOCK_INPUT; | |
2194 names = XListFonts (dpy, pattern, nfonts, &n); | |
2195 UNBLOCK_INPUT; | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2196 #endif |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2197 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2198 /* 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
|
2199 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
|
2200 Lisp_Object lfonts; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2201 Lisp_Object lpattern, tem; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2202 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2203 n = 0; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2204 names = NULL; |
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 lpattern = build_string (pattern); |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2207 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2208 /* 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
|
2209 BLOCK_INPUT; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2210 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
|
2211 UNBLOCK_INPUT; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2212 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2213 /* Count fonts returned */ |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2214 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
|
2215 n++; |
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 /* Allocate array. */ |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2218 if (n) |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2219 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
|
2220 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2221 /* 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
|
2222 tem = lfonts; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2223 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
|
2224 { |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2225 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
|
2226 tem = XCDR (tem); |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2227 } |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2228 #endif |
24995 | 2229 |
2230 if (names) | |
2231 { | |
2232 /* Make a copy of the font names we got from X, and | |
2233 split them into fields. */ | |
2234 for (i = j = 0; i < n; ++i) | |
2235 { | |
2236 /* Make a copy of the font name. */ | |
2237 fonts[j].name = xstrdup (names[i]); | |
2238 | |
2239 /* Ignore fonts having a name that we can't parse. */ | |
2240 if (!split_font_name (f, fonts + j, 1)) | |
2241 xfree (fonts[j].name); | |
2242 else if (font_scalable_p (fonts + j)) | |
2243 { | |
2244 #if SCALABLE_FONTS | |
2245 if (!scalable_fonts_p | |
2246 || !may_use_scalable_font_p (fonts + j, names[i])) | |
2247 xfree (fonts[j].name); | |
2248 else | |
2249 ++j; | |
2250 #else /* !SCALABLE_FONTS */ | |
2251 /* Always ignore scalable fonts. */ | |
2252 xfree (fonts[j].name); | |
2253 #endif /* !SCALABLE_FONTS */ | |
2254 } | |
2255 else | |
2256 ++j; | |
2257 } | |
2258 | |
2259 n = j; | |
2260 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2261 #ifdef HAVE_X_WINDOWS |
24995 | 2262 /* Free font names. */ |
2263 BLOCK_INPUT; | |
2264 XFreeFontNames (names); | |
2265 UNBLOCK_INPUT; | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2266 #endif |
24995 | 2267 } |
2268 | |
2269 | |
2270 /* If no fonts found, try patterns from Valternate_fontname_alist. */ | |
2271 if (n == 0 && try_alternatives_p) | |
2272 { | |
2273 Lisp_Object list = Valternate_fontname_alist; | |
2274 | |
2275 while (CONSP (list)) | |
2276 { | |
2277 Lisp_Object entry = XCAR (list); | |
2278 if (CONSP (entry) | |
2279 && STRINGP (XCAR (entry)) | |
2280 && strcmp (XSTRING (XCAR (entry))->data, pattern) == 0) | |
2281 break; | |
2282 list = XCDR (list); | |
2283 } | |
2284 | |
2285 if (CONSP (list)) | |
2286 { | |
2287 Lisp_Object patterns = XCAR (list); | |
2288 Lisp_Object name; | |
2289 | |
2290 while (CONSP (patterns) | |
2291 /* If list is screwed up, give up. */ | |
2292 && (name = XCAR (patterns), | |
2293 STRINGP (name)) | |
2294 /* Ignore patterns equal to PATTERN because we tried that | |
2295 already with no success. */ | |
2296 && (strcmp (XSTRING (name)->data, pattern) == 0 | |
2297 || (n = x_face_list_fonts (f, XSTRING (name)->data, | |
2298 fonts, nfonts, 0, | |
2299 scalable_fonts_p), | |
2300 n == 0))) | |
2301 patterns = XCDR (patterns); | |
2302 } | |
2303 } | |
2304 | |
2305 return n; | |
2306 } | |
2307 | |
2308 | |
2309 /* Determine the first font matching PATTERN on frame F. Return in | |
2310 *FONT the matching font name, split into fields. Value is non-zero | |
2311 if a match was found. */ | |
2312 | |
2313 static int | |
2314 first_font_matching (f, pattern, font) | |
2315 struct frame *f; | |
2316 char *pattern; | |
2317 struct font_name *font; | |
2318 { | |
2319 int nfonts = 100; | |
2320 struct font_name *fonts; | |
2321 | |
2322 fonts = (struct font_name *) xmalloc (nfonts * sizeof *fonts); | |
2323 nfonts = x_face_list_fonts (f, pattern, fonts, nfonts, 1, 0); | |
2324 | |
2325 if (nfonts > 0) | |
2326 { | |
2327 bcopy (&fonts[0], font, sizeof *font); | |
2328 | |
2329 fonts[0].name = NULL; | |
2330 free_font_names (fonts, nfonts); | |
2331 } | |
2332 | |
2333 return nfonts > 0; | |
2334 } | |
2335 | |
2336 | |
2337 /* Determine fonts matching PATTERN on frame F. Sort resulting fonts | |
2338 using comparison function CMPFN. Value is the number of fonts | |
2339 found. If value is non-zero, *FONTS is set to a vector of | |
2340 font_name structures allocated from the heap containing matching | |
2341 fonts. Each element of *FONTS contains a name member that is also | |
2342 allocated from the heap. Font names in these structures are split | |
2343 into fields. Use free_font_names to free such an array. */ | |
2344 | |
2345 static int | |
2346 sorted_font_list (f, pattern, cmpfn, fonts) | |
2347 struct frame *f; | |
2348 char *pattern; | |
2349 int (*cmpfn) P_ ((const void *, const void *)); | |
2350 struct font_name **fonts; | |
2351 { | |
2352 int nfonts; | |
2353 | |
2354 /* Get the list of fonts matching pattern. 100 should suffice. */ | |
25270 | 2355 nfonts = DEFAULT_FONT_LIST_LIMIT; |
2356 if (INTEGERP (Vfont_list_limit) && XINT (Vfont_list_limit) > 0) | |
2357 nfonts = XFASTINT (Vfont_list_limit); | |
2358 | |
24995 | 2359 *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts); |
2360 #if SCALABLE_FONTS | |
2361 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 1); | |
2362 #else | |
2363 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 0); | |
2364 #endif | |
2365 | |
2366 /* Sort the resulting array and return it in *FONTS. If no | |
2367 fonts were found, make sure to set *FONTS to null. */ | |
2368 if (nfonts) | |
2369 sort_fonts (f, *fonts, nfonts, cmpfn); | |
2370 else | |
2371 { | |
2372 xfree (*fonts); | |
2373 *fonts = NULL; | |
2374 } | |
2375 | |
2376 return nfonts; | |
2377 } | |
2378 | |
2379 | |
2380 /* Compare two font_name structures *A and *B. Value is analogous to | |
2381 strcmp. Sort order is given by the global variable | |
2382 font_sort_order. Font names are sorted so that, everything else | |
2383 being equal, fonts with a resolution closer to that of the frame on | |
2384 which they are used are listed first. The global variable | |
2385 font_frame is the frame on which we operate. */ | |
2386 | |
2387 static int | |
2388 cmp_font_names (a, b) | |
2389 const void *a, *b; | |
2390 { | |
2391 struct font_name *x = (struct font_name *) a; | |
2392 struct font_name *y = (struct font_name *) b; | |
2393 int cmp; | |
2394 | |
2395 /* All strings have been converted to lower-case by split_font_name, | |
2396 so we can use strcmp here. */ | |
2397 cmp = strcmp (x->fields[XLFD_FAMILY], y->fields[XLFD_FAMILY]); | |
2398 if (cmp == 0) | |
2399 { | |
2400 int i; | |
2401 | |
2402 for (i = 0; i < DIM (font_sort_order) && cmp == 0; ++i) | |
2403 { | |
2404 int j = font_sort_order[i]; | |
2405 cmp = x->numeric[j] - y->numeric[j]; | |
2406 } | |
2407 | |
2408 if (cmp == 0) | |
2409 { | |
2410 /* Everything else being equal, we prefer fonts with an | |
2411 y-resolution closer to that of the frame. */ | |
2412 int resy = FRAME_X_DISPLAY_INFO (font_frame)->resy; | |
2413 int x_resy = x->numeric[XLFD_RESY]; | |
2414 int y_resy = y->numeric[XLFD_RESY]; | |
2415 cmp = abs (resy - x_resy) - abs (resy - y_resy); | |
2416 } | |
2417 } | |
2418 | |
2419 return cmp; | |
2420 } | |
2421 | |
2422 | |
2423 /* Get a sorted list of fonts of family FAMILY on frame F. If PATTERN | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2424 is non-nil list fonts matching that pattern. Otherwise, if |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2425 REGISTRY is non-nil return only fonts with that registry, otherwise |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2426 return fonts of any registry. Set *FONTS to a vector of font_name |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2427 structures allocated from the heap containing the fonts found. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2428 Value is the number of fonts found. */ |
24995 | 2429 |
2430 static int | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2431 font_list (f, pattern, family, registry, fonts) |
24995 | 2432 struct frame *f; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2433 Lisp_Object pattern, family, registry; |
24995 | 2434 struct font_name **fonts; |
2435 { | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2436 char *pattern_str, *family_str, *registry_str; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2437 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2438 if (NILP (pattern)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2439 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2440 family_str = (NILP (family) ? "*" : (char *) XSTRING (family)->data); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2441 registry_str = (NILP (registry) ? "*" : (char *) XSTRING (registry)->data); |
24995 | 2442 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2443 pattern_str = (char *) alloca (strlen (family_str) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2444 + strlen (registry_str) |
24995 | 2445 + 10); |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2446 if (index (family_str, '-')) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2447 sprintf (pattern_str, "-%s-*-%s", family_str, registry_str); |
24995 | 2448 else |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2449 sprintf (pattern_str, "-*-%s-*-%s", family_str, registry_str); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2450 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2451 else |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2452 pattern_str = (char *) XSTRING (pattern)->data; |
24995 | 2453 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2454 return sorted_font_list (f, pattern_str, cmp_font_names, fonts); |
24995 | 2455 } |
2456 | |
2457 | |
2458 /* 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
|
2459 x-family-fonts and x-font-family-list to remove duplicate font |
24995 | 2460 entries. */ |
2461 | |
2462 static void | |
2463 remove_duplicates (list) | |
2464 Lisp_Object list; | |
2465 { | |
2466 Lisp_Object tail = list; | |
2467 | |
2468 while (!NILP (tail) && !NILP (XCDR (tail))) | |
2469 { | |
2470 Lisp_Object next = XCDR (tail); | |
2471 if (!NILP (Fequal (XCAR (next), XCAR (tail)))) | |
2472 XCDR (tail) = XCDR (next); | |
2473 else | |
2474 tail = XCDR (tail); | |
2475 } | |
2476 } | |
2477 | |
2478 | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
2479 DEFUN ("x-family-fonts", Fx_family_fonts, Sx_family_fonts, 0, 2, 0, |
24995 | 2480 "Return a list of available fonts of family FAMILY on FRAME.\n\ |
2481 If FAMILY is omitted or nil, list all families.\n\ | |
2482 Otherwise, FAMILY must be a string, possibly containing wildcards\n\ | |
2483 `?' and `*'.\n\ | |
2484 If FRAME is omitted or nil, use the selected frame.\n\ | |
2485 Each element of the result is a vector [FAMILY WIDTH POINT-SIZE WEIGHT\n\ | |
25270 | 2486 SLANT FIXED-P FULL REGISTRY-AND-ENCODING].\n\ |
24995 | 2487 FAMILY is the font family name. POINT-SIZE is the size of the\n\ |
2488 font in 1/10 pt. WIDTH, WEIGHT, and SLANT are symbols describing the\n\ | |
2489 width, weight and slant of the font. These symbols are the same as for\n\ | |
2490 face attributes. FIXED-P is non-nil if the font is fixed-pitch.\n\ | |
25270 | 2491 FULL is the full name of the font, and REGISTRY-AND-ENCODING is a string\n\ |
2492 giving the registry and encoding of the font.\n\ | |
24995 | 2493 The result list is sorted according to the current setting of\n\ |
2494 the face font sort order.") | |
2495 (family, frame) | |
2496 Lisp_Object family, frame; | |
2497 { | |
2498 struct frame *f = check_x_frame (frame); | |
2499 struct font_name *fonts; | |
2500 int i, nfonts; | |
2501 Lisp_Object result; | |
2502 struct gcpro gcpro1; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2503 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2504 if (!NILP (family)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2505 CHECK_STRING (family, 1); |
24995 | 2506 |
2507 result = Qnil; | |
2508 GCPRO1 (result); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2509 nfonts = font_list (f, Qnil, family, Qnil, &fonts); |
24995 | 2510 for (i = nfonts - 1; i >= 0; --i) |
2511 { | |
25270 | 2512 Lisp_Object v = Fmake_vector (make_number (8), Qnil); |
2513 char *tem; | |
24995 | 2514 |
2515 #define ASET(VECTOR, IDX, VAL) (XVECTOR (VECTOR)->contents[IDX] = (VAL)) | |
2516 | |
2517 ASET (v, 0, build_string (fonts[i].fields[XLFD_FAMILY])); | |
2518 ASET (v, 1, xlfd_symbolic_swidth (fonts + i)); | |
2519 ASET (v, 2, make_number (xlfd_point_size (f, fonts + i))); | |
2520 ASET (v, 3, xlfd_symbolic_weight (fonts + i)); | |
2521 ASET (v, 4, xlfd_symbolic_slant (fonts + i)); | |
2522 ASET (v, 5, xlfd_fixed_p (fonts + i) ? Qt : Qnil); | |
25270 | 2523 tem = build_font_name (fonts + i); |
2524 ASET (v, 6, build_string (tem)); | |
2525 sprintf (tem, "%s-%s", fonts[i].fields[XLFD_REGISTRY], | |
2526 fonts[i].fields[XLFD_ENCODING]); | |
2527 ASET (v, 7, build_string (tem)); | |
2528 xfree (tem); | |
2529 | |
24995 | 2530 result = Fcons (v, result); |
2531 | |
2532 #undef ASET | |
2533 } | |
2534 | |
2535 remove_duplicates (result); | |
2536 free_font_names (fonts, nfonts); | |
2537 UNGCPRO; | |
2538 return result; | |
2539 } | |
2540 | |
2541 | |
2542 DEFUN ("x-font-family-list", Fx_font_family_list, Sx_font_family_list, | |
2543 0, 1, 0, | |
2544 "Return a list of available font families on FRAME.\n\ | |
2545 If FRAME is omitted or nil, use the selected frame.\n\ | |
2546 Value is a list of conses (FAMILY . FIXED-P) where FAMILY\n\ | |
2547 is a font family, and FIXED-P is non-nil if fonts of that family\n\ | |
2548 are fixed-pitch.") | |
2549 (frame) | |
2550 Lisp_Object frame; | |
2551 { | |
2552 struct frame *f = check_x_frame (frame); | |
2553 int nfonts, i; | |
2554 struct font_name *fonts; | |
2555 Lisp_Object result; | |
2556 struct gcpro gcpro1; | |
25270 | 2557 int count = specpdl_ptr - specpdl; |
2558 int limit; | |
2559 | |
2560 /* Let's consider all fonts. Increase the limit for matching | |
2561 fonts until we have them all. */ | |
2562 for (limit = 500;;) | |
2563 { | |
2564 specbind (intern ("font-list-limit"), make_number (limit)); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2565 nfonts = font_list (f, Qnil, Qnil, Qnil, &fonts); |
25270 | 2566 |
2567 if (nfonts == limit) | |
2568 { | |
2569 free_font_names (fonts, nfonts); | |
2570 limit *= 2; | |
2571 } | |
2572 else | |
2573 break; | |
2574 } | |
24995 | 2575 |
2576 result = Qnil; | |
2577 GCPRO1 (result); | |
2578 for (i = nfonts - 1; i >= 0; --i) | |
2579 result = Fcons (Fcons (build_string (fonts[i].fields[XLFD_FAMILY]), | |
2580 xlfd_fixed_p (fonts + i) ? Qt : Qnil), | |
2581 result); | |
2582 | |
2583 remove_duplicates (result); | |
2584 free_font_names (fonts, nfonts); | |
2585 UNGCPRO; | |
25270 | 2586 return unbind_to (count, result); |
24995 | 2587 } |
2588 | |
2589 | |
2590 DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 5, 0, | |
2591 "Return a list of the names of available fonts matching PATTERN.\n\ | |
2592 If optional arguments FACE and FRAME are specified, return only fonts\n\ | |
2593 the same size as FACE on FRAME.\n\ | |
2594 PATTERN is a string, perhaps with wildcard characters;\n\ | |
2595 the * character matches any substring, and\n\ | |
2596 the ? character matches any single character.\n\ | |
2597 PATTERN is case-insensitive.\n\ | |
2598 FACE is a face name--a symbol.\n\ | |
2599 \n\ | |
2600 The return value is a list of strings, suitable as arguments to\n\ | |
2601 set-face-font.\n\ | |
2602 \n\ | |
2603 Fonts Emacs can't use may or may not be excluded\n\ | |
2604 even if they match PATTERN and FACE.\n\ | |
2605 The optional fourth argument MAXIMUM sets a limit on how many\n\ | |
2606 fonts to match. The first MAXIMUM fonts are reported.\n\ | |
2607 The optional fifth argument WIDTH, if specified, is a number of columns\n\ | |
2608 occupied by a character of a font. In that case, return only fonts\n\ | |
2609 the WIDTH times as wide as FACE on FRAME.") | |
2610 (pattern, face, frame, maximum, width) | |
2611 Lisp_Object pattern, face, frame, maximum, width; | |
2612 { | |
2613 struct frame *f; | |
2614 int size; | |
2615 int maxnames; | |
2616 | |
2617 check_x (); | |
2618 CHECK_STRING (pattern, 0); | |
2619 | |
2620 if (NILP (maximum)) | |
2621 maxnames = 2000; | |
2622 else | |
2623 { | |
2624 CHECK_NATNUM (maximum, 0); | |
2625 maxnames = XINT (maximum); | |
2626 } | |
2627 | |
2628 if (!NILP (width)) | |
2629 CHECK_NUMBER (width, 4); | |
2630 | |
2631 /* We can't simply call check_x_frame because this function may be | |
2632 called before any frame is created. */ | |
2633 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
|
2634 if (!FRAME_WINDOW_P (f)) |
24995 | 2635 { |
2636 /* Perhaps we have not yet created any frame. */ | |
2637 f = NULL; | |
2638 face = Qnil; | |
2639 } | |
2640 | |
2641 /* Determine the width standard for comparison with the fonts we find. */ | |
2642 | |
2643 if (NILP (face)) | |
2644 size = 0; | |
2645 else | |
2646 { | |
2647 /* This is of limited utility since it works with character | |
2648 widths. Keep it for compatibility. --gerd. */ | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2649 int face_id = lookup_named_face (f, face, 0); |
24995 | 2650 struct face *face = FACE_FROM_ID (f, face_id); |
2651 | |
2652 if (face->font) | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2653 size = FONT_WIDTH (face->font); |
24995 | 2654 else |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2655 size = FONT_WIDTH (FRAME_FONT (f)); |
24995 | 2656 |
2657 if (!NILP (width)) | |
2658 size *= XINT (width); | |
2659 } | |
2660 | |
2661 { | |
2662 Lisp_Object args[2]; | |
2663 | |
2664 args[0] = x_list_fonts (f, pattern, size, maxnames); | |
2665 if (f == NULL) | |
2666 /* We don't have to check fontsets. */ | |
2667 return args[0]; | |
2668 args[1] = list_fontsets (f, pattern, size); | |
2669 return Fnconc (2, args); | |
2670 } | |
2671 } | |
2672 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2673 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 2674 |
2675 | |
2676 | |
2677 /*********************************************************************** | |
2678 Lisp Faces | |
2679 ***********************************************************************/ | |
2680 | |
2681 /* Access face attributes of face FACE, a Lisp vector. */ | |
2682 | |
2683 #define LFACE_FAMILY(LFACE) \ | |
2684 XVECTOR (LFACE)->contents[LFACE_FAMILY_INDEX] | |
2685 #define LFACE_HEIGHT(LFACE) \ | |
2686 XVECTOR (LFACE)->contents[LFACE_HEIGHT_INDEX] | |
2687 #define LFACE_WEIGHT(LFACE) \ | |
2688 XVECTOR (LFACE)->contents[LFACE_WEIGHT_INDEX] | |
2689 #define LFACE_SLANT(LFACE) \ | |
2690 XVECTOR (LFACE)->contents[LFACE_SLANT_INDEX] | |
2691 #define LFACE_UNDERLINE(LFACE) \ | |
2692 XVECTOR (LFACE)->contents[LFACE_UNDERLINE_INDEX] | |
2693 #define LFACE_INVERSE(LFACE) \ | |
2694 XVECTOR (LFACE)->contents[LFACE_INVERSE_INDEX] | |
2695 #define LFACE_FOREGROUND(LFACE) \ | |
2696 XVECTOR (LFACE)->contents[LFACE_FOREGROUND_INDEX] | |
2697 #define LFACE_BACKGROUND(LFACE) \ | |
2698 XVECTOR (LFACE)->contents[LFACE_BACKGROUND_INDEX] | |
2699 #define LFACE_STIPPLE(LFACE) \ | |
2700 XVECTOR (LFACE)->contents[LFACE_STIPPLE_INDEX] | |
2701 #define LFACE_SWIDTH(LFACE) \ | |
2702 XVECTOR (LFACE)->contents[LFACE_SWIDTH_INDEX] | |
2703 #define LFACE_OVERLINE(LFACE) \ | |
2704 XVECTOR (LFACE)->contents[LFACE_OVERLINE_INDEX] | |
2705 #define LFACE_STRIKE_THROUGH(LFACE) \ | |
2706 XVECTOR (LFACE)->contents[LFACE_STRIKE_THROUGH_INDEX] | |
2707 #define LFACE_BOX(LFACE) \ | |
2708 XVECTOR (LFACE)->contents[LFACE_BOX_INDEX] | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2709 #define LFACE_FONT(LFACE) \ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2710 XVECTOR (LFACE)->contents[LFACE_FONT_INDEX] |
24995 | 2711 |
2712 /* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size | |
2713 LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */ | |
2714 | |
2715 #define LFACEP(LFACE) \ | |
2716 (VECTORP (LFACE) \ | |
2717 && XVECTOR (LFACE)->size == LFACE_VECTOR_SIZE \ | |
2718 && EQ (XVECTOR (LFACE)->contents[0], Qface)) | |
2719 | |
2720 | |
2721 #if GLYPH_DEBUG | |
2722 | |
2723 /* Check consistency of Lisp face attribute vector ATTRS. */ | |
2724 | |
2725 static void | |
2726 check_lface_attrs (attrs) | |
2727 Lisp_Object *attrs; | |
2728 { | |
2729 xassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX]) | |
2730 || STRINGP (attrs[LFACE_FAMILY_INDEX])); | |
2731 xassert (UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX]) | |
2732 || SYMBOLP (attrs[LFACE_SWIDTH_INDEX])); | |
2733 xassert (UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX]) | |
2734 || INTEGERP (attrs[LFACE_HEIGHT_INDEX])); | |
2735 xassert (UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX]) | |
2736 || SYMBOLP (attrs[LFACE_WEIGHT_INDEX])); | |
2737 xassert (UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX]) | |
2738 || SYMBOLP (attrs[LFACE_SLANT_INDEX])); | |
2739 xassert (UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX]) | |
2740 || SYMBOLP (attrs[LFACE_UNDERLINE_INDEX]) | |
2741 || STRINGP (attrs[LFACE_UNDERLINE_INDEX])); | |
2742 xassert (UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX]) | |
2743 || SYMBOLP (attrs[LFACE_OVERLINE_INDEX]) | |
2744 || STRINGP (attrs[LFACE_OVERLINE_INDEX])); | |
2745 xassert (UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX]) | |
2746 || SYMBOLP (attrs[LFACE_STRIKE_THROUGH_INDEX]) | |
2747 || STRINGP (attrs[LFACE_STRIKE_THROUGH_INDEX])); | |
2748 xassert (UNSPECIFIEDP (attrs[LFACE_BOX_INDEX]) | |
2749 || SYMBOLP (attrs[LFACE_BOX_INDEX]) | |
2750 || STRINGP (attrs[LFACE_BOX_INDEX]) | |
2751 || INTEGERP (attrs[LFACE_BOX_INDEX]) | |
2752 || CONSP (attrs[LFACE_BOX_INDEX])); | |
2753 xassert (UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX]) | |
2754 || SYMBOLP (attrs[LFACE_INVERSE_INDEX])); | |
2755 xassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX]) | |
2756 || STRINGP (attrs[LFACE_FOREGROUND_INDEX])); | |
2757 xassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX]) | |
2758 || STRINGP (attrs[LFACE_BACKGROUND_INDEX])); | |
2759 #ifdef HAVE_WINDOW_SYSTEM | |
2760 xassert (UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX]) | |
2761 || SYMBOLP (attrs[LFACE_STIPPLE_INDEX]) | |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
2762 || !NILP (Fbitmap_spec_p (attrs[LFACE_STIPPLE_INDEX]))); |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2763 xassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX]) |
28237
2f636fd2f714
(check_lface_attrs) [GLYPH_DEBUG]: Fix syntax error.
Gerd Moellmann <gerd@gnu.org>
parents:
28230
diff
changeset
|
2764 || NILP (attrs[LFACE_FONT_INDEX]) |
2f636fd2f714
(check_lface_attrs) [GLYPH_DEBUG]: Fix syntax error.
Gerd Moellmann <gerd@gnu.org>
parents:
28230
diff
changeset
|
2765 || STRINGP (attrs[LFACE_FONT_INDEX])); |
24995 | 2766 #endif |
2767 } | |
2768 | |
2769 | |
2770 /* Check consistency of attributes of Lisp face LFACE (a Lisp vector). */ | |
2771 | |
2772 static void | |
2773 check_lface (lface) | |
2774 Lisp_Object lface; | |
2775 { | |
2776 if (!NILP (lface)) | |
2777 { | |
2778 xassert (LFACEP (lface)); | |
2779 check_lface_attrs (XVECTOR (lface)->contents); | |
2780 } | |
2781 } | |
2782 | |
2783 #else /* GLYPH_DEBUG == 0 */ | |
2784 | |
2785 #define check_lface_attrs(attrs) (void) 0 | |
2786 #define check_lface(lface) (void) 0 | |
2787 | |
2788 #endif /* GLYPH_DEBUG == 0 */ | |
2789 | |
2790 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2791 /* Resolve face name FACE_NAME. If FACE_NAME is a string, intern it |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2792 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
|
2793 return that face's name. */ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2794 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2795 static Lisp_Object |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2796 resolve_face_name (face_name) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2797 Lisp_Object face_name; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2798 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2799 Lisp_Object aliased; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2800 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2801 if (STRINGP (face_name)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2802 face_name = intern (XSTRING (face_name)->data); |
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 for (;;) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2805 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2806 aliased = Fget (face_name, Qface_alias); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2807 if (NILP (aliased)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2808 break; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2809 else |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2810 face_name = aliased; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2811 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2812 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2813 return face_name; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2814 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2815 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2816 |
24995 | 2817 /* Return the face definition of FACE_NAME on frame F. F null means |
2818 return the global definition. FACE_NAME may be a string or a | |
2819 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
|
2820 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
|
2821 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
|
2822 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
|
2823 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
|
2824 name. */ |
24995 | 2825 |
2826 static INLINE Lisp_Object | |
2827 lface_from_face_name (f, face_name, signal_p) | |
2828 struct frame *f; | |
2829 Lisp_Object face_name; | |
2830 int signal_p; | |
2831 { | |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2832 Lisp_Object lface; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2833 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
2834 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
|
2835 |
24995 | 2836 if (f) |
2837 lface = assq_no_quit (face_name, f->face_alist); | |
2838 else | |
2839 lface = assq_no_quit (face_name, Vface_new_frame_defaults); | |
2840 | |
2841 if (CONSP (lface)) | |
2842 lface = XCDR (lface); | |
2843 else if (signal_p) | |
2844 signal_error ("Invalid face", face_name); | |
2845 | |
2846 check_lface (lface); | |
2847 return lface; | |
2848 } | |
2849 | |
2850 | |
2851 /* Get face attributes of face FACE_NAME from frame-local faces on | |
2852 frame F. Store the resulting attributes in ATTRS which must point | |
2853 to a vector of Lisp_Objects of size LFACE_VECTOR_SIZE. If SIGNAL_P | |
2854 is non-zero, signal an error if FACE_NAME does not name a face. | |
2855 Otherwise, value is zero if FACE_NAME is not a face. */ | |
2856 | |
2857 static INLINE int | |
2858 get_lface_attributes (f, face_name, attrs, signal_p) | |
2859 struct frame *f; | |
2860 Lisp_Object face_name; | |
2861 Lisp_Object *attrs; | |
2862 int signal_p; | |
2863 { | |
2864 Lisp_Object lface; | |
2865 int success_p; | |
2866 | |
2867 lface = lface_from_face_name (f, face_name, signal_p); | |
2868 if (!NILP (lface)) | |
2869 { | |
2870 bcopy (XVECTOR (lface)->contents, attrs, | |
2871 LFACE_VECTOR_SIZE * sizeof *attrs); | |
2872 success_p = 1; | |
2873 } | |
2874 else | |
2875 success_p = 0; | |
2876 | |
2877 return success_p; | |
2878 } | |
2879 | |
2880 | |
2881 /* Non-zero if all attributes in face attribute vector ATTRS are | |
2882 specified, i.e. are non-nil. */ | |
2883 | |
2884 static int | |
2885 lface_fully_specified_p (attrs) | |
2886 Lisp_Object *attrs; | |
2887 { | |
2888 int i; | |
2889 | |
2890 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
28237
2f636fd2f714
(check_lface_attrs) [GLYPH_DEBUG]: Fix syntax error.
Gerd Moellmann <gerd@gnu.org>
parents:
28230
diff
changeset
|
2891 if (UNSPECIFIEDP (attrs[i]) && i != LFACE_FONT_INDEX) |
24995 | 2892 break; |
2893 | |
2894 return i == LFACE_VECTOR_SIZE; | |
2895 } | |
2896 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2897 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 2898 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2899 /* Set font-related attributes of Lisp face LFACE from the fullname of |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2900 the font opened by FONTNAME. If FORCE_P is zero, set only |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2901 unspecified attributes of LFACE. The exception is `font' |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2902 attribute. It is set to FONTNAME as is regardless of FORCE_P. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2903 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2904 If FONTNAME is not available on frame F, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2905 return 0 if MAY_FAIL_P is non-zero, otherwise abort. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2906 If the fullname is not in a valid XLFD format, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2907 return 0 if MAY_FAIL_P is non-zero, otherwise set normal values |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2908 in LFACE and return 1. |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2909 Otherwise, return 1. */ |
24995 | 2910 |
2911 static int | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2912 set_lface_from_font_name (f, lface, fontname, 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
|
2913 struct frame *f; |
24995 | 2914 Lisp_Object lface; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2915 Lisp_Object fontname; |
26594
f24bdf26ad39
(set_lface_from_font_name): New parameter may_fail_p.
Gerd Moellmann <gerd@gnu.org>
parents:
26574
diff
changeset
|
2916 int force_p, may_fail_p; |
24995 | 2917 { |
2918 struct font_name font; | |
2919 char *buffer; | |
2920 int pt; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2921 int have_xlfd_p; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2922 int fontset; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2923 char *font_name = XSTRING (fontname)->data; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2924 struct font_info *font_info; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2925 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2926 /* If FONTNAME is actually a fontset name, get ASCII font name of it. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2927 fontset = fs_query_fontset (fontname, 0); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2928 if (fontset >= 0) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2929 font_name = XSTRING (fontset_ascii (fontset))->data; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2930 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2931 /* Check if FONT_NAME is surely available on the system. Usually |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2932 FONT_NAME is already cached for the frame F and FS_LOAD_FONT |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2933 returns quickly. But, even if FONT_NAME is not yet cached, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2934 caching it now is not futail because we anyway load the font |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2935 later. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2936 BLOCK_INPUT; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2937 font_info = FS_LOAD_FONT (f, 0, font_name, -1); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2938 UNBLOCK_INPUT; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2939 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2940 if (!font_info) |
26594
f24bdf26ad39
(set_lface_from_font_name): New parameter may_fail_p.
Gerd Moellmann <gerd@gnu.org>
parents:
26574
diff
changeset
|
2941 { |
f24bdf26ad39
(set_lface_from_font_name): New parameter may_fail_p.
Gerd Moellmann <gerd@gnu.org>
parents:
26574
diff
changeset
|
2942 if (may_fail_p) |
f24bdf26ad39
(set_lface_from_font_name): New parameter may_fail_p.
Gerd Moellmann <gerd@gnu.org>
parents:
26574
diff
changeset
|
2943 return 0; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2944 abort (); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2945 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2946 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2947 font.name = STRDUPA (font_info->full_name); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2948 have_xlfd_p = split_font_name (f, &font, 1); |
24995 | 2949 |
2950 /* Set attributes only if unspecified, otherwise face defaults for | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2951 new frames would never take effect. If we couldn't get a font |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2952 name conforming to XLFD, set normal values. */ |
24995 | 2953 |
2954 if (force_p || UNSPECIFIEDP (LFACE_FAMILY (lface))) | |
2955 { | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2956 Lisp_Object val; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2957 if (have_xlfd_p) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2958 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2959 buffer = (char *) alloca (strlen (font.fields[XLFD_FAMILY]) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2960 + strlen (font.fields[XLFD_FOUNDRY]) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2961 + 2); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2962 sprintf (buffer, "%s-%s", font.fields[XLFD_FOUNDRY], |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2963 font.fields[XLFD_FAMILY]); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2964 val = build_string (buffer); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2965 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2966 else |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2967 val = build_string ("*"); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2968 LFACE_FAMILY (lface) = val; |
24995 | 2969 } |
2970 | |
2971 if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface))) | |
2972 { | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2973 if (have_xlfd_p) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2974 pt = xlfd_point_size (f, &font); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2975 else |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2976 pt = pixel_point_size (f, font_info->height * 10); |
24995 | 2977 xassert (pt > 0); |
2978 LFACE_HEIGHT (lface) = make_number (pt); | |
2979 } | |
2980 | |
2981 if (force_p || UNSPECIFIEDP (LFACE_SWIDTH (lface))) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2982 LFACE_SWIDTH (lface) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2983 = have_xlfd_p ? xlfd_symbolic_swidth (&font) : Qnormal; |
24995 | 2984 |
2985 if (force_p || UNSPECIFIEDP (LFACE_WEIGHT (lface))) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2986 LFACE_WEIGHT (lface) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2987 = have_xlfd_p ? xlfd_symbolic_weight (&font) : Qnormal; |
24995 | 2988 |
2989 if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface))) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2990 LFACE_SLANT (lface) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2991 = have_xlfd_p ? xlfd_symbolic_slant (&font) : Qnormal; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2992 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
2993 LFACE_FONT (lface) = fontname; |
24995 | 2994 |
2995 return 1; | |
2996 } | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
2997 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 2998 |
2999 | |
3000 /* Merge two Lisp face attribute vectors FROM and TO and store the | |
3001 resulting attributes in TO. Every non-nil attribute of FROM | |
3002 overrides the corresponding attribute of TO. */ | |
3003 | |
3004 static INLINE void | |
3005 merge_face_vectors (from, to) | |
3006 Lisp_Object *from, *to; | |
3007 { | |
3008 int i; | |
3009 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
3010 if (!UNSPECIFIEDP (from[i])) | |
3011 to[i] = from[i]; | |
3012 } | |
3013 | |
3014 | |
3015 /* Given a Lisp face attribute vector TO and a Lisp object PROP that | |
3016 is a face property, determine the resulting face attributes on | |
3017 frame F, and store them in TO. PROP may be a single face | |
3018 specification or a list of such specifications. Each face | |
3019 specification can be | |
3020 | |
3021 1. A symbol or string naming a Lisp face. | |
3022 | |
3023 2. A property list of the form (KEYWORD VALUE ...) where each | |
3024 KEYWORD is a face attribute name, and value is an appropriate value | |
3025 for that attribute. | |
3026 | |
3027 3. Conses or the form (FOREGROUND-COLOR . COLOR) or | |
3028 (BACKGROUND-COLOR . COLOR) where COLOR is a color name. This is | |
3029 for compatibility with 20.2. | |
3030 | |
3031 Face specifications earlier in lists take precedence over later | |
3032 specifications. */ | |
3033 | |
3034 static void | |
3035 merge_face_vector_with_property (f, to, prop) | |
3036 struct frame *f; | |
3037 Lisp_Object *to; | |
3038 Lisp_Object prop; | |
3039 { | |
3040 if (CONSP (prop)) | |
3041 { | |
3042 Lisp_Object first = XCAR (prop); | |
3043 | |
3044 if (EQ (first, Qforeground_color) | |
3045 || EQ (first, Qbackground_color)) | |
3046 { | |
3047 /* One of (FOREGROUND-COLOR . COLOR) or (BACKGROUND-COLOR | |
3048 . COLOR). COLOR must be a string. */ | |
3049 Lisp_Object color_name = XCDR (prop); | |
3050 Lisp_Object color = first; | |
3051 | |
3052 if (STRINGP (color_name)) | |
3053 { | |
3054 if (EQ (color, Qforeground_color)) | |
3055 to[LFACE_FOREGROUND_INDEX] = color_name; | |
3056 else | |
3057 to[LFACE_BACKGROUND_INDEX] = color_name; | |
3058 } | |
3059 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3060 add_to_log ("Invalid face color", color_name, Qnil); |
24995 | 3061 } |
3062 else if (SYMBOLP (first) | |
3063 && *XSYMBOL (first)->name->data == ':') | |
3064 { | |
3065 /* Assume this is the property list form. */ | |
3066 while (CONSP (prop) && CONSP (XCDR (prop))) | |
3067 { | |
3068 Lisp_Object keyword = XCAR (prop); | |
3069 Lisp_Object value = XCAR (XCDR (prop)); | |
3070 | |
3071 if (EQ (keyword, QCfamily)) | |
3072 { | |
3073 if (STRINGP (value)) | |
3074 to[LFACE_FAMILY_INDEX] = value; | |
3075 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3076 add_to_log ("Illegal face font family", value, Qnil); |
24995 | 3077 } |
3078 else if (EQ (keyword, QCheight)) | |
3079 { | |
3080 if (INTEGERP (value)) | |
3081 to[LFACE_HEIGHT_INDEX] = value; | |
3082 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3083 add_to_log ("Illegal face font height", value, Qnil); |
24995 | 3084 } |
3085 else if (EQ (keyword, QCweight)) | |
3086 { | |
3087 if (SYMBOLP (value) | |
3088 && face_numeric_weight (value) >= 0) | |
3089 to[LFACE_WEIGHT_INDEX] = value; | |
3090 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3091 add_to_log ("Illegal face weight", value, Qnil); |
24995 | 3092 } |
3093 else if (EQ (keyword, QCslant)) | |
3094 { | |
3095 if (SYMBOLP (value) | |
3096 && face_numeric_slant (value) >= 0) | |
3097 to[LFACE_SLANT_INDEX] = value; | |
3098 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3099 add_to_log ("Illegal face slant", value, Qnil); |
24995 | 3100 } |
3101 else if (EQ (keyword, QCunderline)) | |
3102 { | |
3103 if (EQ (value, Qt) | |
3104 || NILP (value) | |
3105 || STRINGP (value)) | |
3106 to[LFACE_UNDERLINE_INDEX] = value; | |
3107 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3108 add_to_log ("Illegal face underline", value, Qnil); |
24995 | 3109 } |
3110 else if (EQ (keyword, QCoverline)) | |
3111 { | |
3112 if (EQ (value, Qt) | |
3113 || NILP (value) | |
3114 || STRINGP (value)) | |
3115 to[LFACE_OVERLINE_INDEX] = value; | |
3116 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3117 add_to_log ("Illegal face overline", value, Qnil); |
24995 | 3118 } |
3119 else if (EQ (keyword, QCstrike_through)) | |
3120 { | |
3121 if (EQ (value, Qt) | |
3122 || NILP (value) | |
3123 || STRINGP (value)) | |
3124 to[LFACE_STRIKE_THROUGH_INDEX] = value; | |
3125 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3126 add_to_log ("Illegal face strike-through", value, Qnil); |
24995 | 3127 } |
3128 else if (EQ (keyword, QCbox)) | |
3129 { | |
3130 if (EQ (value, Qt)) | |
3131 value = make_number (1); | |
3132 if (INTEGERP (value) | |
3133 || STRINGP (value) | |
3134 || CONSP (value) | |
3135 || NILP (value)) | |
3136 to[LFACE_BOX_INDEX] = value; | |
3137 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3138 add_to_log ("Illegal face box", value, Qnil); |
24995 | 3139 } |
3140 else if (EQ (keyword, QCinverse_video) | |
3141 || EQ (keyword, QCreverse_video)) | |
3142 { | |
3143 if (EQ (value, Qt) || NILP (value)) | |
3144 to[LFACE_INVERSE_INDEX] = value; | |
3145 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3146 add_to_log ("Illegal face inverse-video", value, Qnil); |
24995 | 3147 } |
3148 else if (EQ (keyword, QCforeground)) | |
3149 { | |
3150 if (STRINGP (value)) | |
3151 to[LFACE_FOREGROUND_INDEX] = value; | |
3152 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3153 add_to_log ("Illegal face foreground", value, Qnil); |
24995 | 3154 } |
3155 else if (EQ (keyword, QCbackground)) | |
3156 { | |
3157 if (STRINGP (value)) | |
3158 to[LFACE_BACKGROUND_INDEX] = value; | |
3159 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3160 add_to_log ("Illegal face background", value, Qnil); |
24995 | 3161 } |
3162 else if (EQ (keyword, QCstipple)) | |
3163 { | |
3164 #ifdef HAVE_X_WINDOWS | |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
3165 Lisp_Object pixmap_p = Fbitmap_spec_p (value); |
24995 | 3166 if (!NILP (pixmap_p)) |
3167 to[LFACE_STIPPLE_INDEX] = value; | |
3168 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3169 add_to_log ("Illegal face stipple", value, Qnil); |
24995 | 3170 #endif |
3171 } | |
3172 else if (EQ (keyword, QCwidth)) | |
3173 { | |
3174 if (SYMBOLP (value) | |
3175 && face_numeric_swidth (value) >= 0) | |
3176 to[LFACE_SWIDTH_INDEX] = value; | |
3177 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3178 add_to_log ("Illegal face width", value, Qnil); |
24995 | 3179 } |
3180 else | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3181 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
|
3182 keyword, Qnil); |
24995 | 3183 |
3184 prop = XCDR (XCDR (prop)); | |
3185 } | |
3186 } | |
3187 else | |
3188 { | |
3189 /* This is a list of face specs. Specifications at the | |
3190 beginning of the list take precedence over later | |
3191 specifications, so we have to merge starting with the | |
3192 last specification. */ | |
3193 Lisp_Object next = XCDR (prop); | |
3194 if (!NILP (next)) | |
3195 merge_face_vector_with_property (f, to, next); | |
3196 merge_face_vector_with_property (f, to, first); | |
3197 } | |
3198 } | |
3199 else | |
3200 { | |
3201 /* PROP ought to be a face name. */ | |
3202 Lisp_Object lface = lface_from_face_name (f, prop, 0); | |
3203 if (NILP (lface)) | |
25799
1c370ec939da
(load_pixmap): Call add_to_log without frame parameter.
Gerd Moellmann <gerd@gnu.org>
parents:
25678
diff
changeset
|
3204 add_to_log ("Invalid face text property value: %s", prop, Qnil); |
24995 | 3205 else |
3206 merge_face_vectors (XVECTOR (lface)->contents, to); | |
3207 } | |
3208 } | |
3209 | |
3210 | |
3211 DEFUN ("internal-make-lisp-face", Finternal_make_lisp_face, | |
3212 Sinternal_make_lisp_face, 1, 2, 0, | |
3213 "Make FACE, a symbol, a Lisp face with all attributes nil.\n\ | |
3214 If FACE was not known as a face before, create a new one.\n\ | |
3215 If optional argument FRAME is specified, make a frame-local face\n\ | |
3216 for that frame. Otherwise operate on the global face definition.\n\ | |
3217 Value is a vector of face attributes.") | |
3218 (face, frame) | |
3219 Lisp_Object face, frame; | |
3220 { | |
3221 Lisp_Object global_lface, lface; | |
3222 struct frame *f; | |
3223 int i; | |
3224 | |
3225 CHECK_SYMBOL (face, 0); | |
3226 global_lface = lface_from_face_name (NULL, face, 0); | |
3227 | |
3228 if (!NILP (frame)) | |
3229 { | |
3230 CHECK_LIVE_FRAME (frame, 1); | |
3231 f = XFRAME (frame); | |
3232 lface = lface_from_face_name (f, face, 0); | |
3233 } | |
3234 else | |
3235 f = NULL, lface = Qnil; | |
3236 | |
3237 /* Add a global definition if there is none. */ | |
3238 if (NILP (global_lface)) | |
3239 { | |
3240 global_lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), | |
3241 Qunspecified); | |
3242 XVECTOR (global_lface)->contents[0] = Qface; | |
3243 Vface_new_frame_defaults = Fcons (Fcons (face, global_lface), | |
3244 Vface_new_frame_defaults); | |
3245 | |
3246 /* Assign the new Lisp face a unique ID. The mapping from Lisp | |
3247 face id to Lisp face is given by the vector lface_id_to_name. | |
3248 The mapping from Lisp face to Lisp face id is given by the | |
3249 property `face' of the Lisp face name. */ | |
3250 if (next_lface_id == lface_id_to_name_size) | |
3251 { | |
3252 int new_size = max (50, 2 * lface_id_to_name_size); | |
3253 int sz = new_size * sizeof *lface_id_to_name; | |
3254 lface_id_to_name = (Lisp_Object *) xrealloc (lface_id_to_name, sz); | |
3255 lface_id_to_name_size = new_size; | |
3256 } | |
3257 | |
3258 lface_id_to_name[next_lface_id] = face; | |
3259 Fput (face, Qface, make_number (next_lface_id)); | |
3260 ++next_lface_id; | |
3261 } | |
3262 else if (f == NULL) | |
3263 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
3264 XVECTOR (global_lface)->contents[i] = Qunspecified; | |
3265 | |
3266 /* Add a frame-local definition. */ | |
3267 if (f) | |
3268 { | |
3269 if (NILP (lface)) | |
3270 { | |
3271 lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), | |
3272 Qunspecified); | |
3273 XVECTOR (lface)->contents[0] = Qface; | |
3274 f->face_alist = Fcons (Fcons (face, lface), f->face_alist); | |
3275 } | |
3276 else | |
3277 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
3278 XVECTOR (lface)->contents[i] = Qunspecified; | |
3279 } | |
3280 else | |
3281 lface = global_lface; | |
3282 | |
3283 xassert (LFACEP (lface)); | |
3284 check_lface (lface); | |
3285 return lface; | |
3286 } | |
3287 | |
3288 | |
3289 DEFUN ("internal-lisp-face-p", Finternal_lisp_face_p, | |
3290 Sinternal_lisp_face_p, 1, 2, 0, | |
3291 "Return non-nil if FACE names a face.\n\ | |
3292 If optional second parameter FRAME is non-nil, check for the\n\ | |
3293 existence of a frame-local face with name FACE on that frame.\n\ | |
3294 Otherwise check for the existence of a global face.") | |
3295 (face, frame) | |
3296 Lisp_Object face, frame; | |
3297 { | |
3298 Lisp_Object lface; | |
3299 | |
3300 if (!NILP (frame)) | |
3301 { | |
3302 CHECK_LIVE_FRAME (frame, 1); | |
3303 lface = lface_from_face_name (XFRAME (frame), face, 0); | |
3304 } | |
3305 else | |
3306 lface = lface_from_face_name (NULL, face, 0); | |
3307 | |
3308 return lface; | |
3309 } | |
3310 | |
3311 | |
3312 DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face, | |
3313 Sinternal_copy_lisp_face, 4, 4, 0, | |
3314 "Copy face FROM to TO.\n\ | |
3315 If FRAME it t, copy the global face definition of FROM to the\n\ | |
3316 global face definition of TO. Otherwise, copy the frame-local\n\ | |
3317 definition of FROM on FRAME to the frame-local definition of TO\n\ | |
3318 on NEW-FRAME, or FRAME if NEW-FRAME is nil.\n\ | |
3319 \n\ | |
3320 Value is TO.") | |
3321 (from, to, frame, new_frame) | |
3322 Lisp_Object from, to, frame, new_frame; | |
3323 { | |
3324 Lisp_Object lface, copy; | |
3325 | |
3326 CHECK_SYMBOL (from, 0); | |
3327 CHECK_SYMBOL (to, 1); | |
3328 if (NILP (new_frame)) | |
3329 new_frame = frame; | |
3330 | |
3331 if (EQ (frame, Qt)) | |
3332 { | |
3333 /* Copy global definition of FROM. We don't make copies of | |
3334 strings etc. because 20.2 didn't do it either. */ | |
3335 lface = lface_from_face_name (NULL, from, 1); | |
3336 copy = Finternal_make_lisp_face (to, Qnil); | |
3337 } | |
3338 else | |
3339 { | |
3340 /* Copy frame-local definition of FROM. */ | |
3341 CHECK_LIVE_FRAME (frame, 2); | |
3342 CHECK_LIVE_FRAME (new_frame, 3); | |
3343 lface = lface_from_face_name (XFRAME (frame), from, 1); | |
3344 copy = Finternal_make_lisp_face (to, new_frame); | |
3345 } | |
3346 | |
3347 bcopy (XVECTOR (lface)->contents, XVECTOR (copy)->contents, | |
3348 LFACE_VECTOR_SIZE * sizeof (Lisp_Object)); | |
3349 | |
3350 return to; | |
3351 } | |
3352 | |
3353 | |
3354 DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute, | |
3355 Sinternal_set_lisp_face_attribute, 3, 4, 0, | |
3356 "Set attribute ATTR of FACE to VALUE.\n\ | |
3357 If optional argument FRAME is given, set the face attribute of face FACE\n\ | |
3358 on that frame. If FRAME is t, set the attribute of the default for face\n\ | |
3359 FACE (for new frames). If FRAME is omitted or nil, use the selected\n\ | |
3360 frame.") | |
3361 (face, attr, value, frame) | |
3362 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
|
3363 { |
24995 | 3364 Lisp_Object lface; |
3365 Lisp_Object old_value = Qnil; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3366 /* Set 1 if ATTR is QCfont. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3367 int font_attr_p = 0; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3368 /* Set 1 if ATTR is one of font-related attributes other than QCfont. */ |
24995 | 3369 int font_related_attr_p = 0; |
3370 | |
3371 CHECK_SYMBOL (face, 0); | |
3372 CHECK_SYMBOL (attr, 1); | |
3373 | |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3374 face = resolve_face_name (face); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3375 |
24995 | 3376 /* Set lface to the Lisp attribute vector of FACE. */ |
3377 if (EQ (frame, Qt)) | |
3378 lface = lface_from_face_name (NULL, face, 1); | |
3379 else | |
3380 { | |
3381 if (NILP (frame)) | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
3382 frame = selected_frame; |
24995 | 3383 |
3384 CHECK_LIVE_FRAME (frame, 3); | |
3385 lface = lface_from_face_name (XFRAME (frame), face, 0); | |
3386 | |
3387 /* If a frame-local face doesn't exist yet, create one. */ | |
3388 if (NILP (lface)) | |
3389 lface = Finternal_make_lisp_face (face, frame); | |
3390 } | |
3391 | |
3392 if (EQ (attr, QCfamily)) | |
3393 { | |
3394 if (!UNSPECIFIEDP (value)) | |
3395 { | |
3396 CHECK_STRING (value, 3); | |
3397 if (XSTRING (value)->size == 0) | |
3398 signal_error ("Invalid face family", value); | |
3399 } | |
3400 old_value = LFACE_FAMILY (lface); | |
3401 LFACE_FAMILY (lface) = value; | |
3402 font_related_attr_p = 1; | |
3403 } | |
3404 else if (EQ (attr, QCheight)) | |
3405 { | |
3406 if (!UNSPECIFIEDP (value)) | |
3407 { | |
3408 CHECK_NUMBER (value, 3); | |
3409 if (XINT (value) <= 0) | |
3410 signal_error ("Invalid face height", value); | |
3411 } | |
3412 old_value = LFACE_HEIGHT (lface); | |
3413 LFACE_HEIGHT (lface) = value; | |
3414 font_related_attr_p = 1; | |
3415 } | |
3416 else if (EQ (attr, QCweight)) | |
3417 { | |
3418 if (!UNSPECIFIEDP (value)) | |
3419 { | |
3420 CHECK_SYMBOL (value, 3); | |
3421 if (face_numeric_weight (value) < 0) | |
3422 signal_error ("Invalid face weight", value); | |
3423 } | |
3424 old_value = LFACE_WEIGHT (lface); | |
3425 LFACE_WEIGHT (lface) = value; | |
3426 font_related_attr_p = 1; | |
3427 } | |
3428 else if (EQ (attr, QCslant)) | |
3429 { | |
3430 if (!UNSPECIFIEDP (value)) | |
3431 { | |
3432 CHECK_SYMBOL (value, 3); | |
3433 if (face_numeric_slant (value) < 0) | |
3434 signal_error ("Invalid face slant", value); | |
3435 } | |
3436 old_value = LFACE_SLANT (lface); | |
3437 LFACE_SLANT (lface) = value; | |
3438 font_related_attr_p = 1; | |
3439 } | |
3440 else if (EQ (attr, QCunderline)) | |
3441 { | |
3442 if (!UNSPECIFIEDP (value)) | |
3443 if ((SYMBOLP (value) | |
3444 && !EQ (value, Qt) | |
3445 && !EQ (value, Qnil)) | |
3446 /* Underline color. */ | |
3447 || (STRINGP (value) | |
3448 && XSTRING (value)->size == 0)) | |
3449 signal_error ("Invalid face underline", value); | |
3450 | |
3451 old_value = LFACE_UNDERLINE (lface); | |
3452 LFACE_UNDERLINE (lface) = value; | |
3453 } | |
3454 else if (EQ (attr, QCoverline)) | |
3455 { | |
3456 if (!UNSPECIFIEDP (value)) | |
3457 if ((SYMBOLP (value) | |
3458 && !EQ (value, Qt) | |
3459 && !EQ (value, Qnil)) | |
3460 /* Overline color. */ | |
3461 || (STRINGP (value) | |
3462 && XSTRING (value)->size == 0)) | |
3463 signal_error ("Invalid face overline", value); | |
3464 | |
3465 old_value = LFACE_OVERLINE (lface); | |
3466 LFACE_OVERLINE (lface) = value; | |
3467 } | |
3468 else if (EQ (attr, QCstrike_through)) | |
3469 { | |
3470 if (!UNSPECIFIEDP (value)) | |
3471 if ((SYMBOLP (value) | |
3472 && !EQ (value, Qt) | |
3473 && !EQ (value, Qnil)) | |
3474 /* Strike-through color. */ | |
3475 || (STRINGP (value) | |
3476 && XSTRING (value)->size == 0)) | |
3477 signal_error ("Invalid face strike-through", value); | |
3478 | |
3479 old_value = LFACE_STRIKE_THROUGH (lface); | |
3480 LFACE_STRIKE_THROUGH (lface) = value; | |
3481 } | |
3482 else if (EQ (attr, QCbox)) | |
3483 { | |
3484 int valid_p; | |
3485 | |
3486 /* Allow t meaning a simple box of width 1 in foreground color | |
3487 of the face. */ | |
3488 if (EQ (value, Qt)) | |
3489 value = make_number (1); | |
3490 | |
3491 if (UNSPECIFIEDP (value)) | |
3492 valid_p = 1; | |
3493 else if (NILP (value)) | |
3494 valid_p = 1; | |
3495 else if (INTEGERP (value)) | |
3496 valid_p = XINT (value) > 0; | |
3497 else if (STRINGP (value)) | |
3498 valid_p = XSTRING (value)->size > 0; | |
3499 else if (CONSP (value)) | |
3500 { | |
3501 Lisp_Object tem; | |
3502 | |
3503 tem = value; | |
3504 while (CONSP (tem)) | |
3505 { | |
3506 Lisp_Object k, v; | |
3507 | |
3508 k = XCAR (tem); | |
3509 tem = XCDR (tem); | |
3510 if (!CONSP (tem)) | |
3511 break; | |
3512 v = XCAR (tem); | |
3513 tem = XCDR (tem); | |
3514 | |
3515 if (EQ (k, QCline_width)) | |
3516 { | |
3517 if (!INTEGERP (v) || XINT (v) <= 0) | |
3518 break; | |
3519 } | |
3520 else if (EQ (k, QCcolor)) | |
3521 { | |
3522 if (!STRINGP (v) || XSTRING (v)->size == 0) | |
3523 break; | |
3524 } | |
3525 else if (EQ (k, QCstyle)) | |
3526 { | |
3527 if (!EQ (v, Qpressed_button) && !EQ (v, Qreleased_button)) | |
3528 break; | |
3529 } | |
3530 else | |
3531 break; | |
3532 } | |
3533 | |
3534 valid_p = NILP (tem); | |
3535 } | |
3536 else | |
3537 valid_p = 0; | |
3538 | |
3539 if (!valid_p) | |
3540 signal_error ("Invalid face box", value); | |
3541 | |
3542 old_value = LFACE_BOX (lface); | |
3543 LFACE_BOX (lface) = value; | |
3544 } | |
3545 else if (EQ (attr, QCinverse_video) | |
3546 || EQ (attr, QCreverse_video)) | |
3547 { | |
3548 if (!UNSPECIFIEDP (value)) | |
3549 { | |
3550 CHECK_SYMBOL (value, 3); | |
3551 if (!EQ (value, Qt) && !NILP (value)) | |
3552 signal_error ("Invalid inverse-video face attribute value", value); | |
3553 } | |
3554 old_value = LFACE_INVERSE (lface); | |
3555 LFACE_INVERSE (lface) = value; | |
3556 } | |
3557 else if (EQ (attr, QCforeground)) | |
3558 { | |
27114
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
3559 if (!UNSPECIFIEDP (value)) |
24995 | 3560 { |
3561 /* Don't check for valid color names here because it depends | |
3562 on the frame (display) whether the color will be valid | |
3563 when the face is realized. */ | |
3564 CHECK_STRING (value, 3); | |
3565 if (XSTRING (value)->size == 0) | |
3566 signal_error ("Empty foreground color value", value); | |
3567 } | |
3568 old_value = LFACE_FOREGROUND (lface); | |
3569 LFACE_FOREGROUND (lface) = value; | |
3570 } | |
3571 else if (EQ (attr, QCbackground)) | |
3572 { | |
27114
4efa5e54e9a9
(Qunspecified_fg, Qunspecified_bg): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
27100
diff
changeset
|
3573 if (!UNSPECIFIEDP (value)) |
24995 | 3574 { |
3575 /* Don't check for valid color names here because it depends | |
3576 on the frame (display) whether the color will be valid | |
3577 when the face is realized. */ | |
3578 CHECK_STRING (value, 3); | |
3579 if (XSTRING (value)->size == 0) | |
3580 signal_error ("Empty background color value", value); | |
3581 } | |
3582 old_value = LFACE_BACKGROUND (lface); | |
3583 LFACE_BACKGROUND (lface) = value; | |
3584 } | |
3585 else if (EQ (attr, QCstipple)) | |
3586 { | |
3587 #ifdef HAVE_X_WINDOWS | |
3588 if (!UNSPECIFIEDP (value) | |
3589 && !NILP (value) | |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
3590 && NILP (Fbitmap_spec_p (value))) |
24995 | 3591 signal_error ("Invalid stipple attribute", value); |
3592 old_value = LFACE_STIPPLE (lface); | |
3593 LFACE_STIPPLE (lface) = value; | |
3594 #endif /* HAVE_X_WINDOWS */ | |
3595 } | |
3596 else if (EQ (attr, QCwidth)) | |
3597 { | |
3598 if (!UNSPECIFIEDP (value)) | |
3599 { | |
3600 CHECK_SYMBOL (value, 3); | |
3601 if (face_numeric_swidth (value) < 0) | |
3602 signal_error ("Invalid face width", value); | |
3603 } | |
3604 old_value = LFACE_SWIDTH (lface); | |
3605 LFACE_SWIDTH (lface) = value; | |
3606 font_related_attr_p = 1; | |
3607 } | |
3608 else if (EQ (attr, QCfont)) | |
3609 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3610 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 3611 /* Set font-related attributes of the Lisp face from an |
3612 XLFD font name. */ | |
3613 struct frame *f; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3614 Lisp_Object tmp; |
24995 | 3615 |
3616 CHECK_STRING (value, 3); | |
3617 if (EQ (frame, Qt)) | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
3618 f = SELECTED_FRAME (); |
24995 | 3619 else |
3620 f = check_x_frame (frame); | |
3621 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3622 /* VALUE may be a fontset name or an alias of fontset. In such |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3623 a case, use the base fontset name. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3624 tmp = Fquery_fontset (value, Qnil); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3625 if (!NILP (tmp)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3626 value = tmp; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3627 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3628 if (!set_lface_from_font_name (f, lface, value, 1, 1)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3629 signal_error ("Invalid font or fontset name", value); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3630 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3631 font_attr_p = 1; |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3632 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 3633 } |
3634 else if (EQ (attr, QCbold)) | |
3635 { | |
3636 old_value = LFACE_WEIGHT (lface); | |
3637 LFACE_WEIGHT (lface) = NILP (value) ? Qnormal : Qbold; | |
3638 font_related_attr_p = 1; | |
3639 } | |
3640 else if (EQ (attr, QCitalic)) | |
3641 { | |
3642 old_value = LFACE_SLANT (lface); | |
3643 LFACE_SLANT (lface) = NILP (value) ? Qnormal : Qitalic; | |
3644 font_related_attr_p = 1; | |
3645 } | |
3646 else | |
3647 signal_error ("Invalid face attribute name", attr); | |
3648 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3649 if (font_related_attr_p |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3650 && !UNSPECIFIEDP (value)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3651 /* If a font-related attribute other than QCfont is specified, the |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3652 original `font' attribute nor that of default face is useless |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3653 to determine a new font. Thus, we set it to nil so that font |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3654 selection mechanism doesn't use it. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3655 LFACE_FONT (lface) = Qnil; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3656 |
24995 | 3657 /* Changing a named face means that all realized faces depending on |
3658 that face are invalid. Since we cannot tell which realized faces | |
3659 depend on the face, make sure they are all removed. This is done | |
3660 by incrementing face_change_count. The next call to | |
3661 init_iterator will then free realized faces. */ | |
3662 if (!EQ (frame, Qt) | |
3663 && (EQ (attr, QCfont) | |
3664 || NILP (Fequal (old_value, value)))) | |
3665 { | |
3666 ++face_change_count; | |
3667 ++windows_or_buffers_changed; | |
3668 } | |
3669 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3670 #ifdef HAVE_WINDOW_SYSTEM |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3671 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3672 if (!EQ (frame, Qt) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3673 && !UNSPECIFIEDP (value) |
24995 | 3674 && NILP (Fequal (old_value, value))) |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3675 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3676 Lisp_Object param; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3677 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3678 param = Qnil; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3679 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3680 if (EQ (face, Qdefault)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3681 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3682 /* 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
|
3683 reflected in changed `font' frame parameters. */ |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3684 if ((font_related_attr_p || font_attr_p) |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3685 && lface_fully_specified_p (XVECTOR (lface)->contents)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3686 set_font_frame_param (frame, lface); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3687 else if (EQ (attr, QCforeground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3688 param = Qforeground_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3689 else if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3690 param = Qbackground_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3691 } |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3692 #ifndef WINDOWSNT |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3693 else if (EQ (face, Qscroll_bar)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3694 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3695 /* 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
|
3696 `scroll-bar-foreground' and `scroll-bar-background'. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3697 if (EQ (attr, QCforeground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3698 param = Qscroll_bar_foreground; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3699 else if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3700 param = Qscroll_bar_background; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3701 } |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3702 #endif |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3703 else if (EQ (face, Qborder)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3704 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3705 /* Changing background color of `border' sets frame parameter |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3706 `border-color'. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3707 if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3708 param = Qborder_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3709 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3710 else if (EQ (face, Qcursor)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3711 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3712 /* Changing background color of `cursor' sets frame parameter |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3713 `cursor-color'. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3714 if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3715 param = Qcursor_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3716 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3717 else if (EQ (face, Qmouse)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3718 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3719 /* Changing background color of `mouse' sets frame parameter |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3720 `mouse-color'. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3721 if (EQ (attr, QCbackground)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3722 param = Qmouse_color; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3723 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3724 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3725 if (!NILP (param)) |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3726 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
|
3727 } |
24995 | 3728 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3729 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 3730 |
3731 return face; | |
3732 } | |
3733 | |
3734 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3735 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 3736 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3737 /* Set the `font' frame parameter of FRAME determined from `default' |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3738 face attributes LFACE. If a face or fontset name is explicitely |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3739 specfied in LFACE, use it as is. Otherwise, determine a font name |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3740 from the other font-related atrributes of LFACE. In that case, if |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3741 there's no matching font, signals an error. */ |
24995 | 3742 |
3743 static void | |
3744 set_font_frame_param (frame, lface) | |
3745 Lisp_Object frame, lface; | |
3746 { | |
3747 struct frame *f = XFRAME (frame); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3748 Lisp_Object font_name; |
24995 | 3749 char *font; |
3750 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3751 if (STRINGP (LFACE_FONT (lface))) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3752 font_name = LFACE_FONT (lface); |
24995 | 3753 else |
3754 { | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3755 /* Choose a font name that reflects LFACE's attributes and has |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3756 the registry and encoding pattern specified in the default |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3757 fontset (3rd arg: -1) for ASCII characters (4th arg: 0). */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3758 font = choose_face_font (f, XVECTOR (lface)->contents, -1, 0); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3759 if (!font) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3760 error ("No font matches the specified attribute"); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3761 font_name = build_string (font); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3762 xfree (font); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3763 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
3764 store_frame_param (f, Qfont, font_name); |
24995 | 3765 } |
3766 | |
3767 | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3768 /* 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
|
3769 has been assigned the value NEW_VALUE. */ |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3770 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3771 void |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3772 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
|
3773 struct frame *f; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3774 Lisp_Object param, new_value; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3775 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3776 Lisp_Object lface; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3777 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3778 /* 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
|
3779 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
|
3780 face-set-after-frame-defaults. */ |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3781 if (NILP (f->face_alist)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3782 return; |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3783 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3784 if (EQ (param, Qforeground_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3785 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3786 lface = lface_from_face_name (f, Qdefault, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3787 LFACE_FOREGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3788 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3789 realize_basic_faces (f); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3790 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3791 else if (EQ (param, Qbackground_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3792 { |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3793 Lisp_Object frame; |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3794 |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3795 /* 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
|
3796 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
|
3797 frame-update-face-colors to do that. */ |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3798 XSETFRAME (frame, f); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3799 call1 (Qframe_update_face_colors, frame); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
3800 |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3801 lface = lface_from_face_name (f, Qdefault, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3802 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3803 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3804 realize_basic_faces (f); |
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, Qborder_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, Qborder, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3809 LFACE_BACKGROUND (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 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3812 else if (EQ (param, Qcursor_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3813 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3814 lface = lface_from_face_name (f, Qcursor, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3815 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3816 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3817 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3818 else if (EQ (param, Qmouse_color)) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3819 { |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3820 lface = lface_from_face_name (f, Qmouse, 1); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3821 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3822 ? new_value : Qunspecified); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3823 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3824 } |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3825 |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
3826 |
24995 | 3827 /* Get the value of X resource RESOURCE, class CLASS for the display |
3828 of frame FRAME. This is here because ordinary `x-get-resource' | |
3829 doesn't take a frame argument. */ | |
3830 | |
3831 DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource, | |
3832 Sinternal_face_x_get_resource, 3, 3, 0, "") | |
3833 (resource, class, frame) | |
3834 Lisp_Object resource, class, frame; | |
3835 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3836 Lisp_Object value = Qnil; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3837 #ifndef WINDOWSNT |
24995 | 3838 CHECK_STRING (resource, 0); |
3839 CHECK_STRING (class, 1); | |
3840 CHECK_LIVE_FRAME (frame, 2); | |
3841 BLOCK_INPUT; | |
3842 value = display_x_get_resource (FRAME_X_DISPLAY_INFO (XFRAME (frame)), | |
3843 resource, class, Qnil, Qnil); | |
3844 UNBLOCK_INPUT; | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3845 #endif |
24995 | 3846 return value; |
3847 } | |
3848 | |
3849 | |
3850 /* Return resource string VALUE as a boolean value, i.e. nil, or t. | |
3851 If VALUE is "on" or "true", return t. If VALUE is "off" or | |
3852 "false", return nil. Otherwise, if SIGNAL_P is non-zero, signal an | |
3853 error; if SIGNAL_P is zero, return 0. */ | |
3854 | |
3855 static Lisp_Object | |
3856 face_boolean_x_resource_value (value, signal_p) | |
3857 Lisp_Object value; | |
3858 int signal_p; | |
3859 { | |
3860 Lisp_Object result = make_number (0); | |
3861 | |
3862 xassert (STRINGP (value)); | |
3863 | |
3864 if (xstricmp (XSTRING (value)->data, "on") == 0 | |
3865 || xstricmp (XSTRING (value)->data, "true") == 0) | |
3866 result = Qt; | |
3867 else if (xstricmp (XSTRING (value)->data, "off") == 0 | |
3868 || xstricmp (XSTRING (value)->data, "false") == 0) | |
3869 result = Qnil; | |
3870 else if (xstricmp (XSTRING (value)->data, "unspecified") == 0) | |
3871 result = Qunspecified; | |
3872 else if (signal_p) | |
3873 signal_error ("Invalid face attribute value from X resource", value); | |
3874 | |
3875 return result; | |
3876 } | |
3877 | |
3878 | |
3879 DEFUN ("internal-set-lisp-face-attribute-from-resource", | |
3880 Finternal_set_lisp_face_attribute_from_resource, | |
3881 Sinternal_set_lisp_face_attribute_from_resource, | |
3882 3, 4, 0, "") | |
3883 (face, attr, value, frame) | |
3884 Lisp_Object face, attr, value, frame; | |
3885 { | |
3886 CHECK_SYMBOL (face, 0); | |
3887 CHECK_SYMBOL (attr, 1); | |
3888 CHECK_STRING (value, 2); | |
3889 | |
3890 if (xstricmp (XSTRING (value)->data, "unspecified") == 0) | |
3891 value = Qunspecified; | |
3892 else if (EQ (attr, QCheight)) | |
3893 { | |
3894 value = Fstring_to_number (value, make_number (10)); | |
3895 if (XINT (value) <= 0) | |
3896 signal_error ("Invalid face height from X resource", value); | |
3897 } | |
3898 else if (EQ (attr, QCbold) || EQ (attr, QCitalic)) | |
3899 value = face_boolean_x_resource_value (value, 1); | |
3900 else if (EQ (attr, QCweight) || EQ (attr, QCslant) || EQ (attr, QCwidth)) | |
3901 value = intern (XSTRING (value)->data); | |
3902 else if (EQ (attr, QCreverse_video) || EQ (attr, QCinverse_video)) | |
3903 value = face_boolean_x_resource_value (value, 1); | |
3904 else if (EQ (attr, QCunderline) | |
3905 || EQ (attr, QCoverline) | |
3906 || EQ (attr, QCstrike_through) | |
3907 || EQ (attr, QCbox)) | |
3908 { | |
3909 Lisp_Object boolean_value; | |
3910 | |
3911 /* If the result of face_boolean_x_resource_value is t or nil, | |
3912 VALUE does NOT specify a color. */ | |
3913 boolean_value = face_boolean_x_resource_value (value, 0); | |
3914 if (SYMBOLP (boolean_value)) | |
3915 value = boolean_value; | |
3916 } | |
3917 | |
3918 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
|
3919 } |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
3920 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3921 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 3922 |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3923 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
3924 #ifdef HAVE_X_WINDOWS |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3925 /*********************************************************************** |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3926 Menu face |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3927 ***********************************************************************/ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3928 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3929 #ifdef USE_X_TOOLKIT |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3930 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3931 /* 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
|
3932 XtApplyToWidgets. */ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3933 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3934 struct x_resources |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3935 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3936 Arg *av; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3937 int ac; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3938 }; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3939 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3940 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3941 #ifdef USE_MOTIF |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3942 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3943 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
|
3944 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
|
3945 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3946 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3947 /* 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
|
3948 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
|
3949 submenu. */ |
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 static void |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3952 xm_apply_resources (w, p) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3953 Widget w; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3954 XtPointer p; |
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 Widget submenu = 0; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3957 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
|
3958 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3959 XtSetValues (w, res->av, res->ac); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3960 XtVaGetValues (w, XmNsubMenuId, &submenu, NULL); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3961 if (submenu) |
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 XtSetValues (submenu, res->av, res->ac); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3964 XtApplyToWidgets (submenu, xm_apply_resources, p); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3965 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3966 } |
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 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
|
3970 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
|
3971 following problems: |
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 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
|
3974 somewhere in LessTif. */ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3975 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3976 static void |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3977 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
|
3978 struct frame *f; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3979 Widget widget; |
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 struct face *face; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3982 Lisp_Object lface; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3983 Arg av[3]; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3984 int ac = 0; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3985 XmFontList fl = 0; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3986 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3987 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
|
3988 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
|
3989 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3990 if (!UNSPECIFIEDP (LFACE_FOREGROUND (lface))) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3991 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3992 XtSetArg (av[ac], XmNforeground, face->foreground); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3993 ++ac; |
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 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3996 if (!UNSPECIFIEDP (LFACE_BACKGROUND (lface))) |
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 XtSetArg (av[ac], XmNbackground, face->background); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
3999 ++ac; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4000 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4001 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4002 /* 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
|
4003 if (face->font |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4004 && (!UNSPECIFIEDP (LFACE_FAMILY (lface)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4005 || !UNSPECIFIEDP (LFACE_SWIDTH (lface)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4006 || !UNSPECIFIEDP (LFACE_WEIGHT (lface)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4007 || !UNSPECIFIEDP (LFACE_SLANT (lface)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4008 || !UNSPECIFIEDP (LFACE_HEIGHT (lface)))) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4009 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4010 #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
|
4011 in LessTif during geometry computation. */ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4012 XmFontListEntry fe; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4013 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
|
4014 fl = XmFontListAppendEntry (NULL, fe); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4015 XtSetArg (av[ac], XmNfontList, fl); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4016 ++ac; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4017 #endif |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4018 } |
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 xassert (ac <= sizeof av / sizeof *av); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4021 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4022 if (ac) |
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 struct x_resources res; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4025 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4026 XtSetValues (widget, av, ac); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4027 res.av = av, res.ac = ac; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4028 XtApplyToWidgets (widget, xm_apply_resources, &res); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4029 if (fl) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4030 XmFontListFree (fl); |
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 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4033 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4034 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4035 #endif /* USE_MOTIF */ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4036 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4037 #ifdef USE_LUCID |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4038 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4039 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
|
4040 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
|
4041 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4042 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4043 /* 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
|
4044 structure. */ |
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 static void |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4047 xl_apply_resources (widget, p) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4048 Widget widget; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4049 XtPointer p; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4050 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4051 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
|
4052 XtSetValues (widget, res->av, res->ac); |
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 /* 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
|
4057 This is the Lucid version. */ |
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 static void |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4060 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
|
4061 struct frame *f; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4062 Widget 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 struct face *face; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4065 Lisp_Object lface; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4066 Arg av[3]; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4067 int ac = 0; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4068 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4069 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
|
4070 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
|
4071 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4072 if (!UNSPECIFIEDP (LFACE_FOREGROUND (lface))) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4073 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4074 XtSetArg (av[ac], XtNforeground, face->foreground); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4075 ++ac; |
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 if (!UNSPECIFIEDP (LFACE_BACKGROUND (lface))) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4079 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4080 XtSetArg (av[ac], XtNbackground, face->background); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4081 ++ac; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4082 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4083 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4084 if (face->font |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4085 && (!UNSPECIFIEDP (LFACE_FAMILY (lface)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4086 || !UNSPECIFIEDP (LFACE_SWIDTH (lface)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4087 || !UNSPECIFIEDP (LFACE_WEIGHT (lface)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4088 || !UNSPECIFIEDP (LFACE_SLANT (lface)) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4089 || !UNSPECIFIEDP (LFACE_HEIGHT (lface)))) |
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 XtSetArg (av[ac], XtNfont, face->font); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4092 ++ac; |
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 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4095 if (ac) |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4096 { |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4097 struct x_resources res; |
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 XtSetValues (widget, av, ac); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4100 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4101 /* 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
|
4102 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
|
4103 is a function from lwlib. */ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4104 res.av = av, res.ac = ac; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4105 XtApplyToWidgets (widget, xl_apply_resources, &res); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4106 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4107 } |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4108 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4109 #endif /* USE_LUCID */ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4110 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4111 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4112 /* 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
|
4113 |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4114 void |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4115 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
|
4116 struct frame *f; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4117 Widget widget; |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4118 { |
26759
01f067d61668
(x_set_menu_resources_from_menu_face): Make sure
Gerd Moellmann <gerd@gnu.org>
parents:
26740
diff
changeset
|
4119 /* 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
|
4120 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
|
4121 will need the `menu' face. */ |
01f067d61668
(x_set_menu_resources_from_menu_face): Make sure
Gerd Moellmann <gerd@gnu.org>
parents:
26740
diff
changeset
|
4122 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
|
4123 recompute_basic_faces (f); |
01f067d61668
(x_set_menu_resources_from_menu_face): Make sure
Gerd Moellmann <gerd@gnu.org>
parents:
26740
diff
changeset
|
4124 |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4125 #ifdef USE_LUCID |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4126 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
|
4127 #endif |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4128 #ifdef USE_MOTIF |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4129 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
|
4130 #endif |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4131 } |
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 #endif /* USE_X_TOOLKIT */ |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
4134 |
24995 | 4135 #endif /* HAVE_X_WINDOWS */ |
4136 | |
4137 | |
4138 | |
4139 DEFUN ("internal-get-lisp-face-attribute", Finternal_get_lisp_face_attribute, | |
4140 Sinternal_get_lisp_face_attribute, | |
4141 2, 3, 0, | |
4142 "Return face attribute KEYWORD of face SYMBOL.\n\ | |
4143 If SYMBOL does not name a valid Lisp face or KEYWORD isn't a valid\n\ | |
4144 face attribute name, signal an error.\n\ | |
4145 If the optional argument FRAME is given, report on face FACE in that\n\ | |
4146 frame. If FRAME is t, report on the defaults for face FACE (for new\n\ | |
4147 frames). If FRAME is omitted or nil, use the selected frame.") | |
4148 (symbol, keyword, frame) | |
4149 Lisp_Object symbol, keyword, frame; | |
4150 { | |
4151 Lisp_Object lface, value = Qnil; | |
4152 | |
4153 CHECK_SYMBOL (symbol, 0); | |
4154 CHECK_SYMBOL (keyword, 1); | |
4155 | |
4156 if (EQ (frame, Qt)) | |
4157 lface = lface_from_face_name (NULL, symbol, 1); | |
4158 else | |
4159 { | |
4160 if (NILP (frame)) | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
4161 frame = selected_frame; |
24995 | 4162 CHECK_LIVE_FRAME (frame, 2); |
4163 lface = lface_from_face_name (XFRAME (frame), symbol, 1); | |
4164 } | |
4165 | |
4166 if (EQ (keyword, QCfamily)) | |
4167 value = LFACE_FAMILY (lface); | |
4168 else if (EQ (keyword, QCheight)) | |
4169 value = LFACE_HEIGHT (lface); | |
4170 else if (EQ (keyword, QCweight)) | |
4171 value = LFACE_WEIGHT (lface); | |
4172 else if (EQ (keyword, QCslant)) | |
4173 value = LFACE_SLANT (lface); | |
4174 else if (EQ (keyword, QCunderline)) | |
4175 value = LFACE_UNDERLINE (lface); | |
4176 else if (EQ (keyword, QCoverline)) | |
4177 value = LFACE_OVERLINE (lface); | |
4178 else if (EQ (keyword, QCstrike_through)) | |
4179 value = LFACE_STRIKE_THROUGH (lface); | |
4180 else if (EQ (keyword, QCbox)) | |
4181 value = LFACE_BOX (lface); | |
4182 else if (EQ (keyword, QCinverse_video) | |
4183 || EQ (keyword, QCreverse_video)) | |
4184 value = LFACE_INVERSE (lface); | |
4185 else if (EQ (keyword, QCforeground)) | |
4186 value = LFACE_FOREGROUND (lface); | |
4187 else if (EQ (keyword, QCbackground)) | |
4188 value = LFACE_BACKGROUND (lface); | |
4189 else if (EQ (keyword, QCstipple)) | |
4190 value = LFACE_STIPPLE (lface); | |
4191 else if (EQ (keyword, QCwidth)) | |
4192 value = LFACE_SWIDTH (lface); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4193 else if (EQ (keyword, QCfont)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4194 value = LFACE_FONT (lface); |
24995 | 4195 else |
4196 signal_error ("Invalid face attribute name", keyword); | |
4197 | |
4198 return value; | |
4199 } | |
4200 | |
4201 | |
4202 DEFUN ("internal-lisp-face-attribute-values", | |
4203 Finternal_lisp_face_attribute_values, | |
4204 Sinternal_lisp_face_attribute_values, 1, 1, 0, | |
4205 "Return a list of valid discrete values for face attribute ATTR.\n\ | |
4206 Value is nil if ATTR doesn't have a discrete set of valid values.") | |
4207 (attr) | |
4208 Lisp_Object attr; | |
4209 { | |
4210 Lisp_Object result = Qnil; | |
4211 | |
4212 CHECK_SYMBOL (attr, 0); | |
4213 | |
4214 if (EQ (attr, QCweight) | |
4215 || EQ (attr, QCslant) | |
4216 || EQ (attr, QCwidth)) | |
4217 { | |
4218 /* Extract permissible symbols from tables. */ | |
4219 struct table_entry *table; | |
4220 int i, dim; | |
4221 | |
4222 if (EQ (attr, QCweight)) | |
4223 table = weight_table, dim = DIM (weight_table); | |
4224 else if (EQ (attr, QCslant)) | |
4225 table = slant_table, dim = DIM (slant_table); | |
4226 else | |
4227 table = swidth_table, dim = DIM (swidth_table); | |
4228 | |
4229 for (i = 0; i < dim; ++i) | |
4230 { | |
4231 Lisp_Object symbol = *table[i].symbol; | |
4232 Lisp_Object tail = result; | |
4233 | |
4234 while (!NILP (tail) | |
4235 && !EQ (XCAR (tail), symbol)) | |
4236 tail = XCDR (tail); | |
4237 | |
4238 if (NILP (tail)) | |
4239 result = Fcons (symbol, result); | |
4240 } | |
4241 } | |
4242 else if (EQ (attr, QCunderline)) | |
4243 result = Fcons (Qt, Fcons (Qnil, Qnil)); | |
4244 else if (EQ (attr, QCoverline)) | |
4245 result = Fcons (Qt, Fcons (Qnil, Qnil)); | |
4246 else if (EQ (attr, QCstrike_through)) | |
4247 result = Fcons (Qt, Fcons (Qnil, Qnil)); | |
4248 else if (EQ (attr, QCinverse_video) || EQ (attr, QCreverse_video)) | |
4249 result = Fcons (Qt, Fcons (Qnil, Qnil)); | |
4250 | |
4251 return result; | |
4252 } | |
4253 | |
4254 | |
4255 DEFUN ("internal-merge-in-global-face", Finternal_merge_in_global_face, | |
4256 Sinternal_merge_in_global_face, 2, 2, 0, | |
4257 "Add attributes from frame-default definition of FACE to FACE on FRAME.") | |
4258 (face, frame) | |
4259 Lisp_Object face, frame; | |
4260 { | |
4261 Lisp_Object global_lface, local_lface; | |
4262 CHECK_LIVE_FRAME (frame, 1); | |
4263 global_lface = lface_from_face_name (NULL, face, 1); | |
4264 local_lface = lface_from_face_name (XFRAME (frame), face, 0); | |
4265 if (NILP (local_lface)) | |
4266 local_lface = Finternal_make_lisp_face (face, frame); | |
4267 merge_face_vectors (XVECTOR (global_lface)->contents, | |
4268 XVECTOR (local_lface)->contents); | |
4269 return face; | |
4270 } | |
4271 | |
4272 | |
4273 /* The following function is implemented for compatibility with 20.2. | |
4274 The function is used in x-resolve-fonts when it is asked to | |
4275 return fonts with the same size as the font of a face. This is | |
4276 done in fontset.el. */ | |
4277 | |
4278 DEFUN ("face-font", Fface_font, Sface_font, 1, 2, 0, | |
4279 "Return the font name of face FACE, or nil if it is unspecified.\n\ | |
4280 If the optional argument FRAME is given, report on face FACE in that frame.\n\ | |
4281 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ | |
4282 The font default for a face is either nil, or a list\n\ | |
4283 of the form (bold), (italic) or (bold italic).\n\ | |
4284 If FRAME is omitted or nil, use the selected frame.") | |
4285 (face, frame) | |
4286 Lisp_Object face, frame; | |
4287 { | |
4288 if (EQ (frame, Qt)) | |
4289 { | |
4290 Lisp_Object result = Qnil; | |
4291 Lisp_Object lface = lface_from_face_name (NULL, face, 1); | |
4292 | |
4293 if (!UNSPECIFIEDP (LFACE_WEIGHT (lface)) | |
4294 && !EQ (LFACE_WEIGHT (lface), Qnormal)) | |
4295 result = Fcons (Qbold, result); | |
4296 | |
4297 if (!NILP (LFACE_SLANT (lface)) | |
4298 && !EQ (LFACE_SLANT (lface), Qnormal)) | |
4299 result = Fcons (Qitalic, result); | |
4300 | |
4301 return result; | |
4302 } | |
4303 else | |
4304 { | |
4305 struct frame *f = frame_or_selected_frame (frame, 1); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4306 int face_id = lookup_named_face (f, face, 0); |
24995 | 4307 struct face *face = FACE_FROM_ID (f, face_id); |
4308 return build_string (face->font_name); | |
4309 } | |
4310 } | |
4311 | |
4312 | |
4313 /* Compare face vectors V1 and V2 for equality. Value is non-zero if | |
4314 all attributes are `equal'. Tries to be fast because this function | |
4315 is called quite often. */ | |
4316 | |
4317 static INLINE int | |
4318 lface_equal_p (v1, v2) | |
4319 Lisp_Object *v1, *v2; | |
4320 { | |
4321 int i, equal_p = 1; | |
4322 | |
4323 for (i = 1; i < LFACE_VECTOR_SIZE && equal_p; ++i) | |
4324 { | |
4325 Lisp_Object a = v1[i]; | |
4326 Lisp_Object b = v2[i]; | |
4327 | |
4328 /* Type can differ, e.g. when one attribute is unspecified, i.e. nil, | |
4329 and the other is specified. */ | |
4330 equal_p = XTYPE (a) == XTYPE (b); | |
4331 if (!equal_p) | |
4332 break; | |
4333 | |
4334 if (!EQ (a, b)) | |
4335 { | |
4336 switch (XTYPE (a)) | |
4337 { | |
4338 case Lisp_String: | |
4339 equal_p = (XSTRING (a)->size == XSTRING (b)->size | |
4340 && bcmp (XSTRING (a)->data, XSTRING (b)->data, | |
4341 XSTRING (a)->size) == 0); | |
4342 break; | |
4343 | |
4344 case Lisp_Int: | |
4345 case Lisp_Symbol: | |
4346 equal_p = 0; | |
4347 break; | |
4348 | |
4349 default: | |
4350 equal_p = !NILP (Fequal (a, b)); | |
4351 break; | |
4352 } | |
4353 } | |
4354 } | |
4355 | |
4356 return equal_p; | |
4357 } | |
4358 | |
4359 | |
4360 DEFUN ("internal-lisp-face-equal-p", Finternal_lisp_face_equal_p, | |
4361 Sinternal_lisp_face_equal_p, 2, 3, 0, | |
4362 "True if FACE1 and FACE2 are equal.\n\ | |
4363 If the optional argument FRAME is given, report on face FACE in that frame.\n\ | |
4364 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ | |
4365 If FRAME is omitted or nil, use the selected frame.") | |
4366 (face1, face2, frame) | |
4367 Lisp_Object face1, face2, frame; | |
4368 { | |
4369 int equal_p; | |
4370 struct frame *f; | |
4371 Lisp_Object lface1, lface2; | |
4372 | |
4373 if (EQ (frame, Qt)) | |
4374 f = NULL; | |
4375 else | |
4376 /* Don't use check_x_frame here because this function is called | |
4377 before X frames exist. At that time, if FRAME is nil, | |
4378 selected_frame will be used which is the frame dumped with | |
4379 Emacs. That frame is not an X frame. */ | |
4380 f = frame_or_selected_frame (frame, 2); | |
4381 | |
4382 lface1 = lface_from_face_name (NULL, face1, 1); | |
4383 lface2 = lface_from_face_name (NULL, face2, 1); | |
4384 equal_p = lface_equal_p (XVECTOR (lface1)->contents, | |
4385 XVECTOR (lface2)->contents); | |
4386 return equal_p ? Qt : Qnil; | |
4387 } | |
4388 | |
4389 | |
4390 DEFUN ("internal-lisp-face-empty-p", Finternal_lisp_face_empty_p, | |
4391 Sinternal_lisp_face_empty_p, 1, 2, 0, | |
4392 "True if FACE has no attribute specified.\n\ | |
4393 If the optional argument FRAME is given, report on face FACE in that frame.\n\ | |
4394 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ | |
4395 If FRAME is omitted or nil, use the selected frame.") | |
4396 (face, frame) | |
4397 Lisp_Object face, frame; | |
4398 { | |
4399 struct frame *f; | |
4400 Lisp_Object lface; | |
4401 int i; | |
4402 | |
4403 if (NILP (frame)) | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
4404 frame = selected_frame; |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
4405 CHECK_LIVE_FRAME (frame, 0); |
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
4406 f = XFRAME (frame); |
24995 | 4407 |
4408 if (EQ (frame, Qt)) | |
4409 lface = lface_from_face_name (NULL, face, 1); | |
4410 else | |
4411 lface = lface_from_face_name (f, face, 1); | |
4412 | |
4413 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) | |
4414 if (!UNSPECIFIEDP (XVECTOR (lface)->contents[i])) | |
4415 break; | |
4416 | |
4417 return i == LFACE_VECTOR_SIZE ? Qt : Qnil; | |
4418 } | |
4419 | |
4420 | |
4421 DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist, | |
4422 0, 1, 0, | |
4423 "Return an alist of frame-local faces defined on FRAME.\n\ | |
4424 For internal use only.") | |
4425 (frame) | |
4426 Lisp_Object frame; | |
4427 { | |
4428 struct frame *f = frame_or_selected_frame (frame, 0); | |
4429 return f->face_alist; | |
4430 } | |
4431 | |
4432 | |
4433 /* Return a hash code for Lisp string STRING with case ignored. Used | |
4434 below in computing a hash value for a Lisp face. */ | |
4435 | |
4436 static INLINE unsigned | |
4437 hash_string_case_insensitive (string) | |
4438 Lisp_Object string; | |
4439 { | |
4440 unsigned char *s; | |
4441 unsigned hash = 0; | |
4442 xassert (STRINGP (string)); | |
4443 for (s = XSTRING (string)->data; *s; ++s) | |
4444 hash = (hash << 1) ^ tolower (*s); | |
4445 return hash; | |
4446 } | |
4447 | |
4448 | |
4449 /* Return a hash code for face attribute vector V. */ | |
4450 | |
4451 static INLINE unsigned | |
4452 lface_hash (v) | |
4453 Lisp_Object *v; | |
4454 { | |
4455 return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX]) | |
4456 ^ hash_string_case_insensitive (v[LFACE_FOREGROUND_INDEX]) | |
4457 ^ hash_string_case_insensitive (v[LFACE_BACKGROUND_INDEX]) | |
4458 ^ (unsigned) v[LFACE_WEIGHT_INDEX] | |
4459 ^ (unsigned) v[LFACE_SLANT_INDEX] | |
4460 ^ (unsigned) v[LFACE_SWIDTH_INDEX] | |
4461 ^ XFASTINT (v[LFACE_HEIGHT_INDEX])); | |
4462 } | |
4463 | |
4464 | |
4465 /* Return non-zero if LFACE1 and LFACE2 specify the same font (without | |
4466 considering charsets/registries). They do if they specify the same | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4467 family, point size, weight, width, slant, and fontset. Both LFACE1 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4468 and LFACE2 must be fully-specified. */ |
24995 | 4469 |
4470 static INLINE int | |
4471 lface_same_font_attributes_p (lface1, lface2) | |
4472 Lisp_Object *lface1, *lface2; | |
4473 { | |
4474 xassert (lface_fully_specified_p (lface1) | |
4475 && lface_fully_specified_p (lface2)); | |
4476 return (xstricmp (XSTRING (lface1[LFACE_FAMILY_INDEX])->data, | |
4477 XSTRING (lface2[LFACE_FAMILY_INDEX])->data) == 0 | |
4478 && (XFASTINT (lface1[LFACE_HEIGHT_INDEX]) | |
4479 == XFASTINT (lface2[LFACE_HEIGHT_INDEX])) | |
4480 && EQ (lface1[LFACE_SWIDTH_INDEX], lface2[LFACE_SWIDTH_INDEX]) | |
4481 && EQ (lface1[LFACE_WEIGHT_INDEX], lface2[LFACE_WEIGHT_INDEX]) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4482 && EQ (lface1[LFACE_SLANT_INDEX], lface2[LFACE_SLANT_INDEX]) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4483 && (EQ (lface1[LFACE_FONT_INDEX], lface2[LFACE_FONT_INDEX]) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4484 || (STRINGP (lface1[LFACE_FONT_INDEX]) |
28263
73181b84ea57
(lface_same_font_attributes_p): Compare font attributes
Gerd Moellmann <gerd@gnu.org>
parents:
28237
diff
changeset
|
4485 && STRINGP (lface2[LFACE_FONT_INDEX]) |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4486 && xstricmp (XSTRING (lface1[LFACE_FONT_INDEX])->data, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4487 XSTRING (lface2[LFACE_FONT_INDEX])->data)))); |
24995 | 4488 } |
4489 | |
4490 | |
4491 | |
4492 /*********************************************************************** | |
4493 Realized Faces | |
4494 ***********************************************************************/ | |
4495 | |
4496 /* Allocate and return a new realized face for Lisp face attribute | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4497 vector ATTR. */ |
24995 | 4498 |
4499 static struct face * | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4500 make_realized_face (attr) |
24995 | 4501 Lisp_Object *attr; |
4502 { | |
4503 struct face *face = (struct face *) xmalloc (sizeof *face); | |
4504 bzero (face, sizeof *face); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4505 face->ascii_face = face; |
24995 | 4506 bcopy (attr, face->lface, sizeof face->lface); |
4507 return face; | |
4508 } | |
4509 | |
4510 | |
4511 /* Free realized face FACE, including its X resources. FACE may | |
4512 be null. */ | |
4513 | |
4514 static void | |
4515 free_realized_face (f, face) | |
4516 struct frame *f; | |
4517 struct face *face; | |
4518 { | |
4519 if (face) | |
4520 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4521 #ifdef HAVE_WINDOW_SYSTEM |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4522 if (FRAME_WINDOW_P (f)) |
24995 | 4523 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4524 /* Free fontset of FACE if it is ASCII face. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4525 if (face->fontset >= 0 && face == face->ascii_face) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4526 free_face_fontset (f, face); |
24995 | 4527 if (face->gc) |
4528 { | |
4529 x_free_gc (f, face->gc); | |
4530 face->gc = 0; | |
4531 } | |
4532 | |
4533 free_face_colors (f, face); | |
4534 x_destroy_bitmap (f, face->stipple); | |
4535 } | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4536 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 4537 |
4538 xfree (face); | |
4539 } | |
4540 } | |
4541 | |
4542 | |
4543 /* Prepare face FACE for subsequent display on frame F. This | |
4544 allocated GCs if they haven't been allocated yet or have been freed | |
4545 by clearing the face cache. */ | |
4546 | |
4547 void | |
4548 prepare_face_for_display (f, face) | |
4549 struct frame *f; | |
4550 struct face *face; | |
4551 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4552 #ifdef HAVE_WINDOW_SYSTEM |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4553 xassert (FRAME_WINDOW_P (f)); |
24995 | 4554 |
4555 if (face->gc == 0) | |
4556 { | |
4557 XGCValues xgcv; | |
4558 unsigned long mask = GCForeground | GCBackground | GCGraphicsExposures; | |
4559 | |
4560 xgcv.foreground = face->foreground; | |
4561 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
|
4562 #ifdef HAVE_X_WINDOWS |
24995 | 4563 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
|
4564 #endif |
24995 | 4565 /* The font of FACE may be null if we couldn't load it. */ |
4566 if (face->font) | |
4567 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4568 #ifdef HAVE_X_WINDOWS |
24995 | 4569 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
|
4570 #endif |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4571 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4572 xgcv.font = face->font; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4573 #endif |
24995 | 4574 mask |= GCFont; |
4575 } | |
4576 | |
4577 BLOCK_INPUT; | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4578 #ifdef HAVE_X_WINDOWS |
24995 | 4579 if (face->stipple) |
4580 { | |
25092
79a5a567bdb0
(prepare_face_for_display): Use FillOpaqueStippled instead of
Gerd Moellmann <gerd@gnu.org>
parents:
25062
diff
changeset
|
4581 xgcv.fill_style = FillOpaqueStippled; |
24995 | 4582 xgcv.stipple = x_bitmap_pixmap (f, face->stipple); |
4583 mask |= GCFillStyle | GCStipple; | |
4584 } | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4585 #endif |
24995 | 4586 face->gc = x_create_gc (f, mask, &xgcv); |
4587 UNBLOCK_INPUT; | |
4588 } | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4589 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 4590 } |
4591 | |
4592 | |
4593 /*********************************************************************** | |
4594 Face Cache | |
4595 ***********************************************************************/ | |
4596 | |
4597 /* Return a new face cache for frame F. */ | |
4598 | |
4599 static struct face_cache * | |
4600 make_face_cache (f) | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4601 struct frame *f; |
24995 | 4602 { |
4603 struct face_cache *c; | |
4604 int size; | |
4605 | |
4606 c = (struct face_cache *) xmalloc (sizeof *c); | |
4607 bzero (c, sizeof *c); | |
4608 size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | |
4609 c->buckets = (struct face **) xmalloc (size); | |
4610 bzero (c->buckets, size); | |
4611 c->size = 50; | |
4612 c->faces_by_id = (struct face **) xmalloc (c->size * sizeof *c->faces_by_id); | |
4613 c->f = f; | |
4614 return c; | |
4615 } | |
4616 | |
4617 | |
4618 /* Clear out all graphics contexts for all realized faces, except for | |
4619 the basic faces. This should be done from time to time just to avoid | |
4620 keeping too many graphics contexts that are no longer needed. */ | |
4621 | |
4622 static void | |
4623 clear_face_gcs (c) | |
4624 struct face_cache *c; | |
4625 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4626 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
|
4627 { |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4628 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 4629 int i; |
4630 for (i = BASIC_FACE_ID_SENTINEL; i < c->used; ++i) | |
4631 { | |
4632 struct face *face = c->faces_by_id[i]; | |
4633 if (face && face->gc) | |
4634 { | |
4635 x_free_gc (c->f, face->gc); | |
4636 face->gc = 0; | |
4637 } | |
4638 } | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4639 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 4640 } |
4641 } | |
4642 | |
4643 | |
4644 /* Free all realized faces in face cache C, including basic faces. C | |
4645 may be null. If faces are freed, make sure the frame's current | |
4646 matrix is marked invalid, so that a display caused by an expose | |
4647 event doesn't try to use faces we destroyed. */ | |
4648 | |
4649 static void | |
4650 free_realized_faces (c) | |
4651 struct face_cache *c; | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4652 { |
24995 | 4653 if (c && c->used) |
4654 { | |
4655 int i, size; | |
4656 struct frame *f = c->f; | |
4657 | |
4658 for (i = 0; i < c->used; ++i) | |
4659 { | |
4660 free_realized_face (f, c->faces_by_id[i]); | |
4661 c->faces_by_id[i] = NULL; | |
4662 } | |
4663 | |
4664 c->used = 0; | |
4665 size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; | |
4666 bzero (c->buckets, size); | |
4667 | |
4668 /* Must do a thorough redisplay the next time. Mark current | |
4669 matrices as invalid because they will reference faces freed | |
4670 above. This function is also called when a frame is | |
4671 destroyed. In this case, the root window of F is nil. */ | |
4672 if (WINDOWP (f->root_window)) | |
4673 { | |
4674 clear_current_matrices (f); | |
4675 ++windows_or_buffers_changed; | |
4676 } | |
4677 } | |
4678 } | |
4679 | |
4680 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4681 /* Free all faces realized for multibyte characters on frame F that |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4682 has FONTSET. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4683 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4684 void |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4685 free_realized_multibyte_face (f, fontset) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4686 struct frame *f; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4687 int fontset; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4688 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4689 struct face_cache *cache = FRAME_FACE_CACHE (f); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4690 struct face *face; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4691 int i; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4692 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4693 for (i = 0; i < cache->used; i++) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4694 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4695 face = cache->faces_by_id[i]; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4696 if (face |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4697 && face != face->ascii_face |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4698 && face->fontset == fontset) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4699 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4700 uncache_face (cache, face); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4701 free_realized_face (f, face); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4702 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4703 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4704 if (WINDOWP (f->root_window)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4705 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4706 clear_current_matrices (f); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4707 ++windows_or_buffers_changed; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4708 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4709 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4710 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4711 |
24995 | 4712 /* Free all realized faces on FRAME or on all frames if FRAME is nil. |
4713 This is done after attributes of a named face have been changed, | |
4714 because we can't tell which realized faces depend on that face. */ | |
4715 | |
4716 void | |
4717 free_all_realized_faces (frame) | |
4718 Lisp_Object frame; | |
4719 { | |
4720 if (NILP (frame)) | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4721 { |
24995 | 4722 Lisp_Object rest; |
4723 FOR_EACH_FRAME (rest, frame) | |
4724 free_realized_faces (FRAME_FACE_CACHE (XFRAME (frame))); | |
4725 } | |
4726 else | |
4727 free_realized_faces (FRAME_FACE_CACHE (XFRAME (frame))); | |
4728 } | |
4729 | |
4730 | |
4731 /* Free face cache C and faces in it, including their X resources. */ | |
4732 | |
4733 static void | |
4734 free_face_cache (c) | |
4735 struct face_cache *c; | |
4736 { | |
4737 if (c) | |
4738 { | |
4739 free_realized_faces (c); | |
4740 xfree (c->buckets); | |
4741 xfree (c->faces_by_id); | |
4742 xfree (c); | |
4743 } | |
4744 } | |
4745 | |
4746 | |
4747 /* Cache realized face FACE in face cache C. HASH is the hash value | |
4748 of FACE. If FACE->fontset >= 0, add the new face to the end of the | |
4749 collision list of the face hash table of C. This is done because | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4750 otherwise lookup_face would find FACE for every character, even if |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4751 faces with the same attributes but for specific characters exist. */ |
24995 | 4752 |
4753 static void | |
4754 cache_face (c, face, hash) | |
4755 struct face_cache *c; | |
4756 struct face *face; | |
4757 unsigned hash; | |
4758 { | |
4759 int i = hash % FACE_CACHE_BUCKETS_SIZE; | |
4760 | |
4761 face->hash = hash; | |
4762 | |
4763 if (face->fontset >= 0) | |
4764 { | |
4765 struct face *last = c->buckets[i]; | |
4766 if (last) | |
4767 { | |
4768 while (last->next) | |
4769 last = last->next; | |
4770 last->next = face; | |
4771 face->prev = last; | |
4772 face->next = NULL; | |
4773 } | |
4774 else | |
4775 { | |
4776 c->buckets[i] = face; | |
4777 face->prev = face->next = NULL; | |
4778 } | |
4779 } | |
4780 else | |
4781 { | |
4782 face->prev = NULL; | |
4783 face->next = c->buckets[i]; | |
4784 if (face->next) | |
4785 face->next->prev = face; | |
4786 c->buckets[i] = face; | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4787 } |
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4788 |
24995 | 4789 /* Find a free slot in C->faces_by_id and use the index of the free |
4790 slot as FACE->id. */ | |
4791 for (i = 0; i < c->used; ++i) | |
4792 if (c->faces_by_id[i] == NULL) | |
4793 break; | |
4794 face->id = i; | |
4795 | |
4796 /* Maybe enlarge C->faces_by_id. */ | |
4797 if (i == c->used && c->used == c->size) | |
4798 { | |
4799 int new_size = 2 * c->size; | |
4800 int sz = new_size * sizeof *c->faces_by_id; | |
4801 c->faces_by_id = (struct face **) xrealloc (c->faces_by_id, sz); | |
4802 c->size = new_size; | |
4803 } | |
4804 | |
4805 #if GLYPH_DEBUG | |
4806 /* Check that FACE got a unique id. */ | |
4807 { | |
4808 int j, n; | |
4809 struct face *face; | |
4810 | |
4811 for (j = n = 0; j < FACE_CACHE_BUCKETS_SIZE; ++j) | |
4812 for (face = c->buckets[j]; face; face = face->next) | |
4813 if (face->id == i) | |
4814 ++n; | |
4815 | |
4816 xassert (n == 1); | |
4817 } | |
4818 #endif /* GLYPH_DEBUG */ | |
4819 | |
4820 c->faces_by_id[i] = face; | |
4821 if (i == c->used) | |
4822 ++c->used; | |
4823 } | |
4824 | |
4825 | |
4826 /* Remove face FACE from cache C. */ | |
4827 | |
4828 static void | |
4829 uncache_face (c, face) | |
4830 struct face_cache *c; | |
4831 struct face *face; | |
4832 { | |
4833 int i = face->hash % FACE_CACHE_BUCKETS_SIZE; | |
4834 | |
4835 if (face->prev) | |
4836 face->prev->next = face->next; | |
4837 else | |
4838 c->buckets[i] = face->next; | |
4839 | |
4840 if (face->next) | |
4841 face->next->prev = face->prev; | |
4842 | |
4843 c->faces_by_id[face->id] = NULL; | |
4844 if (face->id == c->used) | |
4845 --c->used; | |
4846 } | |
4847 | |
4848 | |
4849 /* Look up a realized face with face attributes ATTR in the face cache | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4850 of frame F. The face will be used to display character C. Value |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4851 is the ID of the face found. If no suitable face is found, realize |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4852 a new one. In that case, if C is a multibyte character, BASE_FACE |
28409 | 4853 is a face for ASCII characters that has the same attributes. */ |
24995 | 4854 |
4855 INLINE int | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4856 lookup_face (f, attr, c, base_face) |
24995 | 4857 struct frame *f; |
4858 Lisp_Object *attr; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4859 int c; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4860 struct face *base_face; |
24995 | 4861 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4862 struct face_cache *cache = FRAME_FACE_CACHE (f); |
24995 | 4863 unsigned hash; |
4864 int i; | |
4865 struct face *face; | |
4866 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4867 xassert (cache != NULL); |
24995 | 4868 check_lface_attrs (attr); |
4869 | |
4870 /* Look up ATTR in the face cache. */ | |
4871 hash = lface_hash (attr); | |
4872 i = hash % FACE_CACHE_BUCKETS_SIZE; | |
4873 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4874 for (face = cache->buckets[i]; face; face = face->next) |
24995 | 4875 if (face->hash == hash |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
4876 && (!FRAME_WINDOW_P (f) |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4877 || FACE_SUITABLE_FOR_CHAR_P (face, c)) |
24995 | 4878 && lface_equal_p (face->lface, attr)) |
4879 break; | |
4880 | |
4881 /* If not found, realize a new face. */ | |
4882 if (face == NULL) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4883 face = realize_face (cache, attr, c, base_face, -1); |
24995 | 4884 |
4885 #if GLYPH_DEBUG | |
4886 xassert (face == FACE_FROM_ID (f, face->id)); | |
28409 | 4887 |
4888 /* When this function is called from face_for_char (in this case, C is | |
4889 a multibyte character), a fontset of a face returned by | |
4890 realize_face is not yet set, i.e. FACE_SUITABLE_FOR_CHAR_P (FACE, | |
4891 C) is not sutisfied. The fontset is set for this face by | |
4892 face_for_char later. */ | |
28349
26f2a2e9a2b5
(lookup_face): Don't assert FACE_SUITABLE_FOR_CHAR_P.
Gerd Moellmann <gerd@gnu.org>
parents:
28263
diff
changeset
|
4893 #if 0 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4894 if (FRAME_WINDOW_P (f)) |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4895 xassert (FACE_SUITABLE_FOR_CHAR_P (face, c)); |
28349
26f2a2e9a2b5
(lookup_face): Don't assert FACE_SUITABLE_FOR_CHAR_P.
Gerd Moellmann <gerd@gnu.org>
parents:
28263
diff
changeset
|
4896 #endif |
24995 | 4897 #endif /* GLYPH_DEBUG */ |
4898 | |
4899 return face->id; | |
8472
0d0b32e78a5b
(compute_glyph_face_1): New function.
Richard M. Stallman <rms@gnu.org>
parents:
8119
diff
changeset
|
4900 } |
24995 | 4901 |
4902 | |
4903 /* Return the face id of the realized face for named face SYMBOL on | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4904 frame F suitable for displaying character C. */ |
24995 | 4905 |
4906 int | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4907 lookup_named_face (f, symbol, c) |
24995 | 4908 struct frame *f; |
4909 Lisp_Object symbol; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4910 int c; |
24995 | 4911 { |
4912 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
4913 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; | |
4914 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
4915 | |
4916 get_lface_attributes (f, symbol, symbol_attrs, 1); | |
4917 bcopy (default_face->lface, attrs, sizeof attrs); | |
4918 merge_face_vectors (symbol_attrs, attrs); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4919 return lookup_face (f, attrs, c, NULL); |
24995 | 4920 } |
4921 | |
4922 | |
4923 /* Return the ID of the realized ASCII face of Lisp face with ID | |
4924 LFACE_ID on frame F. Value is -1 if LFACE_ID isn't valid. */ | |
4925 | |
4926 int | |
4927 ascii_face_of_lisp_face (f, lface_id) | |
4928 struct frame *f; | |
4929 int lface_id; | |
4930 { | |
4931 int face_id; | |
4932 | |
4933 if (lface_id >= 0 && lface_id < lface_id_to_name_size) | |
4934 { | |
4935 Lisp_Object face_name = lface_id_to_name[lface_id]; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4936 face_id = lookup_named_face (f, face_name, 0); |
24995 | 4937 } |
4938 else | |
4939 face_id = -1; | |
4940 | |
4941 return face_id; | |
4942 } | |
4943 | |
4944 | |
4945 /* Return a face for charset ASCII that is like the face with id | |
4946 FACE_ID on frame F, but has a font that is STEPS steps smaller. | |
4947 STEPS < 0 means larger. Value is the id of the face. */ | |
4948 | |
4949 int | |
4950 smaller_face (f, face_id, steps) | |
4951 struct frame *f; | |
4952 int face_id, steps; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4953 { |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4954 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 4955 struct face *face; |
4956 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
4957 int pt, last_pt, last_height; | |
4958 int delta; | |
4959 int new_face_id; | |
4960 struct face *new_face; | |
4961 | |
4962 /* If not called for an X frame, just return the original face. */ | |
4963 if (FRAME_TERMCAP_P (f)) | |
4964 return face_id; | |
4965 | |
4966 /* Try in increments of 1/2 pt. */ | |
4967 delta = steps < 0 ? 5 : -5; | |
4968 steps = abs (steps); | |
4969 | |
4970 face = FACE_FROM_ID (f, face_id); | |
4971 bcopy (face->lface, attrs, sizeof attrs); | |
4972 pt = last_pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]); | |
4973 new_face_id = face_id; | |
4974 last_height = FONT_HEIGHT (face->font); | |
4975 | |
4976 while (steps | |
4977 && pt + delta > 0 | |
4978 /* Give up if we cannot find a font within 10pt. */ | |
4979 && abs (last_pt - pt) < 100) | |
4980 { | |
4981 /* Look up a face for a slightly smaller/larger font. */ | |
4982 pt += delta; | |
4983 attrs[LFACE_HEIGHT_INDEX] = make_number (pt); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
4984 new_face_id = lookup_face (f, attrs, 0, NULL); |
24995 | 4985 new_face = FACE_FROM_ID (f, new_face_id); |
4986 | |
4987 /* If height changes, count that as one step. */ | |
4988 if (FONT_HEIGHT (new_face->font) != last_height) | |
4989 { | |
4990 --steps; | |
4991 last_height = FONT_HEIGHT (new_face->font); | |
4992 last_pt = pt; | |
4993 } | |
4994 } | |
4995 | |
4996 return new_face_id; | |
4997 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
4998 #else /* not HAVE_WINDOW_SYSTEM */ |
24995 | 4999 |
5000 return face_id; | |
5001 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5002 #endif /* not HAVE_WINDOW_SYSTEM */ |
24995 | 5003 } |
5004 | |
5005 | |
5006 /* Return a face for charset ASCII that is like the face with id | |
5007 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
|
5008 |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
5009 int |
24995 | 5010 face_with_height (f, face_id, height) |
5011 struct frame *f; | |
5012 int face_id; | |
5013 int height; | |
5014 { | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5015 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 5016 struct face *face; |
5017 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
5018 | |
5019 if (FRAME_TERMCAP_P (f) | |
5020 || height <= 0) | |
5021 return face_id; | |
5022 | |
5023 face = FACE_FROM_ID (f, face_id); | |
5024 bcopy (face->lface, attrs, sizeof attrs); | |
5025 attrs[LFACE_HEIGHT_INDEX] = make_number (height); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5026 face_id = lookup_face (f, attrs, 0, NULL); |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5027 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 5028 |
5029 return face_id; | |
5030 } | |
5031 | |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5032 /* Return the face id of the realized face for named face SYMBOL on |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5033 frame F suitable for displaying character C, and use attributes of |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5034 the face FACE_ID for attributes that aren't completely specified by |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5035 SYMBOL. This is like lookup_named_face, except that the default |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5036 attributes come from FACE_ID, not from the default face. FACE_ID |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5037 is assumed to be already realized. */ |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5038 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5039 int |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5040 lookup_derived_face (f, symbol, c, face_id) |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5041 struct frame *f; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5042 Lisp_Object symbol; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5043 int c; |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5044 int face_id; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5045 { |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5046 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5047 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
|
5048 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
|
5049 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5050 if (!default_face) |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5051 abort (); |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5052 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5053 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
|
5054 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
|
5055 merge_face_vectors (symbol_attrs, attrs); |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5056 return lookup_face (f, attrs, c, default_face); |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5057 } |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5058 |
24995 | 5059 |
5060 | |
5061 /*********************************************************************** | |
5062 Font selection | |
5063 ***********************************************************************/ | |
5064 | |
5065 DEFUN ("internal-set-font-selection-order", | |
5066 Finternal_set_font_selection_order, | |
5067 Sinternal_set_font_selection_order, 1, 1, 0, | |
5068 "Set font selection order for face font selection to ORDER.\n\ | |
5069 ORDER must be a list of length 4 containing the symbols `:width',\n\ | |
5070 `:height', `:weight', and `:slant'. Face attributes appearing\n\ | |
5071 first in ORDER are matched first, e.g. if `:height' appears before\n\ | |
5072 `:weight' in ORDER, font selection first tries to find a font with\n\ | |
5073 a suitable height, and then tries to match the font weight.\n\ | |
5074 Value is ORDER.") | |
5075 (order) | |
5076 Lisp_Object order; | |
5077 { | |
5078 Lisp_Object list; | |
5079 int i; | |
5080 int indices[4]; | |
5081 | |
5082 CHECK_LIST (order, 0); | |
5083 bzero (indices, sizeof indices); | |
5084 i = 0; | |
5085 | |
5086 for (list = order; | |
5087 CONSP (list) && i < DIM (indices); | |
5088 list = XCDR (list), ++i) | |
5089 { | |
5090 Lisp_Object attr = XCAR (list); | |
5091 int xlfd; | |
5092 | |
5093 if (EQ (attr, QCwidth)) | |
5094 xlfd = XLFD_SWIDTH; | |
5095 else if (EQ (attr, QCheight)) | |
5096 xlfd = XLFD_POINT_SIZE; | |
5097 else if (EQ (attr, QCweight)) | |
5098 xlfd = XLFD_WEIGHT; | |
5099 else if (EQ (attr, QCslant)) | |
5100 xlfd = XLFD_SLANT; | |
5101 else | |
5102 break; | |
5103 | |
5104 if (indices[i] != 0) | |
5105 break; | |
5106 indices[i] = xlfd; | |
5107 } | |
5108 | |
5109 if (!NILP (list) | |
5110 || i != DIM (indices) | |
5111 || indices[0] == 0 | |
5112 || indices[1] == 0 | |
5113 || indices[2] == 0 | |
5114 || indices[3] == 0) | |
5115 signal_error ("Invalid font sort order", order); | |
5116 | |
5117 if (bcmp (indices, font_sort_order, sizeof indices) != 0) | |
5118 { | |
5119 bcopy (indices, font_sort_order, sizeof font_sort_order); | |
5120 free_all_realized_faces (Qnil); | |
5121 } | |
5122 | |
5123 return Qnil; | |
5124 } | |
5125 | |
5126 | |
5127 DEFUN ("internal-set-alternative-font-family-alist", | |
5128 Finternal_set_alternative_font_family_alist, | |
5129 Sinternal_set_alternative_font_family_alist, 1, 1, 0, | |
5130 "Define alternative font families to try in face font selection.\n\ | |
5131 ALIST is an alist of (FAMILY ALTERNATIVE1 ALTERNATIVE2 ...) entries.\n\ | |
5132 Each ALTERNATIVE is tried in order if no fonts of font family FAMILY can\n\ | |
5133 be found. Value is ALIST.") | |
5134 (alist) | |
5135 Lisp_Object alist; | |
5136 { | |
5137 CHECK_LIST (alist, 0); | |
5138 Vface_alternative_font_family_alist = alist; | |
5139 free_all_realized_faces (Qnil); | |
5140 return alist; | |
5141 } | |
5142 | |
5143 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5144 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 5145 |
5146 /* Value is non-zero if FONT is the name of a scalable font. The | |
5147 X11R6 XLFD spec says that point size, pixel size, and average width | |
5148 are zero for scalable fonts. Intlfonts contain at least one | |
5149 scalable font ("*-muleindian-1") for which this isn't true, so we | |
5150 just test average width. */ | |
5151 | |
5152 static int | |
5153 font_scalable_p (font) | |
5154 struct font_name *font; | |
5155 { | |
5156 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
|
5157 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
|
5158 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5159 /* 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
|
5160 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
|
5161 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
|
5162 || *s == '*' |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5163 #endif |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5164 ; |
24995 | 5165 } |
5166 | |
5167 | |
5168 /* Value is non-zero if FONT1 is a better match for font attributes | |
5169 VALUES than FONT2. VALUES is an array of face attribute values in | |
5170 font sort order. COMPARE_PT_P zero means don't compare point | |
5171 sizes. */ | |
5172 | |
5173 static int | |
5174 better_font_p (values, font1, font2, compare_pt_p) | |
5175 int *values; | |
5176 struct font_name *font1, *font2; | |
5177 int compare_pt_p; | |
5178 { | |
5179 int i; | |
5180 | |
5181 for (i = 0; i < 4; ++i) | |
5182 { | |
5183 int xlfd_idx = font_sort_order[i]; | |
5184 | |
5185 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) | |
5186 { | |
5187 int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); | |
5188 int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); | |
5189 | |
5190 if (delta1 > delta2) | |
5191 return 0; | |
5192 else if (delta1 < delta2) | |
5193 return 1; | |
5194 else | |
5195 { | |
5196 /* The difference may be equal because, e.g., the face | |
5197 specifies `italic' but we have only `regular' and | |
5198 `oblique'. Prefer `oblique' in this case. */ | |
5199 if ((xlfd_idx == XLFD_WEIGHT || xlfd_idx == XLFD_SLANT) | |
5200 && font1->numeric[xlfd_idx] > values[i] | |
5201 && font2->numeric[xlfd_idx] < values[i]) | |
5202 return 1; | |
5203 } | |
5204 } | |
5205 } | |
5206 | |
5207 return 0; | |
5208 } | |
5209 | |
5210 | |
5211 #if SCALABLE_FONTS | |
5212 | |
5213 /* Value is non-zero if FONT is an exact match for face attributes in | |
5214 SPECIFIED. SPECIFIED is an array of face attribute values in font | |
5215 sort order. */ | |
5216 | |
5217 static int | |
5218 exact_face_match_p (specified, font) | |
5219 int *specified; | |
5220 struct font_name *font; | |
5221 { | |
5222 int i; | |
5223 | |
5224 for (i = 0; i < 4; ++i) | |
5225 if (specified[i] != font->numeric[font_sort_order[i]]) | |
5226 break; | |
5227 | |
5228 return i == 4; | |
5229 } | |
5230 | |
5231 | |
5232 /* Value is the name of a scaled font, generated from scalable font | |
5233 FONT on frame F. SPECIFIED_PT is the point-size to scale FONT to. | |
5234 Value is allocated from heap. */ | |
5235 | |
5236 static char * | |
5237 build_scalable_font_name (f, font, specified_pt) | |
5238 struct frame *f; | |
5239 struct font_name *font; | |
5240 int specified_pt; | |
5241 { | |
5242 char point_size[20], pixel_size[20]; | |
5243 int pixel_value; | |
5244 double resy = FRAME_X_DISPLAY_INFO (f)->resy; | |
5245 double pt; | |
5246 | |
5247 /* If scalable font is for a specific resolution, compute | |
5248 the point size we must specify from the resolution of | |
5249 the display and the specified resolution of the font. */ | |
5250 if (font->numeric[XLFD_RESY] != 0) | |
5251 { | |
5252 pt = resy / font->numeric[XLFD_RESY] * specified_pt + 0.5; | |
5253 pixel_value = font->numeric[XLFD_RESY] / 720.0 * pt; | |
5254 } | |
5255 else | |
5256 { | |
5257 pt = specified_pt; | |
5258 pixel_value = resy / 720.0 * pt; | |
5259 } | |
5260 | |
5261 /* Set point size of the font. */ | |
5262 sprintf (point_size, "%d", (int) pt); | |
5263 font->fields[XLFD_POINT_SIZE] = point_size; | |
5264 font->numeric[XLFD_POINT_SIZE] = pt; | |
5265 | |
5266 /* Set pixel size. */ | |
5267 sprintf (pixel_size, "%d", pixel_value); | |
5268 font->fields[XLFD_PIXEL_SIZE] = pixel_size; | |
5269 font->numeric[XLFD_PIXEL_SIZE] = pixel_value; | |
5270 | |
5271 /* If font doesn't specify its resolution, use the | |
5272 resolution of the display. */ | |
5273 if (font->numeric[XLFD_RESY] == 0) | |
5274 { | |
5275 char buffer[20]; | |
5276 sprintf (buffer, "%d", (int) resy); | |
5277 font->fields[XLFD_RESY] = buffer; | |
5278 font->numeric[XLFD_RESY] = resy; | |
5279 } | |
5280 | |
5281 if (strcmp (font->fields[XLFD_RESX], "0") == 0) | |
5282 { | |
5283 char buffer[20]; | |
5284 int resx = FRAME_X_DISPLAY_INFO (f)->resx; | |
5285 sprintf (buffer, "%d", resx); | |
5286 font->fields[XLFD_RESX] = buffer; | |
5287 font->numeric[XLFD_RESX] = resx; | |
5288 } | |
5289 | |
5290 return build_font_name (font); | |
5291 } | |
5292 | |
5293 | |
5294 /* Value is non-zero if we are allowed to use scalable font FONT. We | |
5295 can't run a Lisp function here since this function may be called | |
5296 with input blocked. */ | |
5297 | |
5298 static int | |
5299 may_use_scalable_font_p (font, name) | |
5300 struct font_name *font; | |
5301 char *name; | |
5302 { | |
5303 if (EQ (Vscalable_fonts_allowed, Qt)) | |
5304 return 1; | |
5305 else if (CONSP (Vscalable_fonts_allowed)) | |
5306 { | |
5307 Lisp_Object tail, regexp; | |
5308 | |
5309 for (tail = Vscalable_fonts_allowed; CONSP (tail); tail = XCDR (tail)) | |
5310 { | |
5311 regexp = XCAR (tail); | |
5312 if (STRINGP (regexp) | |
5313 && fast_c_string_match_ignore_case (regexp, name) >= 0) | |
5314 return 1; | |
5315 } | |
5316 } | |
5317 | |
5318 return 0; | |
5319 } | |
5320 | |
5321 #endif /* SCALABLE_FONTS != 0 */ | |
5322 | |
5323 | |
5324 /* Return the name of the best matching font for face attributes | |
5325 ATTRS in the array of font_name structures FONTS which contains | |
5326 NFONTS elements. Value is a font name which is allocated from | |
5327 the heap. FONTS is freed by this function. */ | |
5328 | |
5329 static char * | |
5330 best_matching_font (f, attrs, fonts, nfonts) | |
5331 struct frame *f; | |
5332 Lisp_Object *attrs; | |
5333 struct font_name *fonts; | |
5334 int nfonts; | |
5335 { | |
5336 char *font_name; | |
5337 struct font_name *best; | |
5338 int i, pt; | |
5339 int specified[4]; | |
5340 int exact_p; | |
5341 | |
5342 if (nfonts == 0) | |
5343 return NULL; | |
5344 | |
5345 /* Make specified font attributes available in `specified', | |
5346 indexed by sort order. */ | |
5347 for (i = 0; i < DIM (font_sort_order); ++i) | |
5348 { | |
5349 int xlfd_idx = font_sort_order[i]; | |
5350 | |
5351 if (xlfd_idx == XLFD_SWIDTH) | |
5352 specified[i] = face_numeric_swidth (attrs[LFACE_SWIDTH_INDEX]); | |
5353 else if (xlfd_idx == XLFD_POINT_SIZE) | |
5354 specified[i] = pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]); | |
5355 else if (xlfd_idx == XLFD_WEIGHT) | |
5356 specified[i] = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]); | |
5357 else if (xlfd_idx == XLFD_SLANT) | |
5358 specified[i] = face_numeric_slant (attrs[LFACE_SLANT_INDEX]); | |
5359 else | |
5360 abort (); | |
5361 } | |
5362 | |
5363 #if SCALABLE_FONTS | |
5364 | |
5365 /* Set to 1 */ | |
5366 exact_p = 0; | |
5367 | |
5368 /* Start with the first non-scalable font in the list. */ | |
5369 for (i = 0; i < nfonts; ++i) | |
5370 if (!font_scalable_p (fonts + i)) | |
5371 break; | |
5372 | |
5373 /* Find the best match among the non-scalable fonts. */ | |
5374 if (i < nfonts) | |
5375 { | |
5376 best = fonts + i; | |
5377 | |
5378 for (i = 1; i < nfonts; ++i) | |
5379 if (!font_scalable_p (fonts + i) | |
5380 && better_font_p (specified, fonts + i, best, 1)) | |
5381 { | |
5382 best = fonts + i; | |
5383 | |
5384 exact_p = exact_face_match_p (specified, best); | |
5385 if (exact_p) | |
5386 break; | |
5387 } | |
5388 | |
5389 } | |
5390 else | |
5391 best = NULL; | |
5392 | |
5393 /* Unless we found an exact match among non-scalable fonts, see if | |
5394 we can find a better match among scalable fonts. */ | |
5395 if (!exact_p) | |
5396 { | |
5397 /* A scalable font is better if | |
5398 | |
5399 1. its weight, slant, swidth attributes are better, or. | |
5400 | |
5401 2. the best non-scalable font doesn't have the required | |
5402 point size, and the scalable fonts weight, slant, swidth | |
5403 isn't worse. */ | |
5404 | |
5405 int non_scalable_has_exact_height_p; | |
5406 | |
5407 if (best && best->numeric[XLFD_POINT_SIZE] == pt) | |
5408 non_scalable_has_exact_height_p = 1; | |
5409 else | |
5410 non_scalable_has_exact_height_p = 0; | |
5411 | |
5412 for (i = 0; i < nfonts; ++i) | |
5413 if (font_scalable_p (fonts + i)) | |
5414 { | |
5415 if (best == NULL | |
5416 || better_font_p (specified, fonts + i, best, 0) | |
5417 || (!non_scalable_has_exact_height_p | |
5418 && !better_font_p (specified, best, fonts + i, 0))) | |
5419 best = fonts + i; | |
5420 } | |
5421 } | |
5422 | |
5423 if (font_scalable_p (best)) | |
5424 font_name = build_scalable_font_name (f, best, pt); | |
5425 else | |
5426 font_name = build_font_name (best); | |
5427 | |
5428 #else /* !SCALABLE_FONTS */ | |
5429 | |
5430 /* Find the best non-scalable font. */ | |
5431 best = fonts; | |
5432 | |
5433 for (i = 1; i < nfonts; ++i) | |
5434 { | |
5435 xassert (!font_scalable_p (fonts + i)); | |
5436 if (better_font_p (specified, fonts + i, best, 1)) | |
5437 best = fonts + i; | |
5438 } | |
5439 | |
5440 font_name = build_font_name (best); | |
5441 | |
5442 #endif /* !SCALABLE_FONTS */ | |
5443 | |
5444 /* Free font_name structures. */ | |
5445 free_font_names (fonts, nfonts); | |
5446 | |
5447 return font_name; | |
5448 } | |
5449 | |
5450 | |
5451 /* Try to get a list of fonts on frame F with font family FAMILY and | |
5452 registry/encoding REGISTRY. Return in *FONTS a pointer to a vector | |
5453 of font_name structures for the fonts matched. Value is the number | |
5454 of fonts found. */ | |
5455 | |
5456 static int | |
5457 try_font_list (f, attrs, pattern, family, registry, fonts) | |
5458 struct frame *f; | |
5459 Lisp_Object *attrs; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5460 Lisp_Object pattern, family, registry; |
24995 | 5461 struct font_name **fonts; |
5462 { | |
5463 int nfonts; | |
5464 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5465 if (NILP (family) && STRINGP (attrs[LFACE_FAMILY_INDEX])) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5466 family = attrs[LFACE_FAMILY_INDEX]; |
24995 | 5467 |
5468 nfonts = font_list (f, pattern, family, registry, fonts); | |
5469 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5470 if (nfonts == 0 && !NILP (family)) |
24995 | 5471 { |
5472 Lisp_Object alter; | |
5473 | |
5474 /* Try alternative font families from | |
5475 Vface_alternative_font_family_alist. */ | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5476 alter = Fassoc (family, Vface_alternative_font_family_alist); |
24995 | 5477 if (CONSP (alter)) |
5478 for (alter = XCDR (alter); | |
5479 CONSP (alter) && nfonts == 0; | |
5480 alter = XCDR (alter)) | |
5481 { | |
5482 if (STRINGP (XCAR (alter))) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5483 nfonts = font_list (f, Qnil, XCAR (alter), registry, fonts); |
24995 | 5484 } |
5485 | |
5486 /* Try font family of the default face or "fixed". */ | |
5487 if (nfonts == 0) | |
5488 { | |
5489 struct face *dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
5490 if (dflt) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5491 family = dflt->lface[LFACE_FAMILY_INDEX]; |
24995 | 5492 else |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5493 family = build_string ("fixed"); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5494 nfonts = font_list (f, Qnil, family, registry, fonts); |
24995 | 5495 } |
5496 | |
5497 /* Try any family with the given registry. */ | |
5498 if (nfonts == 0) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5499 nfonts = font_list (f, Qnil, Qnil, registry, fonts); |
24995 | 5500 } |
5501 | |
5502 return nfonts; | |
5503 } | |
5504 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5505 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5506 /* Return the fontset id of the base fontset name or alias name given |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5507 by the fontset attribute of ATTRS. Value is -1 if the fontset |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5508 attribute of ATTRS doesn't name a fontset. */ |
24995 | 5509 |
5510 static int | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5511 face_fontset (attrs) |
24995 | 5512 Lisp_Object *attrs; |
5513 { | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5514 Lisp_Object name; |
24995 | 5515 int fontset; |
5516 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5517 name = attrs[LFACE_FONT_INDEX]; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5518 if (!STRINGP (name)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5519 return -1; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5520 return fs_query_fontset (name, 0); |
24995 | 5521 } |
5522 | |
5523 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5524 /* Choose a name of font to use on frame F to display character C with |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5525 Lisp face attributes specified by ATTRS. The font name is |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5526 determined by the font-related attributes in ATTRS and the name |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5527 pattern for C in FONTSET. Value is the font name which is |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5528 allocated from the heap and must be freed by the caller, or NULL if |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5529 we can get no information about the font name of C. It is assured |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5530 that we always get some information for a single byte |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5531 character. */ |
24995 | 5532 |
5533 static char * | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5534 choose_face_font (f, attrs, fontset, c) |
24995 | 5535 struct frame *f; |
5536 Lisp_Object *attrs; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5537 int fontset, c; |
24995 | 5538 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5539 Lisp_Object pattern; |
24995 | 5540 char *font_name = NULL; |
5541 struct font_name *fonts; | |
5542 int nfonts; | |
5543 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5544 /* Get (foundry and) family name and registry (and encoding) name of |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5545 a font for C. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5546 pattern = fontset_font_pattern (f, fontset, c); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5547 if (NILP (pattern)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5548 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5549 xassert (!SINGLE_BYTE_CHAR_P (c)); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5550 return NULL; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5551 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5552 /* If what we got is a name pattern, return it. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5553 if (STRINGP (pattern)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5554 return xstrdup (XSTRING (pattern)->data); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5555 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5556 /* Family name may be specified both in ATTRS and car part of |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5557 PATTERN. The former has higher priority if C is a single byte |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5558 character. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5559 if (STRINGP (attrs[LFACE_FAMILY_INDEX]) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5560 && SINGLE_BYTE_CHAR_P (c)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5561 XCAR (pattern) = Qnil; |
24995 | 5562 |
5563 /* Get a list of fonts matching that pattern and choose the | |
5564 best match for the specified face attributes from it. */ | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5565 nfonts = try_font_list (f, attrs, Qnil, XCAR (pattern), XCDR (pattern), |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5566 &fonts); |
24995 | 5567 font_name = best_matching_font (f, attrs, fonts, nfonts); |
5568 return font_name; | |
5569 } | |
5570 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5571 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 5572 |
5573 | |
5574 | |
5575 /*********************************************************************** | |
5576 Face Realization | |
5577 ***********************************************************************/ | |
5578 | |
5579 /* Realize basic faces on frame F. Value is zero if frame parameters | |
5580 of F don't contain enough information needed to realize the default | |
5581 face. */ | |
5582 | |
5583 static int | |
5584 realize_basic_faces (f) | |
2342 | 5585 struct frame *f; |
24995 | 5586 { |
5587 int success_p = 0; | |
5588 | |
5589 if (realize_default_face (f)) | |
5590 { | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
5591 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
|
5592 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
|
5593 realize_named_face (f, Qfringe, BITMAP_AREA_FACE_ID); |
25546 | 5594 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
|
5595 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
|
5596 realize_named_face (f, Qborder, BORDER_FACE_ID); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
5597 realize_named_face (f, Qcursor, CURSOR_FACE_ID); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
5598 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
|
5599 realize_named_face (f, Qmenu, MENU_FACE_ID); |
24995 | 5600 success_p = 1; |
5601 } | |
5602 | |
5603 return success_p; | |
5604 } | |
5605 | |
5606 | |
5607 /* Realize the default face on frame F. If the face is not fully | |
5608 specified, make it fully-specified. Attributes of the default face | |
5609 that are not explicitly specified are taken from frame parameters. */ | |
5610 | |
5611 static int | |
5612 realize_default_face (f) | |
5613 struct frame *f; | |
5614 { | |
5615 struct face_cache *c = FRAME_FACE_CACHE (f); | |
5616 Lisp_Object lface; | |
5617 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
5618 Lisp_Object frame_font; | |
5619 struct face *face; | |
5620 int fontset; | |
5621 | |
5622 /* If the `default' face is not yet known, create it. */ | |
5623 lface = lface_from_face_name (f, Qdefault, 0); | |
5624 if (NILP (lface)) | |
5625 { | |
5626 Lisp_Object frame; | |
5627 XSETFRAME (frame, f); | |
5628 lface = Finternal_make_lisp_face (Qdefault, frame); | |
5629 } | |
5630 | |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5631 #ifdef HAVE_WINDOW_SYSTEM |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5632 if (FRAME_WINDOW_P (f)) |
24995 | 5633 { |
5634 /* Set frame_font to the value of the `font' frame parameter. */ | |
5635 frame_font = Fassq (Qfont, f->param_alist); | |
5636 xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font))); | |
5637 frame_font = XCDR (frame_font); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5638 set_lface_from_font_name (f, lface, frame_font, 0, 1); |
24995 | 5639 } |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5640 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 5641 |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
5642 if (!FRAME_WINDOW_P (f)) |
24995 | 5643 { |
5644 LFACE_FAMILY (lface) = build_string ("default"); | |
5645 LFACE_SWIDTH (lface) = Qnormal; | |
5646 LFACE_HEIGHT (lface) = make_number (1); | |
5647 LFACE_WEIGHT (lface) = Qnormal; | |
5648 LFACE_SLANT (lface) = Qnormal; | |
5649 } | |
5650 | |
5651 if (UNSPECIFIEDP (LFACE_UNDERLINE (lface))) | |
5652 LFACE_UNDERLINE (lface) = Qnil; | |
5653 | |
5654 if (UNSPECIFIEDP (LFACE_OVERLINE (lface))) | |
5655 LFACE_OVERLINE (lface) = Qnil; | |
5656 | |
5657 if (UNSPECIFIEDP (LFACE_STRIKE_THROUGH (lface))) | |
5658 LFACE_STRIKE_THROUGH (lface) = Qnil; | |
5659 | |
5660 if (UNSPECIFIEDP (LFACE_BOX (lface))) | |
5661 LFACE_BOX (lface) = Qnil; | |
5662 | |
5663 if (UNSPECIFIEDP (LFACE_INVERSE (lface))) | |
5664 LFACE_INVERSE (lface) = Qnil; | |
5665 | |
5666 if (UNSPECIFIEDP (LFACE_FOREGROUND (lface))) | |
5667 { | |
5668 /* This function is called so early that colors are not yet | |
5669 set in the frame parameter list. */ | |
5670 Lisp_Object color = Fassq (Qforeground_color, f->param_alist); | |
5671 | |
5672 if (CONSP (color) && STRINGP (XCDR (color))) | |
5673 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
|
5674 else if (FRAME_WINDOW_P (f)) |
24995 | 5675 return 0; |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
5676 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
|
5677 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
|
5678 else |
24995 | 5679 abort (); |
5680 } | |
5681 | |
5682 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface))) | |
5683 { | |
5684 /* This function is called so early that colors are not yet | |
5685 set in the frame parameter list. */ | |
5686 Lisp_Object color = Fassq (Qbackground_color, f->param_alist); | |
5687 if (CONSP (color) && STRINGP (XCDR (color))) | |
5688 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
|
5689 else if (FRAME_WINDOW_P (f)) |
24995 | 5690 return 0; |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
5691 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
|
5692 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
|
5693 else |
24995 | 5694 abort (); |
5695 } | |
5696 | |
5697 if (UNSPECIFIEDP (LFACE_STIPPLE (lface))) | |
5698 LFACE_STIPPLE (lface) = Qnil; | |
5699 | |
5700 /* Realize the face; it must be fully-specified now. */ | |
5701 xassert (lface_fully_specified_p (XVECTOR (lface)->contents)); | |
5702 check_lface (lface); | |
5703 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5704 face = realize_face (c, attrs, 0, NULL, DEFAULT_FACE_ID); |
24995 | 5705 return 1; |
5706 } | |
5707 | |
5708 | |
5709 /* Realize basic faces other than the default face in face cache C. | |
5710 SYMBOL is the face name, ID is the face id the realized face must | |
5711 have. The default face must have been realized already. */ | |
5712 | |
5713 static void | |
5714 realize_named_face (f, symbol, id) | |
5715 struct frame *f; | |
5716 Lisp_Object symbol; | |
5717 int id; | |
5718 { | |
5719 struct face_cache *c = FRAME_FACE_CACHE (f); | |
5720 Lisp_Object lface = lface_from_face_name (f, symbol, 0); | |
5721 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
5722 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; | |
5723 struct face *new_face; | |
5724 | |
5725 /* The default face must exist and be fully specified. */ | |
5726 get_lface_attributes (f, Qdefault, attrs, 1); | |
5727 check_lface_attrs (attrs); | |
5728 xassert (lface_fully_specified_p (attrs)); | |
5729 | |
5730 /* If SYMBOL isn't know as a face, create it. */ | |
5731 if (NILP (lface)) | |
5732 { | |
5733 Lisp_Object frame; | |
5734 XSETFRAME (frame, f); | |
5735 lface = Finternal_make_lisp_face (symbol, frame); | |
5736 } | |
5737 | |
5738 /* Merge SYMBOL's face with the default face. */ | |
5739 get_lface_attributes (f, symbol, symbol_attrs, 1); | |
5740 merge_face_vectors (symbol_attrs, attrs); | |
5741 | |
5742 /* Realize the face. */ | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5743 new_face = realize_face (c, attrs, 0, NULL, id); |
24995 | 5744 } |
5745 | |
5746 | |
5747 /* Realize the fully-specified face with attributes ATTRS in face | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5748 cache CACHE for character C. If C is a multibyte character, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5749 BASE_FACE is a face for ASCII characters that has the same |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5750 attributes. Otherwise, BASE_FACE is ignored. If FORMER_FACE_ID is |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5751 non-negative, it is an ID of face to remove before caching the new |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5752 face. Value is a pointer to the newly created realized face. */ |
24995 | 5753 |
5754 static struct face * | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5755 realize_face (cache, attrs, c, base_face, former_face_id) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5756 struct face_cache *cache; |
24995 | 5757 Lisp_Object *attrs; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5758 int c; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5759 struct face *base_face; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5760 int former_face_id; |
24995 | 5761 { |
5762 struct face *face; | |
5763 | |
5764 /* LFACE must be fully specified. */ | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5765 xassert (cache != NULL); |
24995 | 5766 check_lface_attrs (attrs); |
5767 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5768 if (former_face_id >= 0 && cache->used > former_face_id) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5769 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5770 /* Remove the former face. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5771 struct face *former_face = cache->faces_by_id[former_face_id]; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5772 uncache_face (cache, former_face); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5773 free_realized_face (cache->f, former_face); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5774 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5775 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5776 if (FRAME_WINDOW_P (cache->f)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5777 face = realize_x_face (cache, attrs, c, base_face); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5778 else if (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5779 face = realize_tty_face (cache, attrs, c); |
24995 | 5780 else |
5781 abort (); | |
5782 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5783 /* Insert the new face. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5784 cache_face (cache, face, lface_hash (attrs)); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5785 #ifdef HAVE_WINDOW_SYSTEM |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5786 if (FRAME_X_P (cache->f) && face->font == NULL) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5787 load_face_font (cache->f, face, c); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5788 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 5789 return face; |
5790 } | |
5791 | |
5792 | |
5793 /* Realize the fully-specified face with attributes ATTRS in face | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5794 cache CACHE for character C. Do it for X frame CACHE->f. If C is |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5795 a multibyte character, BASE_FACE is a face for ASCII characters |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5796 that has the same attributes. Otherwise, BASE_FACE is ignored. If |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5797 the new face doesn't share font with the default face, a fontname |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5798 is allocated from the heap and set in `font_name' of the new face, |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5799 but it is not yet loaded here. Value is a pointer to the newly |
24995 | 5800 created realized face. */ |
5801 | |
5802 static struct face * | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5803 realize_x_face (cache, attrs, c, base_face) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5804 struct face_cache *cache; |
24995 | 5805 Lisp_Object *attrs; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5806 int c; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5807 struct face *base_face; |
24995 | 5808 { |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5809 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 5810 struct face *face, *default_face; |
26875
d6aa11f2a4af
(choose_face_fontset_font): Delete codes for a
Kenichi Handa <handa@m17n.org>
parents:
26759
diff
changeset
|
5811 struct frame *f; |
24995 | 5812 Lisp_Object stipple, overline, strike_through, box; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5813 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5814 xassert (FRAME_WINDOW_P (cache->f)); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5815 xassert (SINGLE_BYTE_CHAR_P (c) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5816 || (base_face && base_face->ascii_face == base_face)); |
24995 | 5817 |
5818 /* Allocate a new realized face. */ | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5819 face = make_realized_face (attrs); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5820 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5821 f = cache->f; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5822 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5823 /* If C is a multibyte character, we share all face attirbutes with |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5824 BASE_FACE including the realized fontset. But, we must load a |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5825 different font. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5826 if (!SINGLE_BYTE_CHAR_P (c)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5827 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5828 bcopy (base_face, face, sizeof *face); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5829 face->gc = 0; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5830 face->font = NULL; /* to force realize_face to load font */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5831 return face; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5832 } |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5833 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5834 /* Now we are realizing a face for ASCII (and unibyte) characters. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5835 |
24995 | 5836 /* Determine the font to use. Most of the time, the font will be |
5837 the same as the font of the default face, so try that first. */ | |
5838 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
5839 if (default_face | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5840 && FACE_SUITABLE_FOR_CHAR_P (default_face, c) |
24995 | 5841 && lface_same_font_attributes_p (default_face->lface, attrs)) |
5842 { | |
5843 face->font = default_face->font; | |
5844 face->fontset = default_face->fontset; | |
5845 face->font_info_id = default_face->font_info_id; | |
5846 face->font_name = default_face->font_name; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5847 face->ascii_face = face; |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5848 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5849 /* But, as we can't share the fontset, make a new realized |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5850 fontset that has the same base fontset as of the default |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5851 face. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5852 face->fontset |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5853 = make_fontset_for_ascii_face (f, default_face->fontset); |
24995 | 5854 } |
5855 else | |
5856 { | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5857 /* If the face attribute ATTRS specifies a fontset, use it as |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5858 the base of a new realized fontset. Otherwise, use the |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5859 default fontset as the base. The base determines registry |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5860 and encoding of a font. It may also determine foundry and |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5861 family. The other fields of font name pattern are |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5862 constructed from ATTRS. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5863 face->fontset |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5864 = make_fontset_for_ascii_face (f, face_fontset (attrs)); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5865 face->font = NULL; /* to force realize_face to load font */ |
24995 | 5866 } |
5867 | |
5868 /* Load colors, and set remaining attributes. */ | |
5869 | |
5870 load_face_colors (f, face, attrs); | |
5871 | |
5872 /* Set up box. */ | |
5873 box = attrs[LFACE_BOX_INDEX]; | |
5874 if (STRINGP (box)) | |
5875 { | |
5876 /* A simple box of line width 1 drawn in color given by | |
5877 the string. */ | |
5878 face->box_color = load_color (f, face, attrs[LFACE_BOX_INDEX], | |
5879 LFACE_BOX_INDEX); | |
5880 face->box = FACE_SIMPLE_BOX; | |
5881 face->box_line_width = 1; | |
5882 } | |
5883 else if (INTEGERP (box)) | |
5884 { | |
5885 /* Simple box of specified line width in foreground color of the | |
5886 face. */ | |
5887 xassert (XINT (box) > 0); | |
5888 face->box = FACE_SIMPLE_BOX; | |
5889 face->box_line_width = XFASTINT (box); | |
5890 face->box_color = face->foreground; | |
5891 face->box_color_defaulted_p = 1; | |
5892 } | |
5893 else if (CONSP (box)) | |
5894 { | |
5895 /* `(:width WIDTH :color COLOR :shadow SHADOW)'. SHADOW | |
5896 being one of `raised' or `sunken'. */ | |
5897 face->box = FACE_SIMPLE_BOX; | |
5898 face->box_color = face->foreground; | |
5899 face->box_color_defaulted_p = 1; | |
5900 face->box_line_width = 1; | |
5901 | |
5902 while (CONSP (box)) | |
5903 { | |
5904 Lisp_Object keyword, value; | |
5905 | |
5906 keyword = XCAR (box); | |
5907 box = XCDR (box); | |
5908 | |
5909 if (!CONSP (box)) | |
5910 break; | |
5911 value = XCAR (box); | |
5912 box = XCDR (box); | |
5913 | |
5914 if (EQ (keyword, QCline_width)) | |
5915 { | |
5916 if (INTEGERP (value) && XINT (value) > 0) | |
5917 face->box_line_width = XFASTINT (value); | |
5918 } | |
5919 else if (EQ (keyword, QCcolor)) | |
5920 { | |
5921 if (STRINGP (value)) | |
5922 { | |
5923 face->box_color = load_color (f, face, value, | |
5924 LFACE_BOX_INDEX); | |
5925 face->use_box_color_for_shadows_p = 1; | |
5926 } | |
5927 } | |
5928 else if (EQ (keyword, QCstyle)) | |
5929 { | |
5930 if (EQ (value, Qreleased_button)) | |
5931 face->box = FACE_RAISED_BOX; | |
5932 else if (EQ (value, Qpressed_button)) | |
5933 face->box = FACE_SUNKEN_BOX; | |
5934 } | |
5935 } | |
5936 } | |
5937 | |
5938 /* Text underline, overline, strike-through. */ | |
5939 | |
5940 if (EQ (attrs[LFACE_UNDERLINE_INDEX], Qt)) | |
5941 { | |
5942 /* Use default color (same as foreground color). */ | |
5943 face->underline_p = 1; | |
5944 face->underline_defaulted_p = 1; | |
5945 face->underline_color = 0; | |
5946 } | |
5947 else if (STRINGP (attrs[LFACE_UNDERLINE_INDEX])) | |
5948 { | |
5949 /* Use specified color. */ | |
5950 face->underline_p = 1; | |
5951 face->underline_defaulted_p = 0; | |
5952 face->underline_color | |
5953 = load_color (f, face, attrs[LFACE_UNDERLINE_INDEX], | |
5954 LFACE_UNDERLINE_INDEX); | |
5955 } | |
5956 else if (NILP (attrs[LFACE_UNDERLINE_INDEX])) | |
5957 { | |
5958 face->underline_p = 0; | |
5959 face->underline_defaulted_p = 0; | |
5960 face->underline_color = 0; | |
5961 } | |
5962 | |
5963 overline = attrs[LFACE_OVERLINE_INDEX]; | |
5964 if (STRINGP (overline)) | |
5965 { | |
5966 face->overline_color | |
5967 = load_color (f, face, attrs[LFACE_OVERLINE_INDEX], | |
5968 LFACE_OVERLINE_INDEX); | |
5969 face->overline_p = 1; | |
5970 } | |
5971 else if (EQ (overline, Qt)) | |
5972 { | |
5973 face->overline_color = face->foreground; | |
5974 face->overline_color_defaulted_p = 1; | |
5975 face->overline_p = 1; | |
5976 } | |
5977 | |
5978 strike_through = attrs[LFACE_STRIKE_THROUGH_INDEX]; | |
5979 if (STRINGP (strike_through)) | |
5980 { | |
5981 face->strike_through_color | |
5982 = load_color (f, face, attrs[LFACE_STRIKE_THROUGH_INDEX], | |
5983 LFACE_STRIKE_THROUGH_INDEX); | |
5984 face->strike_through_p = 1; | |
5985 } | |
5986 else if (EQ (strike_through, Qt)) | |
5987 { | |
5988 face->strike_through_color = face->foreground; | |
5989 face->strike_through_color_defaulted_p = 1; | |
5990 face->strike_through_p = 1; | |
5991 } | |
5992 | |
5993 stipple = attrs[LFACE_STIPPLE_INDEX]; | |
5994 if (!NILP (stipple)) | |
5995 face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h); | |
5996 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
5997 xassert (FACE_SUITABLE_FOR_CHAR_P (face, c)); |
24995 | 5998 return face; |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
5999 #endif /* HAVE_WINDOW_SYSTEM */ |
24995 | 6000 } |
6001 | |
6002 | |
6003 /* Realize the fully-specified face with attributes ATTRS in face | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6004 cache CACHE for character C. Do it for TTY frame CACHE->f. Value is a |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6005 pointer to the newly created realized face. */ |
24995 | 6006 |
6007 static struct face * | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6008 realize_tty_face (cache, attrs, c) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6009 struct face_cache *cache; |
24995 | 6010 Lisp_Object *attrs; |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6011 int c; |
24995 | 6012 { |
6013 struct face *face; | |
6014 int weight, slant; | |
6015 Lisp_Object color; | |
28412
1a817fd04b31
(realize_tty_face): Use find_symbol_value instead
Gerd Moellmann <gerd@gnu.org>
parents:
28409
diff
changeset
|
6016 Lisp_Object tty_defined_color_alist |
1a817fd04b31
(realize_tty_face): Use find_symbol_value instead
Gerd Moellmann <gerd@gnu.org>
parents:
28409
diff
changeset
|
6017 = find_symbol_value (intern ("tty-defined-color-alist")); |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
6018 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
|
6019 Lisp_Object frame; |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
6020 int face_colors_defaulted = 0; |
24995 | 6021 |
6022 /* Frame must be a termcap frame. */ | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6023 xassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f)); |
24995 | 6024 |
6025 /* Allocate a new realized face. */ | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6026 face = make_realized_face (attrs); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6027 face->font_name = FRAME_MSDOS_P (cache->f) ? "ms-dos" : "tty"; |
24995 | 6028 |
6029 /* Map face attributes to TTY appearances. We map slant to | |
6030 dimmed text because we want italic text to appear differently | |
6031 and because dimmed text is probably used infrequently. */ | |
6032 weight = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]); | |
6033 slant = face_numeric_slant (attrs[LFACE_SLANT_INDEX]); | |
6034 | |
6035 if (weight > XLFD_WEIGHT_MEDIUM) | |
6036 face->tty_bold_p = 1; | |
6037 if (weight < XLFD_WEIGHT_MEDIUM || slant != XLFD_SLANT_ROMAN) | |
6038 face->tty_dim_p = 1; | |
6039 if (!NILP (attrs[LFACE_UNDERLINE_INDEX])) | |
6040 face->tty_underline_p = 1; | |
6041 if (!NILP (attrs[LFACE_INVERSE_INDEX])) | |
6042 face->tty_reverse_p = 1; | |
6043 | |
6044 /* 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
|
6045 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
|
6046 face->background = FACE_TTY_DEFAULT_BG_COLOR; |
24995 | 6047 |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6048 XSETFRAME (frame, cache->f); |
24995 | 6049 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
|
6050 if (STRINGP (color) |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
6051 && XSTRING (color)->size |
28412
1a817fd04b31
(realize_tty_face): Use find_symbol_value instead
Gerd Moellmann <gerd@gnu.org>
parents:
28409
diff
changeset
|
6052 && CONSP (tty_defined_color_alist) |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
6053 && (color = Fassoc (color, call1 (tty_color_alist, frame)), |
24995 | 6054 CONSP (color))) |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
6055 /* 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
|
6056 (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
|
6057 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
|
6058 |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6059 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
|
6060 && STRINGP (attrs[LFACE_FOREGROUND_INDEX])) |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6061 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6062 face->foreground = load_color (cache->f, face, |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6063 attrs[LFACE_FOREGROUND_INDEX], |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6064 LFACE_FOREGROUND_INDEX); |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6065 |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6066 #if defined (MSDOS) || defined (WINDOWSNT) |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6067 /* 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
|
6068 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
|
6069 #ifdef MSDOS |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6070 if (FRAME_MSDOS_P (cache->f)) |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6071 { |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6072 #endif /* MSDOS */ |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6073 |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6074 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
|
6075 || face->foreground == FACE_TTY_DEFAULT_COLOR) |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6076 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6077 face->foreground = FRAME_FOREGROUND_PIXEL (cache->f); |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6078 attrs[LFACE_FOREGROUND_INDEX] = |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6079 tty_color_name (cache->f, face->foreground); |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6080 face_colors_defaulted = 1; |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6081 } |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6082 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
|
6083 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6084 face->foreground = FRAME_BACKGROUND_PIXEL (cache->f); |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6085 attrs[LFACE_FOREGROUND_INDEX] = |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6086 tty_color_name (cache->f, face->foreground); |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6087 face_colors_defaulted = 1; |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6088 } |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6089 #ifdef MSDOS |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6090 } |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
6091 #endif |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6092 #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
|
6093 } |
25114
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
6094 |
24995 | 6095 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
|
6096 if (STRINGP (color) |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
6097 && XSTRING (color)->size |
28412
1a817fd04b31
(realize_tty_face): Use find_symbol_value instead
Gerd Moellmann <gerd@gnu.org>
parents:
28409
diff
changeset
|
6098 && CONSP (tty_defined_color_alist) |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
6099 && (color = Fassoc (color, call1 (tty_color_alist, frame)), |
24995 | 6100 CONSP (color))) |
27088
23bd823f11f4
(tty_defined_color): Pass frame to tty-color-desc. The
Eli Zaretskii <eliz@gnu.org>
parents:
26976
diff
changeset
|
6101 /* 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
|
6102 (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
|
6103 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
|
6104 |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6105 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
|
6106 && STRINGP (attrs[LFACE_BACKGROUND_INDEX])) |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6107 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6108 face->background = load_color (cache->f, face, |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6109 attrs[LFACE_BACKGROUND_INDEX], |
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6110 LFACE_BACKGROUND_INDEX); |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6111 #if defined (MSDOS) || defined (WINDOWSNT) |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6112 /* 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
|
6113 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
|
6114 #ifdef MSDOS |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6115 if (FRAME_MSDOS_P (cache->f)) |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6116 { |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6117 #endif /* MSDOS */ |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6118 |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6119 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
|
6120 || face->background == FACE_TTY_DEFAULT_COLOR) |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6121 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6122 face->background = FRAME_BACKGROUND_PIXEL (cache->f); |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6123 attrs[LFACE_BACKGROUND_INDEX] = |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6124 tty_color_name (cache->f, face->background); |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6125 face_colors_defaulted = 1; |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6126 } |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6127 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
|
6128 { |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6129 face->background = FRAME_FOREGROUND_PIXEL (cache->f); |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6130 attrs[LFACE_BACKGROUND_INDEX] = |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6131 tty_color_name (cache->f, face->background); |
26902
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6132 face_colors_defaulted = 1; |
264b83a3a688
Changes for separate unspecified foreground and background colors
Eli Zaretskii <eliz@gnu.org>
parents:
26875
diff
changeset
|
6133 } |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6134 #ifdef MSDOS |
25213
11d01c90da6d
(realize_default_face) [MSDOS]: Don't take default
Eli Zaretskii <eliz@gnu.org>
parents:
25114
diff
changeset
|
6135 } |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
6136 #endif |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6137 #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
|
6138 } |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
6139 |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
6140 /* 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
|
6141 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
|
6142 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
|
6143 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
|
6144 { |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
6145 unsigned long tem = face->foreground; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
6146 |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
6147 face->foreground = face->background; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
6148 face->background = tem; |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
6149 } |
be5d3e21fbd7
(load_color): Remove static from definition and remove
Eli Zaretskii <eliz@gnu.org>
parents:
25092
diff
changeset
|
6150 |
24995 | 6151 return face; |
6152 } | |
6153 | |
6154 | |
6155 | |
6156 /*********************************************************************** | |
6157 Computing Faces | |
6158 ***********************************************************************/ | |
6159 | |
6160 /* Return the ID of the face to use to display character CH with face | |
6161 property PROP on frame F in current_buffer. */ | |
6162 | |
6163 int | |
6164 compute_char_face (f, ch, prop) | |
6165 struct frame *f; | |
6166 int ch; | |
6167 Lisp_Object prop; | |
6168 { | |
6169 int face_id; | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6170 |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6171 if (NILP (current_buffer->enable_multibyte_characters)) |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6172 ch = -1; |
24995 | 6173 |
6174 if (NILP (prop)) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6175 { |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6176 struct face *face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6177 face_id = FACE_FOR_CHAR (f, face, ch); |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6178 } |
24995 | 6179 else |
6180 { | |
6181 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
6182 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); | |
6183 bcopy (default_face->lface, attrs, sizeof attrs); | |
6184 merge_face_vector_with_property (f, attrs, prop); | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6185 face_id = lookup_face (f, attrs, ch, NULL); |
24995 | 6186 } |
6187 | |
6188 return face_id; | |
6189 } | |
6190 | |
6191 | |
6192 /* Return the face ID associated with buffer position POS for | |
6193 displaying ASCII characters. Return in *ENDPTR the position at | |
6194 which a different face is needed, as far as text properties and | |
6195 overlays are concerned. W is a window displaying current_buffer. | |
6196 | |
6197 REGION_BEG, REGION_END delimit the region, so it can be | |
6198 highlighted. | |
6199 | |
6200 LIMIT is a position not to scan beyond. That is to limit the time | |
6201 this function can take. | |
6202 | |
6203 If MOUSE is non-zero, use the character's mouse-face, not its face. | |
6204 | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6205 The face returned is suitable for displaying ASCII characters. */ |
24995 | 6206 |
6207 int | |
6208 face_at_buffer_position (w, pos, region_beg, region_end, | |
6209 endptr, limit, mouse) | |
2391 | 6210 struct window *w; |
2342 | 6211 int pos; |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6212 int region_beg, region_end; |
2342 | 6213 int *endptr; |
5084
863e092a5891
(compute_char_face): Accept new arg LIMIT.
Richard M. Stallman <rms@gnu.org>
parents:
4696
diff
changeset
|
6214 int limit; |
6615
96ddf85642d1
(compute_char_face): New arg MOUSE.
Richard M. Stallman <rms@gnu.org>
parents:
5858
diff
changeset
|
6215 int mouse; |
2342 | 6216 { |
24995 | 6217 struct frame *f = XFRAME (w->frame); |
6218 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
|
6219 Lisp_Object prop, position; |
24995 | 6220 int i, noverlays; |
2342 | 6221 Lisp_Object *overlay_vec; |
2391 | 6222 Lisp_Object frame; |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
6223 int endpos; |
24995 | 6224 Lisp_Object propname = mouse ? Qmouse_face : Qface; |
6225 Lisp_Object limit1, end; | |
6226 struct face *default_face; | |
6227 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
|
6228 |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
6229 /* 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
|
6230 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
|
6231 /* xassert (XBUFFER (w->buffer) == current_buffer); */ |
2391 | 6232 |
9284
a969e0eefaf5
(compute_char_face): Use new accessor macros instead of calling XSET directly.
Karl Heuer <kwzh@gnu.org>
parents:
9186
diff
changeset
|
6233 XSETFRAME (frame, f); |
24995 | 6234 XSETFASTINT (position, pos); |
2342 | 6235 |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
6236 endpos = ZV; |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6237 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
|
6238 endpos = region_beg; |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
6239 |
24995 | 6240 /* Get the `face' or `mouse_face' text property at POS, and |
6241 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
|
6242 prop = Fget_text_property (position, propname, w->buffer); |
24995 | 6243 XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); |
6244 end = Fnext_single_property_change (position, propname, w->buffer, limit1); | |
6245 if (INTEGERP (end)) | |
6246 endpos = XINT (end); | |
6247 | |
6248 /* 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
|
6249 { |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
6250 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
|
6251 int len; |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
6252 |
2838
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
6253 /* 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
|
6254 len = 40; |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
6255 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
|
6256 noverlays = overlays_at (pos, 0, &overlay_vec, &len, |
24995 | 6257 &next_overlay, NULL); |
6258 | |
6259 /* If there are more than 40, make enough space for all, and try | |
6260 again. */ | |
2838
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
6261 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
|
6262 { |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
6263 len = noverlays; |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
6264 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
|
6265 noverlays = overlays_at (pos, 0, &overlay_vec, &len, |
24995 | 6266 &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
|
6267 } |
5f6a2d52d2ef
(compute_char_face): Pass 0 as EXTEND arg to overlays_at.
Richard M. Stallman <rms@gnu.org>
parents:
2821
diff
changeset
|
6268 |
2784
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
6269 if (next_overlay < endpos) |
f8c6796b7777
* xfaces.c (compute_char_face): When merging the overlays,
Jim Blandy <jimb@redhat.com>
parents:
2767
diff
changeset
|
6270 endpos = next_overlay; |
2767
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
6271 } |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
6272 |
482fa0725db6
* xfaces.c (intern_frame_face): Exchange order of arguments, to
Jim Blandy <jimb@redhat.com>
parents:
2743
diff
changeset
|
6273 *endptr = endpos; |
2342 | 6274 |
24995 | 6275 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
6276 | |
6277 /* Optimize common cases where we can use the default face. */ | |
6278 if (noverlays == 0 | |
6279 && NILP (prop) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6280 && !(pos >= region_beg && pos < region_end)) |
24995 | 6281 return DEFAULT_FACE_ID; |
6282 | |
6283 /* Begin with attributes from the default face. */ | |
6284 bcopy (default_face->lface, attrs, sizeof attrs); | |
6285 | |
6286 /* Merge in attributes specified via text properties. */ | |
6287 if (!NILP (prop)) | |
6288 merge_face_vector_with_property (f, attrs, prop); | |
6289 | |
6290 /* 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
|
6291 noverlays = sort_overlays (overlay_vec, noverlays, w); |
2342 | 6292 for (i = 0; i < noverlays; i++) |
6293 { | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6294 Lisp_Object oend; |
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6295 int oendpos; |
9186
45bac5feb065
(compute_char_face): Handle list as overlay face property.
Richard M. Stallman <rms@gnu.org>
parents:
9184
diff
changeset
|
6296 |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6297 prop = Foverlay_get (overlay_vec[i], propname); |
24995 | 6298 if (!NILP (prop)) |
6299 merge_face_vector_with_property (f, attrs, prop); | |
2342 | 6300 |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6301 oend = OVERLAY_END (overlay_vec[i]); |
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6302 oendpos = OVERLAY_POSITION (oend); |
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6303 if (oendpos < endpos) |
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6304 endpos = oendpos; |
2342 | 6305 } |
6306 | |
24995 | 6307 /* 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
|
6308 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
|
6309 { |
24995 | 6310 Lisp_Object region_face = lface_from_face_name (f, Qregion, 0); |
6311 merge_face_vectors (XVECTOR (region_face)->contents, attrs); | |
6312 | |
2795
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6313 if (region_end < endpos) |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6314 endpos = region_end; |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6315 } |
e97e96fb0cb8
(compute_char_face): New args REGION_BEG, REGION_END.
Richard M. Stallman <rms@gnu.org>
parents:
2784
diff
changeset
|
6316 |
2342 | 6317 *endptr = endpos; |
6318 | |
24995 | 6319 /* Look up a realized face with the given face attributes, |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6320 or realize a new one for ASCII characters. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6321 return lookup_face (f, attrs, 0, NULL); |
2342 | 6322 } |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6323 |
24995 | 6324 |
6325 /* Compute the face at character position POS in Lisp string STRING on | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6326 window W, for ASCII characters. |
24995 | 6327 |
6328 If STRING is an overlay string, it comes from position BUFPOS in | |
6329 current_buffer, otherwise BUFPOS is zero to indicate that STRING is | |
6330 not an overlay string. W must display the current buffer. | |
6331 REGION_BEG and REGION_END give the start and end positions of the | |
6332 region; both are -1 if no region is visible. BASE_FACE_ID is the | |
6333 id of the basic face to merge with. It is usually equal to | |
25546 | 6334 DEFAULT_FACE_ID but can be MODE_LINE_FACE_ID or HEADER_LINE_FACE_ID |
24995 | 6335 for strings displayed in the mode or top line. |
6336 | |
6337 Set *ENDPTR to the next position where to check for faces in | |
6338 STRING; -1 if the face is constant from POS to the end of the | |
6339 string. | |
6340 | |
6341 Value is the id of the face to use. The face returned is suitable | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6342 for displaying ASCII characters. */ |
24995 | 6343 |
6344 int | |
6345 face_at_string_position (w, string, pos, bufpos, region_beg, | |
6346 region_end, endptr, base_face_id) | |
6347 struct window *w; | |
6348 Lisp_Object string; | |
6349 int pos, bufpos; | |
6350 int region_beg, region_end; | |
6351 int *endptr; | |
6352 enum face_id base_face_id; | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6353 { |
24995 | 6354 Lisp_Object prop, position, end, limit; |
6355 struct frame *f = XFRAME (WINDOW_FRAME (w)); | |
6356 Lisp_Object attrs[LFACE_VECTOR_SIZE]; | |
6357 struct face *base_face; | |
6358 int multibyte_p = STRING_MULTIBYTE (string); | |
6359 | |
6360 /* Get the value of the face property at the current position within | |
6361 STRING. Value is nil if there is no face property. */ | |
6362 XSETFASTINT (position, pos); | |
6363 prop = Fget_text_property (position, Qface, string); | |
6364 | |
6365 /* Get the next position at which to check for faces. Value of end | |
6366 is nil if face is constant all the way to the end of the string. | |
6367 Otherwise it is a string position where to check faces next. | |
6368 Limit is the maximum position up to which to check for property | |
6369 changes in Fnext_single_property_change. Strings are usually | |
6370 short, so set the limit to the end of the string. */ | |
6371 XSETFASTINT (limit, XSTRING (string)->size); | |
6372 end = Fnext_single_property_change (position, Qface, string, limit); | |
6373 if (INTEGERP (end)) | |
6374 *endptr = XFASTINT (end); | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6375 else |
24995 | 6376 *endptr = -1; |
6377 | |
6378 base_face = FACE_FROM_ID (f, base_face_id); | |
6379 xassert (base_face); | |
6380 | |
6381 /* Optimize the default case that there is no face property and we | |
6382 are not in the region. */ | |
6383 if (NILP (prop) | |
6384 && (base_face_id != DEFAULT_FACE_ID | |
6385 /* BUFPOS <= 0 means STRING is not an overlay string, so | |
6386 that the region doesn't have to be taken into account. */ | |
6387 || bufpos <= 0 | |
6388 || bufpos < region_beg | |
6389 || bufpos >= region_end) | |
6390 && (multibyte_p | |
6391 /* We can't realize faces for different charsets differently | |
6392 if we don't have fonts, so we can stop here if not working | |
6393 on a window-system frame. */ | |
6394 || !FRAME_WINDOW_P (f) | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6395 || FACE_SUITABLE_FOR_CHAR_P (base_face, 0))) |
24995 | 6396 return base_face->id; |
6397 | |
6398 /* Begin with attributes from the base face. */ | |
6399 bcopy (base_face->lface, attrs, sizeof attrs); | |
6400 | |
6401 /* Merge in attributes specified via text properties. */ | |
6402 if (!NILP (prop)) | |
6403 merge_face_vector_with_property (f, attrs, prop); | |
6404 | |
6405 /* If in the region, merge in the region face. */ | |
6406 if (bufpos | |
6407 && bufpos >= region_beg | |
6408 && bufpos < region_end) | |
19128
e789b647f15b
(merge_face_list): New function.
Richard M. Stallman <rms@gnu.org>
parents:
18723
diff
changeset
|
6409 { |
24995 | 6410 Lisp_Object region_face = lface_from_face_name (f, Qregion, 0); |
6411 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
|
6412 } |
24995 | 6413 |
6414 /* Look up a realized face with the given face attributes, | |
28230
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6415 or realize a new one for ASCII characters. */ |
8e330f701881
(Qx_charset_registry, Vface_default_registry):
Kenichi Handa <handa@m17n.org>
parents:
27984
diff
changeset
|
6416 return lookup_face (f, attrs, 0, NULL); |
3074
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
6417 } |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
6418 |
96b4623fdeb3
* xterm.h: New section for declarations for xfaces.c.
Jim Blandy <jimb@redhat.com>
parents:
3065
diff
changeset
|
6419 |
2336 | 6420 |
24995 | 6421 /*********************************************************************** |
6422 Tests | |
6423 ***********************************************************************/ | |
6424 | |
6425 #if GLYPH_DEBUG | |
6426 | |
6427 /* Print the contents of the realized face FACE to stderr. */ | |
6428 | |
6429 static void | |
6430 dump_realized_face (face) | |
6431 struct face *face; | |
2336 | 6432 { |
24995 | 6433 fprintf (stderr, "ID: %d\n", face->id); |
6434 #ifdef HAVE_X_WINDOWS | |
6435 fprintf (stderr, "gc: %d\n", (int) face->gc); | |
6436 #endif | |
6437 fprintf (stderr, "foreground: 0x%lx (%s)\n", | |
6438 face->foreground, | |
6439 XSTRING (face->lface[LFACE_FOREGROUND_INDEX])->data); | |
6440 fprintf (stderr, "background: 0x%lx (%s)\n", | |
6441 face->background, | |
6442 XSTRING (face->lface[LFACE_BACKGROUND_INDEX])->data); | |
6443 fprintf (stderr, "font_name: %s (%s)\n", | |
6444 face->font_name, | |
6445 XSTRING (face->lface[LFACE_FAMILY_INDEX])->data); | |
6446 #ifdef HAVE_X_WINDOWS | |
6447 fprintf (stderr, "font = %p\n", face->font); | |
6448 #endif | |
6449 fprintf (stderr, "font_info_id = %d\n", face->font_info_id); | |
6450 fprintf (stderr, "fontset: %d\n", face->fontset); | |
6451 fprintf (stderr, "underline: %d (%s)\n", | |
6452 face->underline_p, | |
6453 XSTRING (Fsymbol_name (face->lface[LFACE_UNDERLINE_INDEX]))->data); | |
6454 fprintf (stderr, "hash: %d\n", face->hash); | |
6455 fprintf (stderr, "charset: %d\n", face->charset); | |
6456 } | |
6457 | |
6458 | |
6459 DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, "") | |
6460 (n) | |
6461 Lisp_Object n; | |
6462 { | |
6463 if (NILP (n)) | |
2336 | 6464 { |
24995 | 6465 int i; |
6466 | |
6467 fprintf (stderr, "font selection order: "); | |
6468 for (i = 0; i < DIM (font_sort_order); ++i) | |
6469 fprintf (stderr, "%d ", font_sort_order[i]); | |
6470 fprintf (stderr, "\n"); | |
6471 | |
6472 fprintf (stderr, "alternative fonts: "); | |
6473 debug_print (Vface_alternative_font_family_alist); | |
6474 fprintf (stderr, "\n"); | |
6475 | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
6476 for (i = 0; i < FRAME_FACE_CACHE (SELECTED_FRAME ())->used; ++i) |
24995 | 6477 Fdump_face (make_number (i)); |
2336 | 6478 } |
24995 | 6479 else |
6480 { | |
6481 struct face *face; | |
6482 CHECK_NUMBER (n, 0); | |
25678
1878f7ae0df5
(frame_or_selected_frame): Change for Lisp_Object
Gerd Moellmann <gerd@gnu.org>
parents:
25661
diff
changeset
|
6483 face = FACE_FROM_ID (SELECTED_FRAME (), XINT (n)); |
24995 | 6484 if (face == NULL) |
6485 error ("Not a valid face"); | |
6486 dump_realized_face (face); | |
6487 } | |
6488 | |
2336 | 6489 return Qnil; |
6490 } | |
6491 | |
6492 | |
24995 | 6493 DEFUN ("show-face-resources", Fshow_face_resources, Sshow_face_resources, |
6494 0, 0, 0, "") | |
6495 () | |
2336 | 6496 { |
24995 | 6497 fprintf (stderr, "number of colors = %d\n", ncolors_allocated); |
6498 fprintf (stderr, "number of pixmaps = %d\n", npixmaps_allocated); | |
6499 fprintf (stderr, "number of GCs = %d\n", ngcs); | |
2336 | 6500 return Qnil; |
6501 } | |
24995 | 6502 |
6503 #endif /* GLYPH_DEBUG != 0 */ | |
6504 | |
18083
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
6505 |
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
6506 |
24995 | 6507 /*********************************************************************** |
6508 Initialization | |
6509 ***********************************************************************/ | |
2730
139740855fa6
* xfaces.c (Fmake_face_internal): Do nothing for non-X frames.
Jim Blandy <jimb@redhat.com>
parents:
2538
diff
changeset
|
6510 |
2336 | 6511 void |
2391 | 6512 syms_of_xfaces () |
2336 | 6513 { |
2391 | 6514 Qface = intern ("face"); |
6515 staticpro (&Qface); | |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
6516 Qbitmap_spec_p = intern ("bitmap-spec-p"); |
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
6517 staticpro (&Qbitmap_spec_p); |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6518 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
|
6519 staticpro (&Qframe_update_face_colors); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6520 |
24995 | 6521 /* Lisp face attribute keywords. */ |
6522 QCfamily = intern (":family"); | |
6523 staticpro (&QCfamily); | |
6524 QCheight = intern (":height"); | |
6525 staticpro (&QCheight); | |
6526 QCweight = intern (":weight"); | |
6527 staticpro (&QCweight); | |
6528 QCslant = intern (":slant"); | |
6529 staticpro (&QCslant); | |
6530 QCunderline = intern (":underline"); | |
6531 staticpro (&QCunderline); | |
6532 QCinverse_video = intern (":inverse-video"); | |
6533 staticpro (&QCinverse_video); | |
6534 QCreverse_video = intern (":reverse-video"); | |
6535 staticpro (&QCreverse_video); | |
6536 QCforeground = intern (":foreground"); | |
6537 staticpro (&QCforeground); | |
6538 QCbackground = intern (":background"); | |
6539 staticpro (&QCbackground); | |
6540 QCstipple = intern (":stipple");; | |
6541 staticpro (&QCstipple); | |
6542 QCwidth = intern (":width"); | |
6543 staticpro (&QCwidth); | |
6544 QCfont = intern (":font"); | |
6545 staticpro (&QCfont); | |
6546 QCbold = intern (":bold"); | |
6547 staticpro (&QCbold); | |
6548 QCitalic = intern (":italic"); | |
6549 staticpro (&QCitalic); | |
6550 QCoverline = intern (":overline"); | |
6551 staticpro (&QCoverline); | |
6552 QCstrike_through = intern (":strike-through"); | |
6553 staticpro (&QCstrike_through); | |
6554 QCbox = intern (":box"); | |
6555 staticpro (&QCbox); | |
6556 | |
6557 /* Symbols used for Lisp face attribute values. */ | |
6558 QCcolor = intern (":color"); | |
6559 staticpro (&QCcolor); | |
6560 QCline_width = intern (":line-width"); | |
6561 staticpro (&QCline_width); | |
6562 QCstyle = intern (":style"); | |
6563 staticpro (&QCstyle); | |
6564 Qreleased_button = intern ("released-button"); | |
6565 staticpro (&Qreleased_button); | |
6566 Qpressed_button = intern ("pressed-button"); | |
6567 staticpro (&Qpressed_button); | |
6568 Qnormal = intern ("normal"); | |
6569 staticpro (&Qnormal); | |
6570 Qultra_light = intern ("ultra-light"); | |
6571 staticpro (&Qultra_light); | |
6572 Qextra_light = intern ("extra-light"); | |
6573 staticpro (&Qextra_light); | |
6574 Qlight = intern ("light"); | |
6575 staticpro (&Qlight); | |
6576 Qsemi_light = intern ("semi-light"); | |
6577 staticpro (&Qsemi_light); | |
6578 Qsemi_bold = intern ("semi-bold"); | |
6579 staticpro (&Qsemi_bold); | |
6580 Qbold = intern ("bold"); | |
6581 staticpro (&Qbold); | |
6582 Qextra_bold = intern ("extra-bold"); | |
6583 staticpro (&Qextra_bold); | |
6584 Qultra_bold = intern ("ultra-bold"); | |
6585 staticpro (&Qultra_bold); | |
6586 Qoblique = intern ("oblique"); | |
6587 staticpro (&Qoblique); | |
6588 Qitalic = intern ("italic"); | |
6589 staticpro (&Qitalic); | |
6590 Qreverse_oblique = intern ("reverse-oblique"); | |
6591 staticpro (&Qreverse_oblique); | |
6592 Qreverse_italic = intern ("reverse-italic"); | |
6593 staticpro (&Qreverse_italic); | |
6594 Qultra_condensed = intern ("ultra-condensed"); | |
6595 staticpro (&Qultra_condensed); | |
6596 Qextra_condensed = intern ("extra-condensed"); | |
6597 staticpro (&Qextra_condensed); | |
6598 Qcondensed = intern ("condensed"); | |
6599 staticpro (&Qcondensed); | |
6600 Qsemi_condensed = intern ("semi-condensed"); | |
6601 staticpro (&Qsemi_condensed); | |
6602 Qsemi_expanded = intern ("semi-expanded"); | |
6603 staticpro (&Qsemi_expanded); | |
6604 Qexpanded = intern ("expanded"); | |
6605 staticpro (&Qexpanded); | |
6606 Qextra_expanded = intern ("extra-expanded"); | |
6607 staticpro (&Qextra_expanded); | |
6608 Qultra_expanded = intern ("ultra-expanded"); | |
6609 staticpro (&Qultra_expanded); | |
6610 Qbackground_color = intern ("background-color"); | |
6611 staticpro (&Qbackground_color); | |
6612 Qforeground_color = intern ("foreground-color"); | |
6613 staticpro (&Qforeground_color); | |
6614 Qunspecified = intern ("unspecified"); | |
6615 staticpro (&Qunspecified); | |
6616 | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6617 Qface_alias = intern ("face-alias"); |
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6618 staticpro (&Qface_alias); |
24995 | 6619 Qdefault = intern ("default"); |
6620 staticpro (&Qdefault); | |
25544
693ca9ba497a
Change spelling of `toolbar' to `tool_bar' or `tool-bar'.
Gerd Moellmann <gerd@gnu.org>
parents:
25389
diff
changeset
|
6621 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
|
6622 staticpro (&Qtool_bar); |
24995 | 6623 Qregion = intern ("region"); |
6624 staticpro (&Qregion); | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6625 Qfringe = intern ("fringe"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6626 staticpro (&Qfringe); |
25546 | 6627 Qheader_line = intern ("header-line"); |
6628 staticpro (&Qheader_line); | |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6629 Qscroll_bar = intern ("scroll-bar"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6630 staticpro (&Qscroll_bar); |
25883
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
6631 Qmenu = intern ("menu"); |
2955c353186a
(toplevel) [USE_MOTIF]: Include some Motif headers.
Gerd Moellmann <gerd@gnu.org>
parents:
25799
diff
changeset
|
6632 staticpro (&Qmenu); |
25592
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6633 Qcursor = intern ("cursor"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6634 staticpro (&Qcursor); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6635 Qborder = intern ("border"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6636 staticpro (&Qborder); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6637 Qmouse = intern ("mouse"); |
c6be980d15a6
(recompute_basic_faces): Clear face cache.
Gerd Moellmann <gerd@gnu.org>
parents:
25546
diff
changeset
|
6638 staticpro (&Qmouse); |
26729
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
6639 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
|
6640 staticpro (&Qtty_color_desc); |
f5dded41adcc
Changes for automatic remapping of X colors on terminal frames:
Eli Zaretskii <eliz@gnu.org>
parents:
26601
diff
changeset
|
6641 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
|
6642 staticpro (&Qtty_color_by_index); |
24995 | 6643 |
6644 defsubr (&Sinternal_make_lisp_face); | |
6645 defsubr (&Sinternal_lisp_face_p); | |
6646 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
|
6647 #ifdef HAVE_WINDOW_SYSTEM |
24995 | 6648 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
|
6649 #endif |
27120
24a08208cf3a
(syms_of_xfaces): Change Sface_color_gray_p to
Gerd Moellmann <gerd@gnu.org>
parents:
27114
diff
changeset
|
6650 defsubr (&Scolor_gray_p); |
24a08208cf3a
(syms_of_xfaces): Change Sface_color_gray_p to
Gerd Moellmann <gerd@gnu.org>
parents:
27114
diff
changeset
|
6651 defsubr (&Scolor_supported_p); |
24995 | 6652 defsubr (&Sinternal_get_lisp_face_attribute); |
6653 defsubr (&Sinternal_lisp_face_attribute_values); | |
6654 defsubr (&Sinternal_lisp_face_equal_p); | |
6655 defsubr (&Sinternal_lisp_face_empty_p); | |
6656 defsubr (&Sinternal_copy_lisp_face); | |
6657 defsubr (&Sinternal_merge_in_global_face); | |
6658 defsubr (&Sface_font); | |
6659 defsubr (&Sframe_face_alist); | |
6660 defsubr (&Sinternal_set_font_selection_order); | |
6661 defsubr (&Sinternal_set_alternative_font_family_alist); | |
6662 #if GLYPH_DEBUG | |
6663 defsubr (&Sdump_face); | |
6664 defsubr (&Sshow_face_resources); | |
6665 #endif /* GLYPH_DEBUG */ | |
6666 defsubr (&Sclear_face_cache); | |
6667 | |
25270 | 6668 DEFVAR_LISP ("font-list-limit", &Vfont_list_limit, |
6669 "*Limit for font matching.\n\ | |
6670 If an integer > 0, font matching functions won't load more than\n\ | |
6671 that number of fonts when searching for a matching font."); | |
6672 Vfont_list_limit = make_number (DEFAULT_FONT_LIST_LIMIT); | |
6673 | |
24995 | 6674 DEFVAR_LISP ("face-new-frame-defaults", &Vface_new_frame_defaults, |
6675 "List of global face definitions (for internal use only.)"); | |
6676 Vface_new_frame_defaults = Qnil; | |
6677 | |
6678 DEFVAR_LISP ("face-default-stipple", &Vface_default_stipple, | |
6679 "*Default stipple pattern used on monochrome displays.\n\ | |
6680 This stipple pattern is used on monochrome displays\n\ | |
6681 instead of shades of gray for a face background color.\n\ | |
6682 See `set-face-stipple' for possible values for this variable."); | |
6683 Vface_default_stipple = build_string ("gray3"); | |
6684 | |
6685 DEFVAR_LISP ("face-alternative-font-family-alist", | |
6686 &Vface_alternative_font_family_alist, ""); | |
6687 Vface_alternative_font_family_alist = Qnil; | |
6688 | |
6689 #if SCALABLE_FONTS | |
6690 | |
6691 DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed, | |
6692 "Allowed scalable fonts.\n\ | |
6693 A value of nil means don't allow any scalable fonts.\n\ | |
6694 A value of t means allow any scalable font.\n\ | |
6695 Otherwise, value must be a list of regular expressions. A font may be\n\ | |
6696 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
|
6697 #ifdef WINDOWSNT |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6698 /* 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
|
6699 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
|
6700 Vscalable_fonts_allowed = Qt; |
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6701 #else |
24995 | 6702 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
|
6703 #endif |
24995 | 6704 #endif /* SCALABLE_FONTS */ |
18083
c361afa561c5
Include frame.h unconditionally.
Richard M. Stallman <rms@gnu.org>
parents:
17047
diff
changeset
|
6705 |
27982
86de01dd01eb
Change many FRAME_X... macros to FRAME_WINDOW... or other
Jason Rumney <jasonr@gnu.org>
parents:
27960
diff
changeset
|
6706 #ifdef HAVE_WINDOW_SYSTEM |
25890
b10a34d40b55
(Qbitmap_spec_p): Replaces Qpixmap_spec_p.
Gerd Moellmann <gerd@gnu.org>
parents:
25883
diff
changeset
|
6707 defsubr (&Sbitmap_spec_p); |
24995 | 6708 defsubr (&Sx_list_fonts); |
6709 defsubr (&Sinternal_face_x_get_resource); | |
25661
a6e2ae7964fb
(Fx_family_fonts): Replaces Fx_font_list.
Gerd Moellmann <gerd@gnu.org>
parents:
25592
diff
changeset
|
6710 defsubr (&Sx_family_fonts); |
24995 | 6711 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
|
6712 #endif /* HAVE_WINDOW_SYSTEM */ |
2336 | 6713 } |