Mercurial > emacs
annotate src/w32faces.c @ 27488:f2b4d355b3e2
Fix use of mark-active in examples.
author | Dave Love <fx@gnu.org> |
---|---|
date | Fri, 28 Jan 2000 22:58:46 +0000 |
parents | 323eb9ca333f |
children | d0c413d1b2c2 |
rev | line source |
---|---|
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1 /* xfaces.c -- "Face" primitives. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2 Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation. |
13434 | 3 |
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 | |
8 the Free Software Foundation; either version 2, or (at your option) | |
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:
14036
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:
14036
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
13434 | 20 |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
21 /* New face implementation by Gerd Moellmann <gerd@gnu.org>. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
22 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
23 /* Faces. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
24 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
25 When using Emacs with X, the display style of characters can be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
26 changed by defining `faces'. Each face can specify the following |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
27 display attributes: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
28 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
29 1. Font family or fontset alias name. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
30 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
31 2. Relative proportionate width, aka character set width or set |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
32 width (swidth), e.g. `semi-compressed'. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
33 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
34 3. Font height in 1/10pt |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
35 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
36 4. Font weight, e.g. `bold'. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
37 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
38 5. Font slant, e.g. `italic'. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
39 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
40 6. Foreground color. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
41 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
42 7. Background color. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
43 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
44 8. Whether or not characters should be underlined, and in what color. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
45 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
46 9. Whether or not characters should be displayed in inverse video. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
47 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
48 10. A background stipple, a bitmap. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
49 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
50 11. Whether or not characters should be overlined, and in what color. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
51 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
52 12. Whether or not characters should be strike-through, and in what |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
53 color. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
54 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
55 13. Whether or not a box should be drawn around characters, the box |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
56 type, and, for simple boxes, in what color. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
57 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
58 Faces are frame-local by nature because Emacs allows to define the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
59 same named face (face names are symbols) differently for different |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
60 frames. Each frame has an alist of face definitions for all named |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
61 faces. The value of a named face in such an alist is a Lisp vector |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
62 with the symbol `face' in slot 0, and a slot for each each of the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
63 face attributes mentioned above. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
64 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
65 There is also a global face alist `Vface_new_frame_defaults'. Face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
66 definitions from this list are used to initialize faces of newly |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
67 created frames. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
68 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
69 A face doesn't have to specify all attributes. Those not specified |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
70 have a value of `unspecified'. Faces specifying all attributes are |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
71 called `fully-specified'. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
72 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
73 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
74 Face merging. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
75 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
76 The display style of a given character in the text is determined by |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
77 combining several faces. This process is called `face merging'. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
78 Any aspect of the display style that isn't specified by overlays or |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
79 text properties is taken from the `default' face. Since it is made |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
80 sure that the default face is always fully-specified, face merging |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
81 always results in a fully-specified face. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
82 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
83 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
84 Face realization. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
85 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
86 After all face attributes for a character have been determined by |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
87 merging faces of that character, that face is `realized'. The |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
88 realization process maps face attributes to what is physically |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
89 available on the system where Emacs runs. The result is a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
90 `realized face' in form of a struct face which is stored in the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
91 face cache of the frame on which it was realized. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
92 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
93 Face realization is done in the context of the charset of the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
94 character to display because different fonts and encodings are used |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
95 for different charsets. In other words, for characters of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
96 different charsets, different realized faces are needed to display |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
97 them. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
98 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
99 Faces are always realized for a specific character set and contain |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
100 a specific font, even if the face being realized specifies a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
101 fontset (see `font selection' below). The reason is that the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
102 result of the new font selection stage is better than what can be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
103 done with statically defined font name patterns in fontsets. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
104 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
105 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
106 Unibyte text. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
107 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
108 In unibyte text, Emacs' charsets aren't applicable; function |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
109 `char-charset' reports CHARSET_ASCII for all characters, including |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
110 those > 0x7f. The X registry and encoding of fonts to use is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
111 determined from the variable `x-unibyte-registry-and-encoding' in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
112 this case. The variable is initialized at Emacs startup time from |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
113 the font the user specified for Emacs. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
114 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
115 Currently all unibyte text, i.e. all buffers with |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
116 enable_multibyte_characters nil are displayed with fonts of the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
117 same registry and encoding `x-unibyte-registry-and-encoding'. This |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
118 is consistent with the fact that languages can also be set |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
119 globally, only. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
120 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
121 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
122 Font selection. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
123 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
124 Font selection tries to find the best available matching font for a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
125 given (charset, face) combination. This is done slightly |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
126 differently for faces specifying a fontset, or a font family name. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
127 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
128 If the face specifies a fontset alias name, that fontset determines |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
129 a pattern for fonts of the given charset. If the face specifies a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
130 font family, a font pattern is constructed. Charset symbols have a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
131 property `x-charset-registry' for that purpose that maps a charset |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
132 to an XLFD registry and encoding in the font pattern constructed. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
133 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
134 Available fonts on the system on which Emacs runs are then matched |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
135 against the font pattern. The result of font selection is the best |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
136 match for the given face attributes in this font list. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
137 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
138 Font selection can be influenced by the user. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
139 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
140 1. The user can specify the relative importance he gives the face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
141 attributes width, height, weight, and slant by setting |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
142 face-font-selection-order (faces.el) to a list of face attribute |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
143 names. The default is '(:width :height :weight :slant), and means |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
144 that font selection first tries to find a good match for the font |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
145 width specified by a face, then---within fonts with that |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
146 width---tries to find a best match for the specified font height, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
147 etc. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
148 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
149 2. Setting face-alternative-font-family-alist allows the user to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
150 specify alternative font families to try if a family specified by a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
151 face doesn't exist. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
152 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
153 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
154 Composite characters. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
155 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
156 Realized faces for composite characters are the only ones having a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
157 fontset id >= 0. When a composite character is encoded into a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
158 sequence of non-composite characters (in xterm.c), a suitable font |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
159 for the non-composite characters is then selected and realized, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
160 i.e. the realization process is delayed but in principle the same. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
161 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
162 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
163 Initialization of basic faces. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
164 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
165 The faces `default', `modeline' are considered `basic faces'. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
166 When redisplay happens the first time for a newly created frame, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
167 basic faces are realized for CHARSET_ASCII. Frame parameters are |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
168 used to fill in unspecified attributes of the default face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
169 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
170 /* Define SCALABLE_FONTS to a non-zero value to enable scalable |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
171 font use. Define it to zero to disable scalable font use. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
172 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
173 Use of too many or too large scalable fonts can crash XFree86 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
174 servers. That's why I've put the code dealing with scalable fonts |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
175 in #if's. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
176 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
177 #define SCALABLE_FONTS 1 |
13434 | 178 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25646
diff
changeset
|
179 #include <config.h> |
13434 | 180 #include <sys/types.h> |
181 #include <sys/stat.h> | |
182 #include "lisp.h" | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
183 #include "charset.h" |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
184 #include "frame.h" |
13434 | 185 #include "w32term.h" |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
186 #include "fontset.h" |
13434 | 187 #include "buffer.h" |
188 #include "dispextern.h" | |
189 #include "blockinput.h" | |
190 #include "window.h" | |
191 #include "intervals.h" | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
192 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
193 #include <stdio.h> |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
194 #include <ctype.h> |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
195 #include "keyboard.h" |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
196 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
197 #ifndef max |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
198 #define max(A, B) ((A) > (B) ? (A) : (B)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
199 #define min(A, B) ((A) < (B) ? (A) : (B)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
200 #define abs(X) ((X) < 0 ? -(X) : (X)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
201 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
202 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
203 /* Non-zero if face attribute ATTR is unspecified. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
204 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
205 #define UNSPECIFIEDP(ATTR) EQ ((ATTR), Qunspecified) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
206 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
207 /* Value is the number of elements of VECTOR. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
208 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
209 #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
210 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
211 /* Make a copy of string S on the stack using alloca. Value is a pointer |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
212 to the copy. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
213 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
214 #define STRDUPA(S) strcpy ((char *) alloca (strlen ((S)) + 1), (S)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
215 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
216 /* Make a copy of the contents of Lisp string S on the stack using |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
217 alloca. Value is a pointer to the copy. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
218 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
219 #define LSTRDUPA(S) STRDUPA (XSTRING ((S))->data) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
220 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
221 /* Size of hash table of realized faces in face caches (should be a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
222 prime number). */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
223 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
224 #define FACE_CACHE_BUCKETS_SIZE 1001 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
225 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
226 /* A definition of XColor for non-X frames. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
227 #ifndef HAVE_X_WINDOWS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
228 typedef struct { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
229 unsigned long pixel; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
230 unsigned short red, green, blue; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
231 char flags; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
232 char pad; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
233 } XColor; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
234 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
235 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
236 /* Keyword symbols used for face attribute names. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
237 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
238 Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
239 Lisp_Object QCinverse_video, QCforeground, QCbackground, QCstipple; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
240 Lisp_Object QCwidth, QCfont, QCbold, QCitalic; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
241 Lisp_Object QCreverse_video; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
242 Lisp_Object QCoverline, QCstrike_through, QCbox; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
243 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
244 /* Symbols used for attribute values. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
245 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
246 Lisp_Object Qnormal, Qbold, Qultra_light, Qextra_light, Qlight; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
247 Lisp_Object Qsemi_light, Qsemi_bold, Qextra_bold, Qultra_bold; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
248 Lisp_Object Qoblique, Qitalic, Qreverse_oblique, Qreverse_italic; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
249 Lisp_Object Qultra_condensed, Qextra_condensed, Qcondensed; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
250 Lisp_Object Qsemi_condensed, Qsemi_expanded, Qexpanded, Qextra_expanded; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
251 Lisp_Object Qultra_expanded; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
252 Lisp_Object Qreleased_button, Qpressed_button; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
253 Lisp_Object QCstyle, QCcolor, QCline_width; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
254 Lisp_Object Qunspecified; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
255 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
256 char unspecified_fg[] = "unspecified-fg", unspecified_bg[] = "unspecified-bg"; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
257 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
258 /* The symbol `x-charset-registry'. This property of charsets defines |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
259 the X registry and encoding that fonts should have that are used to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
260 display characters of that charset. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
261 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
262 Lisp_Object Qx_charset_registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
263 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
264 /* The name of the function to call when the background of the frame |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
265 has changed, frame_update_face_colors. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
266 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
267 Lisp_Object Qframe_update_face_colors; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
268 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
269 /* Names of basic faces. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
270 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
271 Lisp_Object Qdefault, Qtool_bar, Qregion, Qfringe; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
272 Lisp_Object Qheader_line, Qscroll_bar, Qcursor, Qborder, Qmouse, Qmenu; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
273 extern Lisp_Object Qmode_line; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
274 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
275 /* The symbol `face-alias'. A symbols having that property is an |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
276 alias for another face. Value of the property is the name of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
277 the aliased face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
278 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
279 Lisp_Object Qface_alias; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
280 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
281 /* Names of frame parameters related to faces. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
282 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
283 extern Lisp_Object Qborder_color, Qcursor_color, Qmouse_color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
284 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
285 /* Default stipple pattern used on monochrome displays. This stipple |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
286 pattern is used on monochrome displays instead of shades of gray |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
287 for a face background color. See `set-face-stipple' for possible |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
288 values for this variable. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
289 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
290 Lisp_Object Vface_default_stipple; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
291 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
292 /* Default registry and encoding to use for charsets whose charset |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
293 symbols don't specify one. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
294 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
295 Lisp_Object Vface_default_registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
296 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
297 /* Alist of alternative font families. Each element is of the form |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
298 (FAMILY FAMILY1 FAMILY2 ...). If fonts of FAMILY can't be loaded, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
299 try FAMILY1, then FAMILY2, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
300 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
301 Lisp_Object Vface_alternative_font_family_alist; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
302 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
303 /* Allowed scalable fonts. A value of nil means don't allow any |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
304 scalable fonts. A value of t means allow the use of any scalable |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
305 font. Otherwise, value must be a list of regular expressions. A |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
306 font may be scaled if its name matches a regular expression in the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
307 list. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
308 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
309 #if SCALABLE_FONTS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
310 Lisp_Object Vscalable_fonts_allowed; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
311 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
312 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
313 /* Maximum number of fonts to consider in font_list. If not an |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
314 integer > 0, DEFAULT_FONT_LIST_LIMIT is used instead. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
315 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
316 Lisp_Object Vfont_list_limit; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
317 #define DEFAULT_FONT_LIST_LIMIT 100 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
318 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
319 /* The symbols `foreground-color' and `background-color' which can be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
320 used as part of a `face' property. This is for compatibility with |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
321 Emacs 20.2. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
322 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
323 Lisp_Object Qforeground_color, Qbackground_color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
324 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
325 /* The symbols `face' and `mouse-face' used as text properties. */ |
13434 | 326 |
23623
f6c3cc94ae4f
(Qmouse_face): Replace definition with extern decl.
Geoff Voelker <voelker@cs.washington.edu>
parents:
23505
diff
changeset
|
327 Lisp_Object Qface; |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
328 extern Lisp_Object Qmouse_face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
329 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
330 /* Error symbol for wrong_type_argument in load_pixmap. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
331 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
332 Lisp_Object Qbitmap_spec_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
333 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
334 /* Alist of global face definitions. Each element is of the form |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
335 (FACE . LFACE) where FACE is a symbol naming a face and LFACE |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
336 is a Lisp vector of face attributes. These faces are used |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
337 to initialize faces for new frames. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
338 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
339 Lisp_Object Vface_new_frame_defaults; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
340 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
341 /* The next ID to assign to Lisp faces. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
342 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
343 static int next_lface_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
344 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
345 /* A vector mapping Lisp face Id's to face names. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
346 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
347 static Lisp_Object *lface_id_to_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
348 static int lface_id_to_name_size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
349 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
350 /* tty color-related functions (defined on lisp/term/tty-colors.el). */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
351 Lisp_Object Qtty_color_desc, Qtty_color_by_index; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
352 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
353 /* Counter for calls to clear_face_cache. If this counter reaches |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
354 CLEAR_FONT_TABLE_COUNT, and a frame has more than |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
355 CLEAR_FONT_TABLE_NFONTS load, unused fonts are freed. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
356 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
357 static int clear_font_table_count; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
358 #define CLEAR_FONT_TABLE_COUNT 100 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
359 #define CLEAR_FONT_TABLE_NFONTS 10 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
360 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
361 /* Non-zero means face attributes have been changed since the last |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
362 redisplay. Used in redisplay_internal. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
363 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
364 int face_change_count; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
365 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
366 /* The total number of colors currently allocated. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
367 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
368 #if GLYPH_DEBUG |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
369 static int ncolors_allocated; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
370 static int npixmaps_allocated; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
371 static int ngcs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
372 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
373 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
374 |
13434 | 375 |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
376 /* Function prototypes. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
377 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
378 struct font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
379 struct table_entry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
380 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
381 static Lisp_Object resolve_face_name P_ ((Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
382 static int may_use_scalable_font_p P_ ((struct font_name *, char *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
383 static void set_font_frame_param P_ ((Lisp_Object, Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
384 static int better_font_p P_ ((int *, struct font_name *, struct font_name *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
385 int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
386 static int first_font_matching P_ ((struct frame *f, char *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
387 struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
388 static int x_face_list_fonts P_ ((struct frame *, char *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
389 struct font_name *, int, int, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
390 static int font_scalable_p P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
391 static Lisp_Object deduce_unibyte_registry P_ ((struct frame *, char *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
392 static int get_lface_attributes P_ ((struct frame *, Lisp_Object, Lisp_Object *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
393 static int load_pixmap P_ ((struct frame *, Lisp_Object, unsigned *, unsigned *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
394 static char *xstrdup P_ ((char *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
395 static unsigned char *xstrlwr P_ ((unsigned char *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
396 static void signal_error P_ ((char *, Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
397 static struct frame *frame_or_selected_frame P_ ((Lisp_Object, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
398 static void load_face_font_or_fontset P_ ((struct frame *, struct face *, char *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
399 static void load_face_colors P_ ((struct frame *, struct face *, Lisp_Object *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
400 static void free_face_colors P_ ((struct frame *, struct face *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
401 static int face_color_gray_p P_ ((struct frame *, char *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
402 static char *build_font_name P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
403 static void free_font_names P_ ((struct font_name *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
404 static int sorted_font_list P_ ((struct frame *, char *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
405 int (*cmpfn) P_ ((const void *, const void *)), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
406 struct font_name **)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
407 static int font_list P_ ((struct frame *, char *, char *, char *, struct font_name **)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
408 static int try_font_list P_ ((struct frame *, Lisp_Object *, char *, char *, char *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
409 struct font_name **)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
410 static int cmp_font_names P_ ((const void *, const void *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
411 static struct face *realize_face P_ ((struct face_cache *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
412 Lisp_Object *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
413 static struct face *realize_x_face P_ ((struct face_cache *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
414 Lisp_Object *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
415 static struct face *realize_tty_face P_ ((struct face_cache *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
416 Lisp_Object *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
417 static int realize_basic_faces P_ ((struct frame *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
418 static int realize_default_face P_ ((struct frame *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
419 static void realize_named_face P_ ((struct frame *, Lisp_Object, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
420 static int lface_fully_specified_p P_ ((Lisp_Object *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
421 static int lface_equal_p P_ ((Lisp_Object *, Lisp_Object *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
422 static unsigned hash_string_case_insensitive P_ ((Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
423 static unsigned lface_hash P_ ((Lisp_Object *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
424 static int lface_same_font_attributes_p P_ ((Lisp_Object *, Lisp_Object *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
425 static struct face_cache *make_face_cache P_ ((struct frame *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
426 static void free_realized_face P_ ((struct frame *, struct face *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
427 static void clear_face_gcs P_ ((struct face_cache *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
428 static void free_face_cache P_ ((struct face_cache *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
429 static int face_numeric_weight P_ ((Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
430 static int face_numeric_slant P_ ((Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
431 static int face_numeric_swidth P_ ((Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
432 static int face_fontset P_ ((struct frame *, Lisp_Object *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
433 static char *choose_face_font P_ ((struct frame *, Lisp_Object *, int, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
434 Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
435 static char *choose_face_fontset_font P_ ((struct frame *, Lisp_Object *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
436 int, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
437 static void merge_face_vectors P_ ((Lisp_Object *from, Lisp_Object *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
438 static void merge_face_vector_with_property P_ ((struct frame *, Lisp_Object *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
439 Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
440 static int set_lface_from_font_name P_ ((struct frame *, Lisp_Object, char *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
441 int, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
442 static Lisp_Object lface_from_face_name P_ ((struct frame *, Lisp_Object, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
443 static struct face *make_realized_face P_ ((Lisp_Object *, int, Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
444 static void free_realized_faces P_ ((struct face_cache *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
445 static char *best_matching_font P_ ((struct frame *, Lisp_Object *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
446 struct font_name *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
447 static void cache_face P_ ((struct face_cache *, struct face *, unsigned)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
448 static void uncache_face P_ ((struct face_cache *, struct face *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
449 static int xlfd_numeric_slant P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
450 static int xlfd_numeric_weight P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
451 static int xlfd_numeric_swidth P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
452 static Lisp_Object xlfd_symbolic_slant P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
453 static Lisp_Object xlfd_symbolic_weight P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
454 static Lisp_Object xlfd_symbolic_swidth P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
455 static int xlfd_fixed_p P_ ((struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
456 static int xlfd_numeric_value P_ ((struct table_entry *, int, struct font_name *, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
457 int, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
458 static Lisp_Object xlfd_symbolic_value P_ ((struct table_entry *, int, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
459 struct font_name *, int, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
460 static struct table_entry *xlfd_lookup_field_contents P_ ((struct table_entry *, int, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
461 struct font_name *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
462 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
463 static int split_font_name P_ ((struct frame *, struct font_name *, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
464 static int xlfd_point_size P_ ((struct frame *, struct font_name *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
465 static void sort_fonts P_ ((struct frame *, struct font_name *, int, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
466 int (*cmpfn) P_ ((const void *, const void *)))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
467 static GC x_create_gc P_ ((struct frame *, unsigned long, XGCValues *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
468 static void x_free_gc P_ ((struct frame *, GC)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
469 static void clear_font_table P_ ((struct frame *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
470 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
471 extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
472 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
473 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
474 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
475 Utilities |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
476 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
477 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
478 /* Create and return a GC for use on frame F. GC values and mask |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
479 are given by XGCV and MASK. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
480 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
481 static INLINE GC |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
482 x_create_gc (f, mask, xgcv) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
483 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
484 unsigned long mask; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
485 XGCValues *xgcv; |
13434 | 486 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
487 GC gc; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
488 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
489 gc = XCreateGC (NULL, FRAME_W32_WINDOW (f), mask, xgcv); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
490 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
491 IF_DEBUG (++ngcs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
492 return gc; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
493 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
494 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
495 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
496 /* Free GC which was used on frame F. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
497 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
498 static INLINE void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
499 x_free_gc (f, gc) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
500 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
501 GC gc; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
502 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
503 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
504 xassert (--ngcs >= 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
505 xfree (gc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
506 UNBLOCK_INPUT; |
13434 | 507 } |
508 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
509 /* Like strdup, but uses xmalloc. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
510 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
511 static char * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
512 xstrdup (s) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
513 char *s; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
514 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
515 int len = strlen (s) + 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
516 char *p = (char *) xmalloc (len); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
517 bcopy (s, p, len); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
518 return p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
519 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
520 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
521 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
522 /* Like stricmp. Used to compare parts of font names which are in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
523 ISO8859-1. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
524 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
525 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
526 xstricmp (s1, s2) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
527 unsigned char *s1, *s2; |
13434 | 528 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
529 while (*s1 && *s2) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
530 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
531 unsigned char c1 = tolower (*s1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
532 unsigned char c2 = tolower (*s2); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
533 if (c1 != c2) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
534 return c1 < c2 ? -1 : 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
535 ++s1, ++s2; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
536 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
537 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
538 if (*s1 == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
539 return *s2 == 0 ? 0 : -1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
540 return 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
541 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
542 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
543 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
544 /* Like strlwr, which might not always be available. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
545 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
546 static unsigned char * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
547 xstrlwr (s) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
548 unsigned char *s; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
549 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
550 unsigned char *p = s; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
551 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
552 for (p = s; *p; ++p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
553 *p = tolower (*p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
554 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
555 return s; |
13434 | 556 } |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
557 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
558 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
559 /* Signal `error' with message S, and additional argument ARG. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
560 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
561 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
562 signal_error (s, arg) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
563 char *s; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
564 Lisp_Object arg; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
565 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
566 Fsignal (Qerror, Fcons (build_string (s), Fcons (arg, Qnil))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
567 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
568 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
569 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
570 /* If FRAME is nil, return a pointer to the selected frame. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
571 Otherwise, check that FRAME is a live frame, and return a pointer |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
572 to it. NPARAM is the parameter number of FRAME, for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
573 CHECK_LIVE_FRAME. This is here because it's a frequent pattern in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
574 Lisp function definitions. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
575 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
576 static INLINE struct frame * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
577 frame_or_selected_frame (frame, nparam) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
578 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
579 int nparam; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
580 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
581 if (NILP (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
582 frame = selected_frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
583 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
584 CHECK_LIVE_FRAME (frame, nparam); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
585 return XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
586 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
587 |
13434 | 588 |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
589 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
590 Frames and faces |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
591 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
592 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
593 /* Initialize face cache and basic faces for frame F. */ |
13434 | 594 |
595 void | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
596 init_frame_faces (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
597 struct frame *f; |
13434 | 598 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
599 /* Make a face cache, if F doesn't have one. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
600 if (FRAME_FACE_CACHE (f) == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
601 FRAME_FACE_CACHE (f) = make_face_cache (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
602 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
603 /* Make the image cache. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
604 if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
605 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
606 if (FRAME_X_IMAGE_CACHE (f) == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
607 FRAME_X_IMAGE_CACHE (f) = make_image_cache (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
608 ++FRAME_X_IMAGE_CACHE (f)->refcount; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
609 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
610 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
611 /* Realize basic faces. Must have enough information in frame |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
612 parameters to realize basic faces at this point. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
613 if (!FRAME_WINDOW_P (f) || FRAME_W32_WINDOW (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
614 if (!realize_basic_faces (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
615 abort (); |
13434 | 616 } |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
617 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
618 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
619 /* Free face cache of frame F. Called from Fdelete_frame. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
620 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
621 void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
622 free_frame_faces (f) |
13434 | 623 struct frame *f; |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
624 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
625 struct face_cache *face_cache = FRAME_FACE_CACHE (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
626 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
627 if (face_cache) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
628 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
629 free_face_cache (face_cache); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
630 FRAME_FACE_CACHE (f) = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
631 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
632 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
633 if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
634 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
635 struct image_cache *image_cache = FRAME_X_IMAGE_CACHE (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
636 if (image_cache) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
637 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
638 --image_cache->refcount; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
639 if (image_cache->refcount == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
640 free_image_cache (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
641 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
642 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
643 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
644 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
645 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
646 /* Clear face caches, and recompute basic faces for frame F. Call |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
647 this after changing frame parameters on which those faces depend, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
648 or when realized faces have been freed due to changing attributes |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
649 of named faces. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
650 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
651 void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
652 recompute_basic_faces (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
653 struct frame *f; |
13434 | 654 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
655 if (FRAME_FACE_CACHE (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
656 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
657 clear_face_cache (0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
658 if (!realize_basic_faces (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
659 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
660 } |
13434 | 661 } |
662 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
663 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
664 /* Clear the face caches of all frames. CLEAR_FONTS_P non-zero means |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
665 try to free unused fonts, too. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
666 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
667 void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
668 clear_face_cache (clear_fonts_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
669 int clear_fonts_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
670 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
671 Lisp_Object tail, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
672 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
673 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
674 if (clear_fonts_p |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
675 || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
676 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
677 /* From time to time see if we can unload some fonts. This also |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
678 frees all realized faces on all frames. Fonts needed by |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
679 faces will be loaded again when faces are realized again. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
680 clear_font_table_count = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
681 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
682 FOR_EACH_FRAME (tail, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
683 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
684 f = XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
685 if (FRAME_WINDOW_P (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
686 && FRAME_W32_DISPLAY_INFO (f)->n_fonts > CLEAR_FONT_TABLE_NFONTS) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
687 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
688 free_all_realized_faces (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
689 clear_font_table (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
690 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
691 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
692 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
693 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
694 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
695 /* Clear GCs of realized faces. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
696 FOR_EACH_FRAME (tail, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
697 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
698 f = XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
699 if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
700 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
701 clear_face_gcs (FRAME_FACE_CACHE (f)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
702 clear_image_cache (f, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
703 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
704 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
705 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
706 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
707 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
708 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
709 DEFUN ("clear-face-cache", Fclear_face_cache, Sclear_face_cache, 0, 1, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
710 "Clear face caches on all frames.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
711 Optional THOROUGHLY non-nil means try to free unused fonts, too.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
712 (thorougly) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
713 Lisp_Object thorougly; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
714 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
715 clear_face_cache (!NILP (thorougly)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
716 return Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
717 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
718 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
719 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
720 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
721 /* Remove those fonts from the font table of frame F that are not used |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
722 by fontsets. Called from clear_face_cache from time to time. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
723 |
13434 | 724 static void |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
725 clear_font_table (f) |
13434 | 726 struct frame *f; |
727 { | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
728 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
729 char *used; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
730 Lisp_Object rest, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
731 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
732 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
733 xassert (FRAME_WINDOW_P (f)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
734 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
735 used = (char *) alloca (dpyinfo->n_fonts * sizeof *used); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
736 bzero (used, dpyinfo->n_fonts * sizeof *used); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
737 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
738 /* For all frames with the same w32_display_info as F, record |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
739 in `used' those fonts that are in use by fontsets. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
740 FOR_EACH_FRAME (rest, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
741 if (FRAME_W32_DISPLAY_INFO (XFRAME (frame)) == dpyinfo) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
742 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
743 struct frame *f = XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
744 struct fontset_data *fontset_data = FRAME_FONTSET_DATA (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
745 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
746 for (i = 0; i < fontset_data->n_fontsets; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
747 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
748 struct fontset_info *info = fontset_data->fontset_table[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
749 int j; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
750 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
751 for (j = 0; j <= MAX_CHARSET; ++j) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
752 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
753 int idx = info->font_indexes[j]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
754 if (idx >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
755 used[idx] = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
756 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
757 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
758 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
759 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
760 /* Free those fonts that are not used by fontsets. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
761 for (i = 0; i < dpyinfo->n_fonts; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
762 if (used[i] == 0 && dpyinfo->font_table[i].name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
763 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
764 struct font_info *font_info = dpyinfo->font_table + i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
765 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
766 /* Free names. In xfns.c there is a comment that full_name |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
767 should never be freed because it is always shared with |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
768 something else. I don't think this is true anymore---see |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
769 x_load_font. It's either equal to font_info->name or |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
770 allocated via xmalloc, and there seems to be no place in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
771 the source files where full_name is transferred to another |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
772 data structure. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
773 if (font_info->full_name != font_info->name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
774 xfree (font_info->full_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
775 xfree (font_info->name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
776 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
777 /* Free the font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
778 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
779 w32_unload_font (dpyinfo, font_info->font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
780 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
781 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
782 /* Mark font table slot free. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
783 font_info->font = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
784 font_info->name = font_info->full_name = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
785 } |
13434 | 786 } |
787 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
788 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
789 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
790 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
791 X Pixmaps |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
792 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
793 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
794 DEFUN ("bitmap-spec-p", Fbitmap_spec_p, Sbitmap_spec_p, 1, 1, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
795 "Value is non-nil if OBJECT is a valid bitmap specification.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
796 A bitmap specification is either a string, a filename, or a list\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
797 (WIDTH HEIGHT DATA) where WIDTH is the pixel width of the bitmap,\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
798 HEIGHT is its height, and DATA is a string containing the bits of the\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
799 bitmap. Bits are stored row by row, each row occupies\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
800 (WIDTH + 7) / 8 bytes.") |
23505
1050835fbcef
Update comments referring to obsolete structs.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21607
diff
changeset
|
801 (object) |
1050835fbcef
Update comments referring to obsolete structs.
Geoff Voelker <voelker@cs.washington.edu>
parents:
21607
diff
changeset
|
802 Lisp_Object object; |
13434 | 803 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
804 int pixmap_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
805 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
806 if (STRINGP (object)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
807 /* If OBJECT is a string, it's a file name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
808 pixmap_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
809 else if (CONSP (object)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
810 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
811 /* Otherwise OBJECT must be (WIDTH HEIGHT DATA), WIDTH and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
812 HEIGHT must be integers > 0, and DATA must be string large |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
813 enough to hold a bitmap of the specified size. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
814 Lisp_Object width, height, data; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
815 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
816 height = width = data = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
817 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
818 if (CONSP (object)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
819 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
820 width = XCAR (object); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
821 object = XCDR (object); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
822 if (CONSP (object)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
823 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
824 height = XCAR (object); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
825 object = XCDR (object); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
826 if (CONSP (object)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
827 data = XCAR (object); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
828 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
829 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
830 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
831 if (NATNUMP (width) && NATNUMP (height) && STRINGP (data)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
832 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
833 int bytes_per_row = ((XFASTINT (width) + BITS_PER_CHAR - 1) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
834 / BITS_PER_CHAR); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
835 if (STRING_BYTES (XSTRING (data)) >= bytes_per_row * height) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
836 pixmap_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
837 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
838 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
839 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
840 return pixmap_p ? Qt : Qnil; |
13434 | 841 } |
842 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
843 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
844 /* Load a bitmap according to NAME (which is either a file name or a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
845 pixmap spec) for use on frame F. Value is the bitmap_id (see |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
846 xfns.c). If NAME is nil, return with a bitmap id of zero. If |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
847 bitmap cannot be loaded, display a message saying so, and return |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
848 zero. Store the bitmap width in *W_PTR and its height in *H_PTR, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
849 if these pointers are not null. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
850 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
851 static int |
13434 | 852 load_pixmap (f, name, w_ptr, h_ptr) |
853 FRAME_PTR f; | |
854 Lisp_Object name; | |
855 unsigned int *w_ptr, *h_ptr; | |
856 { | |
857 int bitmap_id; | |
858 Lisp_Object tem; | |
859 | |
860 if (NILP (name)) | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
861 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
862 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
863 tem = Fbitmap_spec_p (name); |
13434 | 864 if (NILP (tem)) |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
865 wrong_type_argument (Qbitmap_spec_p, name); |
13434 | 866 |
867 BLOCK_INPUT; | |
868 if (CONSP (name)) | |
869 { | |
870 /* Decode a bitmap spec into a bitmap. */ | |
871 | |
872 int h, w; | |
873 Lisp_Object bits; | |
874 | |
875 w = XINT (Fcar (name)); | |
876 h = XINT (Fcar (Fcdr (name))); | |
877 bits = Fcar (Fcdr (Fcdr (name))); | |
878 | |
879 bitmap_id = x_create_bitmap_from_data (f, XSTRING (bits)->data, | |
880 w, h); | |
881 } | |
882 else | |
883 { | |
884 /* It must be a string -- a file name. */ | |
885 bitmap_id = x_create_bitmap_from_file (f, name); | |
886 } | |
887 UNBLOCK_INPUT; | |
888 | |
889 if (bitmap_id < 0) | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
890 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
891 add_to_log ("Invalid or undefined bitmap %s", name, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
892 bitmap_id = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
893 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
894 if (w_ptr) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
895 *w_ptr = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
896 if (h_ptr) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
897 *h_ptr = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
898 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
899 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
900 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
901 #if GLYPH_DEBUG |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
902 ++npixmaps_allocated; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
903 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
904 if (w_ptr) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
905 *w_ptr = x_bitmap_width (f, bitmap_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
906 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
907 if (h_ptr) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
908 *h_ptr = x_bitmap_height (f, bitmap_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
909 } |
13434 | 910 |
911 return bitmap_id; | |
912 } | |
913 | |
914 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
915 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
916 |
13434 | 917 |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
918 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
919 Minimum font bounds |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
920 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
921 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
922 /* Update the line_height of frame F. Return non-zero if line height |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
923 changes. */ |
13434 | 924 |
925 int | |
926 frame_update_line_height (f) | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
927 struct frame *f; |
13434 | 928 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
929 int fontset, line_height, changed_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
930 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
931 fontset = FRAME_FONTSET (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
932 if (fontset > 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
933 line_height = FRAME_FONTSET_DATA (f)->fontset_table[fontset]->height; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
934 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
935 line_height = FONT_HEIGHT (FRAME_FONT (f)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
936 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
937 changed_p = line_height != FRAME_LINE_HEIGHT (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
938 FRAME_LINE_HEIGHT (f) = line_height; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
939 return changed_p; |
13434 | 940 } |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
941 |
13434 | 942 |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
943 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
944 Fonts |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
945 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
946 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
947 /* Load font or fontset of face FACE which is used on frame F. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
948 FONTSET is the fontset FACE should use or -1, if FACE doesn't use a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
949 fontset. FONT_NAME is the name of the font to load, if no fontset |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
950 is used. It is null if no suitable font name could be determined |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
951 for the face. */ |
13434 | 952 |
953 static void | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
954 load_face_font_or_fontset (f, face, font_name, fontset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
955 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
956 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
957 char *font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
958 int fontset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
959 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
960 struct font_info *font_info = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
961 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
962 face->font_info_id = -1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
963 face->fontset = fontset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
964 face->font = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
965 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
966 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
967 if (fontset >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
968 font_info = FS_LOAD_FONT (f, FRAME_W32_FONT_TABLE (f), CHARSET_ASCII, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
969 NULL, fontset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
970 else if (font_name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
971 font_info = FS_LOAD_FONT (f, FRAME_W32_FONT_TABLE (f), face->charset, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
972 font_name, -1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
973 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
974 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
975 if (font_info) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
976 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
977 char *s; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
978 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
979 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
980 face->font_info_id = FONT_INFO_ID (f, font_info); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
981 face->font = font_info->font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
982 face->font_name = font_info->full_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
983 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
984 /* Make the registry part of the font name readily accessible. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
985 The registry is used to find suitable faces for unibyte text. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
986 s = font_info->full_name + strlen (font_info->full_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
987 i = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
988 while (i < 2 && --s >= font_info->full_name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
989 if (*s == '-') |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
990 ++i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
991 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
992 if (!STRINGP (face->registry) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
993 || xstricmp (XSTRING (face->registry)->data, s + 1) != 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
994 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
995 if (STRINGP (Vface_default_registry) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
996 && !xstricmp (XSTRING (Vface_default_registry)->data, s + 1)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
997 face->registry = Vface_default_registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
998 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
999 face->registry = build_string (s + 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1000 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1001 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1002 else if (fontset >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1003 add_to_log ("Unable to load ASCII font of fontset %d", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1004 make_number (fontset), Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1005 else if (font_name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1006 add_to_log ("Unable to load font %s", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1007 build_string (font_name), Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1008 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1009 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1010 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1011 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1012 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1013 X Colors |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1014 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1015 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1016 /* A version of defined_color for non-X frames. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1017 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1018 tty_defined_color (f, color_name, color_def, alloc) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1019 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1020 char *color_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1021 XColor *color_def; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1022 int alloc; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1023 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1024 Lisp_Object color_desc; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1025 int color_idx = FACE_TTY_DEFAULT_COLOR, red = 0, green = 0, blue = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1026 int status = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1027 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1028 if (*color_name && !NILP (Ffboundp (Qtty_color_desc))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1029 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1030 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1031 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1032 XSETFRAME (frame, f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1033 status = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1034 color_desc = call2 (Qtty_color_desc, build_string (color_name), frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1035 if (CONSP (color_desc) && CONSP (XCDR (color_desc))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1036 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1037 color_idx = XINT (XCAR (XCDR (color_desc))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1038 if (CONSP (XCDR (XCDR (color_desc)))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1039 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1040 red = XINT (XCAR (XCDR (XCDR (color_desc)))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1041 green = XINT (XCAR (XCDR (XCDR (XCDR (color_desc))))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1042 blue = XINT (XCAR (XCDR (XCDR (XCDR (XCDR (color_desc)))))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1043 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1044 status = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1045 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1046 else if (NILP (Fsymbol_value (intern ("tty-defined-color-alist")))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1047 /* We were called early during startup, and the colors are not |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1048 yet set up in tty-defined-color-alist. Don't return a failure |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1049 indication, since this produces the annoying "Unable to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1050 load color" messages in the *Messages* buffer. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1051 status = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1052 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1053 if (color_idx == FACE_TTY_DEFAULT_COLOR && *color_name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1054 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1055 if (strcmp (color_name, "unspecified-fg") == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1056 color_idx = FACE_TTY_DEFAULT_FG_COLOR; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1057 else if (strcmp (color_name, "unspecified-bg") == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1058 color_idx = FACE_TTY_DEFAULT_BG_COLOR; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1059 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1060 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1061 color_def->pixel = (unsigned long) color_idx; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1062 color_def->red = red; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1063 color_def->green = green; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1064 color_def->blue = blue; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1065 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1066 return status; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1067 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1068 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1069 /* Decide if color named COLOR is valid for the display associated |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1070 with the frame F; if so, return the rgb values in COLOR_DEF. If |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1071 ALLOC is nonzero, allocate a new colormap cell. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1072 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1073 This does the right thing for any type of frame. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1074 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1075 defined_color (f, color_name, color_def, alloc) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1076 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1077 char *color_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1078 XColor *color_def; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1079 int alloc; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1080 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1081 if (!f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1082 return 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1083 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1084 if (!FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1085 return tty_defined_color (f, color_name, color_def, alloc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1086 #ifdef HAVE_X_WINDOWS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1087 else if (FRAME_X_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1088 return x_defined_color (f, color_name, color_def, alloc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1089 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1090 #ifdef WINDOWSNT |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1091 else if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1092 /* FIXME: w32_defined_color doesn't exist! w32fns.c defines |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1093 defined_color which needs to be renamed, and the declaration |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1094 of color_def therein should be changed. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1095 return w32_defined_color (f, color_name, color_def, alloc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1096 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1097 #ifdef macintosh |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1098 else if (FRAME_MAC_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1099 /* FIXME: mac_defined_color doesn't exist! */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1100 return mac_defined_color (f, color_name, color_def, alloc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1101 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1102 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1103 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1104 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1105 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1106 /* Given the index of the tty color, return its name, a Lisp string. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1107 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1108 Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1109 tty_color_name (f, idx) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1110 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1111 int idx; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1112 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1113 char *color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1114 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1115 if (idx >= 0 && !NILP (Ffboundp (Qtty_color_by_index))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1116 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1117 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1118 Lisp_Object coldesc; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1119 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1120 XSETFRAME (frame, f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1121 coldesc = call2 (Qtty_color_by_index, make_number (idx), frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1122 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1123 if (!NILP (coldesc)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1124 return XCAR (coldesc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1125 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1126 #ifdef MSDOS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1127 /* We can have an MSDOG frame under -nw for a short window of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1128 opportunity before internal_terminal_init is called. DTRT. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1129 if (FRAME_MSDOS_P (f) && !inhibit_window_system) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1130 return msdos_stdcolor_name (idx); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1131 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1132 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1133 #ifdef WINDOWSNT |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1134 /* FIXME: When/if w32 supports colors in non-window mode, there should |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1135 be a call here to a w32-specific function that returns the color |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1136 by index using the default color mapping on a Windows console. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1137 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1138 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1139 if (idx == FACE_TTY_DEFAULT_FG_COLOR) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1140 return build_string (unspecified_fg); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1141 if (idx == FACE_TTY_DEFAULT_BG_COLOR) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1142 return build_string (unspecified_bg); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1143 return Qunspecified; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1144 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1145 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1146 /* Return non-zero if COLOR_NAME is a shade of gray (or white or |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1147 black) on frame F. The algorithm is taken from 20.2 faces.el. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1148 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1149 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1150 face_color_gray_p (f, color_name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1151 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1152 char *color_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1153 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1154 XColor color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1155 int gray_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1156 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1157 if (defined_color (f, color_name, &color, 0)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1158 gray_p = ((abs (color.red - color.green) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1159 < max (color.red, color.green) / 20) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1160 && (abs (color.green - color.blue) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1161 < max (color.green, color.blue) / 20) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1162 && (abs (color.blue - color.red) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1163 < max (color.blue, color.red) / 20)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1164 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1165 gray_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1166 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1167 return gray_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1168 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1169 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1170 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1171 /* Return non-zero if color COLOR_NAME can be displayed on frame F. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1172 BACKGROUND_P non-zero means the color will be used as background |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1173 color. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1174 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1175 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1176 face_color_supported_p (f, color_name, background_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1177 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1178 char *color_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1179 int background_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1180 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1181 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1182 XColor not_used; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1183 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1184 XSETFRAME (frame, f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1185 return (FRAME_WINDOW_P (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1186 ? (!NILP (Fxw_display_color_p (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1187 || xstricmp (color_name, "black") == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1188 || xstricmp (color_name, "white") == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1189 || (background_p |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1190 && face_color_gray_p (f, color_name)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1191 || (!NILP (Fx_display_grayscale_p (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1192 && face_color_gray_p (f, color_name))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1193 : tty_defined_color (f, color_name, ¬_used, 0)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1194 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1195 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1196 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1197 DEFUN ("color-gray-p", Fcolor_gray_p, Scolor_gray_p, 1, 2, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1198 "Return non-nil if COLOR is a shade of gray (or white or black).\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1199 FRAME specifies the frame and thus the display for interpreting COLOR.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1200 If FRAME is nil or omitted, use the selected frame.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1201 (color, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1202 Lisp_Object color, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1203 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1204 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1205 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1206 CHECK_FRAME (frame, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1207 CHECK_STRING (color, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1208 f = XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1209 return face_color_gray_p (f, XSTRING (color)->data) ? Qt : Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1210 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1211 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1212 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1213 DEFUN ("color-supported-p", Fcolor_supported_p, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1214 Scolor_supported_p, 2, 3, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1215 "Return non-nil if COLOR can be displayed on FRAME.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1216 BACKGROUND-P non-nil means COLOR is used as a background.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1217 If FRAME is nil or omitted, use the selected frame.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1218 COLOR must be a valid color name.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1219 (color, frame, background_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1220 Lisp_Object frame, color, background_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1221 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1222 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1223 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1224 CHECK_FRAME (frame, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1225 CHECK_STRING (color, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1226 f = XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1227 if (face_color_supported_p (f, XSTRING (color)->data, !NILP (background_p))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1228 return Qt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1229 return Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1230 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1231 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1232 /* Load color with name NAME for use by face FACE on frame F. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1233 TARGET_INDEX must be one of LFACE_FOREGROUND_INDEX, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1234 LFACE_BACKGROUND_INDEX, LFACE_UNDERLINE_INDEX, LFACE_OVERLINE_INDEX, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1235 LFACE_STRIKE_THROUGH_INDEX, or LFACE_BOX_INDEX. Value is the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1236 pixel color. If color cannot be loaded, display a message, and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1237 return the foreground, background or underline color of F, but |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1238 record that fact in flags of the face so that we don't try to free |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1239 these colors. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1240 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1241 unsigned long |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1242 load_color (f, face, name, target_index) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1243 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1244 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1245 Lisp_Object name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1246 enum lface_attribute_index target_index; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1247 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1248 XColor color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1249 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1250 xassert (STRINGP (name)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1251 xassert (target_index == LFACE_FOREGROUND_INDEX |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1252 || target_index == LFACE_BACKGROUND_INDEX |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1253 || target_index == LFACE_UNDERLINE_INDEX |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1254 || target_index == LFACE_OVERLINE_INDEX |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1255 || target_index == LFACE_STRIKE_THROUGH_INDEX |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1256 || target_index == LFACE_BOX_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1257 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1258 /* if the color map is full, defined_color will return a best match |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1259 to the values in an existing cell. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1260 if (!defined_color (f, XSTRING (name)->data, &color, 1)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1261 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1262 add_to_log ("Unable to load color \"%s\"", name, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1263 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1264 switch (target_index) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1265 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1266 case LFACE_FOREGROUND_INDEX: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1267 face->foreground_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1268 color.pixel = FRAME_FOREGROUND_PIXEL (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1269 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1270 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1271 case LFACE_BACKGROUND_INDEX: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1272 face->background_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1273 color.pixel = FRAME_BACKGROUND_PIXEL (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1274 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1275 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1276 case LFACE_UNDERLINE_INDEX: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1277 face->underline_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1278 color.pixel = FRAME_FOREGROUND_PIXEL (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1279 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1280 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1281 case LFACE_OVERLINE_INDEX: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1282 face->overline_color_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1283 color.pixel = FRAME_FOREGROUND_PIXEL (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1284 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1285 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1286 case LFACE_STRIKE_THROUGH_INDEX: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1287 face->strike_through_color_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1288 color.pixel = FRAME_FOREGROUND_PIXEL (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1289 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1290 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1291 case LFACE_BOX_INDEX: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1292 face->box_color_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1293 color.pixel = FRAME_FOREGROUND_PIXEL (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1294 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1295 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1296 default: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1297 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1298 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1299 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1300 #if GLYPH_DEBUG |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1301 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1302 ++ncolors_allocated; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1303 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1304 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1305 return color.pixel; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1306 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1307 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1308 #ifdef HAVE_WINDOW_SYSTEM |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1309 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1310 /* Load colors for face FACE which is used on frame F. Colors are |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1311 specified by slots LFACE_BACKGROUND_INDEX and LFACE_FOREGROUND_INDEX |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1312 of ATTRS. If the background color specified is not supported on F, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1313 try to emulate gray colors with a stipple from Vface_default_stipple. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1314 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1315 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1316 load_face_colors (f, face, attrs) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1317 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1318 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1319 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1320 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1321 Lisp_Object fg, bg; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1322 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1323 bg = attrs[LFACE_BACKGROUND_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1324 fg = attrs[LFACE_FOREGROUND_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1325 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1326 /* Swap colors if face is inverse-video. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1327 if (EQ (attrs[LFACE_INVERSE_INDEX], Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1328 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1329 Lisp_Object tmp; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1330 tmp = fg; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1331 fg = bg; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1332 bg = tmp; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1333 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1334 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1335 /* Check for support for foreground, not for background because |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1336 face_color_supported_p is smart enough to know that grays are |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1337 "supported" as background because we are supposed to use stipple |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1338 for them. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1339 if (!face_color_supported_p (f, XSTRING (bg)->data, 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1340 && !NILP (Fbitmap_spec_p (Vface_default_stipple))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1341 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1342 x_destroy_bitmap (f, face->stipple); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1343 face->stipple = load_pixmap (f, Vface_default_stipple, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1344 &face->pixmap_w, &face->pixmap_h); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1345 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1346 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1347 face->background = load_color (f, face, bg, LFACE_BACKGROUND_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1348 face->foreground = load_color (f, face, fg, LFACE_FOREGROUND_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1349 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1350 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1351 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1352 /* Free color PIXEL on frame F. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1353 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1354 void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1355 unload_color (f, pixel) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1356 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1357 unsigned long pixel; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1358 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1359 /* Nothing to do on W32 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1360 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1361 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1362 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1363 /* Free colors allocated for FACE. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1364 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1365 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1366 free_face_colors (f, face) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1367 struct frame *f; |
13434 | 1368 struct face *face; |
1369 { | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1370 /* Nothing to do on W32 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1371 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1372 #endif /* HAVE_WINDOW_SYSTEM */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1373 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1374 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1375 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1376 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1377 XLFD Font Names |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1378 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1379 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1380 /* An enumerator for each field of an XLFD font name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1381 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1382 enum xlfd_field |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1383 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1384 XLFD_FOUNDRY, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1385 XLFD_FAMILY, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1386 XLFD_WEIGHT, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1387 XLFD_SLANT, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1388 XLFD_SWIDTH, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1389 XLFD_ADSTYLE, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1390 XLFD_PIXEL_SIZE, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1391 XLFD_POINT_SIZE, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1392 XLFD_RESX, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1393 XLFD_RESY, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1394 XLFD_SPACING, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1395 XLFD_AVGWIDTH, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1396 XLFD_REGISTRY, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1397 XLFD_ENCODING, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1398 XLFD_LAST |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1399 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1400 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1401 /* An enumerator for each possible slant value of a font. Taken from |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1402 the XLFD specification. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1403 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1404 enum xlfd_slant |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1405 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1406 XLFD_SLANT_UNKNOWN, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1407 XLFD_SLANT_ROMAN, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1408 XLFD_SLANT_ITALIC, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1409 XLFD_SLANT_OBLIQUE, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1410 XLFD_SLANT_REVERSE_ITALIC, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1411 XLFD_SLANT_REVERSE_OBLIQUE, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1412 XLFD_SLANT_OTHER |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1413 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1414 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1415 /* Relative font weight according to XLFD documentation. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1416 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1417 enum xlfd_weight |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1418 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1419 XLFD_WEIGHT_UNKNOWN, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1420 XLFD_WEIGHT_ULTRA_LIGHT, /* 10 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1421 XLFD_WEIGHT_EXTRA_LIGHT, /* 20 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1422 XLFD_WEIGHT_LIGHT, /* 30 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1423 XLFD_WEIGHT_SEMI_LIGHT, /* 40: SemiLight, Book, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1424 XLFD_WEIGHT_MEDIUM, /* 50: Medium, Normal, Regular, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1425 XLFD_WEIGHT_SEMI_BOLD, /* 60: SemiBold, DemiBold, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1426 XLFD_WEIGHT_BOLD, /* 70: Bold, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1427 XLFD_WEIGHT_EXTRA_BOLD, /* 80: ExtraBold, Heavy, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1428 XLFD_WEIGHT_ULTRA_BOLD /* 90: UltraBold, Black, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1429 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1430 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1431 /* Relative proportionate width. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1432 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1433 enum xlfd_swidth |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1434 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1435 XLFD_SWIDTH_UNKNOWN, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1436 XLFD_SWIDTH_ULTRA_CONDENSED, /* 10 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1437 XLFD_SWIDTH_EXTRA_CONDENSED, /* 20 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1438 XLFD_SWIDTH_CONDENSED, /* 30: Condensed, Narrow, Compressed, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1439 XLFD_SWIDTH_SEMI_CONDENSED, /* 40: semicondensed */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1440 XLFD_SWIDTH_MEDIUM, /* 50: Medium, Normal, Regular, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1441 XLFD_SWIDTH_SEMI_EXPANDED, /* 60: SemiExpanded, DemiExpanded, ... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1442 XLFD_SWIDTH_EXPANDED, /* 70: Expanded... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1443 XLFD_SWIDTH_EXTRA_EXPANDED, /* 80: ExtraExpanded, Wide... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1444 XLFD_SWIDTH_ULTRA_EXPANDED /* 90: UltraExpanded... */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1445 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1446 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1447 /* Structure used for tables mapping XLFD weight, slant, and width |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1448 names to numeric and symbolic values. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1449 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1450 struct table_entry |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1451 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1452 char *name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1453 int numeric; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1454 Lisp_Object *symbol; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1455 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1456 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1457 /* Table of XLFD slant names and their numeric and symbolic |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1458 representations. This table must be sorted by slant names in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1459 ascending order. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1460 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1461 static struct table_entry slant_table[] = |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1462 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1463 {"i", XLFD_SLANT_ITALIC, &Qitalic}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1464 {"o", XLFD_SLANT_OBLIQUE, &Qoblique}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1465 {"ot", XLFD_SLANT_OTHER, &Qitalic}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1466 {"r", XLFD_SLANT_ROMAN, &Qnormal}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1467 {"ri", XLFD_SLANT_REVERSE_ITALIC, &Qreverse_italic}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1468 {"ro", XLFD_SLANT_REVERSE_OBLIQUE, &Qreverse_oblique} |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1469 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1470 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1471 /* Table of XLFD weight names. This table must be sorted by weight |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1472 names in ascending order. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1473 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1474 static struct table_entry weight_table[] = |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1475 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1476 {"black", XLFD_WEIGHT_ULTRA_BOLD, &Qultra_bold}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1477 {"bold", XLFD_WEIGHT_BOLD, &Qbold}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1478 {"book", XLFD_WEIGHT_SEMI_LIGHT, &Qsemi_light}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1479 {"demibold", XLFD_WEIGHT_SEMI_BOLD, &Qsemi_bold}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1480 {"extralight", XLFD_WEIGHT_EXTRA_LIGHT, &Qextra_light}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1481 {"extrabold", XLFD_WEIGHT_EXTRA_BOLD, &Qextra_bold}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1482 {"heavy", XLFD_WEIGHT_EXTRA_BOLD, &Qextra_bold}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1483 {"light", XLFD_WEIGHT_LIGHT, &Qlight}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1484 {"medium", XLFD_WEIGHT_MEDIUM, &Qnormal}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1485 {"normal", XLFD_WEIGHT_MEDIUM, &Qnormal}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1486 {"regular", XLFD_WEIGHT_MEDIUM, &Qnormal}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1487 {"semibold", XLFD_WEIGHT_SEMI_BOLD, &Qsemi_bold}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1488 {"semilight", XLFD_WEIGHT_SEMI_LIGHT, &Qsemi_light}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1489 {"ultralight", XLFD_WEIGHT_ULTRA_LIGHT, &Qultra_light}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1490 {"ultrabold", XLFD_WEIGHT_ULTRA_BOLD, &Qultra_bold} |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1491 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1492 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1493 /* Table of XLFD width names. This table must be sorted by width |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1494 names in ascending order. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1495 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1496 static struct table_entry swidth_table[] = |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1497 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1498 {"compressed", XLFD_SWIDTH_CONDENSED, &Qcondensed}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1499 {"condensed", XLFD_SWIDTH_CONDENSED, &Qcondensed}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1500 {"demiexpanded", XLFD_SWIDTH_SEMI_EXPANDED, &Qsemi_expanded}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1501 {"expanded", XLFD_SWIDTH_EXPANDED, &Qexpanded}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1502 {"extracondensed", XLFD_SWIDTH_EXTRA_CONDENSED, &Qextra_condensed}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1503 {"extraexpanded", XLFD_SWIDTH_EXTRA_EXPANDED, &Qextra_expanded}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1504 {"medium", XLFD_SWIDTH_MEDIUM, &Qnormal}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1505 {"narrow", XLFD_SWIDTH_CONDENSED, &Qcondensed}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1506 {"normal", XLFD_SWIDTH_MEDIUM, &Qnormal}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1507 {"regular", XLFD_SWIDTH_MEDIUM, &Qnormal}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1508 {"semicondensed", XLFD_SWIDTH_SEMI_CONDENSED, &Qsemi_condensed}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1509 {"semiexpanded", XLFD_SWIDTH_SEMI_EXPANDED, &Qsemi_expanded}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1510 {"ultracondensed", XLFD_SWIDTH_ULTRA_CONDENSED, &Qultra_condensed}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1511 {"ultraexpanded", XLFD_SWIDTH_ULTRA_EXPANDED, &Qultra_expanded}, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1512 {"wide", XLFD_SWIDTH_EXTRA_EXPANDED, &Qextra_expanded} |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1513 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1514 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1515 /* Structure used to hold the result of splitting font names in XLFD |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1516 format into their fields. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1517 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1518 struct font_name |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1519 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1520 /* The original name which is modified destructively by |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1521 split_font_name. The pointer is kept here to be able to free it |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1522 if it was allocated from the heap. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1523 char *name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1524 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1525 /* Font name fields. Each vector element points into `name' above. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1526 Fields are NUL-terminated. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1527 char *fields[XLFD_LAST]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1528 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1529 /* Numeric values for those fields that interest us. See |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1530 split_font_name for which these are. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1531 int numeric[XLFD_LAST]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1532 }; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1533 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1534 /* The frame in effect when sorting font names. Set temporarily in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1535 sort_fonts so that it is available in font comparison functions. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1536 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1537 static struct frame *font_frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1538 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1539 /* Order by which font selection chooses fonts. The default values |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1540 mean `first, find a best match for the font width, then for the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1541 font height, then for weight, then for slant.' This variable can be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1542 set via set-face-font-sort-order. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1543 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1544 static int font_sort_order[4]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1545 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1546 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1547 /* Look up FONT.fields[FIELD_INDEX] in TABLE which has DIM entries. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1548 TABLE must be sorted by TABLE[i]->name in ascending order. Value |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1549 is a pointer to the matching table entry or null if no table entry |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1550 matches. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1551 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1552 static struct table_entry * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1553 xlfd_lookup_field_contents (table, dim, font, field_index) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1554 struct table_entry *table; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1555 int dim; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1556 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1557 int field_index; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1558 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1559 /* Function split_font_name converts fields to lower-case, so there |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1560 is no need to use xstrlwr or xstricmp here. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1561 char *s = font->fields[field_index]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1562 int low, mid, high, cmp; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1563 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1564 low = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1565 high = dim - 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1566 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1567 while (low <= high) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1568 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1569 mid = (low + high) / 2; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1570 cmp = strcmp (table[mid].name, s); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1571 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1572 if (cmp < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1573 low = mid + 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1574 else if (cmp > 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1575 high = mid - 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1576 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1577 return table + mid; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1578 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1579 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1580 return NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1581 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1582 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1583 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1584 /* Return a numeric representation for font name field |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1585 FONT.fields[FIELD_INDEX]. The field is looked up in TABLE which |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1586 has DIM entries. Value is the numeric value found or DFLT if no |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1587 table entry matches. This function is used to translate weight, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1588 slant, and swidth names of XLFD font names to numeric values. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1589 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1590 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1591 xlfd_numeric_value (table, dim, font, field_index, dflt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1592 struct table_entry *table; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1593 int dim; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1594 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1595 int field_index; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1596 int dflt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1597 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1598 struct table_entry *p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1599 p = xlfd_lookup_field_contents (table, dim, font, field_index); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1600 return p ? p->numeric : dflt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1601 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1602 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1603 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1604 /* Return a symbolic representation for font name field |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1605 FONT.fields[FIELD_INDEX]. The field is looked up in TABLE which |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1606 has DIM entries. Value is the symbolic value found or DFLT if no |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1607 table entry matches. This function is used to translate weight, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1608 slant, and swidth names of XLFD font names to symbols. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1609 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1610 static INLINE Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1611 xlfd_symbolic_value (table, dim, font, field_index, dflt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1612 struct table_entry *table; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1613 int dim; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1614 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1615 int field_index; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1616 int dflt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1617 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1618 struct table_entry *p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1619 p = xlfd_lookup_field_contents (table, dim, font, field_index); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1620 return p ? *p->symbol : dflt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1621 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1622 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1623 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1624 /* Return a numeric value for the slant of the font given by FONT. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1625 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1626 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1627 xlfd_numeric_slant (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1628 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1629 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1630 return xlfd_numeric_value (slant_table, DIM (slant_table), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1631 font, XLFD_SLANT, XLFD_SLANT_ROMAN); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1632 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1633 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1634 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1635 /* Return a symbol representing the weight of the font given by FONT. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1636 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1637 static INLINE Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1638 xlfd_symbolic_slant (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1639 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1640 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1641 return xlfd_symbolic_value (slant_table, DIM (slant_table), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1642 font, XLFD_SLANT, Qnormal); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1643 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1644 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1645 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1646 /* Return a numeric value for the weight of the font given by FONT. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1647 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1648 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1649 xlfd_numeric_weight (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1650 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1651 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1652 return xlfd_numeric_value (weight_table, DIM (weight_table), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1653 font, XLFD_WEIGHT, XLFD_WEIGHT_MEDIUM); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1654 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1655 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1656 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1657 /* Return a symbol representing the slant of the font given by FONT. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1658 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1659 static INLINE Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1660 xlfd_symbolic_weight (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1661 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1662 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1663 return xlfd_symbolic_value (weight_table, DIM (weight_table), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1664 font, XLFD_WEIGHT, Qnormal); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1665 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1666 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1667 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1668 /* Return a numeric value for the swidth of the font whose XLFD font |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1669 name fields are found in FONT. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1670 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1671 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1672 xlfd_numeric_swidth (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1673 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1674 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1675 return xlfd_numeric_value (swidth_table, DIM (swidth_table), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1676 font, XLFD_SWIDTH, XLFD_SWIDTH_MEDIUM); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1677 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1678 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1679 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1680 /* Return a symbolic value for the swidth of FONT. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1681 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1682 static INLINE Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1683 xlfd_symbolic_swidth (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1684 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1685 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1686 return xlfd_symbolic_value (swidth_table, DIM (swidth_table), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1687 font, XLFD_SWIDTH, Qnormal); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1688 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1689 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1690 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1691 /* Look up the entry of SYMBOL in the vector TABLE which has DIM |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1692 entries. Value is a pointer to the matching table entry or null if |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1693 no element of TABLE contains SYMBOL. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1694 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1695 static struct table_entry * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1696 face_value (table, dim, symbol) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1697 struct table_entry *table; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1698 int dim; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1699 Lisp_Object symbol; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1700 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1701 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1702 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1703 xassert (SYMBOLP (symbol)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1704 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1705 for (i = 0; i < dim; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1706 if (EQ (*table[i].symbol, symbol)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1707 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1708 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1709 return i < dim ? table + i : NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1710 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1711 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1712 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1713 /* Return a numeric value for SYMBOL in the vector TABLE which has DIM |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1714 entries. Value is -1 if SYMBOL is not found in TABLE. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1715 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1716 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1717 face_numeric_value (table, dim, symbol) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1718 struct table_entry *table; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1719 int dim; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1720 Lisp_Object symbol; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1721 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1722 struct table_entry *p = face_value (table, dim, symbol); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1723 return p ? p->numeric : -1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1724 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1725 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1726 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1727 /* Return a numeric value representing the weight specified by Lisp |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1728 symbol WEIGHT. Value is one of the enumerators of enum |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1729 xlfd_weight. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1730 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1731 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1732 face_numeric_weight (weight) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1733 Lisp_Object weight; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1734 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1735 return face_numeric_value (weight_table, DIM (weight_table), weight); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1736 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1737 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1738 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1739 /* Return a numeric value representing the slant specified by Lisp |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1740 symbol SLANT. Value is one of the enumerators of enum xlfd_slant. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1741 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1742 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1743 face_numeric_slant (slant) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1744 Lisp_Object slant; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1745 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1746 return face_numeric_value (slant_table, DIM (slant_table), slant); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1747 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1748 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1749 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1750 /* Return a numeric value representing the swidth specified by Lisp |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1751 symbol WIDTH. Value is one of the enumerators of enum xlfd_swidth. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1752 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1753 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1754 face_numeric_swidth (width) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1755 Lisp_Object width; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1756 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1757 return face_numeric_value (swidth_table, DIM (swidth_table), width); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1758 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1759 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1760 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1761 /* Return non-zero if FONT is the name of a fixed-pitch font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1762 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1763 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1764 xlfd_fixed_p (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1765 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1766 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1767 /* Function split_font_name converts fields to lower-case, so there |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1768 is no need to use tolower here. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1769 return *font->fields[XLFD_SPACING] != 'p'; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1770 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1771 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1772 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1773 /* Return the point size of FONT on frame F, measured in 1/10 pt. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1774 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1775 The actual height of the font when displayed on F depends on the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1776 resolution of both the font and frame. For example, a 10pt font |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1777 designed for a 100dpi display will display larger than 10pt on a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1778 75dpi display. (It's not unusual to use fonts not designed for the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1779 display one is using. For example, some intlfonts are available in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1780 72dpi versions, only.) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1781 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1782 Value is the real point size of FONT on frame F, or 0 if it cannot |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1783 be determined. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1784 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1785 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1786 xlfd_point_size (f, font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1787 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1788 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1789 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1790 double resy = FRAME_W32_DISPLAY_INFO (f)->resy; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1791 double font_resy = atoi (font->fields[XLFD_RESY]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1792 double font_pt = atoi (font->fields[XLFD_POINT_SIZE]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1793 int real_pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1794 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1795 if (font_resy == 0 || font_pt == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1796 real_pt = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1797 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1798 real_pt = (font_resy / resy) * font_pt + 0.5; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1799 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1800 return real_pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1801 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1802 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1803 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1804 /* Split XLFD font name FONT->name destructively into NUL-terminated, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1805 lower-case fields in FONT->fields. NUMERIC_P non-zero means |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1806 compute numeric values for fields XLFD_POINT_SIZE, XLFD_SWIDTH, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1807 XLFD_RESY, XLFD_SLANT, and XLFD_WEIGHT in FONT->numeric. Value is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1808 zero if the font name doesn't have the format we expect. The |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1809 expected format is a font name that starts with a `-' and has |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1810 XLFD_LAST fields separated by `-'. (The XLFD specification allows |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1811 forms of font names where certain field contents are enclosed in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1812 square brackets. We don't support that, for now. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1813 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1814 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1815 split_font_name (f, font, numeric_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1816 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1817 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1818 int numeric_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1819 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1820 int i = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1821 int success_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1822 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1823 if (*font->name == '-') |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1824 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1825 char *p = xstrlwr (font->name) + 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1826 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1827 while (i < XLFD_LAST) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1828 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1829 font->fields[i] = p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1830 ++i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1831 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1832 while (*p && *p != '-') |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1833 ++p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1834 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1835 if (*p != '-') |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1836 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1837 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1838 *p++ = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1839 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1840 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1841 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1842 success_p = i == XLFD_LAST; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1843 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1844 /* If requested, and font name was in the expected format, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1845 compute numeric values for some fields. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1846 if (numeric_p && success_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1847 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1848 font->numeric[XLFD_POINT_SIZE] = xlfd_point_size (f, font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1849 font->numeric[XLFD_RESY] = atoi (font->fields[XLFD_RESY]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1850 font->numeric[XLFD_SLANT] = xlfd_numeric_slant (font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1851 font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1852 font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1853 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1854 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1855 return success_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1856 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1857 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1858 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1859 /* Build an XLFD font name from font name fields in FONT. Value is a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1860 pointer to the font name, which is allocated via xmalloc. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1861 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1862 static char * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1863 build_font_name (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1864 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1865 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1866 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1867 int size = 100; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1868 char *font_name = (char *) xmalloc (size); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1869 int total_length = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1870 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1871 for (i = 0; i < XLFD_LAST; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1872 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1873 /* Add 1 because of the leading `-'. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1874 int len = strlen (font->fields[i]) + 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1875 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1876 /* Reallocate font_name if necessary. Add 1 for the final |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1877 NUL-byte. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1878 if (total_length + len + 1 >= size) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1879 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1880 int new_size = max (2 * size, size + len + 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1881 int sz = new_size * sizeof *font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1882 font_name = (char *) xrealloc (font_name, sz); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1883 size = new_size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1884 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1885 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1886 font_name[total_length] = '-'; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1887 bcopy (font->fields[i], font_name + total_length + 1, len - 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1888 total_length += len; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1889 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1890 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1891 font_name[total_length] = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1892 return font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1893 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1894 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1895 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1896 /* Free an array FONTS of N font_name structures. This frees FONTS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1897 itself and all `name' fields in its elements. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1898 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1899 static INLINE void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1900 free_font_names (fonts, n) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1901 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1902 int n; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1903 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1904 while (n) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1905 xfree (fonts[--n].name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1906 xfree (fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1907 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1908 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1909 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1910 /* Sort vector FONTS of font_name structures which contains NFONTS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1911 elements using qsort and comparison function CMPFN. F is the frame |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1912 on which the fonts will be used. The global variable font_frame |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1913 is temporarily set to F to make it available in CMPFN. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1914 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1915 static INLINE void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1916 sort_fonts (f, fonts, nfonts, cmpfn) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1917 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1918 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1919 int nfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1920 int (*cmpfn) P_ ((const void *, const void *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1921 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1922 font_frame = f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1923 qsort (fonts, nfonts, sizeof *fonts, cmpfn); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1924 font_frame = NULL; |
13434 | 1925 } |
1926 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1927 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1928 /* Get fonts matching PATTERN on frame F. If F is null, use the first |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1929 display in x_display_list. FONTS is a pointer to a vector of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1930 NFONTS font_name structures. TRY_ALTERNATIVES_P non-zero means try |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1931 alternative patterns from Valternate_fontname_alist if no fonts are |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1932 found matching PATTERN. SCALABLE_FONTS_P non-zero means include |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1933 scalable fonts. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1934 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1935 For all fonts found, set FONTS[i].name to the name of the font, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1936 allocated via xmalloc, and split font names into fields. Ignore |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1937 fonts that we can't parse. Value is the number of fonts found. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1938 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1939 This is similar to x_list_fonts. The differences are: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1940 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1941 1. It avoids consing. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1942 2. It never calls XLoadQueryFont. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1943 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1944 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1945 x_face_list_fonts (f, pattern, fonts, nfonts, try_alternatives_p, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1946 scalable_fonts_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1947 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1948 char *pattern; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1949 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1950 int nfonts, try_alternatives_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1951 int scalable_fonts_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1952 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1953 /* NTEMACS_TODO : currently this uses w32_list_fonts, but it may be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1954 better to do it the other way around. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1955 int n = 0, i, j; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1956 char **names = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1957 Lisp_Object lfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1958 Lisp_Object lpattern, tem; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1959 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1960 lpattern = build_string (pattern); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1961 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1962 /* Get the list of fonts matching PATTERN. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1963 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1964 lfonts = w32_list_fonts (f, lpattern, 0, nfonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1965 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1966 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1967 /* Count fonts returned */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1968 for (tem = lfonts; CONSP (tem); tem = XCDR (tem)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1969 n++; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1970 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1971 /* Allocate array. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1972 if (n) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1973 names = (char **) xmalloc (n * sizeof (char *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1974 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1975 /* Extract font names into char * array. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1976 tem = lfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1977 for (i = 0; i < n; i++) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1978 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1979 names[i] = XSTRING (XCAR (tem))->data; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1980 tem = XCDR (tem); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1981 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1982 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1983 if (names) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1984 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1985 /* Make a copy of the font names we got from X, and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1986 split them into fields. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1987 for (i = j = 0; i < n; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1988 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1989 /* Make a copy of the font name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1990 fonts[j].name = xstrdup (names[i]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1991 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1992 /* Ignore fonts having a name that we can't parse. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1993 if (!split_font_name (f, fonts + j, 1)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1994 xfree (fonts[j].name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1995 else if (font_scalable_p (fonts + j)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1996 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1997 #if SCALABLE_FONTS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1998 if (!scalable_fonts_p |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
1999 || !may_use_scalable_font_p (fonts + j, names[i])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2000 xfree (fonts[j].name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2001 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2002 ++j; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2003 #else /* !SCALABLE_FONTS */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2004 /* Always ignore scalable fonts. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2005 xfree (fonts[j].name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2006 #endif /* !SCALABLE_FONTS */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2007 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2008 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2009 ++j; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2010 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2011 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2012 n = j; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2013 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2014 /* Free font names. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2015 #if 0 /* NTEMACS_TODO : W32 equivalent? */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2016 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2017 XFreeFontNames (names); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2018 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2019 #endif /* NTEMACS_TODO */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2020 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2021 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2022 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2023 /* If no fonts found, try patterns from Valternate_fontname_alist. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2024 if (n == 0 && try_alternatives_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2025 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2026 Lisp_Object list = Valternate_fontname_alist; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2027 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2028 while (CONSP (list)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2029 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2030 Lisp_Object entry = XCAR (list); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2031 if (CONSP (entry) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2032 && STRINGP (XCAR (entry)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2033 && strcmp (XSTRING (XCAR (entry))->data, pattern) == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2034 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2035 list = XCDR (list); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2036 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2037 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2038 if (CONSP (list)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2039 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2040 Lisp_Object patterns = XCAR (list); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2041 Lisp_Object name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2042 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2043 while (CONSP (patterns) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2044 /* If list is screwed up, give up. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2045 && (name = XCAR (patterns), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2046 STRINGP (name)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2047 /* Ignore patterns equal to PATTERN because we tried that |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2048 already with no success. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2049 && (strcmp (XSTRING (name)->data, pattern) == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2050 || (n = x_face_list_fonts (f, XSTRING (name)->data, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2051 fonts, nfonts, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2052 scalable_fonts_p), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2053 n == 0))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2054 patterns = XCDR (patterns); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2055 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2056 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2057 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2058 return n; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2059 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2060 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2061 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2062 /* Determine the first font matching PATTERN on frame F. Return in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2063 *FONT the matching font name, split into fields. Value is non-zero |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2064 if a match was found. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2065 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2066 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2067 first_font_matching (f, pattern, font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2068 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2069 char *pattern; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2070 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2071 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2072 int nfonts = 100; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2073 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2074 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2075 fonts = (struct font_name *) xmalloc (nfonts * sizeof *fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2076 nfonts = x_face_list_fonts (f, pattern, fonts, nfonts, 1, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2077 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2078 if (nfonts > 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2079 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2080 bcopy (&fonts[0], font, sizeof *font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2081 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2082 fonts[0].name = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2083 free_font_names (fonts, nfonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2084 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2085 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2086 return nfonts > 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2087 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2088 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2089 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2090 /* Determine fonts matching PATTERN on frame F. Sort resulting fonts |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2091 using comparison function CMPFN. Value is the number of fonts |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2092 found. If value is non-zero, *FONTS is set to a vector of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2093 font_name structures allocated from the heap containing matching |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2094 fonts. Each element of *FONTS contains a name member that is also |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2095 allocated from the heap. Font names in these structures are split |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2096 into fields. Use free_font_names to free such an array. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2097 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2098 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2099 sorted_font_list (f, pattern, cmpfn, fonts) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2100 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2101 char *pattern; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2102 int (*cmpfn) P_ ((const void *, const void *)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2103 struct font_name **fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2104 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2105 int nfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2106 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2107 /* Get the list of fonts matching pattern. 100 should suffice. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2108 nfonts = DEFAULT_FONT_LIST_LIMIT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2109 if (INTEGERP (Vfont_list_limit) && XINT (Vfont_list_limit) > 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2110 nfonts = XFASTINT (Vfont_list_limit); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2111 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2112 *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2113 #if SCALABLE_FONTS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2114 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2115 #else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2116 nfonts = x_face_list_fonts (f, pattern, *fonts, nfonts, 1, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2117 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2118 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2119 /* Sort the resulting array and return it in *FONTS. If no |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2120 fonts were found, make sure to set *FONTS to null. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2121 if (nfonts) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2122 sort_fonts (f, *fonts, nfonts, cmpfn); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2123 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2124 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2125 xfree (*fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2126 *fonts = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2127 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2128 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2129 return nfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2130 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2131 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2132 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2133 /* Compare two font_name structures *A and *B. Value is analogous to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2134 strcmp. Sort order is given by the global variable |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2135 font_sort_order. Font names are sorted so that, everything else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2136 being equal, fonts with a resolution closer to that of the frame on |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2137 which they are used are listed first. The global variable |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2138 font_frame is the frame on which we operate. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2139 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2140 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2141 cmp_font_names (a, b) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2142 const void *a, *b; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2143 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2144 struct font_name *x = (struct font_name *) a; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2145 struct font_name *y = (struct font_name *) b; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2146 int cmp; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2147 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2148 /* All strings have been converted to lower-case by split_font_name, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2149 so we can use strcmp here. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2150 cmp = strcmp (x->fields[XLFD_FAMILY], y->fields[XLFD_FAMILY]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2151 if (cmp == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2152 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2153 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2154 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2155 for (i = 0; i < DIM (font_sort_order) && cmp == 0; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2156 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2157 int j = font_sort_order[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2158 cmp = x->numeric[j] - y->numeric[j]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2159 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2160 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2161 if (cmp == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2162 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2163 /* Everything else being equal, we prefer fonts with an |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2164 y-resolution closer to that of the frame. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2165 int resy = FRAME_W32_DISPLAY_INFO (font_frame)->resy; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2166 int x_resy = x->numeric[XLFD_RESY]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2167 int y_resy = y->numeric[XLFD_RESY]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2168 cmp = abs (resy - x_resy) - abs (resy - y_resy); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2169 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2170 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2171 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2172 return cmp; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2173 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2174 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2175 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2176 /* Get a sorted list of fonts of family FAMILY on frame F. If PATTERN |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2177 is non-null list fonts matching that pattern. Otherwise, if |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2178 REGISTRY_AND_ENCODING is non-null return only fonts with that |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2179 registry and encoding, otherwise return fonts of any registry and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2180 encoding. Set *FONTS to a vector of font_name structures allocated |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2181 from the heap containing the fonts found. Value is the number of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2182 fonts found. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2183 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2184 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2185 font_list (f, pattern, family, registry_and_encoding, fonts) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2186 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2187 char *pattern; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2188 char *family; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2189 char *registry_and_encoding; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2190 struct font_name **fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2191 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2192 if (pattern == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2193 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2194 if (family == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2195 family = "*"; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2196 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2197 if (registry_and_encoding == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2198 registry_and_encoding = "*"; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2199 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2200 pattern = (char *) alloca (strlen (family) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2201 + strlen (registry_and_encoding) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2202 + 10); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2203 if (index (family, '-')) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2204 sprintf (pattern, "-%s-*-%s", family, registry_and_encoding); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2205 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2206 sprintf (pattern, "-*-%s-*-%s", family, registry_and_encoding); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2207 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2208 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2209 return sorted_font_list (f, pattern, cmp_font_names, fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2210 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2211 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2212 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2213 /* Remove elements from LIST whose cars are `equal'. Called from |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2214 x-family-fonts and x-font-family-list to remove duplicate font |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2215 entries. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2216 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2217 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2218 remove_duplicates (list) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2219 Lisp_Object list; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2220 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2221 Lisp_Object tail = list; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2222 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2223 while (!NILP (tail) && !NILP (XCDR (tail))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2224 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2225 Lisp_Object next = XCDR (tail); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2226 if (!NILP (Fequal (XCAR (next), XCAR (tail)))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2227 XCDR (tail) = XCDR (next); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2228 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2229 tail = XCDR (tail); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2230 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2231 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2232 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2233 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2234 DEFUN ("x-family-fonts", Fx_family_fonts, Sx_family_fonts, 0, 2, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2235 "Return a list of available fonts of family FAMILY on FRAME.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2236 If FAMILY is omitted or nil, list all families.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2237 Otherwise, FAMILY must be a string, possibly containing wildcards\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2238 `?' and `*'.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2239 If FRAME is omitted or nil, use the selected frame.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2240 Each element of the result is a vector [FAMILY WIDTH POINT-SIZE WEIGHT\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2241 SLANT FIXED-P FULL REGISTRY-AND-ENCODING].\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2242 FAMILY is the font family name. POINT-SIZE is the size of the\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2243 font in 1/10 pt. WIDTH, WEIGHT, and SLANT are symbols describing the\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2244 width, weight and slant of the font. These symbols are the same as for\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2245 face attributes. FIXED-P is non-nil if the font is fixed-pitch.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2246 FULL is the full name of the font, and REGISTRY-AND-ENCODING is a string\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2247 giving the registry and encoding of the font.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2248 The result list is sorted according to the current setting of\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2249 the face font sort order.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2250 (family, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2251 Lisp_Object family, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2252 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2253 struct frame *f = check_x_frame (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2254 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2255 int i, nfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2256 Lisp_Object result; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2257 struct gcpro gcpro1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2258 char *family_pattern; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2259 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2260 if (NILP (family)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2261 family_pattern = "*"; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2262 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2263 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2264 CHECK_STRING (family, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2265 family_pattern = LSTRDUPA (family); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2266 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2267 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2268 result = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2269 GCPRO1 (result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2270 nfonts = font_list (f, NULL, family_pattern, NULL, &fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2271 for (i = nfonts - 1; i >= 0; --i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2272 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2273 Lisp_Object v = Fmake_vector (make_number (8), Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2274 char *tem; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2275 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2276 #define ASET(VECTOR, IDX, VAL) (XVECTOR (VECTOR)->contents[IDX] = (VAL)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2277 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2278 ASET (v, 0, build_string (fonts[i].fields[XLFD_FAMILY])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2279 ASET (v, 1, xlfd_symbolic_swidth (fonts + i)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2280 ASET (v, 2, make_number (xlfd_point_size (f, fonts + i))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2281 ASET (v, 3, xlfd_symbolic_weight (fonts + i)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2282 ASET (v, 4, xlfd_symbolic_slant (fonts + i)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2283 ASET (v, 5, xlfd_fixed_p (fonts + i) ? Qt : Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2284 tem = build_font_name (fonts + i); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2285 ASET (v, 6, build_string (tem)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2286 sprintf (tem, "%s-%s", fonts[i].fields[XLFD_REGISTRY], |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2287 fonts[i].fields[XLFD_ENCODING]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2288 ASET (v, 7, build_string (tem)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2289 xfree (tem); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2290 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2291 result = Fcons (v, result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2292 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2293 #undef ASET |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2294 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2295 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2296 remove_duplicates (result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2297 free_font_names (fonts, nfonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2298 UNGCPRO; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2299 return result; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2300 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2301 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2302 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2303 DEFUN ("x-font-family-list", Fx_font_family_list, Sx_font_family_list, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2304 0, 1, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2305 "Return a list of available font families on FRAME.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2306 If FRAME is omitted or nil, use the selected frame.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2307 Value is a list of conses (FAMILY . FIXED-P) where FAMILY\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2308 is a font family, and FIXED-P is non-nil if fonts of that family\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2309 are fixed-pitch.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2310 (frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2311 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2312 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2313 struct frame *f = check_x_frame (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2314 int nfonts, i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2315 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2316 Lisp_Object result; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2317 struct gcpro gcpro1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2318 int count = specpdl_ptr - specpdl; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2319 int limit; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2320 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2321 /* Let's consider all fonts. Increase the limit for matching |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2322 fonts until we have them all. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2323 for (limit = 500;;) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2324 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2325 specbind (intern ("font-list-limit"), make_number (limit)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2326 nfonts = font_list (f, NULL, "*", NULL, &fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2327 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2328 if (nfonts == limit) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2329 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2330 free_font_names (fonts, nfonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2331 limit *= 2; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2332 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2333 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2334 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2335 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2336 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2337 result = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2338 GCPRO1 (result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2339 for (i = nfonts - 1; i >= 0; --i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2340 result = Fcons (Fcons (build_string (fonts[i].fields[XLFD_FAMILY]), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2341 xlfd_fixed_p (fonts + i) ? Qt : Qnil), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2342 result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2343 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2344 remove_duplicates (result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2345 free_font_names (fonts, nfonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2346 UNGCPRO; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2347 return unbind_to (count, result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2348 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2349 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2350 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2351 DEFUN ("x-list-fonts", Fx_list_fonts, Sx_list_fonts, 1, 5, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2352 "Return a list of the names of available fonts matching PATTERN.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2353 If optional arguments FACE and FRAME are specified, return only fonts\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2354 the same size as FACE on FRAME.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2355 PATTERN is a string, perhaps with wildcard characters;\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2356 the * character matches any substring, and\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2357 the ? character matches any single character.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2358 PATTERN is case-insensitive.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2359 FACE is a face name--a symbol.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2360 \n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2361 The return value is a list of strings, suitable as arguments to\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2362 set-face-font.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2363 \n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2364 Fonts Emacs can't use may or may not be excluded\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2365 even if they match PATTERN and FACE.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2366 The optional fourth argument MAXIMUM sets a limit on how many\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2367 fonts to match. The first MAXIMUM fonts are reported.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2368 The optional fifth argument WIDTH, if specified, is a number of columns\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2369 occupied by a character of a font. In that case, return only fonts\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2370 the WIDTH times as wide as FACE on FRAME.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2371 (pattern, face, frame, maximum, width) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2372 Lisp_Object pattern, face, frame, maximum, width; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2373 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2374 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2375 int size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2376 int maxnames; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2377 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2378 check_w32 (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2379 CHECK_STRING (pattern, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2380 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2381 if (NILP (maximum)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2382 maxnames = 2000; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2383 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2384 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2385 CHECK_NATNUM (maximum, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2386 maxnames = XINT (maximum); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2387 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2388 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2389 if (!NILP (width)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2390 CHECK_NUMBER (width, 4); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2391 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2392 /* We can't simply call check_x_frame because this function may be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2393 called before any frame is created. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2394 f = frame_or_selected_frame (frame, 2); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2395 if (!FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2396 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2397 /* Perhaps we have not yet created any frame. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2398 f = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2399 face = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2400 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2401 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2402 /* Determine the width standard for comparison with the fonts we find. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2403 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2404 if (NILP (face)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2405 size = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2406 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2407 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2408 /* This is of limited utility since it works with character |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2409 widths. Keep it for compatibility. --gerd. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2410 int face_id = lookup_named_face (f, face, CHARSET_ASCII); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2411 struct face *face = FACE_FROM_ID (f, face_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2412 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2413 if (face->font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2414 size = FONT_MAX_WIDTH (face->font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2415 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2416 size = FONT_MAX_WIDTH (FRAME_FONT (f)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2417 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2418 if (!NILP (width)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2419 size *= XINT (width); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2420 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2421 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2422 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2423 Lisp_Object args[2]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2424 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2425 args[0] = w32_list_fonts (f, pattern, size, maxnames); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2426 if (f == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2427 /* We don't have to check fontsets. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2428 return args[0]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2429 args[1] = list_fontsets (f, pattern, size); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2430 return Fnconc (2, args); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2431 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2432 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2433 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2434 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2435 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2436 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2437 Lisp Faces |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2438 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2439 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2440 /* Access face attributes of face FACE, a Lisp vector. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2441 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2442 #define LFACE_FAMILY(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2443 XVECTOR (LFACE)->contents[LFACE_FAMILY_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2444 #define LFACE_HEIGHT(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2445 XVECTOR (LFACE)->contents[LFACE_HEIGHT_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2446 #define LFACE_WEIGHT(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2447 XVECTOR (LFACE)->contents[LFACE_WEIGHT_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2448 #define LFACE_SLANT(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2449 XVECTOR (LFACE)->contents[LFACE_SLANT_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2450 #define LFACE_UNDERLINE(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2451 XVECTOR (LFACE)->contents[LFACE_UNDERLINE_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2452 #define LFACE_INVERSE(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2453 XVECTOR (LFACE)->contents[LFACE_INVERSE_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2454 #define LFACE_FOREGROUND(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2455 XVECTOR (LFACE)->contents[LFACE_FOREGROUND_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2456 #define LFACE_BACKGROUND(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2457 XVECTOR (LFACE)->contents[LFACE_BACKGROUND_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2458 #define LFACE_STIPPLE(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2459 XVECTOR (LFACE)->contents[LFACE_STIPPLE_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2460 #define LFACE_SWIDTH(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2461 XVECTOR (LFACE)->contents[LFACE_SWIDTH_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2462 #define LFACE_OVERLINE(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2463 XVECTOR (LFACE)->contents[LFACE_OVERLINE_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2464 #define LFACE_STRIKE_THROUGH(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2465 XVECTOR (LFACE)->contents[LFACE_STRIKE_THROUGH_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2466 #define LFACE_BOX(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2467 XVECTOR (LFACE)->contents[LFACE_BOX_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2468 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2469 /* Non-zero if LFACE is a Lisp face. A Lisp face is a vector of size |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2470 LFACE_VECTOR_SIZE which has the symbol `face' in slot 0. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2471 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2472 #define LFACEP(LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2473 (VECTORP (LFACE) \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2474 && XVECTOR (LFACE)->size == LFACE_VECTOR_SIZE \ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2475 && EQ (XVECTOR (LFACE)->contents[0], Qface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2476 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2477 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2478 #if GLYPH_DEBUG |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2479 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2480 /* Check consistency of Lisp face attribute vector ATTRS. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2481 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2482 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2483 check_lface_attrs (attrs) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2484 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2485 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2486 xassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2487 || STRINGP (attrs[LFACE_FAMILY_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2488 xassert (UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2489 || SYMBOLP (attrs[LFACE_SWIDTH_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2490 xassert (UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2491 || INTEGERP (attrs[LFACE_HEIGHT_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2492 xassert (UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2493 || SYMBOLP (attrs[LFACE_WEIGHT_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2494 xassert (UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2495 || SYMBOLP (attrs[LFACE_SLANT_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2496 xassert (UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2497 || SYMBOLP (attrs[LFACE_UNDERLINE_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2498 || STRINGP (attrs[LFACE_UNDERLINE_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2499 xassert (UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2500 || SYMBOLP (attrs[LFACE_OVERLINE_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2501 || STRINGP (attrs[LFACE_OVERLINE_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2502 xassert (UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2503 || SYMBOLP (attrs[LFACE_STRIKE_THROUGH_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2504 || STRINGP (attrs[LFACE_STRIKE_THROUGH_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2505 xassert (UNSPECIFIEDP (attrs[LFACE_BOX_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2506 || SYMBOLP (attrs[LFACE_BOX_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2507 || STRINGP (attrs[LFACE_BOX_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2508 || INTEGERP (attrs[LFACE_BOX_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2509 || CONSP (attrs[LFACE_BOX_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2510 xassert (UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2511 || SYMBOLP (attrs[LFACE_INVERSE_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2512 xassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2513 || STRINGP (attrs[LFACE_FOREGROUND_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2514 xassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2515 || STRINGP (attrs[LFACE_BACKGROUND_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2516 #ifdef HAVE_WINDOW_SYSTEM |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2517 xassert (UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2518 || SYMBOLP (attrs[LFACE_STIPPLE_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2519 || !NILP (Fbitmap_spec_p (attrs[LFACE_STIPPLE_INDEX]))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2520 #endif |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2521 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2522 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2523 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2524 /* Check consistency of attributes of Lisp face LFACE (a Lisp vector). */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2525 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2526 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2527 check_lface (lface) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2528 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2529 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2530 if (!NILP (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2531 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2532 xassert (LFACEP (lface)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2533 check_lface_attrs (XVECTOR (lface)->contents); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2534 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2535 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2536 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2537 #else /* GLYPH_DEBUG == 0 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2538 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2539 #define check_lface_attrs(attrs) (void) 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2540 #define check_lface(lface) (void) 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2541 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2542 #endif /* GLYPH_DEBUG == 0 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2543 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2544 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2545 /* Resolve face name FACE_NAME. If FACE_NAME Is a string, intern it |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2546 to make it a symvol. If FACE_NAME is an alias for another face, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2547 return that face's name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2548 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2549 static Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2550 resolve_face_name (face_name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2551 Lisp_Object face_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2552 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2553 Lisp_Object aliased; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2554 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2555 if (STRINGP (face_name)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2556 face_name = intern (XSTRING (face_name)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2557 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2558 for (;;) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2559 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2560 aliased = Fget (face_name, Qface_alias); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2561 if (NILP (aliased)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2562 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2563 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2564 face_name = aliased; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2565 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2566 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2567 return face_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2568 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2569 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2570 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2571 /* Return the face definition of FACE_NAME on frame F. F null means |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2572 return the global definition. FACE_NAME may be a string or a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2573 symbol (apparently Emacs 20.2 allows strings as face names in face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2574 text properties; ediff uses that). If FACE_NAME is an alias for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2575 another face, return that face's definition. If SIGNAL_P is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2576 non-zero, signal an error if FACE_NAME is not a valid face name. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2577 If SIGNAL_P is zero, value is nil if FACE_NAME is not a valid face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2578 name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2579 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2580 static INLINE Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2581 lface_from_face_name (f, face_name, signal_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2582 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2583 Lisp_Object face_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2584 int signal_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2585 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2586 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2587 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2588 face_name = resolve_face_name (face_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2589 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2590 if (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2591 lface = assq_no_quit (face_name, f->face_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2592 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2593 lface = assq_no_quit (face_name, Vface_new_frame_defaults); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2594 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2595 if (CONSP (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2596 lface = XCDR (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2597 else if (signal_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2598 signal_error ("Invalid face", face_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2599 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2600 check_lface (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2601 return lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2602 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2603 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2604 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2605 /* Get face attributes of face FACE_NAME from frame-local faces on |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2606 frame F. Store the resulting attributes in ATTRS which must point |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2607 to a vector of Lisp_Objects of size LFACE_VECTOR_SIZE. If SIGNAL_P |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2608 is non-zero, signal an error if FACE_NAME does not name a face. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2609 Otherwise, value is zero if FACE_NAME is not a face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2610 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2611 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2612 get_lface_attributes (f, face_name, attrs, signal_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2613 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2614 Lisp_Object face_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2615 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2616 int signal_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2617 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2618 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2619 int success_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2620 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2621 lface = lface_from_face_name (f, face_name, signal_p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2622 if (!NILP (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2623 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2624 bcopy (XVECTOR (lface)->contents, attrs, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2625 LFACE_VECTOR_SIZE * sizeof *attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2626 success_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2627 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2628 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2629 success_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2630 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2631 return success_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2632 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2633 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2634 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2635 /* Non-zero if all attributes in face attribute vector ATTRS are |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2636 specified, i.e. are non-nil. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2637 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2638 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2639 lface_fully_specified_p (attrs) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2640 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2641 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2642 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2643 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2644 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2645 if (UNSPECIFIEDP (attrs[i])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2646 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2647 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2648 return i == LFACE_VECTOR_SIZE; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2649 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2650 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2651 #ifdef HAVE_WINDOW_SYSTEM |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2652 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2653 /* Set font-related attributes of Lisp face LFACE from XLFD font name |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2654 FONT_NAME. If FORCE_P is zero, set only unspecified attributes of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2655 LFACE. MAY_FAIL_P non-zero means return 0 if FONT_NAME isn't a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2656 valid font name; otherwise this function tries to use a reasonable |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2657 default font. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2658 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2659 Ignore fields of FONT_NAME containing wildcards. Value is zero if |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2660 not successful because FONT_NAME was not in a valid format and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2661 MAY_FAIL_P was non-zero. A valid format is one that is suitable |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2662 for split_font_name, see the comment there. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2663 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2664 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2665 set_lface_from_font_name (f, lface, font_name, force_p, may_fail_p) |
13434 | 2666 struct frame *f; |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2667 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2668 char *font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2669 int force_p, may_fail_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2670 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2671 struct font_name font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2672 char *buffer; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2673 int pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2674 int free_font_name_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2675 int have_font_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2676 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2677 /* If FONT_NAME contains wildcards, use the first matching font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2678 if (index (font_name, '*') || index (font_name, '?')) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2679 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2680 if (first_font_matching (f, font_name, &font)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2681 free_font_name_p = have_font_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2682 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2683 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2684 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2685 font.name = STRDUPA (font_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2686 if (split_font_name (f, &font, 1)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2687 have_font_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2688 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2689 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2690 /* The font name may be something like `6x13'. Make |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2691 sure we use the full name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2692 struct font_info *font_info; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2693 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2694 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2695 font_info = fs_load_font (f, FRAME_W32_FONT_TABLE (f), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2696 CHARSET_ASCII, font_name, -1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2697 if (font_info) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2698 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2699 font.name = STRDUPA (font_info->full_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2700 split_font_name (f, &font, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2701 have_font_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2702 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2703 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2704 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2705 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2706 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2707 /* If FONT_NAME is completely bogus try to use something reasonable |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2708 if this function must succeed. Otherwise, give up. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2709 if (!have_font_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2710 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2711 if (may_fail_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2712 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2713 else if (first_font_matching (f, "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-iso8859-1", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2714 &font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2715 || first_font_matching (f, "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2716 &font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2717 || first_font_matching (f, "-*-FixedSys-normal-r-*-*-12-*-*-*-c-*-iso8859-1", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2718 &font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2719 || first_font_matching (f, "-*-*-normal-r-*-*-*-*-*-*-c-*-iso8859-1", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2720 &font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2721 || first_font_matching (f, "FixedSys", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2722 &font)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2723 free_font_name_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2724 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2725 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2726 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2727 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2728 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2729 /* Set attributes only if unspecified, otherwise face defaults for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2730 new frames would never take effect. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2731 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2732 if (force_p || UNSPECIFIEDP (LFACE_FAMILY (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2733 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2734 buffer = (char *) alloca (strlen (font.fields[XLFD_FAMILY]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2735 + strlen (font.fields[XLFD_FOUNDRY]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2736 + 2); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2737 sprintf (buffer, "%s-%s", font.fields[XLFD_FOUNDRY], |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2738 font.fields[XLFD_FAMILY]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2739 LFACE_FAMILY (lface) = build_string (buffer); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2740 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2741 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2742 if (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2743 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2744 pt = xlfd_point_size (f, &font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2745 xassert (pt > 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2746 LFACE_HEIGHT (lface) = make_number (pt); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2747 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2748 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2749 if (force_p || UNSPECIFIEDP (LFACE_SWIDTH (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2750 LFACE_SWIDTH (lface) = xlfd_symbolic_swidth (&font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2751 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2752 if (force_p || UNSPECIFIEDP (LFACE_WEIGHT (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2753 LFACE_WEIGHT (lface) = xlfd_symbolic_weight (&font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2754 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2755 if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2756 LFACE_SLANT (lface) = xlfd_symbolic_slant (&font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2757 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2758 if (free_font_name_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2759 xfree (font.name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2760 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2761 return 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2762 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2763 #endif /* HAVE_WINDOW_SYSTEM */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2764 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2765 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2766 /* Merge two Lisp face attribute vectors FROM and TO and store the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2767 resulting attributes in TO. Every non-nil attribute of FROM |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2768 overrides the corresponding attribute of TO. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2769 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2770 static INLINE void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2771 merge_face_vectors (from, to) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2772 Lisp_Object *from, *to; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2773 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2774 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2775 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2776 if (!UNSPECIFIEDP (from[i])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2777 to[i] = from[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2778 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2779 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2780 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2781 /* Given a Lisp face attribute vector TO and a Lisp object PROP that |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2782 is a face property, determine the resulting face attributes on |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2783 frame F, and store them in TO. PROP may be a single face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2784 specification or a list of such specifications. Each face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2785 specification can be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2786 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2787 1. A symbol or string naming a Lisp face. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2788 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2789 2. A property list of the form (KEYWORD VALUE ...) where each |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2790 KEYWORD is a face attribute name, and value is an appropriate value |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2791 for that attribute. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2792 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2793 3. Conses or the form (FOREGROUND-COLOR . COLOR) or |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2794 (BACKGROUND-COLOR . COLOR) where COLOR is a color name. This is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2795 for compatibility with 20.2. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2796 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2797 Face specifications earlier in lists take precedence over later |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2798 specifications. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2799 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2800 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2801 merge_face_vector_with_property (f, to, prop) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2802 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2803 Lisp_Object *to; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2804 Lisp_Object prop; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2805 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2806 if (CONSP (prop)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2807 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2808 Lisp_Object first = XCAR (prop); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2809 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2810 if (EQ (first, Qforeground_color) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2811 || EQ (first, Qbackground_color)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2812 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2813 /* One of (FOREGROUND-COLOR . COLOR) or (BACKGROUND-COLOR |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2814 . COLOR). COLOR must be a string. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2815 Lisp_Object color_name = XCDR (prop); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2816 Lisp_Object color = first; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2817 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2818 if (STRINGP (color_name)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2819 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2820 if (EQ (color, Qforeground_color)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2821 to[LFACE_FOREGROUND_INDEX] = color_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2822 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2823 to[LFACE_BACKGROUND_INDEX] = color_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2824 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2825 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2826 add_to_log ("Invalid face color", color_name, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2827 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2828 else if (SYMBOLP (first) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2829 && *XSYMBOL (first)->name->data == ':') |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2830 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2831 /* Assume this is the property list form. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2832 while (CONSP (prop) && CONSP (XCDR (prop))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2833 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2834 Lisp_Object keyword = XCAR (prop); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2835 Lisp_Object value = XCAR (XCDR (prop)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2836 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2837 if (EQ (keyword, QCfamily)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2838 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2839 if (STRINGP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2840 to[LFACE_FAMILY_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2841 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2842 add_to_log ("Illegal face font family", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2843 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2844 else if (EQ (keyword, QCheight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2845 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2846 if (INTEGERP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2847 to[LFACE_HEIGHT_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2848 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2849 add_to_log ("Illegal face font height", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2850 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2851 else if (EQ (keyword, QCweight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2852 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2853 if (SYMBOLP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2854 && face_numeric_weight (value) >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2855 to[LFACE_WEIGHT_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2856 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2857 add_to_log ("Illegal face weight", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2858 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2859 else if (EQ (keyword, QCslant)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2860 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2861 if (SYMBOLP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2862 && face_numeric_slant (value) >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2863 to[LFACE_SLANT_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2864 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2865 add_to_log ("Illegal face slant", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2866 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2867 else if (EQ (keyword, QCunderline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2868 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2869 if (EQ (value, Qt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2870 || NILP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2871 || STRINGP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2872 to[LFACE_UNDERLINE_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2873 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2874 add_to_log ("Illegal face underline", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2875 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2876 else if (EQ (keyword, QCoverline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2877 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2878 if (EQ (value, Qt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2879 || NILP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2880 || STRINGP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2881 to[LFACE_OVERLINE_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2882 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2883 add_to_log ("Illegal face overline", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2884 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2885 else if (EQ (keyword, QCstrike_through)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2886 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2887 if (EQ (value, Qt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2888 || NILP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2889 || STRINGP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2890 to[LFACE_STRIKE_THROUGH_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2891 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2892 add_to_log ("Illegal face strike-through", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2893 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2894 else if (EQ (keyword, QCbox)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2895 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2896 if (EQ (value, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2897 value = make_number (1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2898 if (INTEGERP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2899 || STRINGP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2900 || CONSP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2901 || NILP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2902 to[LFACE_BOX_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2903 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2904 add_to_log ("Illegal face box", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2905 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2906 else if (EQ (keyword, QCinverse_video) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2907 || EQ (keyword, QCreverse_video)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2908 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2909 if (EQ (value, Qt) || NILP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2910 to[LFACE_INVERSE_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2911 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2912 add_to_log ("Illegal face inverse-video", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2913 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2914 else if (EQ (keyword, QCforeground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2915 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2916 if (STRINGP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2917 to[LFACE_FOREGROUND_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2918 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2919 add_to_log ("Illegal face foreground", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2920 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2921 else if (EQ (keyword, QCbackground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2922 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2923 if (STRINGP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2924 to[LFACE_BACKGROUND_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2925 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2926 add_to_log ("Illegal face background", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2927 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2928 else if (EQ (keyword, QCstipple)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2929 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2930 Lisp_Object pixmap_p = Fbitmap_spec_p (value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2931 if (!NILP (pixmap_p)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2932 to[LFACE_STIPPLE_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2933 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2934 add_to_log ("Illegal face stipple", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2935 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2936 else if (EQ (keyword, QCwidth)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2937 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2938 if (SYMBOLP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2939 && face_numeric_swidth (value) >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2940 to[LFACE_SWIDTH_INDEX] = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2941 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2942 add_to_log ("Illegal face width", value, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2943 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2944 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2945 add_to_log ("Invalid attribute %s in face property", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2946 keyword, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2947 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2948 prop = XCDR (XCDR (prop)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2949 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2950 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2951 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2952 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2953 /* This is a list of face specs. Specifications at the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2954 beginning of the list take precedence over later |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2955 specifications, so we have to merge starting with the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2956 last specification. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2957 Lisp_Object next = XCDR (prop); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2958 if (!NILP (next)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2959 merge_face_vector_with_property (f, to, next); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2960 merge_face_vector_with_property (f, to, first); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2961 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2962 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2963 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2964 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2965 /* PROP ought to be a face name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2966 Lisp_Object lface = lface_from_face_name (f, prop, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2967 if (NILP (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2968 add_to_log ("Invalid face text property value: %s", prop, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2969 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2970 merge_face_vectors (XVECTOR (lface)->contents, to); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2971 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2972 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2973 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2974 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2975 DEFUN ("internal-make-lisp-face", Finternal_make_lisp_face, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2976 Sinternal_make_lisp_face, 1, 2, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2977 "Make FACE, a symbol, a Lisp face with all attributes nil.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2978 If FACE was not known as a face before, create a new one.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2979 If optional argument FRAME is specified, make a frame-local face\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2980 for that frame. Otherwise operate on the global face definition.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2981 Value is a vector of face attributes.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2982 (face, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2983 Lisp_Object face, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2984 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2985 Lisp_Object global_lface, lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2986 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2987 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2988 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2989 CHECK_SYMBOL (face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2990 global_lface = lface_from_face_name (NULL, face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2991 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2992 if (!NILP (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2993 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2994 CHECK_LIVE_FRAME (frame, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2995 f = XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2996 lface = lface_from_face_name (f, face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2997 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2998 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
2999 f = NULL, lface = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3000 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3001 /* Add a global definition if there is none. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3002 if (NILP (global_lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3003 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3004 global_lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3005 Qunspecified); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3006 XVECTOR (global_lface)->contents[0] = Qface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3007 Vface_new_frame_defaults = Fcons (Fcons (face, global_lface), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3008 Vface_new_frame_defaults); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3009 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3010 /* Assign the new Lisp face a unique ID. The mapping from Lisp |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3011 face id to Lisp face is given by the vector lface_id_to_name. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3012 The mapping from Lisp face to Lisp face id is given by the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3013 property `face' of the Lisp face name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3014 if (next_lface_id == lface_id_to_name_size) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3015 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3016 int new_size = max (50, 2 * lface_id_to_name_size); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3017 int sz = new_size * sizeof *lface_id_to_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3018 lface_id_to_name = (Lisp_Object *) xrealloc (lface_id_to_name, sz); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3019 lface_id_to_name_size = new_size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3020 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3021 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3022 lface_id_to_name[next_lface_id] = face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3023 Fput (face, Qface, make_number (next_lface_id)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3024 ++next_lface_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3025 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3026 else if (f == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3027 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3028 XVECTOR (global_lface)->contents[i] = Qunspecified; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3029 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3030 /* Add a frame-local definition. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3031 if (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3032 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3033 if (NILP (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3034 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3035 lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3036 Qunspecified); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3037 XVECTOR (lface)->contents[0] = Qface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3038 f->face_alist = Fcons (Fcons (face, lface), f->face_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3039 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3040 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3041 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3042 XVECTOR (lface)->contents[i] = Qunspecified; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3043 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3044 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3045 lface = global_lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3046 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3047 xassert (LFACEP (lface)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3048 check_lface (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3049 return lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3050 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3051 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3052 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3053 DEFUN ("internal-lisp-face-p", Finternal_lisp_face_p, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3054 Sinternal_lisp_face_p, 1, 2, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3055 "Return non-nil if FACE names a face.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3056 If optional second parameter FRAME is non-nil, check for the\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3057 existence of a frame-local face with name FACE on that frame.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3058 Otherwise check for the existence of a global face.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3059 (face, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3060 Lisp_Object face, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3061 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3062 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3063 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3064 if (!NILP (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3065 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3066 CHECK_LIVE_FRAME (frame, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3067 lface = lface_from_face_name (XFRAME (frame), face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3068 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3069 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3070 lface = lface_from_face_name (NULL, face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3071 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3072 return lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3073 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3074 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3075 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3076 DEFUN ("internal-copy-lisp-face", Finternal_copy_lisp_face, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3077 Sinternal_copy_lisp_face, 4, 4, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3078 "Copy face FROM to TO.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3079 If FRAME it t, copy the global face definition of FROM to the\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3080 global face definition of TO. Otherwise, copy the frame-local\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3081 definition of FROM on FRAME to the frame-local definition of TO\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3082 on NEW-FRAME, or FRAME if NEW-FRAME is nil.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3083 \n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3084 Value is TO.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3085 (from, to, frame, new_frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3086 Lisp_Object from, to, frame, new_frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3087 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3088 Lisp_Object lface, copy; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3089 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3090 CHECK_SYMBOL (from, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3091 CHECK_SYMBOL (to, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3092 if (NILP (new_frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3093 new_frame = frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3094 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3095 if (EQ (frame, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3096 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3097 /* Copy global definition of FROM. We don't make copies of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3098 strings etc. because 20.2 didn't do it either. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3099 lface = lface_from_face_name (NULL, from, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3100 copy = Finternal_make_lisp_face (to, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3101 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3102 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3103 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3104 /* Copy frame-local definition of FROM. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3105 CHECK_LIVE_FRAME (frame, 2); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3106 CHECK_LIVE_FRAME (new_frame, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3107 lface = lface_from_face_name (XFRAME (frame), from, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3108 copy = Finternal_make_lisp_face (to, new_frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3109 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3110 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3111 bcopy (XVECTOR (lface)->contents, XVECTOR (copy)->contents, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3112 LFACE_VECTOR_SIZE * sizeof (Lisp_Object)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3113 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3114 return to; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3115 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3116 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3117 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3118 DEFUN ("internal-set-lisp-face-attribute", Finternal_set_lisp_face_attribute, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3119 Sinternal_set_lisp_face_attribute, 3, 4, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3120 "Set attribute ATTR of FACE to VALUE.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3121 If optional argument FRAME is given, set the face attribute of face FACE\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3122 on that frame. If FRAME is t, set the attribute of the default for face\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3123 FACE (for new frames). If FRAME is omitted or nil, use the selected\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3124 frame.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3125 (face, attr, value, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3126 Lisp_Object face, attr, value, frame; |
13434 | 3127 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3128 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3129 Lisp_Object old_value = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3130 int font_related_attr_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3131 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3132 CHECK_SYMBOL (face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3133 CHECK_SYMBOL (attr, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3134 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3135 face = resolve_face_name (face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3136 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3137 /* Set lface to the Lisp attribute vector of FACE. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3138 if (EQ (frame, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3139 lface = lface_from_face_name (NULL, face, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3140 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3141 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3142 if (NILP (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3143 frame = selected_frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3144 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3145 CHECK_LIVE_FRAME (frame, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3146 lface = lface_from_face_name (XFRAME (frame), face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3147 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3148 /* If a frame-local face doesn't exist yet, create one. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3149 if (NILP (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3150 lface = Finternal_make_lisp_face (face, frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3151 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3152 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3153 if (EQ (attr, QCfamily)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3154 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3155 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3156 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3157 CHECK_STRING (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3158 if (XSTRING (value)->size == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3159 signal_error ("Invalid face family", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3160 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3161 old_value = LFACE_FAMILY (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3162 LFACE_FAMILY (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3163 font_related_attr_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3164 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3165 else if (EQ (attr, QCheight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3166 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3167 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3168 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3169 CHECK_NUMBER (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3170 if (XINT (value) <= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3171 signal_error ("Invalid face height", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3172 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3173 old_value = LFACE_HEIGHT (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3174 LFACE_HEIGHT (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3175 font_related_attr_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3176 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3177 else if (EQ (attr, QCweight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3178 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3179 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3180 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3181 CHECK_SYMBOL (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3182 if (face_numeric_weight (value) < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3183 signal_error ("Invalid face weight", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3184 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3185 old_value = LFACE_WEIGHT (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3186 LFACE_WEIGHT (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3187 font_related_attr_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3188 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3189 else if (EQ (attr, QCslant)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3190 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3191 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3192 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3193 CHECK_SYMBOL (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3194 if (face_numeric_slant (value) < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3195 signal_error ("Invalid face slant", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3196 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3197 old_value = LFACE_SLANT (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3198 LFACE_SLANT (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3199 font_related_attr_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3200 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3201 else if (EQ (attr, QCunderline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3202 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3203 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3204 if ((SYMBOLP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3205 && !EQ (value, Qt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3206 && !EQ (value, Qnil)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3207 /* Underline color. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3208 || (STRINGP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3209 && XSTRING (value)->size == 0)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3210 signal_error ("Invalid face underline", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3211 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3212 old_value = LFACE_UNDERLINE (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3213 LFACE_UNDERLINE (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3214 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3215 else if (EQ (attr, QCoverline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3216 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3217 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3218 if ((SYMBOLP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3219 && !EQ (value, Qt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3220 && !EQ (value, Qnil)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3221 /* Overline color. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3222 || (STRINGP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3223 && XSTRING (value)->size == 0)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3224 signal_error ("Invalid face overline", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3225 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3226 old_value = LFACE_OVERLINE (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3227 LFACE_OVERLINE (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3228 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3229 else if (EQ (attr, QCstrike_through)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3230 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3231 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3232 if ((SYMBOLP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3233 && !EQ (value, Qt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3234 && !EQ (value, Qnil)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3235 /* Strike-through color. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3236 || (STRINGP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3237 && XSTRING (value)->size == 0)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3238 signal_error ("Invalid face strike-through", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3239 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3240 old_value = LFACE_STRIKE_THROUGH (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3241 LFACE_STRIKE_THROUGH (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3242 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3243 else if (EQ (attr, QCbox)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3244 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3245 int valid_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3246 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3247 /* Allow t meaning a simple box of width 1 in foreground color |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3248 of the face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3249 if (EQ (value, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3250 value = make_number (1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3251 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3252 if (UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3253 valid_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3254 else if (NILP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3255 valid_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3256 else if (INTEGERP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3257 valid_p = XINT (value) > 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3258 else if (STRINGP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3259 valid_p = XSTRING (value)->size > 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3260 else if (CONSP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3261 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3262 Lisp_Object tem; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3263 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3264 tem = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3265 while (CONSP (tem)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3266 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3267 Lisp_Object k, v; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3268 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3269 k = XCAR (tem); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3270 tem = XCDR (tem); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3271 if (!CONSP (tem)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3272 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3273 v = XCAR (tem); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3274 tem = XCDR (tem); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3275 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3276 if (EQ (k, QCline_width)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3277 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3278 if (!INTEGERP (v) || XINT (v) <= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3279 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3280 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3281 else if (EQ (k, QCcolor)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3282 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3283 if (!STRINGP (v) || XSTRING (v)->size == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3284 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3285 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3286 else if (EQ (k, QCstyle)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3287 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3288 if (!EQ (v, Qpressed_button) && !EQ (v, Qreleased_button)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3289 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3290 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3291 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3292 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3293 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3294 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3295 valid_p = NILP (tem); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3296 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3297 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3298 valid_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3299 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3300 if (!valid_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3301 signal_error ("Invalid face box", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3302 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3303 old_value = LFACE_BOX (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3304 LFACE_BOX (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3305 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3306 else if (EQ (attr, QCinverse_video) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3307 || EQ (attr, QCreverse_video)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3308 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3309 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3310 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3311 CHECK_SYMBOL (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3312 if (!EQ (value, Qt) && !NILP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3313 signal_error ("Invalid inverse-video face attribute value", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3314 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3315 old_value = LFACE_INVERSE (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3316 LFACE_INVERSE (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3317 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3318 else if (EQ (attr, QCforeground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3319 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3320 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3321 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3322 /* Don't check for valid color names here because it depends |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3323 on the frame (display) whether the color will be valid |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3324 when the face is realized. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3325 CHECK_STRING (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3326 if (XSTRING (value)->size == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3327 signal_error ("Empty foreground color value", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3328 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3329 old_value = LFACE_FOREGROUND (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3330 LFACE_FOREGROUND (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3331 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3332 else if (EQ (attr, QCbackground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3333 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3334 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3335 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3336 /* Don't check for valid color names here because it depends |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3337 on the frame (display) whether the color will be valid |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3338 when the face is realized. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3339 CHECK_STRING (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3340 if (XSTRING (value)->size == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3341 signal_error ("Empty background color value", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3342 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3343 old_value = LFACE_BACKGROUND (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3344 LFACE_BACKGROUND (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3345 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3346 else if (EQ (attr, QCstipple)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3347 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3348 if (!UNSPECIFIEDP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3349 && !NILP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3350 && NILP (Fbitmap_spec_p (value))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3351 signal_error ("Invalid stipple attribute", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3352 old_value = LFACE_STIPPLE (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3353 LFACE_STIPPLE (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3354 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3355 else if (EQ (attr, QCwidth)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3356 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3357 if (!UNSPECIFIEDP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3358 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3359 CHECK_SYMBOL (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3360 if (face_numeric_swidth (value) < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3361 signal_error ("Invalid face width", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3362 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3363 old_value = LFACE_SWIDTH (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3364 LFACE_SWIDTH (lface) = value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3365 font_related_attr_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3366 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3367 else if (EQ (attr, QCfont)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3368 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3369 /* Set font-related attributes of the Lisp face from an |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3370 XLFD font name. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3371 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3372 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3373 CHECK_STRING (value, 3); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3374 if (EQ (frame, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3375 f = SELECTED_FRAME (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3376 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3377 f = check_x_frame (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3378 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3379 if (!set_lface_from_font_name (f, lface, XSTRING (value)->data, 1, 1)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3380 signal_error ("Invalid font name", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3381 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3382 font_related_attr_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3383 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3384 else if (EQ (attr, QCbold)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3385 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3386 old_value = LFACE_WEIGHT (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3387 LFACE_WEIGHT (lface) = NILP (value) ? Qnormal : Qbold; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3388 font_related_attr_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3389 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3390 else if (EQ (attr, QCitalic)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3391 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3392 old_value = LFACE_SLANT (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3393 LFACE_SLANT (lface) = NILP (value) ? Qnormal : Qitalic; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3394 font_related_attr_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3395 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3396 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3397 signal_error ("Invalid face attribute name", attr); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3398 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3399 /* Changing a named face means that all realized faces depending on |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3400 that face are invalid. Since we cannot tell which realized faces |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3401 depend on the face, make sure they are all removed. This is done |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3402 by incrementing face_change_count. The next call to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3403 init_iterator will then free realized faces. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3404 if (!EQ (frame, Qt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3405 && (EQ (attr, QCfont) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3406 || NILP (Fequal (old_value, value)))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3407 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3408 ++face_change_count; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3409 ++windows_or_buffers_changed; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3410 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3411 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3412 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3413 if (!EQ (frame, Qt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3414 && !UNSPECIFIEDP (value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3415 && NILP (Fequal (old_value, value))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3416 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3417 Lisp_Object param; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3418 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3419 param = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3420 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3421 if (EQ (face, Qdefault)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3422 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3423 /* Changed font-related attributes of the `default' face are |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3424 reflected in changed `font' frame parameters. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3425 if (font_related_attr_p |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3426 && lface_fully_specified_p (XVECTOR (lface)->contents)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3427 set_font_frame_param (frame, lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3428 else if (EQ (attr, QCforeground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3429 param = Qforeground_color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3430 else if (EQ (attr, QCbackground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3431 param = Qbackground_color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3432 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3433 #if 0 /* NTEMACS_TODO : Scroll bar colors on W32? */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3434 else if (EQ (face, Qscroll_bar)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3435 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3436 /* Changing the colors of `scroll-bar' sets frame parameters |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3437 `scroll-bar-foreground' and `scroll-bar-background'. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3438 if (EQ (attr, QCforeground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3439 param = Qscroll_bar_foreground; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3440 else if (EQ (attr, QCbackground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3441 param = Qscroll_bar_background; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3442 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3443 #endif /* NTEMACS_TODO */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3444 else if (EQ (face, Qborder)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3445 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3446 /* Changing background color of `border' sets frame parameter |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3447 `border-color'. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3448 if (EQ (attr, QCbackground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3449 param = Qborder_color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3450 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3451 else if (EQ (face, Qcursor)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3452 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3453 /* Changing background color of `cursor' sets frame parameter |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3454 `cursor-color'. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3455 if (EQ (attr, QCbackground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3456 param = Qcursor_color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3457 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3458 else if (EQ (face, Qmouse)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3459 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3460 /* Changing background color of `mouse' sets frame parameter |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3461 `mouse-color'. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3462 if (EQ (attr, QCbackground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3463 param = Qmouse_color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3464 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3465 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3466 if (SYMBOLP (param)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3467 Fmodify_frame_parameters (frame, Fcons (Fcons (param, value), Qnil)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3468 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3469 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3470 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3471 return face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3472 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3473 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3474 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3475 /* Set the `font' frame parameter of FRAME according to `default' face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3476 attributes LFACE. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3477 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3478 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3479 set_font_frame_param (frame, lface) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3480 Lisp_Object frame, lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3481 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3482 struct frame *f = XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3483 Lisp_Object frame_font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3484 int fontset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3485 char *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3486 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3487 /* Get FRAME's font parameter. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3488 frame_font = Fassq (Qfont, f->param_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3489 xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3490 frame_font = XCDR (frame_font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3491 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3492 fontset = fs_query_fontset (f, XSTRING (frame_font)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3493 if (fontset >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3494 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3495 /* Frame parameter is a fontset name. Modify the fontset so |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3496 that all its fonts reflect face attributes LFACE. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3497 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3498 struct fontset_info *fontset_info; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3499 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3500 fontset_info = FRAME_FONTSET_DATA (f)->fontset_table[fontset]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3501 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3502 for (charset = 0; charset < MAX_CHARSET; ++charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3503 if (fontset_info->fontname[charset]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3504 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3505 font = choose_face_fontset_font (f, XVECTOR (lface)->contents, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3506 fontset, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3507 Fset_fontset_font (frame_font, CHARSET_SYMBOL (charset), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3508 build_string (font), frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3509 xfree (font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3510 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3511 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3512 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3513 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3514 /* Frame parameter is an X font name. I believe this can |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3515 only happen in unibyte mode. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3516 font = choose_face_font (f, XVECTOR (lface)->contents, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3517 -1, Vface_default_registry); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3518 if (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3519 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3520 store_frame_param (f, Qfont, build_string (font)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3521 xfree (font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3522 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3523 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3524 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3525 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3526 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3527 /* Update the corresponding face when frame parameter PARAM on frame F |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3528 has been assigned the value NEW_VALUE. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3529 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3530 void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3531 update_face_from_frame_parameter (f, param, new_value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3532 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3533 Lisp_Object param, new_value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3534 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3535 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3536 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3537 /* If there are no faces yet, give up. This is the case when called |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3538 from Fx_create_frame, and we do the necessary things later in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3539 face-set-after-frame-defaults. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3540 if (NILP (f->face_alist)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3541 return; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3542 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3543 if (EQ (param, Qforeground_color)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3544 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3545 lface = lface_from_face_name (f, Qdefault, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3546 LFACE_FOREGROUND (lface) = (STRINGP (new_value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3547 ? new_value : Qunspecified); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3548 realize_basic_faces (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3549 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3550 else if (EQ (param, Qbackground_color)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3551 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3552 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3553 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3554 /* Changing the background color might change the background |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3555 mode, so that we have to load new defface specs. Call |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3556 frame-update-face-colors to do that. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3557 XSETFRAME (frame, f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3558 call1 (Qframe_update_face_colors, frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3559 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3560 lface = lface_from_face_name (f, Qdefault, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3561 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3562 ? new_value : Qunspecified); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3563 realize_basic_faces (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3564 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3565 if (EQ (param, Qborder_color)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3566 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3567 lface = lface_from_face_name (f, Qborder, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3568 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3569 ? new_value : Qunspecified); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3570 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3571 else if (EQ (param, Qcursor_color)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3572 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3573 lface = lface_from_face_name (f, Qcursor, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3574 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3575 ? new_value : Qunspecified); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3576 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3577 else if (EQ (param, Qmouse_color)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3578 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3579 lface = lface_from_face_name (f, Qmouse, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3580 LFACE_BACKGROUND (lface) = (STRINGP (new_value) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3581 ? new_value : Qunspecified); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3582 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3583 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3584 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3585 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3586 /* Get the value of X resource RESOURCE, class CLASS for the display |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3587 of frame FRAME. This is here because ordinary `x-get-resource' |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3588 doesn't take a frame argument. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3589 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3590 DEFUN ("internal-face-x-get-resource", Finternal_face_x_get_resource, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3591 Sinternal_face_x_get_resource, 3, 3, 0, "") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3592 (resource, class, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3593 Lisp_Object resource, class, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3594 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3595 #if 0 /* NTEMACS_TODO : W32 resources */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3596 Lisp_Object value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3597 CHECK_STRING (resource, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3598 CHECK_STRING (class, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3599 CHECK_LIVE_FRAME (frame, 2); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3600 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3601 value = display_x_get_resource (FRAME_W32_DISPLAY_INFO (XFRAME (frame)), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3602 resource, class, Qnil, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3603 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3604 return value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3605 #endif /* NTEMACS_TODO */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3606 return Qnil; |
13434 | 3607 } |
3608 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3609 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3610 /* Return resource string VALUE as a boolean value, i.e. nil, or t. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3611 If VALUE is "on" or "true", return t. If VALUE is "off" or |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3612 "false", return nil. Otherwise, if SIGNAL_P is non-zero, signal an |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3613 error; if SIGNAL_P is zero, return 0. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3614 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3615 static Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3616 face_boolean_x_resource_value (value, signal_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3617 Lisp_Object value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3618 int signal_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3619 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3620 Lisp_Object result = make_number (0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3621 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3622 xassert (STRINGP (value)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3623 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3624 if (xstricmp (XSTRING (value)->data, "on") == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3625 || xstricmp (XSTRING (value)->data, "true") == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3626 result = Qt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3627 else if (xstricmp (XSTRING (value)->data, "off") == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3628 || xstricmp (XSTRING (value)->data, "false") == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3629 result = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3630 else if (xstricmp (XSTRING (value)->data, "unspecified") == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3631 result = Qunspecified; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3632 else if (signal_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3633 signal_error ("Invalid face attribute value from X resource", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3634 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3635 return result; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3636 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3637 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3638 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3639 DEFUN ("internal-set-lisp-face-attribute-from-resource", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3640 Finternal_set_lisp_face_attribute_from_resource, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3641 Sinternal_set_lisp_face_attribute_from_resource, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3642 3, 4, 0, "") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3643 (face, attr, value, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3644 Lisp_Object face, attr, value, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3645 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3646 CHECK_SYMBOL (face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3647 CHECK_SYMBOL (attr, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3648 CHECK_STRING (value, 2); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3649 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3650 if (xstricmp (XSTRING (value)->data, "unspecified") == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3651 value = Qunspecified; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3652 else if (EQ (attr, QCheight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3653 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3654 value = Fstring_to_number (value, make_number (10)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3655 if (XINT (value) <= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3656 signal_error ("Invalid face height from X resource", value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3657 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3658 else if (EQ (attr, QCbold) || EQ (attr, QCitalic)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3659 value = face_boolean_x_resource_value (value, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3660 else if (EQ (attr, QCweight) || EQ (attr, QCslant) || EQ (attr, QCwidth)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3661 value = intern (XSTRING (value)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3662 else if (EQ (attr, QCreverse_video) || EQ (attr, QCinverse_video)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3663 value = face_boolean_x_resource_value (value, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3664 else if (EQ (attr, QCunderline) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3665 || EQ (attr, QCoverline) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3666 || EQ (attr, QCstrike_through) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3667 || EQ (attr, QCbox)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3668 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3669 Lisp_Object boolean_value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3670 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3671 /* If the result of face_boolean_x_resource_value is t or nil, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3672 VALUE does NOT specify a color. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3673 boolean_value = face_boolean_x_resource_value (value, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3674 if (SYMBOLP (boolean_value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3675 value = boolean_value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3676 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3677 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3678 return Finternal_set_lisp_face_attribute (face, attr, value, frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3679 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3680 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3681 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3682 DEFUN ("internal-get-lisp-face-attribute", Finternal_get_lisp_face_attribute, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3683 Sinternal_get_lisp_face_attribute, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3684 2, 3, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3685 "Return face attribute KEYWORD of face SYMBOL.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3686 If SYMBOL does not name a valid Lisp face or KEYWORD isn't a valid\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3687 face attribute name, signal an error.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3688 If the optional argument FRAME is given, report on face FACE in that\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3689 frame. If FRAME is t, report on the defaults for face FACE (for new\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3690 frames). If FRAME is omitted or nil, use the selected frame.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3691 (symbol, keyword, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3692 Lisp_Object symbol, keyword, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3693 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3694 Lisp_Object lface, value = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3695 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3696 CHECK_SYMBOL (symbol, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3697 CHECK_SYMBOL (keyword, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3698 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3699 if (EQ (frame, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3700 lface = lface_from_face_name (NULL, symbol, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3701 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3702 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3703 if (NILP (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3704 frame = selected_frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3705 CHECK_LIVE_FRAME (frame, 2); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3706 lface = lface_from_face_name (XFRAME (frame), symbol, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3707 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3708 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3709 if (EQ (keyword, QCfamily)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3710 value = LFACE_FAMILY (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3711 else if (EQ (keyword, QCheight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3712 value = LFACE_HEIGHT (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3713 else if (EQ (keyword, QCweight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3714 value = LFACE_WEIGHT (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3715 else if (EQ (keyword, QCslant)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3716 value = LFACE_SLANT (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3717 else if (EQ (keyword, QCunderline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3718 value = LFACE_UNDERLINE (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3719 else if (EQ (keyword, QCoverline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3720 value = LFACE_OVERLINE (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3721 else if (EQ (keyword, QCstrike_through)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3722 value = LFACE_STRIKE_THROUGH (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3723 else if (EQ (keyword, QCbox)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3724 value = LFACE_BOX (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3725 else if (EQ (keyword, QCinverse_video) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3726 || EQ (keyword, QCreverse_video)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3727 value = LFACE_INVERSE (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3728 else if (EQ (keyword, QCforeground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3729 value = LFACE_FOREGROUND (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3730 else if (EQ (keyword, QCbackground)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3731 value = LFACE_BACKGROUND (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3732 else if (EQ (keyword, QCstipple)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3733 value = LFACE_STIPPLE (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3734 else if (EQ (keyword, QCwidth)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3735 value = LFACE_SWIDTH (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3736 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3737 signal_error ("Invalid face attribute name", keyword); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3738 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3739 return value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3740 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3741 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3742 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3743 DEFUN ("internal-lisp-face-attribute-values", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3744 Finternal_lisp_face_attribute_values, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3745 Sinternal_lisp_face_attribute_values, 1, 1, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3746 "Return a list of valid discrete values for face attribute ATTR.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3747 Value is nil if ATTR doesn't have a discrete set of valid values.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3748 (attr) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3749 Lisp_Object attr; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3750 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3751 Lisp_Object result = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3752 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3753 CHECK_SYMBOL (attr, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3754 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3755 if (EQ (attr, QCweight) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3756 || EQ (attr, QCslant) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3757 || EQ (attr, QCwidth)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3758 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3759 /* Extract permissible symbols from tables. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3760 struct table_entry *table; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3761 int i, dim; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3762 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3763 if (EQ (attr, QCweight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3764 table = weight_table, dim = DIM (weight_table); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3765 else if (EQ (attr, QCslant)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3766 table = slant_table, dim = DIM (slant_table); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3767 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3768 table = swidth_table, dim = DIM (swidth_table); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3769 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3770 for (i = 0; i < dim; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3771 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3772 Lisp_Object symbol = *table[i].symbol; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3773 Lisp_Object tail = result; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3774 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3775 while (!NILP (tail) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3776 && !EQ (XCAR (tail), symbol)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3777 tail = XCDR (tail); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3778 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3779 if (NILP (tail)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3780 result = Fcons (symbol, result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3781 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3782 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3783 else if (EQ (attr, QCunderline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3784 result = Fcons (Qt, Fcons (Qnil, Qnil)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3785 else if (EQ (attr, QCoverline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3786 result = Fcons (Qt, Fcons (Qnil, Qnil)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3787 else if (EQ (attr, QCstrike_through)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3788 result = Fcons (Qt, Fcons (Qnil, Qnil)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3789 else if (EQ (attr, QCinverse_video) || EQ (attr, QCreverse_video)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3790 result = Fcons (Qt, Fcons (Qnil, Qnil)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3791 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3792 return result; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3793 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3794 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3795 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3796 DEFUN ("internal-merge-in-global-face", Finternal_merge_in_global_face, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3797 Sinternal_merge_in_global_face, 2, 2, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3798 "Add attributes from frame-default definition of FACE to FACE on FRAME.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3799 (face, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3800 Lisp_Object face, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3801 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3802 Lisp_Object global_lface, local_lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3803 CHECK_LIVE_FRAME (frame, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3804 global_lface = lface_from_face_name (NULL, face, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3805 local_lface = lface_from_face_name (XFRAME (frame), face, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3806 if (NILP (local_lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3807 local_lface = Finternal_make_lisp_face (face, frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3808 merge_face_vectors (XVECTOR (global_lface)->contents, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3809 XVECTOR (local_lface)->contents); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3810 return face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3811 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3812 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3813 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3814 /* The following function is implemented for compatibility with 20.2. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3815 The function is used in x-resolve-fonts when it is asked to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3816 return fonts with the same size as the font of a face. This is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3817 done in fontset.el. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3818 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3819 DEFUN ("face-font", Fface_font, Sface_font, 1, 2, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3820 "Return the font name of face FACE, or nil if it is unspecified.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3821 If the optional argument FRAME is given, report on face FACE in that frame.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3822 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3823 The font default for a face is either nil, or a list\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3824 of the form (bold), (italic) or (bold italic).\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3825 If FRAME is omitted or nil, use the selected frame.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3826 (face, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3827 Lisp_Object face, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3828 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3829 if (EQ (frame, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3830 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3831 Lisp_Object result = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3832 Lisp_Object lface = lface_from_face_name (NULL, face, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3833 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3834 if (!UNSPECIFIEDP (LFACE_WEIGHT (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3835 && !EQ (LFACE_WEIGHT (lface), Qnormal)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3836 result = Fcons (Qbold, result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3837 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3838 if (!NILP (LFACE_SLANT (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3839 && !EQ (LFACE_SLANT (lface), Qnormal)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3840 result = Fcons (Qitalic, result); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3841 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3842 return result; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3843 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3844 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3845 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3846 struct frame *f = frame_or_selected_frame (frame, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3847 int face_id = lookup_named_face (f, face, CHARSET_ASCII); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3848 struct face *face = FACE_FROM_ID (f, face_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3849 return build_string (face->font_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3850 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3851 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3852 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3853 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3854 /* Compare face vectors V1 and V2 for equality. Value is non-zero if |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3855 all attributes are `equal'. Tries to be fast because this function |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3856 is called quite often. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3857 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3858 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3859 lface_equal_p (v1, v2) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3860 Lisp_Object *v1, *v2; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3861 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3862 int i, equal_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3863 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3864 for (i = 1; i < LFACE_VECTOR_SIZE && equal_p; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3865 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3866 Lisp_Object a = v1[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3867 Lisp_Object b = v2[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3868 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3869 /* Type can differ, e.g. when one attribute is unspecified, i.e. nil, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3870 and the other is specified. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3871 equal_p = XTYPE (a) == XTYPE (b); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3872 if (!equal_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3873 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3874 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3875 if (!EQ (a, b)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3876 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3877 switch (XTYPE (a)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3878 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3879 case Lisp_String: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3880 equal_p = (XSTRING (a)->size == XSTRING (b)->size |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3881 && bcmp (XSTRING (a)->data, XSTRING (b)->data, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3882 XSTRING (a)->size) == 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3883 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3884 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3885 case Lisp_Int: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3886 case Lisp_Symbol: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3887 equal_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3888 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3889 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3890 default: |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3891 equal_p = !NILP (Fequal (a, b)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3892 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3893 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3894 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3895 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3896 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3897 return equal_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3898 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3899 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3900 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3901 DEFUN ("internal-lisp-face-equal-p", Finternal_lisp_face_equal_p, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3902 Sinternal_lisp_face_equal_p, 2, 3, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3903 "True if FACE1 and FACE2 are equal.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3904 If the optional argument FRAME is given, report on face FACE in that frame.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3905 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3906 If FRAME is omitted or nil, use the selected frame.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3907 (face1, face2, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3908 Lisp_Object face1, face2, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3909 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3910 int equal_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3911 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3912 Lisp_Object lface1, lface2; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3913 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3914 if (EQ (frame, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3915 f = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3916 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3917 /* Don't use check_x_frame here because this function is called |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3918 before frames exist. At that time, if FRAME is nil, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3919 selected_frame will be used which is the frame dumped with |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3920 Emacs. That frame is not a GUI frame. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3921 f = frame_or_selected_frame (frame, 2); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3922 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3923 lface1 = lface_from_face_name (NULL, face1, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3924 lface2 = lface_from_face_name (NULL, face2, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3925 equal_p = lface_equal_p (XVECTOR (lface1)->contents, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3926 XVECTOR (lface2)->contents); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3927 return equal_p ? Qt : Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3928 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3929 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3930 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3931 DEFUN ("internal-lisp-face-empty-p", Finternal_lisp_face_empty_p, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3932 Sinternal_lisp_face_empty_p, 1, 2, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3933 "True if FACE has no attribute specified.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3934 If the optional argument FRAME is given, report on face FACE in that frame.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3935 If FRAME is t, report on the defaults for face FACE (for new frames).\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3936 If FRAME is omitted or nil, use the selected frame.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3937 (face, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3938 Lisp_Object face, frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3939 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3940 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3941 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3942 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3943 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3944 if (NILP (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3945 frame = selected_frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3946 CHECK_LIVE_FRAME (frame, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3947 f = XFRAME (frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3948 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3949 if (EQ (frame, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3950 lface = lface_from_face_name (NULL, face, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3951 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3952 lface = lface_from_face_name (f, face, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3953 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3954 for (i = 1; i < LFACE_VECTOR_SIZE; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3955 if (!UNSPECIFIEDP (XVECTOR (lface)->contents[i])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3956 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3957 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3958 return i == LFACE_VECTOR_SIZE ? Qt : Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3959 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3960 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3961 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3962 DEFUN ("frame-face-alist", Fframe_face_alist, Sframe_face_alist, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3963 0, 1, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3964 "Return an alist of frame-local faces defined on FRAME.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3965 For internal use only.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3966 (frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3967 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3968 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3969 struct frame *f = frame_or_selected_frame (frame, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3970 return f->face_alist; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3971 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3972 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3973 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3974 /* Return a hash code for Lisp string STRING with case ignored. Used |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3975 below in computing a hash value for a Lisp face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3976 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3977 static INLINE unsigned |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3978 hash_string_case_insensitive (string) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3979 Lisp_Object string; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3980 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3981 unsigned char *s; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3982 unsigned hash = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3983 xassert (STRINGP (string)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3984 for (s = XSTRING (string)->data; *s; ++s) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3985 hash = (hash << 1) ^ tolower (*s); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3986 return hash; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3987 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3988 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3989 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3990 /* Return a hash code for face attribute vector V. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3991 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3992 static INLINE unsigned |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3993 lface_hash (v) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3994 Lisp_Object *v; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3995 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3996 return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3997 ^ hash_string_case_insensitive (v[LFACE_FOREGROUND_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3998 ^ hash_string_case_insensitive (v[LFACE_BACKGROUND_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
3999 ^ (unsigned) v[LFACE_WEIGHT_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4000 ^ (unsigned) v[LFACE_SLANT_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4001 ^ (unsigned) v[LFACE_SWIDTH_INDEX] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4002 ^ XFASTINT (v[LFACE_HEIGHT_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4003 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4004 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4005 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4006 /* Return non-zero if LFACE1 and LFACE2 specify the same font (without |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4007 considering charsets/registries). They do if they specify the same |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4008 family, point size, weight, width and slant. Both LFACE1 and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4009 LFACE2 must be fully-specified. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4010 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4011 static INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4012 lface_same_font_attributes_p (lface1, lface2) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4013 Lisp_Object *lface1, *lface2; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4014 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4015 xassert (lface_fully_specified_p (lface1) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4016 && lface_fully_specified_p (lface2)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4017 return (xstricmp (XSTRING (lface1[LFACE_FAMILY_INDEX])->data, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4018 XSTRING (lface2[LFACE_FAMILY_INDEX])->data) == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4019 && (XFASTINT (lface1[LFACE_HEIGHT_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4020 == XFASTINT (lface2[LFACE_HEIGHT_INDEX])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4021 && EQ (lface1[LFACE_SWIDTH_INDEX], lface2[LFACE_SWIDTH_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4022 && EQ (lface1[LFACE_WEIGHT_INDEX], lface2[LFACE_WEIGHT_INDEX]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4023 && EQ (lface1[LFACE_SLANT_INDEX], lface2[LFACE_SLANT_INDEX])); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4024 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4025 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4026 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4027 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4028 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4029 Realized Faces |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4030 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4031 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4032 /* Allocate and return a new realized face for Lisp face attribute |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4033 vector ATTR, charset CHARSET, and registry REGISTRY. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4034 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4035 static struct face * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4036 make_realized_face (attr, charset, registry) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4037 Lisp_Object *attr; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4038 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4039 Lisp_Object registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4040 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4041 struct face *face = (struct face *) xmalloc (sizeof *face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4042 bzero (face, sizeof *face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4043 face->charset = charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4044 face->registry = registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4045 bcopy (attr, face->lface, sizeof face->lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4046 return face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4047 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4048 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4049 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4050 /* Free realized face FACE, including its X resources. FACE may |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4051 be null. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4052 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4053 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4054 free_realized_face (f, face) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4055 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4056 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4057 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4058 if (face) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4059 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4060 if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4061 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4062 if (face->gc) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4063 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4064 x_free_gc (f, face->gc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4065 face->gc = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4066 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4067 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4068 free_face_colors (f, face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4069 x_destroy_bitmap (f, face->stipple); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4070 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4071 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4072 xfree (face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4073 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4074 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4075 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4076 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4077 /* Prepare face FACE for subsequent display on frame F. This |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4078 allocated GCs if they haven't been allocated yet or have been freed |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4079 by clearing the face cache. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4080 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4081 void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4082 prepare_face_for_display (f, face) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4083 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4084 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4085 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4086 xassert (FRAME_WINDOW_P (f)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4087 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4088 if (face->gc == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4089 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4090 XGCValues xgcv; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4091 unsigned long mask = GCForeground | GCBackground; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4092 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4093 xgcv.foreground = face->foreground; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4094 xgcv.background = face->background; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4095 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4096 /* The font of FACE may be null if we couldn't load it. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4097 if (face->font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4098 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4099 xgcv.font = face->font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4100 mask |= GCFont; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4101 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4102 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4103 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4104 if (face->stipple) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4105 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4106 #if 0 /* NTEMACS_TODO: XGCValues not fully simulated */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4107 xgcv.fill_style = FillOpaqueStippled; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4108 xgcv.stipple = x_bitmap_pixmap (f, face->stipple); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4109 mask |= GCFillStyle | GCStipple; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4110 #endif /* NTEMACS_TODO */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4111 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4112 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4113 face->gc = x_create_gc (f, mask, &xgcv); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4114 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4115 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4116 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4117 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4118 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4119 /* Non-zero if FACE is suitable for displaying ISO8859-1. Used in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4120 macro FACE_SUITABLE_FOR_CHARSET_P to avoid realizing a new face for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4121 ISO8859-1 if the ASCII face suffices. */ |
13434 | 4122 |
4123 int | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4124 face_suitable_for_iso8859_1_p (face) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4125 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4126 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4127 int len = strlen (face->font_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4128 return len >= 9 && xstricmp (face->font_name + len - 9, "iso8859-1") == 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4129 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4130 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4131 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4132 /* Value is non-zero if FACE is suitable for displaying characters |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4133 of CHARSET. CHARSET < 0 means unibyte text. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4134 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4135 INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4136 face_suitable_for_charset_p (face, charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4137 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4138 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4139 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4140 int suitable_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4141 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4142 if (charset < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4143 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4144 if (EQ (face->registry, Vface_default_registry) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4145 || !NILP (Fequal (face->registry, Vface_default_registry))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4146 suitable_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4147 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4148 else if (face->charset == charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4149 suitable_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4150 else if (face->charset == CHARSET_ASCII |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4151 && charset == charset_latin_iso8859_1) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4152 suitable_p = face_suitable_for_iso8859_1_p (face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4153 else if (face->charset == charset_latin_iso8859_1 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4154 && charset == CHARSET_ASCII) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4155 suitable_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4156 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4157 return suitable_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4158 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4159 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4160 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4161 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4162 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4163 Face Cache |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4164 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4165 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4166 /* Return a new face cache for frame F. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4167 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4168 static struct face_cache * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4169 make_face_cache (f) |
13434 | 4170 struct frame *f; |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4171 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4172 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4173 int size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4174 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4175 c = (struct face_cache *) xmalloc (sizeof *c); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4176 bzero (c, sizeof *c); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4177 size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4178 c->buckets = (struct face **) xmalloc (size); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4179 bzero (c->buckets, size); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4180 c->size = 50; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4181 c->faces_by_id = (struct face **) xmalloc (c->size * sizeof *c->faces_by_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4182 c->f = f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4183 return c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4184 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4185 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4186 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4187 /* Clear out all graphics contexts for all realized faces, except for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4188 the basic faces. This should be done from time to time just to avoid |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4189 keeping too many graphics contexts that are no longer needed. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4190 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4191 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4192 clear_face_gcs (c) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4193 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4194 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4195 if (c && FRAME_WINDOW_P (c->f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4196 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4197 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4198 for (i = BASIC_FACE_ID_SENTINEL; i < c->used; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4199 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4200 struct face *face = c->faces_by_id[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4201 if (face && face->gc) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4202 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4203 x_free_gc (c->f, face->gc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4204 face->gc = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4205 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4206 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4207 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4208 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4209 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4210 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4211 /* Free all realized faces in face cache C, including basic faces. C |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4212 may be null. If faces are freed, make sure the frame's current |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4213 matrix is marked invalid, so that a display caused by an expose |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4214 event doesn't try to use faces we destroyed. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4215 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4216 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4217 free_realized_faces (c) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4218 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4219 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4220 if (c && c->used) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4221 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4222 int i, size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4223 struct frame *f = c->f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4224 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4225 for (i = 0; i < c->used; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4226 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4227 free_realized_face (f, c->faces_by_id[i]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4228 c->faces_by_id[i] = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4229 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4230 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4231 c->used = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4232 size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4233 bzero (c->buckets, size); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4234 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4235 /* Must do a thorough redisplay the next time. Mark current |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4236 matrices as invalid because they will reference faces freed |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4237 above. This function is also called when a frame is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4238 destroyed. In this case, the root window of F is nil. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4239 if (WINDOWP (f->root_window)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4240 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4241 clear_current_matrices (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4242 ++windows_or_buffers_changed; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4243 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4244 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4245 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4246 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4247 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4248 /* Free all realized faces on FRAME or on all frames if FRAME is nil. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4249 This is done after attributes of a named face have been changed, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4250 because we can't tell which realized faces depend on that face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4251 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4252 void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4253 free_all_realized_faces (frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4254 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4255 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4256 if (NILP (frame)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4257 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4258 Lisp_Object rest; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4259 FOR_EACH_FRAME (rest, frame) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4260 free_realized_faces (FRAME_FACE_CACHE (XFRAME (frame))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4261 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4262 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4263 free_realized_faces (FRAME_FACE_CACHE (XFRAME (frame))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4264 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4265 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4266 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4267 /* Free face cache C and faces in it, including their X resources. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4268 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4269 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4270 free_face_cache (c) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4271 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4272 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4273 if (c) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4274 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4275 free_realized_faces (c); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4276 xfree (c->buckets); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4277 xfree (c->faces_by_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4278 xfree (c); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4279 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4280 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4281 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4282 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4283 /* Cache realized face FACE in face cache C. HASH is the hash value |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4284 of FACE. If FACE->fontset >= 0, add the new face to the end of the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4285 collision list of the face hash table of C. This is done because |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4286 otherwise lookup_face would find FACE for every charset, even if |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4287 faces with the same attributes but for specific charsets exist. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4288 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4289 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4290 cache_face (c, face, hash) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4291 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4292 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4293 unsigned hash; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4294 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4295 int i = hash % FACE_CACHE_BUCKETS_SIZE; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4296 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4297 face->hash = hash; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4298 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4299 if (face->fontset >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4300 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4301 struct face *last = c->buckets[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4302 if (last) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4303 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4304 while (last->next) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4305 last = last->next; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4306 last->next = face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4307 face->prev = last; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4308 face->next = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4309 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4310 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4311 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4312 c->buckets[i] = face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4313 face->prev = face->next = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4314 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4315 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4316 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4317 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4318 face->prev = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4319 face->next = c->buckets[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4320 if (face->next) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4321 face->next->prev = face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4322 c->buckets[i] = face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4323 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4324 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4325 /* Find a free slot in C->faces_by_id and use the index of the free |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4326 slot as FACE->id. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4327 for (i = 0; i < c->used; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4328 if (c->faces_by_id[i] == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4329 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4330 face->id = i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4331 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4332 /* Maybe enlarge C->faces_by_id. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4333 if (i == c->used && c->used == c->size) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4334 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4335 int new_size = 2 * c->size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4336 int sz = new_size * sizeof *c->faces_by_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4337 c->faces_by_id = (struct face **) xrealloc (c->faces_by_id, sz); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4338 c->size = new_size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4339 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4340 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4341 #if GLYPH_DEBUG |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4342 /* Check that FACE got a unique id. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4343 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4344 int j, n; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4345 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4346 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4347 for (j = n = 0; j < FACE_CACHE_BUCKETS_SIZE; ++j) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4348 for (face = c->buckets[j]; face; face = face->next) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4349 if (face->id == i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4350 ++n; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4351 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4352 xassert (n == 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4353 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4354 #endif /* GLYPH_DEBUG */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4355 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4356 c->faces_by_id[i] = face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4357 if (i == c->used) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4358 ++c->used; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4359 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4360 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4361 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4362 /* Remove face FACE from cache C. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4363 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4364 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4365 uncache_face (c, face) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4366 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4367 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4368 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4369 int i = face->hash % FACE_CACHE_BUCKETS_SIZE; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4370 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4371 if (face->prev) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4372 face->prev->next = face->next; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4373 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4374 c->buckets[i] = face->next; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4375 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4376 if (face->next) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4377 face->next->prev = face->prev; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4378 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4379 c->faces_by_id[face->id] = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4380 if (face->id == c->used) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4381 --c->used; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4382 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4383 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4384 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4385 /* Look up a realized face with face attributes ATTR in the face cache |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4386 of frame F. The face will be used to display characters of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4387 CHARSET. CHARSET < 0 means the face will be used to display |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4388 unibyte text. The value of face-default-registry is used to choose |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4389 a font for the face in that case. Value is the ID of the face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4390 found. If no suitable face is found, realize a new one. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4391 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4392 INLINE int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4393 lookup_face (f, attr, charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4394 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4395 Lisp_Object *attr; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4396 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4397 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4398 struct face_cache *c = FRAME_FACE_CACHE (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4399 unsigned hash; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4400 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4401 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4402 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4403 xassert (c != NULL); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4404 check_lface_attrs (attr); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4405 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4406 /* Look up ATTR in the face cache. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4407 hash = lface_hash (attr); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4408 i = hash % FACE_CACHE_BUCKETS_SIZE; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4409 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4410 for (face = c->buckets[i]; face; face = face->next) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4411 if (face->hash == hash |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4412 && (!FRAME_WINDOW_P (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4413 || FACE_SUITABLE_FOR_CHARSET_P (face, charset)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4414 && lface_equal_p (face->lface, attr)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4415 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4416 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4417 /* If not found, realize a new face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4418 if (face == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4419 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4420 face = realize_face (c, attr, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4421 cache_face (c, face, hash); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4422 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4423 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4424 #if GLYPH_DEBUG |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4425 xassert (face == FACE_FROM_ID (f, face->id)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4426 if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4427 xassert (charset < 0 || FACE_SUITABLE_FOR_CHARSET_P (face, charset)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4428 #endif /* GLYPH_DEBUG */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4429 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4430 return face->id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4431 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4432 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4433 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4434 /* Return the face id of the realized face for named face SYMBOL on |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4435 frame F suitable for displaying characters from CHARSET. CHARSET < |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4436 0 means unibyte text. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4437 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4438 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4439 lookup_named_face (f, symbol, charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4440 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4441 Lisp_Object symbol; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4442 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4443 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4444 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4445 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4446 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4447 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4448 get_lface_attributes (f, symbol, symbol_attrs, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4449 bcopy (default_face->lface, attrs, sizeof attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4450 merge_face_vectors (symbol_attrs, attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4451 return lookup_face (f, attrs, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4452 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4453 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4454 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4455 /* Return the ID of the realized ASCII face of Lisp face with ID |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4456 LFACE_ID on frame F. Value is -1 if LFACE_ID isn't valid. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4457 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4458 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4459 ascii_face_of_lisp_face (f, lface_id) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4460 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4461 int lface_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4462 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4463 int face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4464 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4465 if (lface_id >= 0 && lface_id < lface_id_to_name_size) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4466 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4467 Lisp_Object face_name = lface_id_to_name[lface_id]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4468 face_id = lookup_named_face (f, face_name, CHARSET_ASCII); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4469 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4470 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4471 face_id = -1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4472 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4473 return face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4474 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4475 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4476 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4477 /* Return a face for charset ASCII that is like the face with id |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4478 FACE_ID on frame F, but has a font that is STEPS steps smaller. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4479 STEPS < 0 means larger. Value is the id of the face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4480 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4481 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4482 smaller_face (f, face_id, steps) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4483 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4484 int face_id, steps; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4485 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4486 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4487 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4488 int pt, last_pt, last_height; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4489 int delta; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4490 int new_face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4491 struct face *new_face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4492 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4493 /* If not called for an X frame, just return the original face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4494 if (FRAME_TERMCAP_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4495 return face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4496 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4497 /* Try in increments of 1/2 pt. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4498 delta = steps < 0 ? 5 : -5; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4499 steps = abs (steps); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4500 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4501 face = FACE_FROM_ID (f, face_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4502 bcopy (face->lface, attrs, sizeof attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4503 pt = last_pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4504 new_face_id = face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4505 last_height = FONT_HEIGHT (face->font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4506 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4507 while (steps |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4508 && pt + delta > 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4509 /* Give up if we cannot find a font within 10pt. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4510 && abs (last_pt - pt) < 100) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4511 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4512 /* Look up a face for a slightly smaller/larger font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4513 pt += delta; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4514 attrs[LFACE_HEIGHT_INDEX] = make_number (pt); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4515 new_face_id = lookup_face (f, attrs, CHARSET_ASCII); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4516 new_face = FACE_FROM_ID (f, new_face_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4517 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4518 /* If height changes, count that as one step. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4519 if (FONT_HEIGHT (new_face->font) != last_height) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4520 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4521 --steps; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4522 last_height = FONT_HEIGHT (new_face->font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4523 last_pt = pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4524 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4525 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4526 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4527 return new_face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4528 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4529 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4530 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4531 /* Return a face for charset ASCII that is like the face with id |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4532 FACE_ID on frame F, but has height HEIGHT. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4533 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4534 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4535 face_with_height (f, face_id, height) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4536 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4537 int face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4538 int height; |
13434 | 4539 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4540 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4541 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4542 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4543 if (FRAME_TERMCAP_P (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4544 || height <= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4545 return face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4546 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4547 face = FACE_FROM_ID (f, face_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4548 bcopy (face->lface, attrs, sizeof attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4549 attrs[LFACE_HEIGHT_INDEX] = make_number (height); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4550 face_id = lookup_face (f, attrs, CHARSET_ASCII); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4551 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4552 return face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4553 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4554 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4555 /* Return the face id of the realized face for named face SYMBOL on |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4556 frame F suitable for displaying characters from CHARSET (CHARSET < |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4557 0 means unibyte text), and use attributes of the face FACE_ID for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4558 attributes that aren't completely specified by SYMBOL. This is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4559 like lookup_named_face, except that the default attributes come |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4560 from FACE_ID, not from the default face. FACE_ID is assumed to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4561 be already realized. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4562 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4563 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4564 lookup_derived_face (f, symbol, charset, face_id) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4565 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4566 Lisp_Object symbol; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4567 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4568 int face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4569 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4570 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4571 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4572 struct face *default_face = FACE_FROM_ID (f, face_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4573 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4574 if (!default_face) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4575 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4576 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4577 get_lface_attributes (f, symbol, symbol_attrs, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4578 bcopy (default_face->lface, attrs, sizeof attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4579 merge_face_vectors (symbol_attrs, attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4580 return lookup_face (f, attrs, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4581 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4582 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4583 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4584 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4585 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4586 Font selection |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4587 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4588 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4589 DEFUN ("internal-set-font-selection-order", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4590 Finternal_set_font_selection_order, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4591 Sinternal_set_font_selection_order, 1, 1, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4592 "Set font selection order for face font selection to ORDER.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4593 ORDER must be a list of length 4 containing the symbols `:width',\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4594 `:height', `:weight', and `:slant'. Face attributes appearing\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4595 first in ORDER are matched first, e.g. if `:height' appears before\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4596 `:weight' in ORDER, font selection first tries to find a font with\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4597 a suitable height, and then tries to match the font weight.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4598 Value is ORDER.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4599 (order) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4600 Lisp_Object order; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4601 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4602 Lisp_Object list; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4603 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4604 int indices[4]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4605 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4606 CHECK_LIST (order, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4607 bzero (indices, sizeof indices); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4608 i = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4609 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4610 for (list = order; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4611 CONSP (list) && i < DIM (indices); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4612 list = XCDR (list), ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4613 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4614 Lisp_Object attr = XCAR (list); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4615 int xlfd; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4616 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4617 if (EQ (attr, QCwidth)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4618 xlfd = XLFD_SWIDTH; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4619 else if (EQ (attr, QCheight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4620 xlfd = XLFD_POINT_SIZE; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4621 else if (EQ (attr, QCweight)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4622 xlfd = XLFD_WEIGHT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4623 else if (EQ (attr, QCslant)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4624 xlfd = XLFD_SLANT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4625 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4626 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4627 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4628 if (indices[i] != 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4629 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4630 indices[i] = xlfd; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4631 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4632 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4633 if (!NILP (list) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4634 || i != DIM (indices) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4635 || indices[0] == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4636 || indices[1] == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4637 || indices[2] == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4638 || indices[3] == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4639 signal_error ("Invalid font sort order", order); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4640 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4641 if (bcmp (indices, font_sort_order, sizeof indices) != 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4642 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4643 bcopy (indices, font_sort_order, sizeof font_sort_order); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4644 free_all_realized_faces (Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4645 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4646 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4647 return Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4648 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4649 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4650 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4651 DEFUN ("internal-set-alternative-font-family-alist", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4652 Finternal_set_alternative_font_family_alist, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4653 Sinternal_set_alternative_font_family_alist, 1, 1, 0, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4654 "Define alternative font families to try in face font selection.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4655 ALIST is an alist of (FAMILY ALTERNATIVE1 ALTERNATIVE2 ...) entries.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4656 Each ALTERNATIVE is tried in order if no fonts of font family FAMILY can\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4657 be found. Value is ALIST.") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4658 (alist) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4659 Lisp_Object alist; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4660 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4661 CHECK_LIST (alist, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4662 Vface_alternative_font_family_alist = alist; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4663 free_all_realized_faces (Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4664 return alist; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4665 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4666 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4667 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4668 /* Return the X registry and encoding of font name FONT_NAME on frame F. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4669 Value is nil if not successful. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4670 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4671 static Lisp_Object |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4672 deduce_unibyte_registry (f, font_name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4673 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4674 char *font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4675 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4676 struct font_name font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4677 Lisp_Object registry = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4678 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4679 font.name = STRDUPA (font_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4680 if (split_font_name (f, &font, 0)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4681 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4682 char *buffer; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4683 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4684 /* Extract registry and encoding. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4685 buffer = (char *) alloca (strlen (font.fields[XLFD_REGISTRY]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4686 + strlen (font.fields[XLFD_ENCODING]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4687 + 10); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4688 strcpy (buffer, font.fields[XLFD_REGISTRY]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4689 strcat (buffer, "-"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4690 strcat (buffer, font.fields[XLFD_ENCODING]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4691 registry = build_string (buffer); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4692 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4693 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4694 return registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4695 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4696 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4697 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4698 /* Value is non-zero if FONT is the name of a scalable font. The |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4699 X11R6 XLFD spec says that point size, pixel size, and average width |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4700 are zero for scalable fonts. Intlfonts contain at least one |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4701 scalable font ("*-muleindian-1") for which this isn't true, so we |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4702 just test average width. Windows implementation of XLFD is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4703 slightly broken for backward compatibility with previous broken |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4704 versions, so test for wildcards as well as 0. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4705 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4706 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4707 font_scalable_p (font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4708 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4709 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4710 char *s = font->fields[XLFD_AVGWIDTH]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4711 return (*s == '0' && *(s + 1) == '\0') || *s == '*'; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4712 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4713 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4714 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4715 /* Value is non-zero if FONT1 is a better match for font attributes |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4716 VALUES than FONT2. VALUES is an array of face attribute values in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4717 font sort order. COMPARE_PT_P zero means don't compare point |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4718 sizes. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4719 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4720 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4721 better_font_p (values, font1, font2, compare_pt_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4722 int *values; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4723 struct font_name *font1, *font2; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4724 int compare_pt_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4725 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4726 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4727 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4728 for (i = 0; i < 4; ++i) |
13434 | 4729 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4730 int xlfd_idx = font_sort_order[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4731 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4732 if (compare_pt_p || xlfd_idx != XLFD_POINT_SIZE) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4733 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4734 int delta1 = abs (values[i] - font1->numeric[xlfd_idx]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4735 int delta2 = abs (values[i] - font2->numeric[xlfd_idx]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4736 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4737 if (delta1 > delta2) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4738 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4739 else if (delta1 < delta2) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4740 return 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4741 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4742 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4743 /* The difference may be equal because, e.g., the face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4744 specifies `italic' but we have only `regular' and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4745 `oblique'. Prefer `oblique' in this case. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4746 if ((xlfd_idx == XLFD_WEIGHT || xlfd_idx == XLFD_SLANT) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4747 && font1->numeric[xlfd_idx] > values[i] |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4748 && font2->numeric[xlfd_idx] < values[i]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4749 return 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4750 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4751 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4752 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4753 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4754 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4755 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4756 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4757 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4758 #if SCALABLE_FONTS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4759 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4760 /* Value is non-zero if FONT is an exact match for face attributes in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4761 SPECIFIED. SPECIFIED is an array of face attribute values in font |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4762 sort order. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4763 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4764 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4765 exact_face_match_p (specified, font) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4766 int *specified; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4767 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4768 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4769 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4770 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4771 for (i = 0; i < 4; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4772 if (specified[i] != font->numeric[font_sort_order[i]]) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4773 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4774 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4775 return i == 4; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4776 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4777 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4778 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4779 /* Value is the name of a scaled font, generated from scalable font |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4780 FONT on frame F. SPECIFIED_PT is the point-size to scale FONT to. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4781 Value is allocated from heap. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4782 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4783 static char * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4784 build_scalable_font_name (f, font, specified_pt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4785 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4786 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4787 int specified_pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4788 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4789 char point_size[20], pixel_size[20]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4790 int pixel_value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4791 double resy = FRAME_W32_DISPLAY_INFO (f)->resy; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4792 double pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4793 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4794 /* If scalable font is for a specific resolution, compute |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4795 the point size we must specify from the resolution of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4796 the display and the specified resolution of the font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4797 if (font->numeric[XLFD_RESY] != 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4798 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4799 pt = resy / font->numeric[XLFD_RESY] * specified_pt + 0.5; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4800 pixel_value = font->numeric[XLFD_RESY] / 720.0 * pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4801 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4802 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4803 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4804 pt = specified_pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4805 pixel_value = resy / 720.0 * pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4806 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4807 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4808 /* Set point size of the font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4809 sprintf (point_size, "%d", (int) pt); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4810 font->fields[XLFD_POINT_SIZE] = point_size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4811 font->numeric[XLFD_POINT_SIZE] = pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4812 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4813 /* Set pixel size. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4814 sprintf (pixel_size, "%d", pixel_value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4815 font->fields[XLFD_PIXEL_SIZE] = pixel_size; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4816 font->numeric[XLFD_PIXEL_SIZE] = pixel_value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4817 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4818 /* If font doesn't specify its resolution, use the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4819 resolution of the display. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4820 if (font->numeric[XLFD_RESY] == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4821 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4822 char buffer[20]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4823 sprintf (buffer, "%d", (int) resy); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4824 font->fields[XLFD_RESY] = buffer; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4825 font->numeric[XLFD_RESY] = resy; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4826 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4827 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4828 if (strcmp (font->fields[XLFD_RESX], "0") == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4829 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4830 char buffer[20]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4831 int resx = FRAME_W32_DISPLAY_INFO (f)->resx; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4832 sprintf (buffer, "%d", resx); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4833 font->fields[XLFD_RESX] = buffer; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4834 font->numeric[XLFD_RESX] = resx; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4835 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4836 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4837 return build_font_name (font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4838 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4839 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4840 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4841 /* Value is non-zero if we are allowed to use scalable font FONT. We |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4842 can't run a Lisp function here since this function may be called |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4843 with input blocked. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4844 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4845 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4846 may_use_scalable_font_p (font, name) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4847 struct font_name *font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4848 char *name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4849 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4850 if (EQ (Vscalable_fonts_allowed, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4851 return 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4852 else if (CONSP (Vscalable_fonts_allowed)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4853 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4854 Lisp_Object tail, regexp; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4855 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4856 for (tail = Vscalable_fonts_allowed; CONSP (tail); tail = XCDR (tail)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4857 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4858 regexp = XCAR (tail); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4859 if (STRINGP (regexp) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4860 && fast_c_string_match_ignore_case (regexp, name) >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4861 return 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4862 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4863 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4864 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4865 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4866 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4867 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4868 #endif /* SCALABLE_FONTS != 0 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4869 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4870 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4871 /* Return the name of the best matching font for face attributes |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4872 ATTRS in the array of font_name structures FONTS which contains |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4873 NFONTS elements. Value is a font name which is allocated from |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4874 the heap. FONTS is freed by this function. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4875 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4876 static char * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4877 best_matching_font (f, attrs, fonts, nfonts) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4878 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4879 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4880 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4881 int nfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4882 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4883 char *font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4884 struct font_name *best; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4885 int i, pt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4886 int specified[4]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4887 int exact_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4888 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4889 if (nfonts == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4890 return NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4891 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4892 /* Make specified font attributes available in `specified', |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4893 indexed by sort order. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4894 for (i = 0; i < DIM (font_sort_order); ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4895 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4896 int xlfd_idx = font_sort_order[i]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4897 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4898 if (xlfd_idx == XLFD_SWIDTH) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4899 specified[i] = face_numeric_swidth (attrs[LFACE_SWIDTH_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4900 else if (xlfd_idx == XLFD_POINT_SIZE) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4901 specified[i] = pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4902 else if (xlfd_idx == XLFD_WEIGHT) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4903 specified[i] = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4904 else if (xlfd_idx == XLFD_SLANT) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4905 specified[i] = face_numeric_slant (attrs[LFACE_SLANT_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4906 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4907 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4908 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4909 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4910 #if SCALABLE_FONTS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4911 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4912 /* Set to 1 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4913 exact_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4914 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4915 /* Start with the first non-scalable font in the list. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4916 for (i = 0; i < nfonts; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4917 if (!font_scalable_p (fonts + i)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4918 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4919 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4920 /* Find the best match among the non-scalable fonts. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4921 if (i < nfonts) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4922 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4923 best = fonts + i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4924 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4925 for (i = 1; i < nfonts; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4926 if (!font_scalable_p (fonts + i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4927 && better_font_p (specified, fonts + i, best, 1)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4928 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4929 best = fonts + i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4930 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4931 exact_p = exact_face_match_p (specified, best); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4932 if (exact_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4933 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4934 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4935 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4936 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4937 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4938 best = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4939 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4940 /* Unless we found an exact match among non-scalable fonts, see if |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4941 we can find a better match among scalable fonts. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4942 if (!exact_p) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4943 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4944 /* A scalable font is better if |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4945 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4946 1. its weight, slant, swidth attributes are better, or. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4947 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4948 2. the best non-scalable font doesn't have the required |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4949 point size, and the scalable fonts weight, slant, swidth |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4950 isn't worse. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4951 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4952 int non_scalable_has_exact_height_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4953 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4954 if (best && best->numeric[XLFD_POINT_SIZE] == pt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4955 non_scalable_has_exact_height_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4956 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4957 non_scalable_has_exact_height_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4958 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4959 for (i = 0; i < nfonts; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4960 if (font_scalable_p (fonts + i)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4961 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4962 if (best == NULL |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4963 || better_font_p (specified, fonts + i, best, 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4964 || (!non_scalable_has_exact_height_p |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4965 && !better_font_p (specified, best, fonts + i, 0))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4966 best = fonts + i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4967 } |
13434 | 4968 } |
4969 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4970 if (font_scalable_p (best)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4971 font_name = build_scalable_font_name (f, best, pt); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4972 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4973 font_name = build_font_name (best); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4974 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4975 #else /* !SCALABLE_FONTS */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4976 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4977 /* Find the best non-scalable font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4978 best = fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4979 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4980 for (i = 1; i < nfonts; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4981 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4982 xassert (!font_scalable_p (fonts + i)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4983 if (better_font_p (specified, fonts + i, best, 1)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4984 best = fonts + i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4985 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4986 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4987 font_name = build_font_name (best); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4988 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4989 #endif /* !SCALABLE_FONTS */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4990 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4991 /* Free font_name structures. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4992 free_font_names (fonts, nfonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4993 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4994 return font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4995 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4996 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4997 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4998 /* Try to get a list of fonts on frame F with font family FAMILY and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
4999 registry/encoding REGISTRY. Return in *FONTS a pointer to a vector |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5000 of font_name structures for the fonts matched. Value is the number |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5001 of fonts found. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5002 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5003 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5004 try_font_list (f, attrs, pattern, family, registry, fonts) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5005 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5006 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5007 char *pattern, *family, *registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5008 struct font_name **fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5009 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5010 int nfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5011 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5012 if (family == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5013 family = LSTRDUPA (attrs[LFACE_FAMILY_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5014 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5015 nfonts = font_list (f, pattern, family, registry, fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5016 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5017 if (nfonts == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5018 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5019 Lisp_Object alter; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5020 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5021 /* Try alternative font families from |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5022 Vface_alternative_font_family_alist. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5023 alter = Fassoc (build_string (family), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5024 Vface_alternative_font_family_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5025 if (CONSP (alter)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5026 for (alter = XCDR (alter); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5027 CONSP (alter) && nfonts == 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5028 alter = XCDR (alter)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5029 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5030 if (STRINGP (XCAR (alter))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5031 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5032 family = LSTRDUPA (XCAR (alter)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5033 nfonts = font_list (f, NULL, family, registry, fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5034 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5035 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5036 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5037 /* Try font family of the default face or "fixed". */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5038 if (nfonts == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5039 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5040 struct face *dflt = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5041 if (dflt) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5042 family = LSTRDUPA (dflt->lface[LFACE_FAMILY_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5043 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5044 family = "fixed"; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5045 nfonts = font_list (f, NULL, family, registry, fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5046 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5047 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5048 /* Try any family with the given registry. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5049 if (nfonts == 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5050 nfonts = font_list (f, NULL, "*", registry, fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5051 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5052 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5053 return nfonts; |
13434 | 5054 } |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5055 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5056 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5057 /* Return the registry and encoding pattern that fonts for CHARSET |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5058 should match. Value is allocated from the heap. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5059 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5060 char * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5061 x_charset_registry (charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5062 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5063 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5064 Lisp_Object prop, charset_plist; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5065 char *registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5066 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5067 /* Get registry and encoding from the charset's plist. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5068 charset_plist = CHARSET_TABLE_INFO (charset, CHARSET_PLIST_IDX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5069 prop = Fplist_get (charset_plist, Qx_charset_registry); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5070 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5071 if (STRINGP (prop)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5072 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5073 if (index (XSTRING (prop)->data, '-')) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5074 registry = xstrdup (XSTRING (prop)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5075 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5076 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5077 /* If registry doesn't contain a `-', make it a pattern. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5078 registry = (char *) xmalloc (STRING_BYTES (XSTRING (prop)) + 5); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5079 strcpy (registry, XSTRING (prop)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5080 strcat (registry, "*-*"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5081 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5082 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5083 else if (STRINGP (Vface_default_registry)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5084 registry = xstrdup (XSTRING (Vface_default_registry)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5085 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5086 registry = xstrdup ("iso8859-1"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5087 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5088 return registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5089 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5090 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5091 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5092 /* Return the fontset id of the fontset name or alias name given by |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5093 the family attribute of ATTRS on frame F. Value is -1 if the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5094 family attribute of ATTRS doesn't name a fontset. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5095 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5096 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5097 face_fontset (f, attrs) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5098 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5099 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5100 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5101 Lisp_Object name = attrs[LFACE_FAMILY_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5102 int fontset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5103 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5104 name = Fquery_fontset (name, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5105 if (NILP (name)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5106 fontset = -1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5107 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5108 fontset = fs_query_fontset (f, XSTRING (name)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5109 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5110 return fontset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5111 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5112 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5113 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5114 /* Get the font to use for the face realizing the fully-specified Lisp |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5115 face ATTRS for charset CHARSET on frame F. CHARSET < 0 means |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5116 unibyte text; UNIBYTE_REGISTRY is the registry and encoding to use |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5117 in this case. Value is the font name which is allocated from the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5118 heap (which means that it must be freed eventually). */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5119 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5120 static char * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5121 choose_face_font (f, attrs, charset, unibyte_registry) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5122 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5123 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5124 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5125 Lisp_Object unibyte_registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5126 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5127 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5128 int nfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5129 char *registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5130 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5131 /* ATTRS must be fully-specified. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5132 xassert (lface_fully_specified_p (attrs)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5133 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5134 if (STRINGP (unibyte_registry)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5135 registry = xstrdup (XSTRING (unibyte_registry)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5136 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5137 registry = x_charset_registry (charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5138 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5139 nfonts = try_font_list (f, attrs, NULL, NULL, registry, &fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5140 xfree (registry); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5141 return best_matching_font (f, attrs, fonts, nfonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5142 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5143 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5144 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5145 /* Choose a font to use on frame F to display CHARSET using FONTSET |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5146 with Lisp face attributes specified by ATTRS. CHARSET may be any |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5147 valid charset. CHARSET < 0 means unibyte text. If the fontset |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5148 doesn't contain a font pattern for charset, use the pattern for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5149 CHARSET_ASCII. Value is the font name which is allocated from the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5150 heap and must be freed by the caller. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5151 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5152 static char * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5153 choose_face_fontset_font (f, attrs, fontset, charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5154 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5155 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5156 int fontset, charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5157 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5158 char *pattern; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5159 char *font_name = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5160 struct fontset_info *fontset_info; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5161 struct font_name *fonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5162 int nfonts; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5163 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5164 xassert (fontset >= 0 && fontset < FRAME_FONTSET_DATA (f)->n_fontsets); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5165 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5166 /* For unibyte text, use the ASCII font of the fontset. Using the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5167 ASCII font seems to be the most reasonable thing we can do in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5168 this case. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5169 if (charset < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5170 charset = CHARSET_ASCII; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5171 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5172 /* Get the font name pattern to use for CHARSET from the fontset. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5173 fontset_info = FRAME_FONTSET_DATA (f)->fontset_table[fontset]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5174 pattern = fontset_info->fontname[charset]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5175 if (!pattern) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5176 pattern = fontset_info->fontname[CHARSET_ASCII]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5177 xassert (pattern); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5178 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5179 /* Get a list of fonts matching that pattern and choose the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5180 best match for the specified face attributes from it. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5181 nfonts = try_font_list (f, attrs, pattern, NULL, NULL, &fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5182 font_name = best_matching_font (f, attrs, fonts, nfonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5183 return font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5184 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5185 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5186 |
13434 | 5187 |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5188 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5189 Face Realization |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5190 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5191 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5192 /* Realize basic faces on frame F. Value is zero if frame parameters |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5193 of F don't contain enough information needed to realize the default |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5194 face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5195 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5196 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5197 realize_basic_faces (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5198 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5199 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5200 int success_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5201 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5202 if (realize_default_face (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5203 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5204 realize_named_face (f, Qmode_line, MODE_LINE_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5205 realize_named_face (f, Qtool_bar, TOOL_BAR_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5206 realize_named_face (f, Qfringe, BITMAP_AREA_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5207 realize_named_face (f, Qheader_line, HEADER_LINE_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5208 realize_named_face (f, Qscroll_bar, SCROLL_BAR_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5209 realize_named_face (f, Qborder, BORDER_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5210 realize_named_face (f, Qcursor, CURSOR_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5211 realize_named_face (f, Qmouse, MOUSE_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5212 realize_named_face (f, Qmenu, MENU_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5213 success_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5214 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5215 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5216 return success_p; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5217 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5218 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5219 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5220 /* Realize the default face on frame F. If the face is not fully |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5221 specified, make it fully-specified. Attributes of the default face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5222 that are not explicitly specified are taken from frame parameters. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5223 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5224 static int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5225 realize_default_face (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5226 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5227 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5228 struct face_cache *c = FRAME_FACE_CACHE (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5229 Lisp_Object lface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5230 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5231 Lisp_Object unibyte_registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5232 Lisp_Object frame_font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5233 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5234 int fontset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5235 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5236 /* If the `default' face is not yet known, create it. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5237 lface = lface_from_face_name (f, Qdefault, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5238 if (NILP (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5239 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5240 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5241 XSETFRAME (frame, f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5242 lface = Finternal_make_lisp_face (Qdefault, frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5243 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5244 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5245 if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5246 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5247 /* Set frame_font to the value of the `font' frame parameter. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5248 frame_font = Fassq (Qfont, f->param_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5249 xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5250 frame_font = XCDR (frame_font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5251 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5252 fontset = fs_query_fontset (f, XSTRING (frame_font)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5253 if (fontset >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5254 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5255 /* If frame_font is a fontset name, don't use that for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5256 determining font-related attributes of the default face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5257 because it is just an artificial name. Use the ASCII font of |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5258 the fontset, instead. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5259 struct font_info *font_info; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5260 struct font_name font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5261 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5262 BLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5263 font_info = FS_LOAD_FONT (f, FRAME_W32_FONT_TABLE (f), CHARSET_ASCII, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5264 NULL, fontset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5265 UNBLOCK_INPUT; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5266 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5267 /* Set weight etc. from the ASCII font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5268 if (!set_lface_from_font_name (f, lface, font_info->full_name, 0, 0)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5269 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5270 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5271 /* Remember registry and encoding of the frame font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5272 unibyte_registry = deduce_unibyte_registry (f, font_info->full_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5273 if (STRINGP (unibyte_registry)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5274 Vface_default_registry = unibyte_registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5275 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5276 Vface_default_registry = build_string ("iso8859-1"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5277 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5278 /* But set the family to the fontset alias name. Implementation |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5279 note: When a font is passed to Emacs via `-fn FONT', a |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5280 fontset is created in `x-win.el' whose name ends in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5281 `fontset-startup'. This fontset has an alias name that is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5282 equal to frame_font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5283 xassert (STRINGP (frame_font)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5284 font.name = LSTRDUPA (frame_font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5285 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5286 if (!split_font_name (f, &font, 1) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5287 || xstricmp (font.fields[XLFD_REGISTRY], "fontset") != 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5288 || xstricmp (font.fields[XLFD_ENCODING], "startup") != 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5289 LFACE_FAMILY (lface) = frame_font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5290 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5291 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5292 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5293 /* Frame parameters contain a real font. Fill default face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5294 attributes from that font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5295 if (!set_lface_from_font_name (f, lface, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5296 XSTRING (frame_font)->data, 0, 0)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5297 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5298 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5299 /* Remember registry and encoding of the frame font. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5300 unibyte_registry |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5301 = deduce_unibyte_registry (f, XSTRING (frame_font)->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5302 if (STRINGP (unibyte_registry)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5303 Vface_default_registry = unibyte_registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5304 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5305 Vface_default_registry = build_string ("iso8859-1"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5306 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5307 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5308 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5309 if (!FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5310 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5311 LFACE_FAMILY (lface) = build_string ("default"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5312 LFACE_SWIDTH (lface) = Qnormal; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5313 LFACE_HEIGHT (lface) = make_number (1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5314 LFACE_WEIGHT (lface) = Qnormal; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5315 LFACE_SLANT (lface) = Qnormal; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5316 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5317 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5318 if (UNSPECIFIEDP (LFACE_UNDERLINE (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5319 LFACE_UNDERLINE (lface) = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5320 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5321 if (UNSPECIFIEDP (LFACE_OVERLINE (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5322 LFACE_OVERLINE (lface) = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5323 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5324 if (UNSPECIFIEDP (LFACE_STRIKE_THROUGH (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5325 LFACE_STRIKE_THROUGH (lface) = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5326 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5327 if (UNSPECIFIEDP (LFACE_BOX (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5328 LFACE_BOX (lface) = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5329 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5330 if (UNSPECIFIEDP (LFACE_INVERSE (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5331 LFACE_INVERSE (lface) = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5332 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5333 if (UNSPECIFIEDP (LFACE_FOREGROUND (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5334 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5335 /* This function is called so early that colors are not yet |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5336 set in the frame parameter list. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5337 Lisp_Object color = Fassq (Qforeground_color, f->param_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5338 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5339 if (CONSP (color) && STRINGP (XCDR (color))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5340 LFACE_FOREGROUND (lface) = XCDR (color); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5341 else if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5342 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5343 else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5344 LFACE_FOREGROUND (lface) = build_string (unspecified_fg); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5345 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5346 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5347 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5348 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5349 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5350 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5351 /* This function is called so early that colors are not yet |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5352 set in the frame parameter list. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5353 Lisp_Object color = Fassq (Qbackground_color, f->param_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5354 if (CONSP (color) && STRINGP (XCDR (color))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5355 LFACE_BACKGROUND (lface) = XCDR (color); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5356 else if (FRAME_WINDOW_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5357 return 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5358 else if (FRAME_TERMCAP_P (f) || FRAME_MSDOS_P (f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5359 LFACE_BACKGROUND (lface) = build_string (unspecified_bg); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5360 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5361 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5362 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5363 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5364 if (UNSPECIFIEDP (LFACE_STIPPLE (lface))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5365 LFACE_STIPPLE (lface) = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5366 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5367 /* Realize the face; it must be fully-specified now. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5368 xassert (lface_fully_specified_p (XVECTOR (lface)->contents)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5369 check_lface (lface); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5370 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5371 face = realize_face (c, attrs, CHARSET_ASCII); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5372 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5373 /* Remove the former default face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5374 if (c->used > DEFAULT_FACE_ID) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5375 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5376 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5377 uncache_face (c, default_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5378 free_realized_face (f, default_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5379 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5380 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5381 /* Insert the new default face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5382 cache_face (c, face, lface_hash (attrs)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5383 xassert (face->id == DEFAULT_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5384 return 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5385 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5386 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5387 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5388 /* Realize basic faces other than the default face in face cache C. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5389 SYMBOL is the face name, ID is the face id the realized face must |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5390 have. The default face must have been realized already. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5391 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5392 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5393 realize_named_face (f, symbol, id) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5394 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5395 Lisp_Object symbol; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5396 int id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5397 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5398 struct face_cache *c = FRAME_FACE_CACHE (f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5399 Lisp_Object lface = lface_from_face_name (f, symbol, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5400 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5401 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5402 struct face *new_face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5403 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5404 /* The default face must exist and be fully specified. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5405 get_lface_attributes (f, Qdefault, attrs, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5406 check_lface_attrs (attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5407 xassert (lface_fully_specified_p (attrs)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5408 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5409 /* If SYMBOL isn't know as a face, create it. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5410 if (NILP (lface)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5411 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5412 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5413 XSETFRAME (frame, f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5414 lface = Finternal_make_lisp_face (symbol, frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5415 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5416 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5417 /* Merge SYMBOL's face with the default face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5418 get_lface_attributes (f, symbol, symbol_attrs, 1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5419 merge_face_vectors (symbol_attrs, attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5420 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5421 /* Realize the face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5422 new_face = realize_face (c, attrs, CHARSET_ASCII); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5423 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5424 /* Remove the former face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5425 if (c->used > id) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5426 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5427 struct face *old_face = c->faces_by_id[id]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5428 uncache_face (c, old_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5429 free_realized_face (f, old_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5430 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5431 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5432 /* Insert the new face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5433 cache_face (c, new_face, lface_hash (attrs)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5434 xassert (new_face->id == id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5435 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5436 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5437 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5438 /* Realize the fully-specified face with attributes ATTRS in face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5439 cache C for character set CHARSET or for unibyte text if CHARSET < |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5440 0. Value is a pointer to the newly created realized face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5441 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5442 static struct face * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5443 realize_face (c, attrs, charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5444 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5445 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5446 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5447 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5448 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5449 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5450 /* LFACE must be fully specified. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5451 xassert (c != NULL); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5452 check_lface_attrs (attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5453 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5454 if (FRAME_WINDOW_P (c->f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5455 face = realize_x_face (c, attrs, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5456 else if (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5457 face = realize_tty_face (c, attrs, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5458 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5459 abort (); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5460 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5461 return face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5462 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5463 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5464 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5465 /* Realize the fully-specified face with attributes ATTRS in face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5466 cache C for character set CHARSET or for unibyte text if CHARSET < |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5467 0. Do it for X frame C->f. Value is a pointer to the newly |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5468 created realized face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5469 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5470 static struct face * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5471 realize_x_face (c, attrs, charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5472 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5473 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5474 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5475 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5476 struct face *face, *default_face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5477 struct frame *f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5478 Lisp_Object stipple, overline, strike_through, box; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5479 Lisp_Object unibyte_registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5480 struct gcpro gcpro1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5481 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5482 xassert (FRAME_WINDOW_P (c->f)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5483 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5484 /* If realizing a face for use in unibyte text, get the X registry |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5485 and encoding to use from Vface_default_registry. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5486 if (charset < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5487 unibyte_registry = (STRINGP (Vface_default_registry) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5488 ? Vface_default_registry |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5489 : build_string ("iso8859-1")); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5490 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5491 unibyte_registry = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5492 GCPRO1 (unibyte_registry); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5493 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5494 /* Allocate a new realized face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5495 face = make_realized_face (attrs, charset, unibyte_registry); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5496 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5497 f = c->f; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5498 /* Determine the font to use. Most of the time, the font will be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5499 the same as the font of the default face, so try that first. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5500 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5501 if (default_face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5502 && FACE_SUITABLE_FOR_CHARSET_P (default_face, charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5503 && lface_same_font_attributes_p (default_face->lface, attrs)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5504 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5505 face->font = default_face->font; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5506 face->fontset = default_face->fontset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5507 face->font_info_id = default_face->font_info_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5508 face->font_name = default_face->font_name; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5509 face->registry = default_face->registry; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5510 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5511 else if (charset >= 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5512 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5513 /* For all charsets, we use our own font selection functions to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5514 choose a best matching font for the specified face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5515 attributes. If the face specifies a fontset alias name, the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5516 fontset determines the font name pattern, otherwise we |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5517 construct a font pattern from face attributes and charset. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5518 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5519 char *font_name = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5520 int fontset = face_fontset (f, attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5521 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5522 if (fontset < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5523 font_name = choose_face_font (f, attrs, charset, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5524 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5525 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5526 font_name = choose_face_fontset_font (f, attrs, fontset, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5527 fontset = -1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5528 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5529 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5530 load_face_font_or_fontset (f, face, font_name, fontset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5531 xfree (font_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5532 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5533 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5534 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5535 /* Unibyte case, and font is not equal to that of the default |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5536 face. UNIBYTE_REGISTRY is the X registry and encoding the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5537 font should have. What is a reasonable thing to do if the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5538 user specified a fontset alias name for the face in this |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5539 case? We choose a font by taking the ASCII font of the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5540 fontset, but using UNIBYTE_REGISTRY for its registry and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5541 encoding. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5542 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5543 char *font_name = NULL; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5544 int fontset = face_fontset (f, attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5545 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5546 if (fontset < 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5547 font_name = choose_face_font (f, attrs, charset, unibyte_registry); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5548 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5549 font_name = choose_face_fontset_font (f, attrs, fontset, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5550 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5551 load_face_font_or_fontset (f, face, font_name, -1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5552 xfree (font_name); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5553 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5554 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5555 /* Load colors, and set remaining attributes. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5556 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5557 load_face_colors (f, face, attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5558 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5559 /* Set up box. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5560 box = attrs[LFACE_BOX_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5561 if (STRINGP (box)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5562 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5563 /* A simple box of line width 1 drawn in color given by |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5564 the string. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5565 face->box_color = load_color (f, face, attrs[LFACE_BOX_INDEX], |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5566 LFACE_BOX_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5567 face->box = FACE_SIMPLE_BOX; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5568 face->box_line_width = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5569 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5570 else if (INTEGERP (box)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5571 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5572 /* Simple box of specified line width in foreground color of the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5573 face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5574 xassert (XINT (box) > 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5575 face->box = FACE_SIMPLE_BOX; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5576 face->box_line_width = XFASTINT (box); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5577 face->box_color = face->foreground; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5578 face->box_color_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5579 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5580 else if (CONSP (box)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5581 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5582 /* `(:width WIDTH :color COLOR :shadow SHADOW)'. SHADOW |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5583 being one of `raised' or `sunken'. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5584 face->box = FACE_SIMPLE_BOX; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5585 face->box_color = face->foreground; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5586 face->box_color_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5587 face->box_line_width = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5588 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5589 while (CONSP (box)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5590 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5591 Lisp_Object keyword, value; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5592 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5593 keyword = XCAR (box); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5594 box = XCDR (box); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5595 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5596 if (!CONSP (box)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5597 break; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5598 value = XCAR (box); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5599 box = XCDR (box); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5600 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5601 if (EQ (keyword, QCline_width)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5602 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5603 if (INTEGERP (value) && XINT (value) > 0) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5604 face->box_line_width = XFASTINT (value); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5605 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5606 else if (EQ (keyword, QCcolor)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5607 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5608 if (STRINGP (value)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5609 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5610 face->box_color = load_color (f, face, value, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5611 LFACE_BOX_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5612 face->use_box_color_for_shadows_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5613 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5614 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5615 else if (EQ (keyword, QCstyle)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5616 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5617 if (EQ (value, Qreleased_button)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5618 face->box = FACE_RAISED_BOX; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5619 else if (EQ (value, Qpressed_button)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5620 face->box = FACE_SUNKEN_BOX; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5621 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5622 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5623 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5624 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5625 /* Text underline, overline, strike-through. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5626 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5627 if (EQ (attrs[LFACE_UNDERLINE_INDEX], Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5628 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5629 /* Use default color (same as foreground color). */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5630 face->underline_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5631 face->underline_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5632 face->underline_color = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5633 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5634 else if (STRINGP (attrs[LFACE_UNDERLINE_INDEX])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5635 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5636 /* Use specified color. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5637 face->underline_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5638 face->underline_defaulted_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5639 face->underline_color |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5640 = load_color (f, face, attrs[LFACE_UNDERLINE_INDEX], |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5641 LFACE_UNDERLINE_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5642 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5643 else if (NILP (attrs[LFACE_UNDERLINE_INDEX])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5644 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5645 face->underline_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5646 face->underline_defaulted_p = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5647 face->underline_color = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5648 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5649 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5650 overline = attrs[LFACE_OVERLINE_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5651 if (STRINGP (overline)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5652 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5653 face->overline_color |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5654 = load_color (f, face, attrs[LFACE_OVERLINE_INDEX], |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5655 LFACE_OVERLINE_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5656 face->overline_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5657 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5658 else if (EQ (overline, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5659 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5660 face->overline_color = face->foreground; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5661 face->overline_color_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5662 face->overline_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5663 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5664 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5665 strike_through = attrs[LFACE_STRIKE_THROUGH_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5666 if (STRINGP (strike_through)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5667 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5668 face->strike_through_color |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5669 = load_color (f, face, attrs[LFACE_STRIKE_THROUGH_INDEX], |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5670 LFACE_STRIKE_THROUGH_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5671 face->strike_through_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5672 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5673 else if (EQ (strike_through, Qt)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5674 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5675 face->strike_through_color = face->foreground; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5676 face->strike_through_color_defaulted_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5677 face->strike_through_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5678 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5679 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5680 stipple = attrs[LFACE_STIPPLE_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5681 if (!NILP (stipple)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5682 face->stipple = load_pixmap (f, stipple, &face->pixmap_w, &face->pixmap_h); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5683 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5684 UNGCPRO; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5685 xassert (face->fontset < 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5686 xassert (FACE_SUITABLE_FOR_CHARSET_P (face, charset)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5687 return face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5688 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5689 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5690 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5691 /* Realize the fully-specified face with attributes ATTRS in face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5692 cache C for character set CHARSET or for unibyte text if CHARSET < |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5693 0. Do it for TTY frame C->f. Value is a pointer to the newly |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5694 created realized face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5695 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5696 static struct face * |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5697 realize_tty_face (c, attrs, charset) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5698 struct face_cache *c; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5699 Lisp_Object *attrs; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5700 int charset; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5701 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5702 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5703 int weight, slant; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5704 Lisp_Object color; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5705 Lisp_Object tty_defined_color_alist = |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5706 Fsymbol_value (intern ("tty-defined-color-alist")); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5707 Lisp_Object tty_color_alist = intern ("tty-color-alist"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5708 Lisp_Object frame; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5709 int face_colors_defaulted = 0; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5710 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5711 /* Frame must be a termcap frame. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5712 xassert (FRAME_TERMCAP_P (c->f) || FRAME_MSDOS_P (c->f)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5713 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5714 /* Allocate a new realized face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5715 face = make_realized_face (attrs, charset, Qnil); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5716 face->font_name = FRAME_MSDOS_P (c->f) ? "ms-dos" : "tty"; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5717 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5718 /* Map face attributes to TTY appearances. We map slant to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5719 dimmed text because we want italic text to appear differently |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5720 and because dimmed text is probably used infrequently. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5721 weight = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5722 slant = face_numeric_slant (attrs[LFACE_SLANT_INDEX]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5723 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5724 if (weight > XLFD_WEIGHT_MEDIUM) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5725 face->tty_bold_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5726 if (weight < XLFD_WEIGHT_MEDIUM || slant != XLFD_SLANT_ROMAN) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5727 face->tty_dim_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5728 if (!NILP (attrs[LFACE_UNDERLINE_INDEX])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5729 face->tty_underline_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5730 if (!NILP (attrs[LFACE_INVERSE_INDEX])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5731 face->tty_reverse_p = 1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5732 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5733 /* Map color names to color indices. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5734 face->foreground = FACE_TTY_DEFAULT_FG_COLOR; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5735 face->background = FACE_TTY_DEFAULT_BG_COLOR; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5736 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5737 XSETFRAME (frame, c->f); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5738 color = attrs[LFACE_FOREGROUND_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5739 if (STRINGP (color) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5740 && XSTRING (color)->size |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5741 && !NILP (tty_defined_color_alist) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5742 && (color = Fassoc (color, call1 (tty_color_alist, frame)), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5743 CONSP (color))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5744 /* Associations in tty-defined-color-alist are of the form |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5745 (NAME INDEX R G B). We need the INDEX part. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5746 face->foreground = XINT (XCAR (XCDR (color))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5747 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5748 if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5749 && STRINGP (attrs[LFACE_FOREGROUND_INDEX])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5750 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5751 face->foreground = load_color (c->f, face, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5752 attrs[LFACE_FOREGROUND_INDEX], |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5753 LFACE_FOREGROUND_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5754 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5755 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5756 color = attrs[LFACE_BACKGROUND_INDEX]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5757 if (STRINGP (color) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5758 && XSTRING (color)->size |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5759 && !NILP (tty_defined_color_alist) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5760 && (color = Fassoc (color, call1 (tty_color_alist, frame)), |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5761 CONSP (color))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5762 /* Associations in tty-defined-color-alist are of the form |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5763 (NAME INDEX R G B). We need the INDEX part. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5764 face->background = XINT (XCAR (XCDR (color))); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5765 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5766 if (face->background == FACE_TTY_DEFAULT_BG_COLOR |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5767 && STRINGP (attrs[LFACE_BACKGROUND_INDEX])) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5768 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5769 face->background = load_color (c->f, face, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5770 attrs[LFACE_BACKGROUND_INDEX], |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5771 LFACE_BACKGROUND_INDEX); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5772 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5773 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5774 /* Swap colors if face is inverse-video. If the colors are taken |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5775 from the frame colors, they are already inverted, since the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5776 frame-creation function calls x-handle-reverse-video. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5777 if (face->tty_reverse_p && !face_colors_defaulted) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5778 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5779 unsigned long tem = face->foreground; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5780 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5781 face->foreground = face->background; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5782 face->background = tem; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5783 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5784 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5785 return face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5786 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5787 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5788 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5789 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5790 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5791 Computing Faces |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5792 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5793 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5794 /* Return the ID of the face to use to display character CH with face |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5795 property PROP on frame F in current_buffer. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5796 |
13434 | 5797 int |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5798 compute_char_face (f, ch, prop) |
13434 | 5799 struct frame *f; |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5800 int ch; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5801 Lisp_Object prop; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5802 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5803 int face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5804 int charset = (NILP (current_buffer->enable_multibyte_characters) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5805 ? -1 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5806 : CHAR_CHARSET (ch)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5807 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5808 if (NILP (prop)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5809 face_id = FACE_FOR_CHARSET (f, DEFAULT_FACE_ID, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5810 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5811 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5812 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5813 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5814 bcopy (default_face->lface, attrs, sizeof attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5815 merge_face_vector_with_property (f, attrs, prop); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5816 face_id = lookup_face (f, attrs, charset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5817 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5818 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5819 return face_id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5820 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5821 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5822 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5823 /* Return the face ID associated with buffer position POS for |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5824 displaying ASCII characters. Return in *ENDPTR the position at |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5825 which a different face is needed, as far as text properties and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5826 overlays are concerned. W is a window displaying current_buffer. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5827 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5828 REGION_BEG, REGION_END delimit the region, so it can be |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5829 highlighted. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5830 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5831 LIMIT is a position not to scan beyond. That is to limit the time |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5832 this function can take. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5833 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5834 If MOUSE is non-zero, use the character's mouse-face, not its face. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5835 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5836 The face returned is suitable for displaying CHARSET_ASCII if |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5837 current_buffer->enable_multibyte_characters is non-nil. Otherwise, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5838 the face is suitable for displaying unibyte text. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5839 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5840 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5841 face_at_buffer_position (w, pos, region_beg, region_end, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5842 endptr, limit, mouse) |
13434 | 5843 struct window *w; |
5844 int pos; | |
5845 int region_beg, region_end; | |
5846 int *endptr; | |
5847 int limit; | |
5848 int mouse; | |
5849 { | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5850 struct frame *f = XFRAME (w->frame); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5851 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
13434 | 5852 Lisp_Object prop, position; |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5853 int i, noverlays; |
13434 | 5854 Lisp_Object *overlay_vec; |
5855 Lisp_Object frame; | |
5856 int endpos; | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5857 Lisp_Object propname = mouse ? Qmouse_face : Qface; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5858 Lisp_Object limit1, end; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5859 struct face *default_face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5860 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters); |
13434 | 5861 |
5862 /* W must display the current buffer. We could write this function | |
5863 to use the frame and buffer of W, but right now it doesn't. */ | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5864 /* xassert (XBUFFER (w->buffer) == current_buffer); */ |
13434 | 5865 |
5866 XSETFRAME (frame, f); | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5867 XSETFASTINT (position, pos); |
13434 | 5868 |
5869 endpos = ZV; | |
5870 if (pos < region_beg && region_beg < endpos) | |
5871 endpos = region_beg; | |
5872 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5873 /* Get the `face' or `mouse_face' text property at POS, and |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5874 determine the next position at which the property changes. */ |
13434 | 5875 prop = Fget_text_property (position, propname, w->buffer); |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5876 XSETFASTINT (limit1, (limit < endpos ? limit : endpos)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5877 end = Fnext_single_property_change (position, propname, w->buffer, limit1); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5878 if (INTEGERP (end)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5879 endpos = XINT (end); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5880 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5881 /* Look at properties from overlays. */ |
13434 | 5882 { |
5883 int next_overlay; | |
5884 int len; | |
5885 | |
5886 /* First try with room for 40 overlays. */ | |
5887 len = 40; | |
5888 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); | |
5889 noverlays = overlays_at (pos, 0, &overlay_vec, &len, | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5890 &next_overlay, NULL); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5891 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5892 /* If there are more than 40, make enough space for all, and try |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5893 again. */ |
13434 | 5894 if (noverlays > len) |
5895 { | |
5896 len = noverlays; | |
5897 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object)); | |
5898 noverlays = overlays_at (pos, 0, &overlay_vec, &len, | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5899 &next_overlay, NULL); |
13434 | 5900 } |
5901 | |
5902 if (next_overlay < endpos) | |
5903 endpos = next_overlay; | |
5904 } | |
5905 | |
5906 *endptr = endpos; | |
5907 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5908 default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5909 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5910 /* Optimize common cases where we can use the default face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5911 if (noverlays == 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5912 && NILP (prop) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5913 && !(pos >= region_beg && pos < region_end) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5914 && (multibyte_p |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5915 || !FRAME_WINDOW_P (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5916 || FACE_SUITABLE_FOR_CHARSET_P (default_face, -1))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5917 return DEFAULT_FACE_ID; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5918 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5919 /* Begin with attributes from the default face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5920 bcopy (default_face->lface, attrs, sizeof attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5921 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5922 /* Merge in attributes specified via text properties. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5923 if (!NILP (prop)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5924 merge_face_vector_with_property (f, attrs, prop); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5925 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5926 /* Now merge the overlay data. */ |
13434 | 5927 noverlays = sort_overlays (overlay_vec, noverlays, w); |
5928 for (i = 0; i < noverlays; i++) | |
5929 { | |
21607
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5930 Lisp_Object oend; |
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5931 int oendpos; |
13434 | 5932 |
21607
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5933 prop = Foverlay_get (overlay_vec[i], propname); |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5934 if (!NILP (prop)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5935 merge_face_vector_with_property (f, attrs, prop); |
13434 | 5936 |
21607
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5937 oend = OVERLAY_END (overlay_vec[i]); |
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5938 oendpos = OVERLAY_POSITION (oend); |
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5939 if (oendpos < endpos) |
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5940 endpos = oendpos; |
13434 | 5941 } |
5942 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5943 /* If in the region, merge in the region face. */ |
13434 | 5944 if (pos >= region_beg && pos < region_end) |
5945 { | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5946 Lisp_Object region_face = lface_from_face_name (f, Qregion, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5947 merge_face_vectors (XVECTOR (region_face)->contents, attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5948 |
13434 | 5949 if (region_end < endpos) |
5950 endpos = region_end; | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5951 } |
13434 | 5952 |
5953 *endptr = endpos; | |
5954 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5955 /* Look up a realized face with the given face attributes, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5956 or realize a new one. Charset is ignored for tty frames. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5957 return lookup_face (f, attrs, multibyte_p ? CHARSET_ASCII : -1); |
13434 | 5958 } |
21607
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5959 |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5960 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5961 /* Compute the face at character position POS in Lisp string STRING on |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5962 window W, for charset CHARSET_ASCII. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5963 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5964 If STRING is an overlay string, it comes from position BUFPOS in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5965 current_buffer, otherwise BUFPOS is zero to indicate that STRING is |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5966 not an overlay string. W must display the current buffer. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5967 REGION_BEG and REGION_END give the start and end positions of the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5968 region; both are -1 if no region is visible. BASE_FACE_ID is the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5969 id of the basic face to merge with. It is usually equal to |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5970 DEFAULT_FACE_ID but can be MODE_LINE_FACE_ID or HEADER_LINE_FACE_ID |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5971 for strings displayed in the mode or top line. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5972 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5973 Set *ENDPTR to the next position where to check for faces in |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5974 STRING; -1 if the face is constant from POS to the end of the |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5975 string. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5976 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5977 Value is the id of the face to use. The face returned is suitable |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5978 for displaying CHARSET_ASCII if STRING is multibyte. Otherwise, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5979 the face is suitable for displaying unibyte text. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5980 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5981 int |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5982 face_at_string_position (w, string, pos, bufpos, region_beg, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5983 region_end, endptr, base_face_id) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5984 struct window *w; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5985 Lisp_Object string; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5986 int pos, bufpos; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5987 int region_beg, region_end; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5988 int *endptr; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5989 enum face_id base_face_id; |
21607
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
5990 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5991 Lisp_Object prop, position, end, limit; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5992 struct frame *f = XFRAME (WINDOW_FRAME (w)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5993 Lisp_Object attrs[LFACE_VECTOR_SIZE]; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5994 struct face *base_face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5995 int multibyte_p = STRING_MULTIBYTE (string); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5996 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5997 /* Get the value of the face property at the current position within |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5998 STRING. Value is nil if there is no face property. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
5999 XSETFASTINT (position, pos); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6000 prop = Fget_text_property (position, Qface, string); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6001 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6002 /* Get the next position at which to check for faces. Value of end |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6003 is nil if face is constant all the way to the end of the string. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6004 Otherwise it is a string position where to check faces next. |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6005 Limit is the maximum position up to which to check for property |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6006 changes in Fnext_single_property_change. Strings are usually |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6007 short, so set the limit to the end of the string. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6008 XSETFASTINT (limit, XSTRING (string)->size); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6009 end = Fnext_single_property_change (position, Qface, string, limit); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6010 if (INTEGERP (end)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6011 *endptr = XFASTINT (end); |
21607
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
6012 else |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6013 *endptr = -1; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6014 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6015 base_face = FACE_FROM_ID (f, base_face_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6016 xassert (base_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6017 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6018 /* Optimize the default case that there is no face property and we |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6019 are not in the region. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6020 if (NILP (prop) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6021 && (base_face_id != DEFAULT_FACE_ID |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6022 /* BUFPOS <= 0 means STRING is not an overlay string, so |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6023 that the region doesn't have to be taken into account. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6024 || bufpos <= 0 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6025 || bufpos < region_beg |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6026 || bufpos >= region_end) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6027 && (multibyte_p |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6028 /* We can't realize faces for different charsets differently |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6029 if we don't have fonts, so we can stop here if not working |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6030 on a window-system frame. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6031 || !FRAME_WINDOW_P (f) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6032 || FACE_SUITABLE_FOR_CHARSET_P (base_face, -1))) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6033 return base_face->id; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6034 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6035 /* Begin with attributes from the base face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6036 bcopy (base_face->lface, attrs, sizeof attrs); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6037 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6038 /* Merge in attributes specified via text properties. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6039 if (!NILP (prop)) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6040 merge_face_vector_with_property (f, attrs, prop); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6041 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6042 /* If in the region, merge in the region face. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6043 if (bufpos |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6044 && bufpos >= region_beg |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6045 && bufpos < region_end) |
21607
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
6046 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6047 Lisp_Object region_face = lface_from_face_name (f, Qregion, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6048 merge_face_vectors (XVECTOR (region_face)->contents, attrs); |
21607
59159a81b101
(Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16884
diff
changeset
|
6049 } |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6050 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6051 /* Look up a realized face with the given face attributes, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6052 or realize a new one. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6053 return lookup_face (f, attrs, multibyte_p ? CHARSET_ASCII : -1); |
13434 | 6054 } |
6055 | |
6056 | |
6057 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6058 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6059 Tests |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6060 ***********************************************************************/ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6061 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6062 #if GLYPH_DEBUG |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6063 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6064 /* Print the contents of the realized face FACE to stderr. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6065 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6066 static void |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6067 dump_realized_face (face) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6068 struct face *face; |
13434 | 6069 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6070 fprintf (stderr, "ID: %d\n", face->id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6071 fprintf (stderr, "gc: %d\n", (int) face->gc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6072 fprintf (stderr, "foreground: 0x%lx (%s)\n", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6073 face->foreground, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6074 XSTRING (face->lface[LFACE_FOREGROUND_INDEX])->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6075 fprintf (stderr, "background: 0x%lx (%s)\n", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6076 face->background, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6077 XSTRING (face->lface[LFACE_BACKGROUND_INDEX])->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6078 fprintf (stderr, "font_name: %s (%s)\n", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6079 face->font_name, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6080 XSTRING (face->lface[LFACE_FAMILY_INDEX])->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6081 fprintf (stderr, "font = %p\n", face->font); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6082 fprintf (stderr, "font_info_id = %d\n", face->font_info_id); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6083 fprintf (stderr, "fontset: %d\n", face->fontset); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6084 fprintf (stderr, "underline: %d (%s)\n", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6085 face->underline_p, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6086 XSTRING (Fsymbol_name (face->lface[LFACE_UNDERLINE_INDEX]))->data); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6087 fprintf (stderr, "hash: %d\n", face->hash); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6088 fprintf (stderr, "charset: %d\n", face->charset); |
13434 | 6089 } |
6090 | |
6091 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6092 DEFUN ("dump-face", Fdump_face, Sdump_face, 0, 1, 0, "") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6093 (n) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6094 Lisp_Object n; |
13434 | 6095 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6096 if (NILP (n)) |
13434 | 6097 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6098 int i; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6099 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6100 fprintf (stderr, "font selection order: "); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6101 for (i = 0; i < DIM (font_sort_order); ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6102 fprintf (stderr, "%d ", font_sort_order[i]); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6103 fprintf (stderr, "\n"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6104 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6105 fprintf (stderr, "alternative fonts: "); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6106 debug_print (Vface_alternative_font_family_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6107 fprintf (stderr, "\n"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6108 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6109 for (i = 0; i < FRAME_FACE_CACHE (SELECTED_FRAME ())->used; ++i) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6110 Fdump_face (make_number (i)); |
13434 | 6111 } |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6112 else |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6113 { |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6114 struct face *face; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6115 CHECK_NUMBER (n, 0); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6116 face = FACE_FROM_ID (SELECTED_FRAME (), XINT (n)); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6117 if (face == NULL) |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6118 error ("Not a valid face"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6119 dump_realized_face (face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6120 } |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6121 |
13434 | 6122 return Qnil; |
6123 } | |
6124 | |
6125 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6126 DEFUN ("show-face-resources", Fshow_face_resources, Sshow_face_resources, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6127 0, 0, 0, "") |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6128 () |
13434 | 6129 { |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6130 fprintf (stderr, "number of colors = %d\n", ncolors_allocated); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6131 fprintf (stderr, "number of pixmaps = %d\n", npixmaps_allocated); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6132 fprintf (stderr, "number of GCs = %d\n", ngcs); |
13434 | 6133 return Qnil; |
6134 } | |
6135 | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6136 #endif /* GLYPH_DEBUG != 0 */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6137 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6138 |
13434 | 6139 |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6140 /*********************************************************************** |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6141 Initialization |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6142 ***********************************************************************/ |
13434 | 6143 |
6144 void | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16051
diff
changeset
|
6145 syms_of_w32faces () |
13434 | 6146 { |
6147 Qface = intern ("face"); | |
6148 staticpro (&Qface); | |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6149 Qbitmap_spec_p = intern ("bitmap-spec-p"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6150 staticpro (&Qbitmap_spec_p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6151 Qframe_update_face_colors = intern ("frame-update-face-colors"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6152 staticpro (&Qframe_update_face_colors); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6153 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6154 /* Lisp face attribute keywords. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6155 QCfamily = intern (":family"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6156 staticpro (&QCfamily); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6157 QCheight = intern (":height"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6158 staticpro (&QCheight); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6159 QCweight = intern (":weight"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6160 staticpro (&QCweight); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6161 QCslant = intern (":slant"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6162 staticpro (&QCslant); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6163 QCunderline = intern (":underline"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6164 staticpro (&QCunderline); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6165 QCinverse_video = intern (":inverse-video"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6166 staticpro (&QCinverse_video); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6167 QCreverse_video = intern (":reverse-video"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6168 staticpro (&QCreverse_video); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6169 QCforeground = intern (":foreground"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6170 staticpro (&QCforeground); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6171 QCbackground = intern (":background"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6172 staticpro (&QCbackground); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6173 QCstipple = intern (":stipple");; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6174 staticpro (&QCstipple); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6175 QCwidth = intern (":width"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6176 staticpro (&QCwidth); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6177 QCfont = intern (":font"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6178 staticpro (&QCfont); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6179 QCbold = intern (":bold"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6180 staticpro (&QCbold); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6181 QCitalic = intern (":italic"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6182 staticpro (&QCitalic); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6183 QCoverline = intern (":overline"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6184 staticpro (&QCoverline); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6185 QCstrike_through = intern (":strike-through"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6186 staticpro (&QCstrike_through); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6187 QCbox = intern (":box"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6188 staticpro (&QCbox); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6189 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6190 /* Symbols used for Lisp face attribute values. */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6191 QCcolor = intern (":color"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6192 staticpro (&QCcolor); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6193 QCline_width = intern (":line-width"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6194 staticpro (&QCline_width); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6195 QCstyle = intern (":style"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6196 staticpro (&QCstyle); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6197 Qreleased_button = intern ("released-button"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6198 staticpro (&Qreleased_button); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6199 Qpressed_button = intern ("pressed-button"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6200 staticpro (&Qpressed_button); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6201 Qnormal = intern ("normal"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6202 staticpro (&Qnormal); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6203 Qultra_light = intern ("ultra-light"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6204 staticpro (&Qultra_light); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6205 Qextra_light = intern ("extra-light"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6206 staticpro (&Qextra_light); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6207 Qlight = intern ("light"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6208 staticpro (&Qlight); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6209 Qsemi_light = intern ("semi-light"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6210 staticpro (&Qsemi_light); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6211 Qsemi_bold = intern ("semi-bold"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6212 staticpro (&Qsemi_bold); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6213 Qbold = intern ("bold"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6214 staticpro (&Qbold); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6215 Qextra_bold = intern ("extra-bold"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6216 staticpro (&Qextra_bold); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6217 Qultra_bold = intern ("ultra-bold"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6218 staticpro (&Qultra_bold); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6219 Qoblique = intern ("oblique"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6220 staticpro (&Qoblique); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6221 Qitalic = intern ("italic"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6222 staticpro (&Qitalic); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6223 Qreverse_oblique = intern ("reverse-oblique"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6224 staticpro (&Qreverse_oblique); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6225 Qreverse_italic = intern ("reverse-italic"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6226 staticpro (&Qreverse_italic); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6227 Qultra_condensed = intern ("ultra-condensed"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6228 staticpro (&Qultra_condensed); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6229 Qextra_condensed = intern ("extra-condensed"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6230 staticpro (&Qextra_condensed); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6231 Qcondensed = intern ("condensed"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6232 staticpro (&Qcondensed); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6233 Qsemi_condensed = intern ("semi-condensed"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6234 staticpro (&Qsemi_condensed); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6235 Qsemi_expanded = intern ("semi-expanded"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6236 staticpro (&Qsemi_expanded); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6237 Qexpanded = intern ("expanded"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6238 staticpro (&Qexpanded); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6239 Qextra_expanded = intern ("extra-expanded"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6240 staticpro (&Qextra_expanded); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6241 Qultra_expanded = intern ("ultra-expanded"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6242 staticpro (&Qultra_expanded); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6243 Qbackground_color = intern ("background-color"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6244 staticpro (&Qbackground_color); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6245 Qforeground_color = intern ("foreground-color"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6246 staticpro (&Qforeground_color); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6247 Qunspecified = intern ("unspecified"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6248 staticpro (&Qunspecified); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6249 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6250 Qx_charset_registry = intern ("x-charset-registry"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6251 staticpro (&Qx_charset_registry); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6252 Qface_alias = intern ("face-alias"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6253 staticpro (&Qface_alias); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6254 Qdefault = intern ("default"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6255 staticpro (&Qdefault); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6256 Qtool_bar = intern ("tool-bar"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6257 staticpro (&Qtool_bar); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6258 Qregion = intern ("region"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6259 staticpro (&Qregion); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6260 Qfringe = intern ("fringe"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6261 staticpro (&Qfringe); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6262 Qheader_line = intern ("header-line"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6263 staticpro (&Qheader_line); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6264 Qscroll_bar = intern ("scroll-bar"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6265 staticpro (&Qscroll_bar); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6266 Qmenu = intern ("menu"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6267 staticpro (&Qmenu); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6268 Qcursor = intern ("cursor"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6269 staticpro (&Qcursor); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6270 Qborder = intern ("border"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6271 staticpro (&Qborder); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6272 Qmouse = intern ("mouse"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6273 staticpro (&Qmouse); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6274 Qtty_color_desc = intern ("tty-color-desc"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6275 staticpro (&Qtty_color_desc); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6276 Qtty_color_by_index = intern ("tty-color-by-index"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6277 staticpro (&Qtty_color_by_index); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6278 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6279 defsubr (&Sinternal_make_lisp_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6280 defsubr (&Sinternal_lisp_face_p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6281 defsubr (&Sinternal_set_lisp_face_attribute); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6282 defsubr (&Sinternal_set_lisp_face_attribute_from_resource); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6283 defsubr (&Scolor_gray_p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6284 defsubr (&Scolor_supported_p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6285 defsubr (&Sinternal_get_lisp_face_attribute); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6286 defsubr (&Sinternal_lisp_face_attribute_values); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6287 defsubr (&Sinternal_lisp_face_equal_p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6288 defsubr (&Sinternal_lisp_face_empty_p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6289 defsubr (&Sinternal_copy_lisp_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6290 defsubr (&Sinternal_merge_in_global_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6291 defsubr (&Sface_font); |
13434 | 6292 defsubr (&Sframe_face_alist); |
27396
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6293 defsubr (&Sinternal_set_font_selection_order); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6294 defsubr (&Sinternal_set_alternative_font_family_alist); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6295 #if GLYPH_DEBUG |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6296 defsubr (&Sdump_face); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6297 defsubr (&Sshow_face_resources); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6298 #endif /* GLYPH_DEBUG */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6299 defsubr (&Sclear_face_cache); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6300 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6301 DEFVAR_LISP ("font-list-limit", &Vfont_list_limit, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6302 "*Limit for font matching.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6303 If an integer > 0, font matching functions won't load more than\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6304 that number of fonts when searching for a matching font."); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6305 Vfont_list_limit = make_number (DEFAULT_FONT_LIST_LIMIT); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6306 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6307 DEFVAR_LISP ("face-new-frame-defaults", &Vface_new_frame_defaults, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6308 "List of global face definitions (for internal use only.)"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6309 Vface_new_frame_defaults = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6310 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6311 DEFVAR_LISP ("face-default-stipple", &Vface_default_stipple, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6312 "*Default stipple pattern used on monochrome displays.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6313 This stipple pattern is used on monochrome displays\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6314 instead of shades of gray for a face background color.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6315 See `set-face-stipple' for possible values for this variable."); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6316 Vface_default_stipple = build_string ("gray3"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6317 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6318 DEFVAR_LISP ("face-default-registry", &Vface_default_registry, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6319 "Default registry and encoding to use.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6320 This registry and encoding is used for unibyte text. It is set up\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6321 from the specified frame font when Emacs starts. (For internal use only.)"); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6322 Vface_default_registry = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6323 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6324 DEFVAR_LISP ("face-alternative-font-family-alist", |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6325 &Vface_alternative_font_family_alist, ""); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6326 Vface_alternative_font_family_alist = Qnil; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6327 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6328 #if SCALABLE_FONTS |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6329 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6330 DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed, |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6331 "Allowed scalable fonts.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6332 A value of nil means don't allow any scalable fonts.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6333 A value of t means allow any scalable font.\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6334 Otherwise, value must be a list of regular expressions. A font may be\n\ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6335 scaled if its name matches a regular expression in the list."); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6336 Vscalable_fonts_allowed = Qt; |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6337 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6338 #endif /* SCALABLE_FONTS */ |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6339 |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6340 defsubr (&Sbitmap_spec_p); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6341 defsubr (&Sx_list_fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6342 defsubr (&Sinternal_face_x_get_resource); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6343 defsubr (&Sx_family_fonts); |
323eb9ca333f
Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents:
26088
diff
changeset
|
6344 defsubr (&Sx_font_family_list); |
13434 | 6345 } |