annotate src/w32faces.c @ 27830:99b1d31f039b

(footnote): Add :version to defgroup. (footnote-section-tag-regexp): Customize. (footnote-start-tag, footnote-end-tag): New option. (footnote-latin-regexp): New variable. (Footnote-latin): New function. (footnote-style-alist): Add element for latin style. (footnote-style): Moved. (Footnote-goto-footnote): Use eq to test arg.
author Dave Love <fx@gnu.org>
date Wed, 23 Feb 2000 20:25:34 +0000
parents d0c413d1b2c2
children 0f639a575917
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
3
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4 This file is part of GNU Emacs.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
8 the Free Software Foundation; either version 2, or (at your option)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
9 any later version.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
10
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
14 GNU General Public License for more details.
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
15
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
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
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
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
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
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
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
180 #include <sys/types.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
181 #include <sys/stat.h>
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
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"
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
185
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
186 #ifdef HAVE_X_WINDOWS
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
187 #include "xterm.h"
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
188 #include "fontset.h"
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
189 #ifdef USE_MOTIF
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
190 #include <Xm/Xm.h>
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
191 #include <Xm/XmStrDefs.h>
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
192 #endif /* USE_MOTIF */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
193 #endif
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
194
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
195 #ifdef MSDOS
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
196 #include "dosfns.h"
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
197 #endif
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
198
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
199 #ifdef WINDOWSNT
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
200 #include "w32term.h"
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
201 #include "fontset.h"
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
202 #endif
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
203
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
204 #include "buffer.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
205 #include "dispextern.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
206 #include "blockinput.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
207 #include "window.h"
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
208 #include "intervals.h"
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
209
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
210 #ifdef HAVE_X_WINDOWS
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
211
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
212 /* Compensate for a bug in Xos.h on some systems, on which it requires
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
213 time.h. On some such systems, Xos.h tries to redefine struct
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
214 timeval and struct timezone if USG is #defined while it is
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
215 #included. */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
216
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
217 #ifdef XOS_NEEDS_TIME_H
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
218 #include <time.h>
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
219 #undef USG
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
220 #include <X11/Xos.h>
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
221 #define USG
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
222 #define __TIMEVAL__
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
223 #else /* not XOS_NEEDS_TIME_H */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
224 #include <X11/Xos.h>
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
225 #endif /* not XOS_NEEDS_TIME_H */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
226
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
227 #endif /* HAVE_X_WINDOWS */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
228
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
229 #include <stdio.h>
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
230 #include <ctype.h>
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
231 #include "keyboard.h"
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
232
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
233 #ifndef max
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
234 #define max(A, B) ((A) > (B) ? (A) : (B))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
235 #define min(A, B) ((A) < (B) ? (A) : (B))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
236 #define abs(X) ((X) < 0 ? -(X) : (X))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
237 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
238
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
239 /* Non-zero if face attribute ATTR is unspecified. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
240
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
241 #define UNSPECIFIEDP(ATTR) EQ ((ATTR), Qunspecified)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
242
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
243 /* Value is the number of elements of VECTOR. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
244
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
245 #define DIM(VECTOR) (sizeof (VECTOR) / sizeof *(VECTOR))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
246
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
247 /* 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
248 to the copy. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
249
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
250 #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
251
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
252 /* 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
253 alloca. Value is a pointer to the copy. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
254
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
255 #define LSTRDUPA(S) STRDUPA (XSTRING ((S))->data)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
256
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
257 /* 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
258 prime number). */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
259
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
260 #define FACE_CACHE_BUCKETS_SIZE 1001
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 /* A definition of XColor for non-X frames. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
263 #ifndef HAVE_X_WINDOWS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
264 typedef struct {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
265 unsigned long pixel;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
266 unsigned short red, green, blue;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
267 char flags;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
268 char pad;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
269 } XColor;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
270 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
271
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
272 /* Keyword symbols used for face attribute names. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
273
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
274 Lisp_Object QCfamily, QCheight, QCweight, QCslant, QCunderline;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
275 Lisp_Object QCinverse_video, QCforeground, QCbackground, QCstipple;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
276 Lisp_Object QCwidth, QCfont, QCbold, QCitalic;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
277 Lisp_Object QCreverse_video;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
278 Lisp_Object QCoverline, QCstrike_through, QCbox;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
279
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
280 /* Symbols used for attribute values. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
281
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
282 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
283 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
284 Lisp_Object Qoblique, Qitalic, Qreverse_oblique, Qreverse_italic;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
285 Lisp_Object Qultra_condensed, Qextra_condensed, Qcondensed;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
286 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
287 Lisp_Object Qultra_expanded;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
288 Lisp_Object Qreleased_button, Qpressed_button;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
289 Lisp_Object QCstyle, QCcolor, QCline_width;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
290 Lisp_Object Qunspecified;
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 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
293
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
294 /* 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
295 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
296 display characters of that charset. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
297
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
298 Lisp_Object Qx_charset_registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
299
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
300 /* 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
301 has changed, frame_update_face_colors. */
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 Lisp_Object Qframe_update_face_colors;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
304
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
305 /* Names of basic faces. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
306
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
307 Lisp_Object Qdefault, Qtool_bar, Qregion, Qfringe;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
308 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
309 extern Lisp_Object Qmode_line;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
310
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
311 /* 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
312 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
313 the aliased face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
314
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
315 Lisp_Object Qface_alias;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
316
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
317 /* Names of frame parameters related to faces. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
318
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
319 extern Lisp_Object Qscroll_bar_foreground, Qscroll_bar_background;
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
320 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
321
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
322 /* 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
323 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
324 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
325 values for this variable. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
326
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
327 Lisp_Object Vface_default_stipple;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
328
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
329 /* 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
330 symbols don't specify one. */
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 Vface_default_registry;
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 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
335 (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
336 try FAMILY1, then FAMILY2, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
337
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
338 Lisp_Object Vface_alternative_font_family_alist;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
339
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
340 /* 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
341 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
342 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
343 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
344 list. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
345
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
346 #if SCALABLE_FONTS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
347 Lisp_Object Vscalable_fonts_allowed;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
348 #endif
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 /* 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
351 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
352
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
353 Lisp_Object Vfont_list_limit;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
354 #define DEFAULT_FONT_LIST_LIMIT 100
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
355
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
356 /* 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
357 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
358 Emacs 20.2. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
359
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
360 Lisp_Object Qforeground_color, Qbackground_color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
361
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
362 /* The symbols `face' and `mouse-face' used as text properties. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
363
23623
f6c3cc94ae4f (Qmouse_face): Replace definition with extern decl.
Geoff Voelker <voelker@cs.washington.edu>
parents: 23505
diff changeset
364 Lisp_Object Qface;
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
365 extern Lisp_Object Qmouse_face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
366
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
367 /* 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
368
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
369 Lisp_Object Qbitmap_spec_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
370
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
371 /* 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
372 (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
373 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
374 to initialize faces for new frames. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
375
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
376 Lisp_Object Vface_new_frame_defaults;
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 /* The next ID to assign to Lisp faces. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
379
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
380 static int next_lface_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
381
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
382 /* 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
383
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
384 static Lisp_Object *lface_id_to_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
385 static int lface_id_to_name_size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
386
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
387 /* 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
388 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
389
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
390 /* 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
391 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
392 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
393
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
394 static int clear_font_table_count;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
395 #define CLEAR_FONT_TABLE_COUNT 100
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
396 #define CLEAR_FONT_TABLE_NFONTS 10
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
397
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
398 /* 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
399 redisplay. Used in redisplay_internal. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
400
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
401 int face_change_count;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
402
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
403 /* The total number of colors currently allocated. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
404
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
405 #if GLYPH_DEBUG
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
406 static int ncolors_allocated;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
407 static int npixmaps_allocated;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
408 static int ngcs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
409 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
410
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
411
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
412
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
413 /* Function prototypes. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
414
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
415 struct font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
416 struct table_entry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
417
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
418 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
419 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
420 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
421 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
422 int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
423 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
424 struct font_name *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
425 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
426 struct font_name *, int, int, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
427 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
428 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
429 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
430 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
431 static char *xstrdup P_ ((char *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
432 static unsigned char *xstrlwr P_ ((unsigned char *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
433 static void signal_error P_ ((char *, Lisp_Object));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
434 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
435 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
436 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
437 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
438 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
439 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
440 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
441 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
442 int (*cmpfn) P_ ((const void *, const void *)),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
443 struct font_name **));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
444 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
445 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
446 struct font_name **));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
447 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
448 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
449 Lisp_Object *, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
450 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
451 Lisp_Object *, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
452 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
453 Lisp_Object *, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
454 static int realize_basic_faces P_ ((struct frame *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
455 static int realize_default_face P_ ((struct frame *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
456 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
457 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
458 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
459 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
460 static unsigned lface_hash P_ ((Lisp_Object *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
461 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
462 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
463 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
464 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
465 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
466 static int face_numeric_weight P_ ((Lisp_Object));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
467 static int face_numeric_slant P_ ((Lisp_Object));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
468 static int face_numeric_swidth P_ ((Lisp_Object));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
469 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
470 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
471 Lisp_Object));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
472 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
473 int, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
474 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
475 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
476 Lisp_Object));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
477 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
478 int, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
479 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
480 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
481 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
482 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
483 struct font_name *, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
484 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
485 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
486 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
487 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
488 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
489 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
490 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
491 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
492 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
493 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
494 int, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
495 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
496 struct font_name *, int, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
497 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
498 struct font_name *, int));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
499
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
500 #ifdef HAVE_WINDOW_SYSTEM
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
501
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
502 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
503 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
504 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
505 int (*cmpfn) P_ ((const void *, const void *))));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
506 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
507 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
508 static void clear_font_table P_ ((struct frame *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
509
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
510 #ifdef WINDOWSNT
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
511 extern Lisp_Object w32_list_fonts P_ ((struct frame *, Lisp_Object, int, int));
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
512 #endif /* WINDOWSNT */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
513
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
514 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
515
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
516
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
517 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
518 Utilities
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 /* 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
522 are given by XGCV and MASK. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
523
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
524 static INLINE GC
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
525 x_create_gc (f, mask, xgcv)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
526 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
527 unsigned long mask;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
528 XGCValues *xgcv;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
529 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
530 GC gc;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
531 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
532 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
533 UNBLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
534 IF_DEBUG (++ngcs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
535 return gc;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
539 /* Free GC which was used on frame F. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
540
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
541 static INLINE void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
542 x_free_gc (f, gc)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
543 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
544 GC gc;
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 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
547 xassert (--ngcs >= 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
548 xfree (gc);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
549 UNBLOCK_INPUT;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
550 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
551
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
552
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
553 /* Like strdup, but uses xmalloc. */
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 static char *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
556 xstrdup (s)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
557 char *s;
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 int len = strlen (s) + 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
560 char *p = (char *) xmalloc (len);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
561 bcopy (s, p, len);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
562 return p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
563 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
564
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 /* 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
567 ISO8859-1. */
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 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
570 xstricmp (s1, s2)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
571 unsigned char *s1, *s2;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
572 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
573 while (*s1 && *s2)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
574 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
575 unsigned char c1 = tolower (*s1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
576 unsigned char c2 = tolower (*s2);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
577 if (c1 != c2)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
578 return c1 < c2 ? -1 : 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
579 ++s1, ++s2;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
582 if (*s1 == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
583 return *s2 == 0 ? 0 : -1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
584 return 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
585 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
588 /* Like strlwr, which might not always be available. */
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 static unsigned char *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
591 xstrlwr (s)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
592 unsigned char *s;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
593 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
594 unsigned char *p = s;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
595
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
596 for (p = s; *p; ++p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
597 *p = tolower (*p);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
598
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
599 return s;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
600 }
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
601
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 /* 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
604
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
605 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
606 signal_error (s, arg)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
607 char *s;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
608 Lisp_Object arg;
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 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
611 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
612
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
613
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
614 /* 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
615 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
616 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
617 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
618 Lisp function definitions. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
619
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
620 static INLINE struct frame *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
621 frame_or_selected_frame (frame, nparam)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
622 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
623 int nparam;
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 if (NILP (frame))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
626 frame = selected_frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
627
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
628 CHECK_LIVE_FRAME (frame, nparam);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
629 return XFRAME (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
630 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
631
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
632
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
633 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
634 Frames and faces
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
635 ***********************************************************************/
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
636
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
637 /* Initialize face cache and basic faces for frame F. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
638
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
639 void
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
640 init_frame_faces (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
641 struct frame *f;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
642 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
643 /* 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
644 if (FRAME_FACE_CACHE (f) == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
645 FRAME_FACE_CACHE (f) = make_face_cache (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
646
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
647 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
648 /* Make the image cache. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
649 if (FRAME_WINDOW_P (f))
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 if (FRAME_X_IMAGE_CACHE (f) == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
652 FRAME_X_IMAGE_CACHE (f) = make_image_cache ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
653 ++FRAME_X_IMAGE_CACHE (f)->refcount;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
654 }
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
655 #endif /* HAVE_WINDOW_SYSTEM */
27396
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 /* 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
658 parameters to realize basic faces at this point. */
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
659 #ifdef HAVE_X_WINDOWS
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
660 if (!FRAME_X_P (f) || FRAME_X_WINDOW (f))
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
661 #endif
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
662 #ifdef WINDOWSNT
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
663 if (!FRAME_WINDOW_P (f) || FRAME_W32_WINDOW (f))
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
664 #endif
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
665 if (!realize_basic_faces (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
666 abort ();
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
667 }
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
668
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
669
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
670 /* 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
671
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
672 void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
673 free_frame_faces (f)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
674 struct frame *f;
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
675 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
676 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
677
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
678 if (face_cache)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
679 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
680 free_face_cache (face_cache);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
681 FRAME_FACE_CACHE (f) = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
682 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
683
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
684 #ifdef HAVE_WINDOW_SYSTEM
27396
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 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
687 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
688 if (image_cache)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
689 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
690 --image_cache->refcount;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
691 if (image_cache->refcount == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
692 free_image_cache (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
693 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
694 }
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
695 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
696 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
699 /* 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
700 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
701 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
702 of named faces. */
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 void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
705 recompute_basic_faces (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
706 struct frame *f;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
707 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
708 if (FRAME_FACE_CACHE (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
709 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
710 clear_face_cache (0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
711 if (!realize_basic_faces (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
712 abort ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
713 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
714 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
715
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
716
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
717 /* 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
718 try to free unused fonts, too. */
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 void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
721 clear_face_cache (clear_fonts_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
722 int clear_fonts_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
723 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
724 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
725 Lisp_Object tail, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
726 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
727
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
728 if (clear_fonts_p
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
729 || ++clear_font_table_count == CLEAR_FONT_TABLE_COUNT)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
730 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
731 /* 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
732 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
733 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
734 clear_font_table_count = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
735
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
736 FOR_EACH_FRAME (tail, frame)
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 f = XFRAME (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
739 if (FRAME_WINDOW_P (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
740 && 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
741 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
742 free_all_realized_faces (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
743 clear_font_table (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
744 }
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 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
747 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
748 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
749 /* Clear GCs of realized faces. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
750 FOR_EACH_FRAME (tail, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
751 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
752 f = XFRAME (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
753 if (FRAME_WINDOW_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
754 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
755 clear_face_gcs (FRAME_FACE_CACHE (f));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
756 clear_image_cache (f, 0);
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 }
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
760 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
761 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
762
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 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
765 "Clear face caches on all frames.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
766 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
767 (thorougly)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
768 Lisp_Object thorougly;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
769 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
770 clear_face_cache (!NILP (thorougly));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
771 return Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
772 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
773
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
774
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
775
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
776 #ifdef HAVE_WINDOW_SYSTEM
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
777
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
778
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
779 /* 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
780 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
781
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
782 static void
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
783 clear_font_table (f)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
784 struct frame *f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
785 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
786 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
787 char *used;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
788 Lisp_Object rest, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
789 int i;
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 xassert (FRAME_WINDOW_P (f));
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 used = (char *) alloca (dpyinfo->n_fonts * sizeof *used);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
794 bzero (used, dpyinfo->n_fonts * sizeof *used);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
795
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
796 /* 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
797 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
798 FOR_EACH_FRAME (rest, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
799 if (FRAME_W32_DISPLAY_INFO (XFRAME (frame)) == dpyinfo)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
800 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
801 struct frame *f = XFRAME (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
802 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
803
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
804 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
805 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
806 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
807 int j;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
808
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
809 for (j = 0; j <= MAX_CHARSET; ++j)
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 int idx = info->font_indexes[j];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
812 if (idx >= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
813 used[idx] = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
814 }
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 }
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 /* 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
819 for (i = 0; i < dpyinfo->n_fonts; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
820 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
821 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
822 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
823
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
824 /* 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
825 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
826 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
827 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
828 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
829 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
830 data structure. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
831 if (font_info->full_name != font_info->name)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
832 xfree (font_info->full_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
833 xfree (font_info->name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
834
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
835 /* Free the font. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
836 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
837 w32_unload_font (dpyinfo, font_info->font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
838 UNBLOCK_INPUT;
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 /* Mark font table slot free. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
841 font_info->font = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
842 font_info->name = font_info->full_name = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
843 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
844 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
845
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
846
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
847 #endif /* HAVE_WINDOW_SYSTEM */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
848
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
849
27396
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 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
852 X Pixmaps
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
853 ***********************************************************************/
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
854
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
855 #ifdef HAVE_WINDOW_SYSTEM
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
856
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
857 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
858 "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
859 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
860 (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
861 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
862 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
863 (WIDTH + 7) / 8 bytes.")
23505
1050835fbcef Update comments referring to obsolete structs.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21607
diff changeset
864 (object)
1050835fbcef Update comments referring to obsolete structs.
Geoff Voelker <voelker@cs.washington.edu>
parents: 21607
diff changeset
865 Lisp_Object object;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
866 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
867 int pixmap_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
868
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
869 if (STRINGP (object))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
870 /* 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
871 pixmap_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
872 else if (CONSP (object))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
873 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
874 /* 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
875 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
876 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
877 Lisp_Object width, height, data;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
878
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
879 height = width = data = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
880
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
881 if (CONSP (object))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
882 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
883 width = XCAR (object);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
884 object = XCDR (object);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
885 if (CONSP (object))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
886 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
887 height = XCAR (object);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
888 object = XCDR (object);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
889 if (CONSP (object))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
890 data = XCAR (object);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
891 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
892 }
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 (NATNUMP (width) && NATNUMP (height) && STRINGP (data))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
895 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
896 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
897 / BITS_PER_CHAR);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
898 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
899 pixmap_p = 1;
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 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
902
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
903 return pixmap_p ? Qt : Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
904 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
905
27396
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 /* 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
908 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
909 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
910 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
911 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
912 if these pointers are not null. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
913
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
914 static int
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
915 load_pixmap (f, name, w_ptr, h_ptr)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
916 FRAME_PTR f;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
917 Lisp_Object name;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
918 unsigned int *w_ptr, *h_ptr;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
919 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
920 int bitmap_id;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
921 Lisp_Object tem;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
922
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
923 if (NILP (name))
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
924 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
925
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
926 tem = Fbitmap_spec_p (name);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
927 if (NILP (tem))
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
928 wrong_type_argument (Qbitmap_spec_p, name);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
929
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
930 BLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
931 if (CONSP (name))
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
932 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
933 /* Decode a bitmap spec into a bitmap. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
934
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
935 int h, w;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
936 Lisp_Object bits;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
937
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
938 w = XINT (Fcar (name));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
939 h = XINT (Fcar (Fcdr (name)));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
940 bits = Fcar (Fcdr (Fcdr (name)));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
941
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
942 bitmap_id = x_create_bitmap_from_data (f, XSTRING (bits)->data,
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
943 w, h);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
944 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
945 else
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
946 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
947 /* It must be a string -- a file name. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
948 bitmap_id = x_create_bitmap_from_file (f, name);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
949 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
950 UNBLOCK_INPUT;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
951
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
952 if (bitmap_id < 0)
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
953 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
954 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
955 bitmap_id = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
956
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
957 if (w_ptr)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
958 *w_ptr = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
959 if (h_ptr)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
960 *h_ptr = 0;
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 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
963 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
964 #if GLYPH_DEBUG
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
965 ++npixmaps_allocated;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
966 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
967 if (w_ptr)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
968 *w_ptr = x_bitmap_width (f, bitmap_id);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
969
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
970 if (h_ptr)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
971 *h_ptr = x_bitmap_height (f, bitmap_id);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
972 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
973
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
974 return bitmap_id;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
975 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
976
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
977 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
978
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
979
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
980
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
981 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
982 Minimum font bounds
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
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
985 #ifdef HAVE_WINDOW_SYSTEM
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
986
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
987 /* 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
988 changes. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
989
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
990 int
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
991 frame_update_line_height (f)
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
992 struct frame *f;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
993 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
994 int fontset, line_height, changed_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
995
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
996 fontset = FRAME_FONTSET (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
997 if (fontset > 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
998 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
999 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1000 line_height = FONT_HEIGHT (FRAME_FONT (f));
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 changed_p = line_height != FRAME_LINE_HEIGHT (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1003 FRAME_LINE_HEIGHT (f) = line_height;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1004 return changed_p;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1005 }
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1006
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1007 #endif /* HAVE_WINDOW_SYSTEM */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1008
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1009
27396
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 Fonts
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
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1014 #ifdef HAVE_WINDOW_SYSTEM
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1015
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1016 /* 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
1017 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
1018 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
1019 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
1020 for the face. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1021
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1022 static void
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1023 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
1024 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1025 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1026 char *font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1027 int fontset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1028 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1029 struct font_info *font_info = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1030
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1031 face->font_info_id = -1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1032 face->fontset = fontset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1033 face->font = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1034
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1035 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1036 if (fontset >= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1037 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
1038 NULL, fontset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1039 else if (font_name)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1040 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
1041 font_name, -1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1042 UNBLOCK_INPUT;
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 if (font_info)
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 char *s;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1047 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1048
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1049 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
1050 face->font = font_info->font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1051 face->font_name = font_info->full_name;
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 /* 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
1054 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
1055 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
1056 i = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1057 while (i < 2 && --s >= font_info->full_name)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1058 if (*s == '-')
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1059 ++i;
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 if (!STRINGP (face->registry)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1062 || xstricmp (XSTRING (face->registry)->data, s + 1) != 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1063 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1064 if (STRINGP (Vface_default_registry)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1065 && !xstricmp (XSTRING (Vface_default_registry)->data, s + 1))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1066 face->registry = Vface_default_registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1067 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1068 face->registry = build_string (s + 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1069 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1070 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1071 else if (fontset >= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1072 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
1073 make_number (fontset), Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1074 else if (font_name)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1075 add_to_log ("Unable to load font %s",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1076 build_string (font_name), Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1077 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1078
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1079 #endif /* HAVE_WINDOW_SYSTEM */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1080
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1081
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1082
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 X Colors
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1085 ***********************************************************************/
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1086
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1087 /* 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
1088 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1089 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
1090 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1091 char *color_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1092 XColor *color_def;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1093 int alloc;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1094 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1095 Lisp_Object color_desc;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1096 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
1097 int status = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1098
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1099 if (*color_name && !NILP (Ffboundp (Qtty_color_desc)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1100 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1101 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1102
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1103 XSETFRAME (frame, f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1104 status = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1105 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
1106 if (CONSP (color_desc) && CONSP (XCDR (color_desc)))
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 color_idx = XINT (XCAR (XCDR (color_desc)));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1109 if (CONSP (XCDR (XCDR (color_desc))))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1110 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1111 red = XINT (XCAR (XCDR (XCDR (color_desc))));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1112 green = XINT (XCAR (XCDR (XCDR (XCDR (color_desc)))));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1113 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
1114 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1115 status = 1;
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 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
1118 /* 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
1119 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
1120 indication, since this produces the annoying "Unable to
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1121 load color" messages in the *Messages* buffer. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1122 status = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1123 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1124 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
1125 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1126 if (strcmp (color_name, "unspecified-fg") == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1127 color_idx = FACE_TTY_DEFAULT_FG_COLOR;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1128 else if (strcmp (color_name, "unspecified-bg") == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1129 color_idx = FACE_TTY_DEFAULT_BG_COLOR;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1130 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1131
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1132 color_def->pixel = (unsigned long) color_idx;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1133 color_def->red = red;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1134 color_def->green = green;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1135 color_def->blue = blue;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1136
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1137 return status;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1140 /* 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
1141 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
1142 ALLOC is nonzero, allocate a new colormap cell.
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1143
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1144 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
1145 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1146 defined_color (f, color_name, color_def, alloc)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1147 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1148 char *color_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1149 XColor *color_def;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1150 int alloc;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1151 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1152 if (!FRAME_WINDOW_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1153 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
1154 #ifdef HAVE_X_WINDOWS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1155 else if (FRAME_X_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1156 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
1157 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1158 #ifdef WINDOWSNT
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1159 else if (FRAME_W32_P (f))
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1160 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
1161 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1162 #ifdef macintosh
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1163 else if (FRAME_MAC_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1164 /* FIXME: mac_defined_color doesn't exist! */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1165 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
1166 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1167 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1168 abort ();
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 /* 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
1172
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1173 Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1174 tty_color_name (f, idx)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1175 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1176 int idx;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1177 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1178 char *color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1179
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1180 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
1181 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1182 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1183 Lisp_Object coldesc;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1184
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1185 XSETFRAME (frame, f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1186 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
1187
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1188 if (!NILP (coldesc))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1189 return XCAR (coldesc);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1190 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1191 #ifdef MSDOS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1192 /* 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
1193 opportunity before internal_terminal_init is called. DTRT. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1194 if (FRAME_MSDOS_P (f) && !inhibit_window_system)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1195 return msdos_stdcolor_name (idx);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1196 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1197
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1198 if (idx == FACE_TTY_DEFAULT_FG_COLOR)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1199 return build_string (unspecified_fg);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1200 if (idx == FACE_TTY_DEFAULT_BG_COLOR)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1201 return build_string (unspecified_bg);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1202
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1203 #ifdef WINDOWSNT
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1204 return vga_stdcolor_name (idx);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1205 #endif
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1206
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1207 return Qunspecified;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1208 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1209
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1210 /* 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
1211 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
1212
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1213 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1214 face_color_gray_p (f, color_name)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1215 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1216 char *color_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1217 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1218 XColor color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1219 int gray_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1220
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1221 if (defined_color (f, color_name, &color, 0))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1222 gray_p = ((abs (color.red - color.green)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1223 < max (color.red, color.green) / 20)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1224 && (abs (color.green - color.blue)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1225 < max (color.green, color.blue) / 20)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1226 && (abs (color.blue - color.red)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1227 < max (color.blue, color.red) / 20));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1228 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1229 gray_p = 0;
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 return gray_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1232 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1233
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1234
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1235 /* 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
1236 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
1237 color. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1238
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1239 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1240 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
1241 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1242 char *color_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1243 int background_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1244 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1245 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1246 XColor not_used;
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 XSETFRAME (frame, f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1249 return (FRAME_WINDOW_P (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1250 ? (!NILP (Fxw_display_color_p (frame))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1251 || xstricmp (color_name, "black") == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1252 || xstricmp (color_name, "white") == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1253 || (background_p
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1254 && face_color_gray_p (f, color_name))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1255 || (!NILP (Fx_display_grayscale_p (frame))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1256 && face_color_gray_p (f, color_name)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1257 : tty_defined_color (f, color_name, &not_used, 0));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1258 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1259
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1260
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1261 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
1262 "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
1263 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
1264 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
1265 (color, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1266 Lisp_Object color, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1267 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1268 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1269
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1270 CHECK_FRAME (frame, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1271 CHECK_STRING (color, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1272 f = XFRAME (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1273 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
1274 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1277 DEFUN ("color-supported-p", Fcolor_supported_p,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1278 Scolor_supported_p, 2, 3, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1279 "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
1280 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
1281 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
1282 COLOR must be a valid color name.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1283 (color, frame, background_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1284 Lisp_Object frame, color, background_p;
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 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1287
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1288 CHECK_FRAME (frame, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1289 CHECK_STRING (color, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1290 f = XFRAME (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1291 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
1292 return Qt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1293 return Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1294 }
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 /* 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
1297 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
1298 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
1299 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
1300 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
1301 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
1302 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
1303 these colors. */
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 unsigned long
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1306 load_color (f, face, name, target_index)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1307 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1308 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1309 Lisp_Object name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1310 enum lface_attribute_index target_index;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1311 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1312 XColor color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1313
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1314 xassert (STRINGP (name));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1315 xassert (target_index == LFACE_FOREGROUND_INDEX
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1316 || target_index == LFACE_BACKGROUND_INDEX
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1317 || target_index == LFACE_UNDERLINE_INDEX
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1318 || target_index == LFACE_OVERLINE_INDEX
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1319 || target_index == LFACE_STRIKE_THROUGH_INDEX
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1320 || target_index == LFACE_BOX_INDEX);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1321
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1322 /* 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
1323 to the values in an existing cell. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1324 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
1325 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1326 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
1327
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1328 switch (target_index)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1329 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1330 case LFACE_FOREGROUND_INDEX:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1331 face->foreground_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1332 color.pixel = FRAME_FOREGROUND_PIXEL (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1333 break;
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 case LFACE_BACKGROUND_INDEX:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1336 face->background_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1337 color.pixel = FRAME_BACKGROUND_PIXEL (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1338 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1339
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1340 case LFACE_UNDERLINE_INDEX:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1341 face->underline_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1342 color.pixel = FRAME_FOREGROUND_PIXEL (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1343 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1344
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1345 case LFACE_OVERLINE_INDEX:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1346 face->overline_color_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1347 color.pixel = FRAME_FOREGROUND_PIXEL (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1348 break;
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 case LFACE_STRIKE_THROUGH_INDEX:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1351 face->strike_through_color_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1352 color.pixel = FRAME_FOREGROUND_PIXEL (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1353 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1354
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1355 case LFACE_BOX_INDEX:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1356 face->box_color_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1357 color.pixel = FRAME_FOREGROUND_PIXEL (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1358 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1359
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1360 default:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1361 abort ();
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 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1364 #if GLYPH_DEBUG
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1365 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1366 ++ncolors_allocated;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1367 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1368
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1369 return color.pixel;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1370 }
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 #ifdef 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 /* 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
1375 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
1376 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
1377 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
1378
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1379 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1380 load_face_colors (f, face, attrs)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1381 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1382 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1383 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1384 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1385 Lisp_Object fg, bg;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1386
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1387 bg = attrs[LFACE_BACKGROUND_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1388 fg = attrs[LFACE_FOREGROUND_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1389
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1390 /* Swap colors if face is inverse-video. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1391 if (EQ (attrs[LFACE_INVERSE_INDEX], Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1392 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1393 Lisp_Object tmp;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1394 tmp = fg;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1395 fg = bg;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1396 bg = tmp;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1397 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1398
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1399 /* 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
1400 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
1401 "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
1402 for them. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1403 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
1404 && !NILP (Fbitmap_spec_p (Vface_default_stipple)))
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 x_destroy_bitmap (f, face->stipple);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1407 face->stipple = load_pixmap (f, Vface_default_stipple,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1408 &face->pixmap_w, &face->pixmap_h);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1409 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1410
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1411 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
1412 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
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1416 /* Free color PIXEL on frame F. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1417
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1418 void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1419 unload_color (f, pixel)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1420 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1421 unsigned long pixel;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1422 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1423 /* Nothing to do on W32 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1424 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1425
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1426
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1427 /* Free colors allocated for FACE. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1428
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1429 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1430 free_face_colors (f, face)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1431 struct frame *f;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1432 struct face *face;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1433 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1434 /* Nothing to do on W32 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1435 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1436 #endif /* HAVE_WINDOW_SYSTEM */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1437
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1438
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1439
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1440 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1441 XLFD Font Names
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1442 ***********************************************************************/
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1443
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1444 /* 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
1445
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1446 enum xlfd_field
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1447 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1448 XLFD_FOUNDRY,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1449 XLFD_FAMILY,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1450 XLFD_WEIGHT,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1451 XLFD_SLANT,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1452 XLFD_SWIDTH,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1453 XLFD_ADSTYLE,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1454 XLFD_PIXEL_SIZE,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1455 XLFD_POINT_SIZE,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1456 XLFD_RESX,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1457 XLFD_RESY,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1458 XLFD_SPACING,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1459 XLFD_AVGWIDTH,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1460 XLFD_REGISTRY,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1461 XLFD_ENCODING,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1462 XLFD_LAST
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1463 };
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1464
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1465 /* 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
1466 the XLFD specification. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1467
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1468 enum xlfd_slant
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 XLFD_SLANT_UNKNOWN,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1471 XLFD_SLANT_ROMAN,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1472 XLFD_SLANT_ITALIC,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1473 XLFD_SLANT_OBLIQUE,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1474 XLFD_SLANT_REVERSE_ITALIC,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1475 XLFD_SLANT_REVERSE_OBLIQUE,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1476 XLFD_SLANT_OTHER
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1477 };
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1478
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1479 /* Relative font weight according to XLFD documentation. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1480
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1481 enum xlfd_weight
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1482 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1483 XLFD_WEIGHT_UNKNOWN,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1484 XLFD_WEIGHT_ULTRA_LIGHT, /* 10 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1485 XLFD_WEIGHT_EXTRA_LIGHT, /* 20 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1486 XLFD_WEIGHT_LIGHT, /* 30 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1487 XLFD_WEIGHT_SEMI_LIGHT, /* 40: SemiLight, Book, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1488 XLFD_WEIGHT_MEDIUM, /* 50: Medium, Normal, Regular, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1489 XLFD_WEIGHT_SEMI_BOLD, /* 60: SemiBold, DemiBold, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1490 XLFD_WEIGHT_BOLD, /* 70: Bold, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1491 XLFD_WEIGHT_EXTRA_BOLD, /* 80: ExtraBold, Heavy, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1492 XLFD_WEIGHT_ULTRA_BOLD /* 90: UltraBold, Black, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1493 };
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1494
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1495 /* Relative proportionate width. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1496
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1497 enum xlfd_swidth
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1498 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1499 XLFD_SWIDTH_UNKNOWN,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1500 XLFD_SWIDTH_ULTRA_CONDENSED, /* 10 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1501 XLFD_SWIDTH_EXTRA_CONDENSED, /* 20 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1502 XLFD_SWIDTH_CONDENSED, /* 30: Condensed, Narrow, Compressed, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1503 XLFD_SWIDTH_SEMI_CONDENSED, /* 40: semicondensed */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1504 XLFD_SWIDTH_MEDIUM, /* 50: Medium, Normal, Regular, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1505 XLFD_SWIDTH_SEMI_EXPANDED, /* 60: SemiExpanded, DemiExpanded, ... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1506 XLFD_SWIDTH_EXPANDED, /* 70: Expanded... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1507 XLFD_SWIDTH_EXTRA_EXPANDED, /* 80: ExtraExpanded, Wide... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1508 XLFD_SWIDTH_ULTRA_EXPANDED /* 90: UltraExpanded... */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1509 };
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1510
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1511 /* 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
1512 names to numeric and symbolic values. */
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 struct table_entry
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1515 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1516 char *name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1517 int numeric;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1518 Lisp_Object *symbol;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1521 /* 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
1522 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
1523 ascending order. */
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 static struct table_entry slant_table[] =
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1526 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1527 {"i", XLFD_SLANT_ITALIC, &Qitalic},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1528 {"o", XLFD_SLANT_OBLIQUE, &Qoblique},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1529 {"ot", XLFD_SLANT_OTHER, &Qitalic},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1530 {"r", XLFD_SLANT_ROMAN, &Qnormal},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1531 {"ri", XLFD_SLANT_REVERSE_ITALIC, &Qreverse_italic},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1532 {"ro", XLFD_SLANT_REVERSE_OBLIQUE, &Qreverse_oblique}
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1535 /* 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
1536 names in ascending order. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1537
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1538 static struct table_entry weight_table[] =
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1539 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1540 {"black", XLFD_WEIGHT_ULTRA_BOLD, &Qultra_bold},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1541 {"bold", XLFD_WEIGHT_BOLD, &Qbold},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1542 {"book", XLFD_WEIGHT_SEMI_LIGHT, &Qsemi_light},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1543 {"demibold", XLFD_WEIGHT_SEMI_BOLD, &Qsemi_bold},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1544 {"extralight", XLFD_WEIGHT_EXTRA_LIGHT, &Qextra_light},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1545 {"extrabold", XLFD_WEIGHT_EXTRA_BOLD, &Qextra_bold},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1546 {"heavy", XLFD_WEIGHT_EXTRA_BOLD, &Qextra_bold},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1547 {"light", XLFD_WEIGHT_LIGHT, &Qlight},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1548 {"medium", XLFD_WEIGHT_MEDIUM, &Qnormal},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1549 {"normal", XLFD_WEIGHT_MEDIUM, &Qnormal},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1550 {"regular", XLFD_WEIGHT_MEDIUM, &Qnormal},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1551 {"semibold", XLFD_WEIGHT_SEMI_BOLD, &Qsemi_bold},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1552 {"semilight", XLFD_WEIGHT_SEMI_LIGHT, &Qsemi_light},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1553 {"ultralight", XLFD_WEIGHT_ULTRA_LIGHT, &Qultra_light},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1554 {"ultrabold", XLFD_WEIGHT_ULTRA_BOLD, &Qultra_bold}
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1555 };
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1556
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1557 /* 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
1558 names in ascending order. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1559
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1560 static struct table_entry swidth_table[] =
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1561 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1562 {"compressed", XLFD_SWIDTH_CONDENSED, &Qcondensed},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1563 {"condensed", XLFD_SWIDTH_CONDENSED, &Qcondensed},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1564 {"demiexpanded", XLFD_SWIDTH_SEMI_EXPANDED, &Qsemi_expanded},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1565 {"expanded", XLFD_SWIDTH_EXPANDED, &Qexpanded},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1566 {"extracondensed", XLFD_SWIDTH_EXTRA_CONDENSED, &Qextra_condensed},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1567 {"extraexpanded", XLFD_SWIDTH_EXTRA_EXPANDED, &Qextra_expanded},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1568 {"medium", XLFD_SWIDTH_MEDIUM, &Qnormal},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1569 {"narrow", XLFD_SWIDTH_CONDENSED, &Qcondensed},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1570 {"normal", XLFD_SWIDTH_MEDIUM, &Qnormal},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1571 {"regular", XLFD_SWIDTH_MEDIUM, &Qnormal},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1572 {"semicondensed", XLFD_SWIDTH_SEMI_CONDENSED, &Qsemi_condensed},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1573 {"semiexpanded", XLFD_SWIDTH_SEMI_EXPANDED, &Qsemi_expanded},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1574 {"ultracondensed", XLFD_SWIDTH_ULTRA_CONDENSED, &Qultra_condensed},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1575 {"ultraexpanded", XLFD_SWIDTH_ULTRA_EXPANDED, &Qultra_expanded},
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1576 {"wide", XLFD_SWIDTH_EXTRA_EXPANDED, &Qextra_expanded}
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1577 };
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 /* 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
1580 format into their fields. */
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 struct font_name
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 /* The original name which is modified destructively by
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1585 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
1586 if it was allocated from the heap. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1587 char *name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1588
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1589 /* 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
1590 Fields are NUL-terminated. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1591 char *fields[XLFD_LAST];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1592
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1593 /* 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
1594 split_font_name for which these are. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1595 int numeric[XLFD_LAST];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1596 };
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 /* 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
1599 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
1600
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1601 static struct frame *font_frame;
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 /* 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
1604 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
1605 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
1606 set via set-face-font-sort-order. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1607
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1608 static int font_sort_order[4];
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1611 /* 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
1612 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
1613 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
1614 matches. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1615
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1616 static struct table_entry *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1617 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
1618 struct table_entry *table;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1619 int dim;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1620 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1621 int field_index;
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 /* 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
1624 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
1625 char *s = font->fields[field_index];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1626 int low, mid, high, cmp;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1627
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1628 low = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1629 high = dim - 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1630
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1631 while (low <= high)
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 mid = (low + high) / 2;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1634 cmp = strcmp (table[mid].name, s);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1635
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1636 if (cmp < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1637 low = mid + 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1638 else if (cmp > 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1639 high = mid - 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1640 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1641 return table + mid;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1642 }
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 return NULL;
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
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 /* Return a numeric representation for font name field
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1649 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
1650 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
1651 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
1652 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
1653
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1654 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1655 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
1656 struct table_entry *table;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1657 int dim;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1658 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1659 int field_index;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1660 int dflt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1661 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1662 struct table_entry *p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1663 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
1664 return p ? p->numeric : dflt;
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 symbolic representation for font name field
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1669 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
1670 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
1671 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
1672 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
1673
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1674 static INLINE Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1675 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
1676 struct table_entry *table;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1677 int dim;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1678 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1679 int field_index;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1680 int dflt;
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 struct table_entry *p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1683 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
1684 return p ? *p->symbol : dflt;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1687
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1688 /* 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
1689
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1690 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1691 xlfd_numeric_slant (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1692 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1693 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1694 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
1695 font, XLFD_SLANT, XLFD_SLANT_ROMAN);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1696 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1697
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1698
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1699 /* 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
1700
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1701 static INLINE Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1702 xlfd_symbolic_slant (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1703 struct font_name *font;
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 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
1706 font, XLFD_SLANT, Qnormal);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1707 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1710 /* 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
1711
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1712 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1713 xlfd_numeric_weight (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1714 struct font_name *font;
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 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
1717 font, XLFD_WEIGHT, XLFD_WEIGHT_MEDIUM);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1718 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1719
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1720
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1721 /* 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
1722
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1723 static INLINE Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1724 xlfd_symbolic_weight (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1725 struct font_name *font;
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 xlfd_symbolic_value (weight_table, DIM (weight_table),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1728 font, XLFD_WEIGHT, Qnormal);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1729 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1732 /* 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
1733 name fields are found in FONT. */
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 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1736 xlfd_numeric_swidth (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1737 struct font_name *font;
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 xlfd_numeric_value (swidth_table, DIM (swidth_table),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1740 font, XLFD_SWIDTH, XLFD_SWIDTH_MEDIUM);
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1743
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1744 /* 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
1745
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1746 static INLINE Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1747 xlfd_symbolic_swidth (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1748 struct font_name *font;
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 xlfd_symbolic_value (swidth_table, DIM (swidth_table),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1751 font, XLFD_SWIDTH, Qnormal);
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1754
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1755 /* 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
1756 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
1757 no element of TABLE contains SYMBOL. */
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 static struct table_entry *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1760 face_value (table, dim, symbol)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1761 struct table_entry *table;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1762 int dim;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1763 Lisp_Object symbol;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1764 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1765 int i;
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 xassert (SYMBOLP (symbol));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1768
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1769 for (i = 0; i < dim; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1770 if (EQ (*table[i].symbol, symbol))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1771 break;
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 i < dim ? table + i : NULL;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1776
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1777 /* 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
1778 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
1779
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1780 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1781 face_numeric_value (table, dim, symbol)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1782 struct table_entry *table;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1783 int dim;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1784 Lisp_Object symbol;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1785 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1786 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
1787 return p ? p->numeric : -1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1788 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1791 /* 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
1792 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
1793 xlfd_weight. */
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 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1796 face_numeric_weight (weight)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1797 Lisp_Object weight;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1798 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1799 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
1800 }
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 /* 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
1804 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
1805
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1806 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1807 face_numeric_slant (slant)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1808 Lisp_Object slant;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1809 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1810 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
1811 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1812
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 /* 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
1815 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
1816
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1817 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1818 face_numeric_swidth (width)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1819 Lisp_Object width;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1820 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1821 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
1822 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1823
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1824
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1825 #ifdef HAVE_WINDOW_SYSTEM
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
1826
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1827 /* 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
1828
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1829 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1830 xlfd_fixed_p (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1831 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1832 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1833 /* 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
1834 is no need to use tolower here. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1835 return *font->fields[XLFD_SPACING] != 'p';
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1836 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1839 /* 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
1840
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1841 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
1842 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
1843 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
1844 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
1845 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
1846 72dpi versions, only.)
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 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
1849 be determined. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1850
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1851 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1852 xlfd_point_size (f, font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1853 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1854 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1855 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1856 double resy = FRAME_W32_DISPLAY_INFO (f)->resy;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1857 double font_resy = atoi (font->fields[XLFD_RESY]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1858 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
1859 int real_pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1860
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1861 if (font_resy == 0 || font_pt == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1862 real_pt = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1863 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1864 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
1865
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1866 return real_pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1867 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1868
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1869
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1870 /* 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
1871 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
1872 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
1873 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
1874 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
1875 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
1876 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
1877 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
1878 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
1879
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1880 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1881 split_font_name (f, font, numeric_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1882 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1883 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1884 int numeric_p;
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 int i = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1887 int success_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1888
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1889 if (*font->name == '-')
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 char *p = xstrlwr (font->name) + 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1892
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1893 while (i < XLFD_LAST)
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 font->fields[i] = p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1896 ++i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1897
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1898 while (*p && *p != '-')
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1899 ++p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1900
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1901 if (*p != '-')
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1902 break;
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 *p++ = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1905 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1906 }
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 success_p = i == XLFD_LAST;
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 /* 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
1911 compute numeric values for some fields. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1912 if (numeric_p && success_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1913 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1914 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
1915 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
1916 font->numeric[XLFD_SLANT] = xlfd_numeric_slant (font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1917 font->numeric[XLFD_WEIGHT] = xlfd_numeric_weight (font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1918 font->numeric[XLFD_SWIDTH] = xlfd_numeric_swidth (font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1919 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1920
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1921 return success_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1922 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1923
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1924
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1925 /* 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
1926 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
1927
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1928 static char *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1929 build_font_name (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1930 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1931 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1932 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1933 int size = 100;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1934 char *font_name = (char *) xmalloc (size);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1935 int total_length = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1936
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1937 for (i = 0; i < XLFD_LAST; ++i)
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 /* Add 1 because of the leading `-'. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1940 int len = strlen (font->fields[i]) + 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1941
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1942 /* 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
1943 NUL-byte. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1944 if (total_length + len + 1 >= size)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1945 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1946 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
1947 int sz = new_size * sizeof *font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1948 font_name = (char *) xrealloc (font_name, sz);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1949 size = new_size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1950 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1951
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1952 font_name[total_length] = '-';
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1953 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
1954 total_length += len;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1955 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1956
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1957 font_name[total_length] = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1958 return font_name;
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
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 /* 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
1963 itself and all `name' fields in its elements. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1964
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1965 static INLINE void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1966 free_font_names (fonts, n)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1967 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1968 int n;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1969 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1970 while (n)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1971 xfree (fonts[--n].name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1972 xfree (fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1973 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1976 /* 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
1977 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
1978 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
1979 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
1980
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1981 static INLINE void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1982 sort_fonts (f, fonts, nfonts, cmpfn)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1983 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1984 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1985 int nfonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1986 int (*cmpfn) P_ ((const void *, const void *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1987 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1988 font_frame = f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1989 qsort (fonts, nfonts, sizeof *fonts, cmpfn);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1990 font_frame = NULL;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1991 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
1992
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1993
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
1994 /* 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
1995 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
1996 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
1997 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
1998 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
1999 scalable fonts.
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2000
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2001 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
2002 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
2003 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
2004
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2005 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
2006
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2007 1. It avoids consing.
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2008 2. It never calls XLoadQueryFont. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2009
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2010 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2011 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
2012 scalable_fonts_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2013 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2014 char *pattern;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2015 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2016 int nfonts, try_alternatives_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2017 int scalable_fonts_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2018 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2019 /* 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
2020 better to do it the other way around. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2021 int n = 0, i, j;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2022 char **names = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2023 Lisp_Object lfonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2024 Lisp_Object lpattern, tem;
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 lpattern = build_string (pattern);
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 /* Get the list of fonts matching PATTERN. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2029 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2030 lfonts = w32_list_fonts (f, lpattern, 0, nfonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2031 UNBLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2032
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2033 /* Count fonts returned */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2034 for (tem = lfonts; CONSP (tem); tem = XCDR (tem))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2035 n++;
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 /* Allocate array. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2038 if (n)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2039 names = (char **) xmalloc (n * sizeof (char *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2040
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2041 /* Extract font names into char * array. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2042 tem = lfonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2043 for (i = 0; i < n; i++)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2044 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2045 names[i] = XSTRING (XCAR (tem))->data;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2046 tem = XCDR (tem);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2047 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2048
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2049 if (names)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2050 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2051 /* 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
2052 split them into fields. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2053 for (i = j = 0; i < n; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2054 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2055 /* Make a copy of the font name. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2056 fonts[j].name = xstrdup (names[i]);
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 /* 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
2059 if (!split_font_name (f, fonts + j, 1))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2060 xfree (fonts[j].name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2061 else if (font_scalable_p (fonts + j))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2062 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2063 #if SCALABLE_FONTS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2064 if (!scalable_fonts_p
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2065 || !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
2066 xfree (fonts[j].name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2067 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2068 ++j;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2069 #else /* !SCALABLE_FONTS */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2070 /* Always ignore scalable fonts. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2071 xfree (fonts[j].name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2072 #endif /* !SCALABLE_FONTS */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2073 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2074 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2075 ++j;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2076 }
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 n = j;
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 /* Free font names. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2081 #if 0 /* NTEMACS_TODO : W32 equivalent? */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2082 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2083 XFreeFontNames (names);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2084 UNBLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2085 #endif /* NTEMACS_TODO */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2086 }
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 /* 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
2090 if (n == 0 && try_alternatives_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2091 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2092 Lisp_Object list = Valternate_fontname_alist;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2093
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2094 while (CONSP (list))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2095 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2096 Lisp_Object entry = XCAR (list);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2097 if (CONSP (entry)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2098 && STRINGP (XCAR (entry))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2099 && strcmp (XSTRING (XCAR (entry))->data, pattern) == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2100 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2101 list = XCDR (list);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2102 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2103
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2104 if (CONSP (list))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2105 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2106 Lisp_Object patterns = XCAR (list);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2107 Lisp_Object name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2108
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2109 while (CONSP (patterns)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2110 /* If list is screwed up, give up. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2111 && (name = XCAR (patterns),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2112 STRINGP (name))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2113 /* 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
2114 already with no success. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2115 && (strcmp (XSTRING (name)->data, pattern) == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2116 || (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
2117 fonts, nfonts, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2118 scalable_fonts_p),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2119 n == 0)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2120 patterns = XCDR (patterns);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2121 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2122 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2123
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2124 return n;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2125 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2126
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 /* 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
2129 *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
2130 if a match was found. */
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 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2133 first_font_matching (f, pattern, font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2134 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2135 char *pattern;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2136 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2137 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2138 int nfonts = 100;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2139 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2140
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2141 fonts = (struct font_name *) xmalloc (nfonts * sizeof *fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2142 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
2143
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2144 if (nfonts > 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2145 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2146 bcopy (&fonts[0], font, sizeof *font);
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 fonts[0].name = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2149 free_font_names (fonts, nfonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2150 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2151
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2152 return nfonts > 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2153 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2156 /* 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
2157 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
2158 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
2159 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
2160 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
2161 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
2162 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
2163
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2164 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2165 sorted_font_list (f, pattern, cmpfn, fonts)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2166 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2167 char *pattern;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2168 int (*cmpfn) P_ ((const void *, const void *));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2169 struct font_name **fonts;
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 int nfonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2172
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2173 /* 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
2174 nfonts = DEFAULT_FONT_LIST_LIMIT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2175 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
2176 nfonts = XFASTINT (Vfont_list_limit);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2177
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2178 *fonts = (struct font_name *) xmalloc (nfonts * sizeof **fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2179 #if SCALABLE_FONTS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2180 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
2181 #else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2182 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
2183 #endif
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2184
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2185 /* 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
2186 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
2187 if (nfonts)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2188 sort_fonts (f, *fonts, nfonts, cmpfn);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2189 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2190 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2191 xfree (*fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2192 *fonts = 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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2195 return nfonts;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2198
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2199 /* 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
2200 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
2201 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
2202 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
2203 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
2204 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
2205
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2206 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2207 cmp_font_names (a, b)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2208 const void *a, *b;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2209 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2210 struct font_name *x = (struct font_name *) a;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2211 struct font_name *y = (struct font_name *) b;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2212 int cmp;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2213
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2214 /* 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
2215 so we can use strcmp here. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2216 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
2217 if (cmp == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2218 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2219 int i;
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 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
2222 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2223 int j = font_sort_order[i];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2224 cmp = x->numeric[j] - y->numeric[j];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2225 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2226
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2227 if (cmp == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2228 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2229 /* 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
2230 y-resolution closer to that of the frame. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2231 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
2232 int x_resy = x->numeric[XLFD_RESY];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2233 int y_resy = y->numeric[XLFD_RESY];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2234 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
2235 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2236 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2237
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2238 return cmp;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2239 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2240
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2241
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2242 /* 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
2243 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
2244 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
2245 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
2246 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
2247 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
2248 fonts found. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2249
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2250 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2251 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
2252 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2253 char *pattern;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2254 char *family;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2255 char *registry_and_encoding;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2256 struct font_name **fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2257 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2258 if (pattern == NULL)
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 (family == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2261 family = "*";
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2262
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2263 if (registry_and_encoding == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2264 registry_and_encoding = "*";
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2265
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2266 pattern = (char *) alloca (strlen (family)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2267 + strlen (registry_and_encoding)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2268 + 10);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2269 if (index (family, '-'))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2270 sprintf (pattern, "-%s-*-%s", family, registry_and_encoding);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2271 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2272 sprintf (pattern, "-*-%s-*-%s", family, registry_and_encoding);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2273 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2274
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2275 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
2276 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2279 /* 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
2280 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
2281 entries. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2282
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2283 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2284 remove_duplicates (list)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2285 Lisp_Object list;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2286 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2287 Lisp_Object tail = list;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2288
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2289 while (!NILP (tail) && !NILP (XCDR (tail)))
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 Lisp_Object next = XCDR (tail);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2292 if (!NILP (Fequal (XCAR (next), XCAR (tail))))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2293 XCDR (tail) = XCDR (next);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2294 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2295 tail = XCDR (tail);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2296 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2297 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2298
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2299
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2300 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
2301 "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
2302 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
2303 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
2304 `?' and `*'.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2305 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
2306 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
2307 SLANT FIXED-P FULL REGISTRY-AND-ENCODING].\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2308 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
2309 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
2310 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
2311 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
2312 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
2313 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
2314 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
2315 the face font sort order.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2316 (family, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2317 Lisp_Object family, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2318 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2319 struct frame *f = check_x_frame (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2320 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2321 int i, nfonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2322 Lisp_Object result;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2323 struct gcpro gcpro1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2324 char *family_pattern;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2325
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2326 if (NILP (family))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2327 family_pattern = "*";
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2328 else
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 CHECK_STRING (family, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2331 family_pattern = LSTRDUPA (family);
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2334 result = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2335 GCPRO1 (result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2336 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
2337 for (i = nfonts - 1; i >= 0; --i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2338 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2339 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
2340 char *tem;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2341
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2342 #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
2343
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2344 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
2345 ASET (v, 1, xlfd_symbolic_swidth (fonts + i));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2346 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
2347 ASET (v, 3, xlfd_symbolic_weight (fonts + i));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2348 ASET (v, 4, xlfd_symbolic_slant (fonts + i));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2349 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
2350 tem = build_font_name (fonts + i);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2351 ASET (v, 6, build_string (tem));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2352 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
2353 fonts[i].fields[XLFD_ENCODING]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2354 ASET (v, 7, build_string (tem));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2355 xfree (tem);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2356
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2357 result = Fcons (v, result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2358
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2359 #undef ASET
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2360 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2361
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2362 remove_duplicates (result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2363 free_font_names (fonts, nfonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2364 UNGCPRO;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2365 return result;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2366 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2367
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2368
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2369 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
2370 0, 1, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2371 "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
2372 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
2373 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
2374 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
2375 are fixed-pitch.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2376 (frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2377 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2378 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2379 struct frame *f = check_x_frame (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2380 int nfonts, i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2381 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2382 Lisp_Object result;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2383 struct gcpro gcpro1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2384 int count = specpdl_ptr - specpdl;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2385 int limit;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2386
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2387 /* 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
2388 fonts until we have them all. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2389 for (limit = 500;;)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2390 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2391 specbind (intern ("font-list-limit"), make_number (limit));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2392 nfonts = font_list (f, NULL, "*", NULL, &fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2393
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2394 if (nfonts == limit)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2395 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2396 free_font_names (fonts, nfonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2397 limit *= 2;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2398 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2399 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2400 break;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2403 result = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2404 GCPRO1 (result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2405 for (i = nfonts - 1; i >= 0; --i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2406 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
2407 xlfd_fixed_p (fonts + i) ? Qt : Qnil),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2408 result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2409
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2410 remove_duplicates (result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2411 free_font_names (fonts, nfonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2412 UNGCPRO;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2413 return unbind_to (count, result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2414 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2415
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2416
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2417 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
2418 "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
2419 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
2420 the same size as FACE on FRAME.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2421 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
2422 the * character matches any substring, and\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2423 the ? character matches any single character.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2424 PATTERN is case-insensitive.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2425 FACE is a face name--a symbol.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2426 \n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2427 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
2428 set-face-font.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2429 \n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2430 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
2431 even if they match PATTERN and FACE.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2432 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
2433 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
2434 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
2435 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
2436 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
2437 (pattern, face, frame, maximum, width)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2438 Lisp_Object pattern, face, frame, maximum, width;
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 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2441 int size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2442 int maxnames;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2443
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2444 check_w32 ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2445 CHECK_STRING (pattern, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2446
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2447 if (NILP (maximum))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2448 maxnames = 2000;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2449 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2450 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2451 CHECK_NATNUM (maximum, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2452 maxnames = XINT (maximum);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2453 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2454
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2455 if (!NILP (width))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2456 CHECK_NUMBER (width, 4);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2457
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2458 /* 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
2459 called before any frame is created. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2460 f = frame_or_selected_frame (frame, 2);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2461 if (!FRAME_WINDOW_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2462 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2463 /* Perhaps we have not yet created any frame. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2464 f = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2465 face = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2466 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2467
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2468 /* 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
2469
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2470 if (NILP (face))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2471 size = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2472 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2473 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2474 /* 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
2475 widths. Keep it for compatibility. --gerd. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2476 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
2477 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
2478
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2479 if (face->font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2480 size = FONT_MAX_WIDTH (face->font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2481 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2482 size = FONT_MAX_WIDTH (FRAME_FONT (f));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2483
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2484 if (!NILP (width))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2485 size *= XINT (width);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2486 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2487
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2488 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2489 Lisp_Object args[2];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2490
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2491 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
2492 if (f == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2493 /* We don't have to check fontsets. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2494 return args[0];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2495 args[1] = list_fontsets (f, pattern, size);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2496 return Fnconc (2, args);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2497 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2498 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2499
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
2500 #endif /* HAVE_WINDOW_SYSTEM */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
2501
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2502
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2503
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2504 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2505 Lisp Faces
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2506 ***********************************************************************/
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2507
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2508 /* 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
2509
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2510 #define LFACE_FAMILY(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2511 XVECTOR (LFACE)->contents[LFACE_FAMILY_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2512 #define LFACE_HEIGHT(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2513 XVECTOR (LFACE)->contents[LFACE_HEIGHT_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2514 #define LFACE_WEIGHT(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2515 XVECTOR (LFACE)->contents[LFACE_WEIGHT_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2516 #define LFACE_SLANT(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2517 XVECTOR (LFACE)->contents[LFACE_SLANT_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2518 #define LFACE_UNDERLINE(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2519 XVECTOR (LFACE)->contents[LFACE_UNDERLINE_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2520 #define LFACE_INVERSE(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2521 XVECTOR (LFACE)->contents[LFACE_INVERSE_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2522 #define LFACE_FOREGROUND(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2523 XVECTOR (LFACE)->contents[LFACE_FOREGROUND_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2524 #define LFACE_BACKGROUND(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2525 XVECTOR (LFACE)->contents[LFACE_BACKGROUND_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2526 #define LFACE_STIPPLE(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2527 XVECTOR (LFACE)->contents[LFACE_STIPPLE_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2528 #define LFACE_SWIDTH(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2529 XVECTOR (LFACE)->contents[LFACE_SWIDTH_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2530 #define LFACE_OVERLINE(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2531 XVECTOR (LFACE)->contents[LFACE_OVERLINE_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2532 #define LFACE_STRIKE_THROUGH(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2533 XVECTOR (LFACE)->contents[LFACE_STRIKE_THROUGH_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2534 #define LFACE_BOX(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2535 XVECTOR (LFACE)->contents[LFACE_BOX_INDEX]
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 /* 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
2538 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
2539
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2540 #define LFACEP(LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2541 (VECTORP (LFACE) \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2542 && XVECTOR (LFACE)->size == LFACE_VECTOR_SIZE \
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2543 && EQ (XVECTOR (LFACE)->contents[0], Qface))
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2546 #if GLYPH_DEBUG
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2547
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2548 /* Check consistency of Lisp face attribute vector ATTRS. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2549
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2550 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2551 check_lface_attrs (attrs)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2552 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2553 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2554 xassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2555 || STRINGP (attrs[LFACE_FAMILY_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2556 xassert (UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2557 || SYMBOLP (attrs[LFACE_SWIDTH_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2558 xassert (UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2559 || INTEGERP (attrs[LFACE_HEIGHT_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2560 xassert (UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2561 || SYMBOLP (attrs[LFACE_WEIGHT_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2562 xassert (UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2563 || SYMBOLP (attrs[LFACE_SLANT_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2564 xassert (UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2565 || SYMBOLP (attrs[LFACE_UNDERLINE_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2566 || STRINGP (attrs[LFACE_UNDERLINE_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2567 xassert (UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2568 || SYMBOLP (attrs[LFACE_OVERLINE_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2569 || STRINGP (attrs[LFACE_OVERLINE_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2570 xassert (UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2571 || SYMBOLP (attrs[LFACE_STRIKE_THROUGH_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2572 || STRINGP (attrs[LFACE_STRIKE_THROUGH_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2573 xassert (UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2574 || SYMBOLP (attrs[LFACE_BOX_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2575 || STRINGP (attrs[LFACE_BOX_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2576 || INTEGERP (attrs[LFACE_BOX_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2577 || CONSP (attrs[LFACE_BOX_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2578 xassert (UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2579 || SYMBOLP (attrs[LFACE_INVERSE_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2580 xassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2581 || STRINGP (attrs[LFACE_FOREGROUND_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2582 xassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2583 || STRINGP (attrs[LFACE_BACKGROUND_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2584 #ifdef HAVE_WINDOW_SYSTEM
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2585 xassert (UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2586 || SYMBOLP (attrs[LFACE_STIPPLE_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2587 || !NILP (Fbitmap_spec_p (attrs[LFACE_STIPPLE_INDEX])));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2588 #endif
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2591
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2592 /* 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
2593
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2594 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2595 check_lface (lface)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2596 Lisp_Object lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2597 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2598 if (!NILP (lface))
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 xassert (LFACEP (lface));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2601 check_lface_attrs (XVECTOR (lface)->contents);
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 #else /* GLYPH_DEBUG == 0 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2606
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2607 #define check_lface_attrs(attrs) (void) 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2608 #define check_lface(lface) (void) 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2609
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2610 #endif /* GLYPH_DEBUG == 0 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2611
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2612
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2613 /* 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
2614 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
2615 return that face's name. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2616
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2617 static Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2618 resolve_face_name (face_name)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2619 Lisp_Object face_name;
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 Lisp_Object aliased;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2622
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2623 if (STRINGP (face_name))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2624 face_name = intern (XSTRING (face_name)->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2625
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2626 for (;;)
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 aliased = Fget (face_name, Qface_alias);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2629 if (NILP (aliased))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2630 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2631 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2632 face_name = aliased;
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 return face_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2636 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2639 /* 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
2640 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
2641 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
2642 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
2643 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
2644 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
2645 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
2646 name. */
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 static INLINE Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2649 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
2650 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2651 Lisp_Object face_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2652 int signal_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2653 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2654 Lisp_Object lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2655
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2656 face_name = resolve_face_name (face_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2657
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2658 if (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2659 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
2660 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2661 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
2662
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2663 if (CONSP (lface))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2664 lface = XCDR (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2665 else if (signal_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2666 signal_error ("Invalid face", face_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2667
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2668 check_lface (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2669 return lface;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2672
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2673 /* 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
2674 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
2675 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
2676 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
2677 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
2678
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2679 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2680 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
2681 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2682 Lisp_Object face_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2683 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2684 int signal_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2685 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2686 Lisp_Object lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2687 int success_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2688
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2689 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
2690 if (!NILP (lface))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2691 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2692 bcopy (XVECTOR (lface)->contents, attrs,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2693 LFACE_VECTOR_SIZE * sizeof *attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2694 success_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2695 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2696 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2697 success_p = 0;
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 return success_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2700 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2701
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 /* 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
2704 specified, i.e. are non-nil. */
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 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2707 lface_fully_specified_p (attrs)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2708 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2709 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2710 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2711
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2712 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2713 if (UNSPECIFIEDP (attrs[i]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2714 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2715
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2716 return i == LFACE_VECTOR_SIZE;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2717 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2718
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2719 #ifdef HAVE_WINDOW_SYSTEM
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2720
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2721 /* 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
2722 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
2723 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
2724 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
2725 default font.
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 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
2728 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
2729 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
2730 for split_font_name, see the comment there. */
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 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2733 set_lface_from_font_name (f, lface, font_name, force_p, may_fail_p)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
2734 struct frame *f;
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2735 Lisp_Object lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2736 char *font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2737 int force_p, may_fail_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2738 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2739 struct font_name font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2740 char *buffer;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2741 int pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2742 int free_font_name_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2743 int have_font_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2744
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2745 /* 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
2746 if (index (font_name, '*') || index (font_name, '?'))
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 if (first_font_matching (f, font_name, &font))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2749 free_font_name_p = have_font_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2750 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2751 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2752 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2753 font.name = STRDUPA (font_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2754 if (split_font_name (f, &font, 1))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2755 have_font_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2756 else
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 /* 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
2759 sure we use the full name. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2760 struct font_info *font_info;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2761
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2762 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2763 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
2764 CHARSET_ASCII, font_name, -1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2765 if (font_info)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2766 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2767 font.name = STRDUPA (font_info->full_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2768 split_font_name (f, &font, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2769 have_font_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2770 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2771 UNBLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2772 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2775 /* 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
2776 if this function must succeed. Otherwise, give up. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2777 if (!have_font_p)
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 if (may_fail_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2780 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2781 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
2782 &font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2783 || 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
2784 &font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2785 || 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
2786 &font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2787 || 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
2788 &font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2789 || first_font_matching (f, "FixedSys",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2790 &font))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2791 free_font_name_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2792 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2793 abort ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2794 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2795
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 /* 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
2798 new frames would never take effect. */
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 if (force_p || UNSPECIFIEDP (LFACE_FAMILY (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2801 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2802 buffer = (char *) alloca (strlen (font.fields[XLFD_FAMILY])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2803 + strlen (font.fields[XLFD_FOUNDRY])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2804 + 2);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2805 sprintf (buffer, "%s-%s", font.fields[XLFD_FOUNDRY],
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2806 font.fields[XLFD_FAMILY]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2807 LFACE_FAMILY (lface) = build_string (buffer);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2808 }
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 (force_p || UNSPECIFIEDP (LFACE_HEIGHT (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2811 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2812 pt = xlfd_point_size (f, &font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2813 xassert (pt > 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2814 LFACE_HEIGHT (lface) = make_number (pt);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2815 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2816
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2817 if (force_p || UNSPECIFIEDP (LFACE_SWIDTH (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2818 LFACE_SWIDTH (lface) = xlfd_symbolic_swidth (&font);
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 (force_p || UNSPECIFIEDP (LFACE_WEIGHT (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2821 LFACE_WEIGHT (lface) = xlfd_symbolic_weight (&font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2822
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2823 if (force_p || UNSPECIFIEDP (LFACE_SLANT (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2824 LFACE_SLANT (lface) = xlfd_symbolic_slant (&font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2825
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2826 if (free_font_name_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2827 xfree (font.name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2828
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2829 return 1;
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 #endif /* HAVE_WINDOW_SYSTEM */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2832
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 /* 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
2835 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
2836 overrides the corresponding attribute of TO. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2837
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2838 static INLINE void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2839 merge_face_vectors (from, to)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2840 Lisp_Object *from, *to;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2841 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2842 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2843 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2844 if (!UNSPECIFIEDP (from[i]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2845 to[i] = from[i];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2846 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2847
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2848
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2849 /* 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
2850 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
2851 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
2852 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
2853 specification can be
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2854
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2855 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
2856
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2857 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
2858 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
2859 for that attribute.
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 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
2862 (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
2863 for compatibility with 20.2.
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2864
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2865 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
2866 specifications. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2867
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2868 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2869 merge_face_vector_with_property (f, to, prop)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2870 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2871 Lisp_Object *to;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2872 Lisp_Object prop;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2873 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2874 if (CONSP (prop))
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 Lisp_Object first = XCAR (prop);
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 (first, Qforeground_color)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2879 || EQ (first, Qbackground_color))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2880 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2881 /* One of (FOREGROUND-COLOR . COLOR) or (BACKGROUND-COLOR
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2882 . COLOR). COLOR must be a string. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2883 Lisp_Object color_name = XCDR (prop);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2884 Lisp_Object color = first;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2885
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2886 if (STRINGP (color_name))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2887 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2888 if (EQ (color, Qforeground_color))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2889 to[LFACE_FOREGROUND_INDEX] = color_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2890 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2891 to[LFACE_BACKGROUND_INDEX] = color_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2892 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2893 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2894 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
2895 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2896 else if (SYMBOLP (first)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2897 && *XSYMBOL (first)->name->data == ':')
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2898 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2899 /* Assume this is the property list form. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2900 while (CONSP (prop) && CONSP (XCDR (prop)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2901 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2902 Lisp_Object keyword = XCAR (prop);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2903 Lisp_Object value = XCAR (XCDR (prop));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2904
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2905 if (EQ (keyword, QCfamily))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2906 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2907 if (STRINGP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2908 to[LFACE_FAMILY_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2909 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2910 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
2911 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2912 else if (EQ (keyword, QCheight))
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 if (INTEGERP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2915 to[LFACE_HEIGHT_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2916 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2917 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
2918 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2919 else if (EQ (keyword, QCweight))
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 if (SYMBOLP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2922 && face_numeric_weight (value) >= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2923 to[LFACE_WEIGHT_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2924 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2925 add_to_log ("Illegal face weight", value, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2926 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2927 else if (EQ (keyword, QCslant))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2928 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2929 if (SYMBOLP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2930 && face_numeric_slant (value) >= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2931 to[LFACE_SLANT_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2932 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2933 add_to_log ("Illegal face slant", value, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2934 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2935 else if (EQ (keyword, QCunderline))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2936 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2937 if (EQ (value, Qt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2938 || NILP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2939 || STRINGP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2940 to[LFACE_UNDERLINE_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 underline", 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 if (EQ (keyword, QCoverline))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2945 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2946 if (EQ (value, Qt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2947 || NILP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2948 || STRINGP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2949 to[LFACE_OVERLINE_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2950 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2951 add_to_log ("Illegal face overline", value, Qnil);
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 else if (EQ (keyword, QCstrike_through))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2954 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2955 if (EQ (value, Qt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2956 || NILP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2957 || STRINGP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2958 to[LFACE_STRIKE_THROUGH_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2959 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2960 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
2961 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2962 else if (EQ (keyword, QCbox))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2963 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2964 if (EQ (value, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2965 value = make_number (1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2966 if (INTEGERP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2967 || STRINGP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2968 || CONSP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2969 || NILP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2970 to[LFACE_BOX_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2971 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2972 add_to_log ("Illegal face box", value, Qnil);
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 else if (EQ (keyword, QCinverse_video)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2975 || EQ (keyword, QCreverse_video))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2976 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2977 if (EQ (value, Qt) || NILP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2978 to[LFACE_INVERSE_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2979 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2980 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
2981 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2982 else if (EQ (keyword, QCforeground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2983 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2984 if (STRINGP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2985 to[LFACE_FOREGROUND_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2986 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2987 add_to_log ("Illegal face foreground", value, Qnil);
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 else if (EQ (keyword, QCbackground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2990 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2991 if (STRINGP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2992 to[LFACE_BACKGROUND_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2993 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2994 add_to_log ("Illegal face background", value, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2995 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2996 else if (EQ (keyword, QCstipple))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2997 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
2998 #ifdef HAVE_X_WINDOWS
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
2999 Lisp_Object pixmap_p = Fbitmap_spec_p (value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3000 if (!NILP (pixmap_p))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3001 to[LFACE_STIPPLE_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3002 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3003 add_to_log ("Illegal face stipple", value, Qnil);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3004 #endif
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3005 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3006 else if (EQ (keyword, QCwidth))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3007 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3008 if (SYMBOLP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3009 && face_numeric_swidth (value) >= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3010 to[LFACE_SWIDTH_INDEX] = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3011 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3012 add_to_log ("Illegal face width", value, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3013 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3014 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3015 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
3016 keyword, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3017
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3018 prop = XCDR (XCDR (prop));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3019 }
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 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3022 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3023 /* 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
3024 beginning of the list take precedence over later
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3025 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
3026 last specification. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3027 Lisp_Object next = XCDR (prop);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3028 if (!NILP (next))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3029 merge_face_vector_with_property (f, to, next);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3030 merge_face_vector_with_property (f, to, first);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3031 }
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 else
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 /* PROP ought to be a face name. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3036 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
3037 if (NILP (lface))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3038 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
3039 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3040 merge_face_vectors (XVECTOR (lface)->contents, to);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3041 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3042 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3045 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
3046 Sinternal_make_lisp_face, 1, 2, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3047 "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
3048 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
3049 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
3050 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
3051 Value is a vector of face attributes.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3052 (face, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3053 Lisp_Object face, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3054 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3055 Lisp_Object global_lface, lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3056 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3057 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3058
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3059 CHECK_SYMBOL (face, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3060 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
3061
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3062 if (!NILP (frame))
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 CHECK_LIVE_FRAME (frame, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3065 f = XFRAME (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3066 lface = lface_from_face_name (f, face, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3067 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3068 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3069 f = NULL, lface = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3070
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3071 /* Add a global definition if there is none. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3072 if (NILP (global_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 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
3075 Qunspecified);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3076 XVECTOR (global_lface)->contents[0] = Qface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3077 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
3078 Vface_new_frame_defaults);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3079
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3080 /* 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
3081 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
3082 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
3083 property `face' of the Lisp face name. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3084 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
3085 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3086 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
3087 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
3088 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
3089 lface_id_to_name_size = new_size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3090 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3091
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3092 lface_id_to_name[next_lface_id] = face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3093 Fput (face, Qface, make_number (next_lface_id));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3094 ++next_lface_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3095 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3096 else if (f == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3097 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3098 XVECTOR (global_lface)->contents[i] = Qunspecified;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3099
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3100 /* Add a frame-local definition. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3101 if (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3102 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3103 if (NILP (lface))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3104 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3105 lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3106 Qunspecified);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3107 XVECTOR (lface)->contents[0] = Qface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3108 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
3109 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3110 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3111 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3112 XVECTOR (lface)->contents[i] = Qunspecified;
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 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3115 lface = global_lface;
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 xassert (LFACEP (lface));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3118 check_lface (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3119 return lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3120 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3121
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3122
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3123 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
3124 Sinternal_lisp_face_p, 1, 2, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3125 "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
3126 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
3127 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
3128 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
3129 (face, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3130 Lisp_Object face, frame;
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 Lisp_Object lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3133
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3134 if (!NILP (frame))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3135 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3136 CHECK_LIVE_FRAME (frame, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3137 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
3138 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3139 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3140 lface = lface_from_face_name (NULL, face, 0);
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 return lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3143 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3146 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
3147 Sinternal_copy_lisp_face, 4, 4, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3148 "Copy face FROM to TO.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3149 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
3150 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
3151 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
3152 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
3153 \n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3154 Value is TO.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3155 (from, to, frame, new_frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3156 Lisp_Object from, to, frame, new_frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3157 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3158 Lisp_Object lface, copy;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3159
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3160 CHECK_SYMBOL (from, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3161 CHECK_SYMBOL (to, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3162 if (NILP (new_frame))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3163 new_frame = frame;
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 if (EQ (frame, Qt))
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 /* 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
3168 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
3169 lface = lface_from_face_name (NULL, from, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3170 copy = Finternal_make_lisp_face (to, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3171 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3172 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3173 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3174 /* Copy frame-local definition of FROM. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3175 CHECK_LIVE_FRAME (frame, 2);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3176 CHECK_LIVE_FRAME (new_frame, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3177 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
3178 copy = Finternal_make_lisp_face (to, new_frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3179 }
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 bcopy (XVECTOR (lface)->contents, XVECTOR (copy)->contents,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3182 LFACE_VECTOR_SIZE * sizeof (Lisp_Object));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3183
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3184 return to;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3185 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3186
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3187
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3188 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
3189 Sinternal_set_lisp_face_attribute, 3, 4, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3190 "Set attribute ATTR of FACE to VALUE.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3191 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
3192 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
3193 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
3194 frame.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3195 (face, attr, value, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3196 Lisp_Object face, attr, value, frame;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
3197 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3198 Lisp_Object lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3199 Lisp_Object old_value = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3200 int font_related_attr_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3201
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3202 CHECK_SYMBOL (face, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3203 CHECK_SYMBOL (attr, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3204
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3205 face = resolve_face_name (face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3206
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3207 /* 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
3208 if (EQ (frame, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3209 lface = lface_from_face_name (NULL, face, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3210 else
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 if (NILP (frame))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3213 frame = selected_frame;
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 CHECK_LIVE_FRAME (frame, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3216 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
3217
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3218 /* 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
3219 if (NILP (lface))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3220 lface = Finternal_make_lisp_face (face, frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3221 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3222
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3223 if (EQ (attr, QCfamily))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3224 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3225 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3226 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3227 CHECK_STRING (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3228 if (XSTRING (value)->size == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3229 signal_error ("Invalid face family", value);
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 old_value = LFACE_FAMILY (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3232 LFACE_FAMILY (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3233 font_related_attr_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3234 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3235 else if (EQ (attr, QCheight))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3236 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3237 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3238 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3239 CHECK_NUMBER (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3240 if (XINT (value) <= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3241 signal_error ("Invalid face height", 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 old_value = LFACE_HEIGHT (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3244 LFACE_HEIGHT (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3245 font_related_attr_p = 1;
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 else if (EQ (attr, QCweight))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3248 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3249 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3250 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3251 CHECK_SYMBOL (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3252 if (face_numeric_weight (value) < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3253 signal_error ("Invalid face weight", value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3254 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3255 old_value = LFACE_WEIGHT (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3256 LFACE_WEIGHT (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3257 font_related_attr_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3258 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3259 else if (EQ (attr, QCslant))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3260 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3261 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3262 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3263 CHECK_SYMBOL (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3264 if (face_numeric_slant (value) < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3265 signal_error ("Invalid face slant", value);
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 old_value = LFACE_SLANT (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3268 LFACE_SLANT (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3269 font_related_attr_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3270 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3271 else if (EQ (attr, QCunderline))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3272 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3273 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3274 if ((SYMBOLP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3275 && !EQ (value, Qt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3276 && !EQ (value, Qnil))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3277 /* Underline color. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3278 || (STRINGP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3279 && XSTRING (value)->size == 0))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3280 signal_error ("Invalid face underline", value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3281
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3282 old_value = LFACE_UNDERLINE (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3283 LFACE_UNDERLINE (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3284 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3285 else if (EQ (attr, QCoverline))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3286 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3287 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3288 if ((SYMBOLP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3289 && !EQ (value, Qt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3290 && !EQ (value, Qnil))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3291 /* Overline color. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3292 || (STRINGP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3293 && XSTRING (value)->size == 0))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3294 signal_error ("Invalid face overline", value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3295
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3296 old_value = LFACE_OVERLINE (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3297 LFACE_OVERLINE (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3298 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3299 else if (EQ (attr, QCstrike_through))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3300 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3301 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3302 if ((SYMBOLP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3303 && !EQ (value, Qt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3304 && !EQ (value, Qnil))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3305 /* Strike-through color. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3306 || (STRINGP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3307 && XSTRING (value)->size == 0))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3308 signal_error ("Invalid face strike-through", value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3309
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3310 old_value = LFACE_STRIKE_THROUGH (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3311 LFACE_STRIKE_THROUGH (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3312 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3313 else if (EQ (attr, QCbox))
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 int valid_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3316
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3317 /* 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
3318 of the face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3319 if (EQ (value, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3320 value = make_number (1);
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 if (UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3323 valid_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3324 else if (NILP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3325 valid_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3326 else if (INTEGERP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3327 valid_p = XINT (value) > 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3328 else if (STRINGP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3329 valid_p = XSTRING (value)->size > 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3330 else if (CONSP (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 Lisp_Object tem;
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 tem = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3335 while (CONSP (tem))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3336 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3337 Lisp_Object k, v;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3338
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3339 k = XCAR (tem);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3340 tem = XCDR (tem);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3341 if (!CONSP (tem))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3342 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3343 v = XCAR (tem);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3344 tem = XCDR (tem);
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 if (EQ (k, QCline_width))
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 (!INTEGERP (v) || XINT (v) <= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3349 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3350 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3351 else if (EQ (k, QCcolor))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3352 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3353 if (!STRINGP (v) || XSTRING (v)->size == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3354 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3355 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3356 else if (EQ (k, QCstyle))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3357 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3358 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
3359 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3360 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3361 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3362 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3363 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3364
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3365 valid_p = NILP (tem);
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3368 valid_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3369
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3370 if (!valid_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3371 signal_error ("Invalid face box", value);
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 old_value = LFACE_BOX (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3374 LFACE_BOX (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3375 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3376 else if (EQ (attr, QCinverse_video)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3377 || EQ (attr, QCreverse_video))
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 (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3380 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3381 CHECK_SYMBOL (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3382 if (!EQ (value, Qt) && !NILP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3383 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
3384 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3385 old_value = LFACE_INVERSE (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3386 LFACE_INVERSE (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3387 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3388 else if (EQ (attr, QCforeground))
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 if (!UNSPECIFIEDP (value))
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 /* 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
3393 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
3394 when the face is realized. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3395 CHECK_STRING (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3396 if (XSTRING (value)->size == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3397 signal_error ("Empty foreground color value", value);
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 old_value = LFACE_FOREGROUND (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3400 LFACE_FOREGROUND (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3401 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3402 else if (EQ (attr, QCbackground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3403 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3404 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3405 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3406 /* 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
3407 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
3408 when the face is realized. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3409 CHECK_STRING (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3410 if (XSTRING (value)->size == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3411 signal_error ("Empty background color value", value);
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 old_value = LFACE_BACKGROUND (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3414 LFACE_BACKGROUND (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3415 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3416 else if (EQ (attr, QCstipple))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3417 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3418 #ifdef HAVE_X_WINDOWS
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3419 if (!UNSPECIFIEDP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3420 && !NILP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3421 && NILP (Fbitmap_spec_p (value)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3422 signal_error ("Invalid stipple attribute", value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3423 old_value = LFACE_STIPPLE (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3424 LFACE_STIPPLE (lface) = value;
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3425 #endif /* HAVE_X_WINDOWS */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3426 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3427 else if (EQ (attr, QCwidth))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3428 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3429 if (!UNSPECIFIEDP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3430 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3431 CHECK_SYMBOL (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3432 if (face_numeric_swidth (value) < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3433 signal_error ("Invalid face width", value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3434 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3435 old_value = LFACE_SWIDTH (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3436 LFACE_SWIDTH (lface) = value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3437 font_related_attr_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3438 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3439 else if (EQ (attr, QCfont))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3440 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3441 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3442 /* 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
3443 XLFD font name. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3444 struct frame *f;
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 CHECK_STRING (value, 3);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3447 if (EQ (frame, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3448 f = SELECTED_FRAME ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3449 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3450 f = check_x_frame (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3451
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3452 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
3453 signal_error ("Invalid font name", value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3454
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3455 font_related_attr_p = 1;
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3456 #endif /* HAVE_WINDOW_SYSTEM */
27396
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 (attr, QCbold))
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 old_value = LFACE_WEIGHT (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3461 LFACE_WEIGHT (lface) = NILP (value) ? Qnormal : Qbold;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3462 font_related_attr_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3463 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3464 else if (EQ (attr, QCitalic))
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 old_value = LFACE_SLANT (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3467 LFACE_SLANT (lface) = NILP (value) ? Qnormal : Qitalic;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3468 font_related_attr_p = 1;
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 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3471 signal_error ("Invalid face attribute name", attr);
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 /* 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
3474 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
3475 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
3476 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
3477 init_iterator will then free realized faces. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3478 if (!EQ (frame, Qt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3479 && (EQ (attr, QCfont)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3480 || NILP (Fequal (old_value, value))))
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 ++face_change_count;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3483 ++windows_or_buffers_changed;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3484 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3485
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3486 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3487
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3488 if (!EQ (frame, Qt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3489 && !UNSPECIFIEDP (value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3490 && NILP (Fequal (old_value, value)))
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 Lisp_Object param;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3493
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3494 param = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3495
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3496 if (EQ (face, Qdefault))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3497 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3498 /* 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
3499 reflected in changed `font' frame parameters. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3500 if (font_related_attr_p
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3501 && lface_fully_specified_p (XVECTOR (lface)->contents))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3502 set_font_frame_param (frame, lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3503 else if (EQ (attr, QCforeground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3504 param = Qforeground_color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3505 else if (EQ (attr, QCbackground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3506 param = Qbackground_color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3507 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3508 #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
3509 else if (EQ (face, Qscroll_bar))
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 /* 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
3512 `scroll-bar-foreground' and `scroll-bar-background'. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3513 if (EQ (attr, QCforeground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3514 param = Qscroll_bar_foreground;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3515 else if (EQ (attr, QCbackground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3516 param = Qscroll_bar_background;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3517 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3518 #endif /* NTEMACS_TODO */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3519 else if (EQ (face, Qborder))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3520 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3521 /* Changing background color of `border' sets frame parameter
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3522 `border-color'. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3523 if (EQ (attr, QCbackground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3524 param = Qborder_color;
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 else if (EQ (face, Qcursor))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3527 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3528 /* Changing background color of `cursor' sets frame parameter
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3529 `cursor-color'. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3530 if (EQ (attr, QCbackground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3531 param = Qcursor_color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3532 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3533 else if (EQ (face, Qmouse))
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 /* Changing background color of `mouse' sets frame parameter
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3536 `mouse-color'. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3537 if (EQ (attr, QCbackground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3538 param = Qmouse_color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3539 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3540
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3541 if (SYMBOLP (param))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3542 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
3543 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3544
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3545 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3546
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3547 return face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3548 }
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
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3551 #ifdef HAVE_WINDOW_SYSTEM
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3552
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3553 /* 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
3554 attributes LFACE. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3555
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3556 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3557 set_font_frame_param (frame, lface)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3558 Lisp_Object frame, lface;
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 struct frame *f = XFRAME (frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3561 Lisp_Object frame_font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3562 int fontset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3563 char *font;
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 /* Get FRAME's font parameter. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3566 frame_font = Fassq (Qfont, f->param_alist);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3567 xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font)));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3568 frame_font = XCDR (frame_font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3569
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3570 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
3571 if (fontset >= 0)
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 /* 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
3574 that all its fonts reflect face attributes LFACE. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3575 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3576 struct fontset_info *fontset_info;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3577
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3578 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
3579
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3580 for (charset = 0; charset < MAX_CHARSET; ++charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3581 if (fontset_info->fontname[charset])
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 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
3584 fontset, charset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3585 Fset_fontset_font (frame_font, CHARSET_SYMBOL (charset),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3586 build_string (font), frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3587 xfree (font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3588 }
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 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3591 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3592 /* 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
3593 only happen in unibyte mode. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3594 font = choose_face_font (f, XVECTOR (lface)->contents,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3595 -1, Vface_default_registry);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3596 if (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3597 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3598 store_frame_param (f, Qfont, build_string (font));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3599 xfree (font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3600 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3601 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3602 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3603
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3604
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3605 /* 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
3606 has been assigned the value NEW_VALUE. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3607
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3608 void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3609 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
3610 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3611 Lisp_Object param, new_value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3612 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3613 Lisp_Object lface;
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 /* 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
3616 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
3617 face-set-after-frame-defaults. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3618 if (NILP (f->face_alist))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3619 return;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3620
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3621 if (EQ (param, Qforeground_color))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3622 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3623 lface = lface_from_face_name (f, Qdefault, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3624 LFACE_FOREGROUND (lface) = (STRINGP (new_value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3625 ? new_value : Qunspecified);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3626 realize_basic_faces (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3627 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3628 else if (EQ (param, Qbackground_color))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3629 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3630 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3631
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3632 /* Changing the background color might change the background
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3633 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
3634 frame-update-face-colors to do that. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3635 XSETFRAME (frame, f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3636 call1 (Qframe_update_face_colors, frame);
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 lface = lface_from_face_name (f, Qdefault, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3639 LFACE_BACKGROUND (lface) = (STRINGP (new_value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3640 ? new_value : Qunspecified);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3641 realize_basic_faces (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3642 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3643 if (EQ (param, Qborder_color))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3644 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3645 lface = lface_from_face_name (f, Qborder, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3646 LFACE_BACKGROUND (lface) = (STRINGP (new_value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3647 ? new_value : Qunspecified);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3648 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3649 else if (EQ (param, Qcursor_color))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3650 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3651 lface = lface_from_face_name (f, Qcursor, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3652 LFACE_BACKGROUND (lface) = (STRINGP (new_value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3653 ? new_value : Qunspecified);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3654 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3655 else if (EQ (param, Qmouse_color))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3656 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3657 lface = lface_from_face_name (f, Qmouse, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3658 LFACE_BACKGROUND (lface) = (STRINGP (new_value)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3659 ? new_value : Qunspecified);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3660 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3661 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3662
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3663
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3664 /* 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
3665 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
3666 doesn't take a frame argument. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3667
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3668 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
3669 Sinternal_face_x_get_resource, 3, 3, 0, "")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3670 (resource, class, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3671 Lisp_Object resource, class, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3672 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3673 #if 0 /* NTEMACS_TODO : W32 resources */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3674 Lisp_Object value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3675 CHECK_STRING (resource, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3676 CHECK_STRING (class, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3677 CHECK_LIVE_FRAME (frame, 2);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3678 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3679 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
3680 resource, class, Qnil, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3681 UNBLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3682 return value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3683 #endif /* NTEMACS_TODO */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3684 return Qnil;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
3685 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
3686
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3687
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3688 /* 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
3689 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
3690 "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
3691 error; if SIGNAL_P is zero, return 0. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3692
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3693 static Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3694 face_boolean_x_resource_value (value, signal_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3695 Lisp_Object value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3696 int signal_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3697 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3698 Lisp_Object result = make_number (0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3699
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3700 xassert (STRINGP (value));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3701
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3702 if (xstricmp (XSTRING (value)->data, "on") == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3703 || xstricmp (XSTRING (value)->data, "true") == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3704 result = Qt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3705 else if (xstricmp (XSTRING (value)->data, "off") == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3706 || xstricmp (XSTRING (value)->data, "false") == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3707 result = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3708 else if (xstricmp (XSTRING (value)->data, "unspecified") == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3709 result = Qunspecified;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3710 else if (signal_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3711 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
3712
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3713 return result;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3714 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3715
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3716
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3717 DEFUN ("internal-set-lisp-face-attribute-from-resource",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3718 Finternal_set_lisp_face_attribute_from_resource,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3719 Sinternal_set_lisp_face_attribute_from_resource,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3720 3, 4, 0, "")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3721 (face, attr, value, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3722 Lisp_Object face, attr, value, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3723 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3724 CHECK_SYMBOL (face, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3725 CHECK_SYMBOL (attr, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3726 CHECK_STRING (value, 2);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3727
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3728 if (xstricmp (XSTRING (value)->data, "unspecified") == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3729 value = Qunspecified;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3730 else if (EQ (attr, QCheight))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3731 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3732 value = Fstring_to_number (value, make_number (10));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3733 if (XINT (value) <= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3734 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
3735 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3736 else if (EQ (attr, QCbold) || EQ (attr, QCitalic))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3737 value = face_boolean_x_resource_value (value, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3738 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
3739 value = intern (XSTRING (value)->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3740 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
3741 value = face_boolean_x_resource_value (value, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3742 else if (EQ (attr, QCunderline)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3743 || EQ (attr, QCoverline)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3744 || EQ (attr, QCstrike_through)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3745 || EQ (attr, QCbox))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3746 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3747 Lisp_Object boolean_value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3748
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3749 /* 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
3750 VALUE does NOT specify a color. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3751 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
3752 if (SYMBOLP (boolean_value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3753 value = boolean_value;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3756 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
3757 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3758
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3759 #endif /* HAVE_WINDOW_SYSTEM */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
3760
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3761
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3762 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
3763 Sinternal_get_lisp_face_attribute,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3764 2, 3, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3765 "Return face attribute KEYWORD of face SYMBOL.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3766 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
3767 face attribute name, signal an error.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3768 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
3769 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
3770 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
3771 (symbol, keyword, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3772 Lisp_Object symbol, keyword, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3773 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3774 Lisp_Object lface, value = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3775
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3776 CHECK_SYMBOL (symbol, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3777 CHECK_SYMBOL (keyword, 1);
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 (EQ (frame, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3780 lface = lface_from_face_name (NULL, symbol, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3781 else
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 if (NILP (frame))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3784 frame = selected_frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3785 CHECK_LIVE_FRAME (frame, 2);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3786 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
3787 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3788
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3789 if (EQ (keyword, QCfamily))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3790 value = LFACE_FAMILY (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3791 else if (EQ (keyword, QCheight))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3792 value = LFACE_HEIGHT (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3793 else if (EQ (keyword, QCweight))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3794 value = LFACE_WEIGHT (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3795 else if (EQ (keyword, QCslant))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3796 value = LFACE_SLANT (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3797 else if (EQ (keyword, QCunderline))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3798 value = LFACE_UNDERLINE (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3799 else if (EQ (keyword, QCoverline))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3800 value = LFACE_OVERLINE (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3801 else if (EQ (keyword, QCstrike_through))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3802 value = LFACE_STRIKE_THROUGH (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3803 else if (EQ (keyword, QCbox))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3804 value = LFACE_BOX (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3805 else if (EQ (keyword, QCinverse_video)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3806 || EQ (keyword, QCreverse_video))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3807 value = LFACE_INVERSE (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3808 else if (EQ (keyword, QCforeground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3809 value = LFACE_FOREGROUND (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3810 else if (EQ (keyword, QCbackground))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3811 value = LFACE_BACKGROUND (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3812 else if (EQ (keyword, QCstipple))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3813 value = LFACE_STIPPLE (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3814 else if (EQ (keyword, QCwidth))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3815 value = LFACE_SWIDTH (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3816 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3817 signal_error ("Invalid face attribute name", keyword);
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 return value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3820 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3821
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3822
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3823 DEFUN ("internal-lisp-face-attribute-values",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3824 Finternal_lisp_face_attribute_values,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3825 Sinternal_lisp_face_attribute_values, 1, 1, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3826 "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
3827 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
3828 (attr)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3829 Lisp_Object attr;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3833 CHECK_SYMBOL (attr, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3834
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3835 if (EQ (attr, QCweight)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3836 || EQ (attr, QCslant)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3837 || EQ (attr, QCwidth))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3838 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3839 /* Extract permissible symbols from tables. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3840 struct table_entry *table;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3841 int i, dim;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3842
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3843 if (EQ (attr, QCweight))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3844 table = weight_table, dim = DIM (weight_table);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3845 else if (EQ (attr, QCslant))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3846 table = slant_table, dim = DIM (slant_table);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3847 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3848 table = swidth_table, dim = DIM (swidth_table);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3849
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3850 for (i = 0; i < dim; ++i)
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 Lisp_Object symbol = *table[i].symbol;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3853 Lisp_Object tail = result;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3854
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3855 while (!NILP (tail)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3856 && !EQ (XCAR (tail), symbol))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3857 tail = XCDR (tail);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3858
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3859 if (NILP (tail))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3860 result = Fcons (symbol, result);
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 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3863 else if (EQ (attr, QCunderline))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3864 result = Fcons (Qt, Fcons (Qnil, Qnil));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3865 else if (EQ (attr, QCoverline))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3866 result = Fcons (Qt, Fcons (Qnil, Qnil));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3867 else if (EQ (attr, QCstrike_through))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3868 result = Fcons (Qt, Fcons (Qnil, Qnil));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3869 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
3870 result = Fcons (Qt, Fcons (Qnil, Qnil));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3871
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3872 return result;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3873 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3876 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
3877 Sinternal_merge_in_global_face, 2, 2, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3878 "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
3879 (face, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3880 Lisp_Object face, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3881 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3882 Lisp_Object global_lface, local_lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3883 CHECK_LIVE_FRAME (frame, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3884 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
3885 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
3886 if (NILP (local_lface))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3887 local_lface = Finternal_make_lisp_face (face, frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3888 merge_face_vectors (XVECTOR (global_lface)->contents,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3889 XVECTOR (local_lface)->contents);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3890 return face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3891 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3892
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 /* 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
3895 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
3896 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
3897 done in fontset.el. */
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 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
3900 "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
3901 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
3902 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
3903 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
3904 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
3905 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
3906 (face, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3907 Lisp_Object face, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3908 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3909 if (EQ (frame, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3910 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3911 Lisp_Object result = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3912 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
3913
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3914 if (!UNSPECIFIEDP (LFACE_WEIGHT (lface))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3915 && !EQ (LFACE_WEIGHT (lface), Qnormal))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3916 result = Fcons (Qbold, result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3917
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3918 if (!NILP (LFACE_SLANT (lface))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3919 && !EQ (LFACE_SLANT (lface), Qnormal))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3920 result = Fcons (Qitalic, result);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3921
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3922 return result;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3923 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3924 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3925 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3926 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
3927 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
3928 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
3929 return build_string (face->font_name);
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 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3932
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3933
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3934 /* 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
3935 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
3936 is called quite often. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3937
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3938 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3939 lface_equal_p (v1, v2)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3940 Lisp_Object *v1, *v2;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3941 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3942 int i, equal_p = 1;
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 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
3945 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3946 Lisp_Object a = v1[i];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3947 Lisp_Object b = v2[i];
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 /* 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
3950 and the other is specified. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3951 equal_p = XTYPE (a) == XTYPE (b);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3952 if (!equal_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3953 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3954
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3955 if (!EQ (a, b))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3956 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3957 switch (XTYPE (a))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3958 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3959 case Lisp_String:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3960 equal_p = (XSTRING (a)->size == XSTRING (b)->size
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3961 && bcmp (XSTRING (a)->data, XSTRING (b)->data,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3962 XSTRING (a)->size) == 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3963 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3964
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3965 case Lisp_Int:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3966 case Lisp_Symbol:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3967 equal_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3968 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3969
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3970 default:
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3971 equal_p = !NILP (Fequal (a, b));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3972 break;
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 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3975 }
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 return equal_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3978 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3979
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 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
3982 Sinternal_lisp_face_equal_p, 2, 3, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3983 "True if FACE1 and FACE2 are equal.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3984 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
3985 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
3986 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
3987 (face1, face2, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3988 Lisp_Object face1, face2, frame;
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 int equal_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3991 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3992 Lisp_Object lface1, lface2;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3993
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3994 if (EQ (frame, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3995 f = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3996 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
3997 /* 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
3998 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
3999 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
4000 Emacs. That frame is not a GUI frame. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4001 f = frame_or_selected_frame (frame, 2);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4002
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4003 lface1 = lface_from_face_name (NULL, face1, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4004 lface2 = lface_from_face_name (NULL, face2, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4005 equal_p = lface_equal_p (XVECTOR (lface1)->contents,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4006 XVECTOR (lface2)->contents);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4007 return equal_p ? Qt : Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4008 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4009
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 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
4012 Sinternal_lisp_face_empty_p, 1, 2, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4013 "True if FACE has no attribute specified.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4014 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
4015 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
4016 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
4017 (face, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4018 Lisp_Object face, frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4019 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4020 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4021 Lisp_Object lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4022 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4023
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4024 if (NILP (frame))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4025 frame = selected_frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4026 CHECK_LIVE_FRAME (frame, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4027 f = XFRAME (frame);
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 if (EQ (frame, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4030 lface = lface_from_face_name (NULL, face, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4031 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4032 lface = lface_from_face_name (f, face, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4033
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4034 for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4035 if (!UNSPECIFIEDP (XVECTOR (lface)->contents[i]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4036 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4037
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4038 return i == LFACE_VECTOR_SIZE ? Qt : Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4039 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4042 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
4043 0, 1, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4044 "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
4045 For internal use only.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4046 (frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4047 Lisp_Object frame;
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 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
4050 return f->face_alist;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4051 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4054 /* 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
4055 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
4056
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4057 static INLINE unsigned
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4058 hash_string_case_insensitive (string)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4059 Lisp_Object string;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4060 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4061 unsigned char *s;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4062 unsigned hash = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4063 xassert (STRINGP (string));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4064 for (s = XSTRING (string)->data; *s; ++s)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4065 hash = (hash << 1) ^ tolower (*s);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4066 return hash;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4069
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4070 /* 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
4071
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4072 static INLINE unsigned
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4073 lface_hash (v)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4074 Lisp_Object *v;
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 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
4077 ^ hash_string_case_insensitive (v[LFACE_FOREGROUND_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4078 ^ hash_string_case_insensitive (v[LFACE_BACKGROUND_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4079 ^ (unsigned) v[LFACE_WEIGHT_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4080 ^ (unsigned) v[LFACE_SLANT_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4081 ^ (unsigned) v[LFACE_SWIDTH_INDEX]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4082 ^ XFASTINT (v[LFACE_HEIGHT_INDEX]));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4083 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4084
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 /* 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
4087 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
4088 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
4089 LFACE2 must be fully-specified. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4090
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4091 static INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4092 lface_same_font_attributes_p (lface1, lface2)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4093 Lisp_Object *lface1, *lface2;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4094 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4095 xassert (lface_fully_specified_p (lface1)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4096 && lface_fully_specified_p (lface2));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4097 return (xstricmp (XSTRING (lface1[LFACE_FAMILY_INDEX])->data,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4098 XSTRING (lface2[LFACE_FAMILY_INDEX])->data) == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4099 && (XFASTINT (lface1[LFACE_HEIGHT_INDEX])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4100 == XFASTINT (lface2[LFACE_HEIGHT_INDEX]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4101 && 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
4102 && 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
4103 && 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
4104 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4107
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4108 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4109 Realized Faces
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4110 ***********************************************************************/
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 /* 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
4113 vector ATTR, charset CHARSET, and registry REGISTRY. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4114
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4115 static struct face *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4116 make_realized_face (attr, charset, registry)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4117 Lisp_Object *attr;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4118 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4119 Lisp_Object registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4120 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4121 struct face *face = (struct face *) xmalloc (sizeof *face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4122 bzero (face, sizeof *face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4123 face->charset = charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4124 face->registry = registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4125 bcopy (attr, face->lface, sizeof face->lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4126 return face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4127 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4128
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 /* 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
4131 be null. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4132
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4133 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4134 free_realized_face (f, face)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4135 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4136 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4137 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4138 if (face)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4139 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4140 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4141 if (FRAME_WINDOW_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4142 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4143 if (face->gc)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4144 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4145 x_free_gc (f, face->gc);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4146 face->gc = 0;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4149 free_face_colors (f, face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4150 x_destroy_bitmap (f, face->stipple);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4151 }
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4152 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4153
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4154 xfree (face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4155 }
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
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 /* 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
4160 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
4161 by clearing the face cache. */
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 void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4164 prepare_face_for_display (f, face)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4165 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4166 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4167 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4168 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4169 xassert (FRAME_WINDOW_P (f));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4170
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4171 if (face->gc == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4172 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4173 XGCValues xgcv;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4174 unsigned long mask = GCForeground | GCBackground;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4175
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4176 xgcv.foreground = face->foreground;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4177 xgcv.background = face->background;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4178
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4179 /* 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
4180 if (face->font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4181 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4182 xgcv.font = face->font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4183 mask |= GCFont;
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 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4187 if (face->stipple)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4188 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4189 #if 0 /* NTEMACS_TODO: XGCValues not fully simulated */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4190 xgcv.fill_style = FillOpaqueStippled;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4191 xgcv.stipple = x_bitmap_pixmap (f, face->stipple);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4192 mask |= GCFillStyle | GCStipple;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4193 #endif /* NTEMACS_TODO */
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4196 face->gc = x_create_gc (f, mask, &xgcv);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4197 UNBLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4198 }
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4199 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4200 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4201
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 /* 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
4204 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
4205 ISO8859-1 if the ASCII face suffices. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4206
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4207 int
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4208 face_suitable_for_iso8859_1_p (face)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4209 struct face *face;
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 int len = strlen (face->font_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4212 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
4213 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4214
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 /* 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
4217 of CHARSET. CHARSET < 0 means unibyte text. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4218
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4219 INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4220 face_suitable_for_charset_p (face, charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4221 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4222 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4223 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4224 int suitable_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4225
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4226 if (charset < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4227 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4228 if (EQ (face->registry, Vface_default_registry)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4229 || !NILP (Fequal (face->registry, Vface_default_registry)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4230 suitable_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4231 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4232 else if (face->charset == charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4233 suitable_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4234 else if (face->charset == CHARSET_ASCII
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4235 && charset == charset_latin_iso8859_1)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4236 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
4237 else if (face->charset == charset_latin_iso8859_1
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4238 && charset == CHARSET_ASCII)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4239 suitable_p = 1;
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 return suitable_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4242 }
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 Face Cache
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4248 ***********************************************************************/
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4249
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4250 /* Return a new face cache for frame F. */
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 static struct face_cache *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4253 make_face_cache (f)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4254 struct frame *f;
27396
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 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4257 int size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4258
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4259 c = (struct face_cache *) xmalloc (sizeof *c);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4260 bzero (c, sizeof *c);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4261 size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4262 c->buckets = (struct face **) xmalloc (size);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4263 bzero (c->buckets, size);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4264 c->size = 50;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4265 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
4266 c->f = f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4267 return c;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4270
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4271 /* 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
4272 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
4273 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
4274
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4275 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4276 clear_face_gcs (c)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4277 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4278 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4279 if (c && FRAME_WINDOW_P (c->f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4280 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4281 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4282 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4283 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
4284 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4285 struct face *face = c->faces_by_id[i];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4286 if (face && face->gc)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4287 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4288 x_free_gc (c->f, face->gc);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4289 face->gc = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4290 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4291 }
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4292 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4293 }
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
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 /* 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
4298 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
4299 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
4300 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
4301
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4302 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4303 free_realized_faces (c)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4304 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4305 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4306 if (c && c->used)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4307 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4308 int i, size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4309 struct frame *f = c->f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4310
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4311 for (i = 0; i < c->used; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4312 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4313 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
4314 c->faces_by_id[i] = NULL;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4317 c->used = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4318 size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4319 bzero (c->buckets, size);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4320
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4321 /* 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
4322 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
4323 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
4324 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
4325 if (WINDOWP (f->root_window))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4326 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4327 clear_current_matrices (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4328 ++windows_or_buffers_changed;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4329 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4330 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4333
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4334 /* 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
4335 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
4336 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
4337
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4338 void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4339 free_all_realized_faces (frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4340 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4341 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4342 if (NILP (frame))
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 Lisp_Object rest;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4345 FOR_EACH_FRAME (rest, frame)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4346 free_realized_faces (FRAME_FACE_CACHE (XFRAME (frame)));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4347 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4348 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4349 free_realized_faces (FRAME_FACE_CACHE (XFRAME (frame)));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4350 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4353 /* 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
4354
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4355 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4356 free_face_cache (c)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4357 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4358 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4359 if (c)
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 free_realized_faces (c);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4362 xfree (c->buckets);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4363 xfree (c->faces_by_id);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4364 xfree (c);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4365 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4366 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4367
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 /* 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
4370 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
4371 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
4372 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
4373 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
4374
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4375 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4376 cache_face (c, face, hash)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4377 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4378 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4379 unsigned hash;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4380 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4381 int i = hash % FACE_CACHE_BUCKETS_SIZE;
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 face->hash = hash;
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 if (face->fontset >= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4386 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4387 struct face *last = c->buckets[i];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4388 if (last)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4389 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4390 while (last->next)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4391 last = last->next;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4392 last->next = face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4393 face->prev = last;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4394 face->next = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4395 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4396 else
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 c->buckets[i] = face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4399 face->prev = face->next = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4400 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4401 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4402 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4403 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4404 face->prev = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4405 face->next = c->buckets[i];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4406 if (face->next)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4407 face->next->prev = face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4408 c->buckets[i] = face;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4411 /* 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
4412 slot as FACE->id. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4413 for (i = 0; i < c->used; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4414 if (c->faces_by_id[i] == NULL)
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 face->id = i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4417
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4418 /* Maybe enlarge C->faces_by_id. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4419 if (i == c->used && c->used == c->size)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4420 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4421 int new_size = 2 * c->size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4422 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
4423 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
4424 c->size = new_size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4425 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4426
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4427 #if GLYPH_DEBUG
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4428 /* Check that FACE got a unique id. */
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 int j, n;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4431 struct face *face;
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 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
4434 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
4435 if (face->id == i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4436 ++n;
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 xassert (n == 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4439 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4440 #endif /* GLYPH_DEBUG */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4441
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4442 c->faces_by_id[i] = face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4443 if (i == c->used)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4444 ++c->used;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4445 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4446
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 /* Remove face FACE from cache C. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4449
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4450 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4451 uncache_face (c, face)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4452 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4453 struct face *face;
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 int i = face->hash % FACE_CACHE_BUCKETS_SIZE;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4456
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4457 if (face->prev)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4458 face->prev->next = face->next;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4459 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4460 c->buckets[i] = face->next;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4461
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4462 if (face->next)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4463 face->next->prev = face->prev;
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 c->faces_by_id[face->id] = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4466 if (face->id == c->used)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4467 --c->used;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4468 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4471 /* 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
4472 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
4473 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
4474 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
4475 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
4476 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
4477
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4478 INLINE int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4479 lookup_face (f, attr, charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4480 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4481 Lisp_Object *attr;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4482 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4483 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4484 struct face_cache *c = FRAME_FACE_CACHE (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4485 unsigned hash;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4486 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4487 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4488
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4489 xassert (c != NULL);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4490 check_lface_attrs (attr);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4491
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4492 /* Look up ATTR in the face cache. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4493 hash = lface_hash (attr);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4494 i = hash % FACE_CACHE_BUCKETS_SIZE;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4495
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4496 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
4497 if (face->hash == hash
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4498 && (!FRAME_WINDOW_P (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4499 || FACE_SUITABLE_FOR_CHARSET_P (face, charset))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4500 && lface_equal_p (face->lface, attr))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4501 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4502
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4503 /* If not found, realize a new face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4504 if (face == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4505 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4506 face = realize_face (c, attr, charset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4507 cache_face (c, face, hash);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4508 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4509
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4510 #if GLYPH_DEBUG
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4511 xassert (face == FACE_FROM_ID (f, face->id));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4512 if (FRAME_WINDOW_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4513 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
4514 #endif /* GLYPH_DEBUG */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4515
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4516 return 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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4519
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4520 /* 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
4521 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
4522 0 means unibyte text. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4523
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4524 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4525 lookup_named_face (f, symbol, charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4526 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4527 Lisp_Object symbol;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4528 int charset;
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 Lisp_Object attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4531 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4532 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
4533
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4534 get_lface_attributes (f, symbol, symbol_attrs, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4535 bcopy (default_face->lface, attrs, sizeof attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4536 merge_face_vectors (symbol_attrs, attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4537 return lookup_face (f, attrs, charset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4538 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4539
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4540
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4541 /* 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
4542 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
4543
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4544 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4545 ascii_face_of_lisp_face (f, lface_id)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4546 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4547 int lface_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4548 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4549 int face_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4550
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4551 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
4552 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4553 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
4554 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
4555 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4556 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4557 face_id = -1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4558
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4559 return face_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4560 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4561
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 /* 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
4564 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
4565 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
4566
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4567 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4568 smaller_face (f, face_id, steps)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4569 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4570 int face_id, steps;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4571 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4572 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4573 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4574 Lisp_Object attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4575 int pt, last_pt, last_height;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4576 int delta;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4577 int new_face_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4578 struct face *new_face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4579
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4580 /* 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
4581 if (FRAME_TERMCAP_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4582 return face_id;
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 /* Try in increments of 1/2 pt. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4585 delta = steps < 0 ? 5 : -5;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4586 steps = abs (steps);
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 face = FACE_FROM_ID (f, face_id);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4589 bcopy (face->lface, attrs, sizeof attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4590 pt = last_pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4591 new_face_id = face_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4592 last_height = FONT_HEIGHT (face->font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4593
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4594 while (steps
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4595 && pt + delta > 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4596 /* 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
4597 && abs (last_pt - pt) < 100)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4598 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4599 /* 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
4600 pt += delta;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4601 attrs[LFACE_HEIGHT_INDEX] = make_number (pt);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4602 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
4603 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
4604
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4605 /* If height changes, count that as one step. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4606 if (FONT_HEIGHT (new_face->font) != last_height)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4607 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4608 --steps;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4609 last_height = FONT_HEIGHT (new_face->font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4610 last_pt = pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4611 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4612 }
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 return new_face_id;
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4615
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4616 #else /* not HAVE_WINDOW_SYSTEM */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4617
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4618 return face_id;
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4619
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4620 #endif /* not HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4621 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4622
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4623
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4624 /* 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
4625 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
4626
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4627 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4628 face_with_height (f, face_id, height)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4629 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4630 int face_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4631 int height;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4632 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4633 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4634 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4635 Lisp_Object attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4636
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4637 if (FRAME_TERMCAP_P (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4638 || height <= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4639 return face_id;
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 face = FACE_FROM_ID (f, face_id);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4642 bcopy (face->lface, attrs, sizeof attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4643 attrs[LFACE_HEIGHT_INDEX] = make_number (height);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4644 face_id = lookup_face (f, attrs, CHARSET_ASCII);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4645 #endif /* HAVE_WINDOW_SYSTEM */
27396
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 face_id;
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 /* 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
4651 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
4652 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
4653 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
4654 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
4655 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
4656 be already realized. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4657
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4658 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4659 lookup_derived_face (f, symbol, charset, face_id)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4660 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4661 Lisp_Object symbol;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4662 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4663 int face_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4664 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4665 Lisp_Object attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4666 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4667 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
4668
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4669 if (!default_face)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4670 abort ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4671
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4672 get_lface_attributes (f, symbol, symbol_attrs, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4673 bcopy (default_face->lface, attrs, sizeof attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4674 merge_face_vectors (symbol_attrs, attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4675 return lookup_face (f, attrs, charset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4676 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4677
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4680 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4681 Font selection
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4682 ***********************************************************************/
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 DEFUN ("internal-set-font-selection-order",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4685 Finternal_set_font_selection_order,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4686 Sinternal_set_font_selection_order, 1, 1, 0,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4687 "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
4688 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
4689 `:height', `:weight', and `:slant'. Face attributes appearing\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4690 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
4691 `: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
4692 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
4693 Value is ORDER.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4694 (order)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4695 Lisp_Object order;
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 Lisp_Object list;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4698 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4699 int indices[4];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4700
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4701 CHECK_LIST (order, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4702 bzero (indices, sizeof indices);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4703 i = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4704
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4705 for (list = order;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4706 CONSP (list) && i < DIM (indices);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4707 list = XCDR (list), ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4708 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4709 Lisp_Object attr = XCAR (list);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4710 int xlfd;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4711
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4712 if (EQ (attr, QCwidth))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4713 xlfd = XLFD_SWIDTH;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4714 else if (EQ (attr, QCheight))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4715 xlfd = XLFD_POINT_SIZE;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4716 else if (EQ (attr, QCweight))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4717 xlfd = XLFD_WEIGHT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4718 else if (EQ (attr, QCslant))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4719 xlfd = XLFD_SLANT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4720 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4721 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4722
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4723 if (indices[i] != 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4724 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4725 indices[i] = xlfd;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4726 }
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 if (!NILP (list)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4729 || i != DIM (indices)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4730 || indices[0] == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4731 || indices[1] == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4732 || indices[2] == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4733 || indices[3] == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4734 signal_error ("Invalid font sort order", order);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4735
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4736 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
4737 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4738 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
4739 free_all_realized_faces (Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4740 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4741
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4742 return Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4743 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4744
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4745
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4746 DEFUN ("internal-set-alternative-font-family-alist",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4747 Finternal_set_alternative_font_family_alist,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4748 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
4749 "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
4750 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
4751 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
4752 be found. Value is ALIST.")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4753 (alist)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4754 Lisp_Object alist;
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 CHECK_LIST (alist, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4757 Vface_alternative_font_family_alist = alist;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4758 free_all_realized_faces (Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4759 return alist;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4760 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4761
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4762
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4763 #ifdef HAVE_WINDOW_SYSTEM
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
4764
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4765 /* 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
4766 Value is nil if not successful. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4767
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4768 static Lisp_Object
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4769 deduce_unibyte_registry (f, font_name)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4770 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4771 char *font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4772 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4773 struct font_name font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4774 Lisp_Object registry = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4775
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4776 font.name = STRDUPA (font_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4777 if (split_font_name (f, &font, 0))
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 char *buffer;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4780
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4781 /* Extract registry and encoding. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4782 buffer = (char *) alloca (strlen (font.fields[XLFD_REGISTRY])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4783 + strlen (font.fields[XLFD_ENCODING])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4784 + 10);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4785 strcpy (buffer, font.fields[XLFD_REGISTRY]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4786 strcat (buffer, "-");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4787 strcat (buffer, font.fields[XLFD_ENCODING]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4788 registry = build_string (buffer);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4789 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4790
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4791 return registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4792 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4795 /* 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
4796 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
4797 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
4798 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
4799 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
4800 slightly broken for backward compatibility with previous broken
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4801 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
4802
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4803 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4804 font_scalable_p (font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4805 struct font_name *font;
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 char *s = font->fields[XLFD_AVGWIDTH];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4808 return (*s == '0' && *(s + 1) == '\0') || *s == '*';
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4809 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4810
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4811
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4812 /* 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
4813 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
4814 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
4815 sizes. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4816
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4817 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4818 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
4819 int *values;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4820 struct font_name *font1, *font2;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4821 int compare_pt_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4822 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4823 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4824
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4825 for (i = 0; i < 4; ++i)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
4826 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4827 int xlfd_idx = font_sort_order[i];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4828
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4829 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
4830 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4831 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
4832 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
4833
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4834 if (delta1 > delta2)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4835 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4836 else if (delta1 < delta2)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4837 return 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4838 else
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 /* 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
4841 specifies `italic' but we have only `regular' and
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4842 `oblique'. Prefer `oblique' in this case. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4843 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
4844 && font1->numeric[xlfd_idx] > values[i]
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4845 && font2->numeric[xlfd_idx] < values[i])
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4846 return 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4847 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4848 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4851 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4852 }
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4855 #if SCALABLE_FONTS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4856
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4857 /* 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
4858 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
4859 sort order. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4860
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4861 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4862 exact_face_match_p (specified, font)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4863 int *specified;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4864 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4865 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4866 int i;
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 for (i = 0; i < 4; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4869 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
4870 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4871
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4872 return i == 4;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4873 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4874
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 /* 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
4877 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
4878 Value is allocated from heap. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4879
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4880 static char *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4881 build_scalable_font_name (f, font, specified_pt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4882 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4883 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4884 int specified_pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4885 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4886 char point_size[20], pixel_size[20];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4887 int pixel_value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4888 double resy = FRAME_W32_DISPLAY_INFO (f)->resy;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4889 double pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4890
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4891 /* 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
4892 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
4893 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
4894 if (font->numeric[XLFD_RESY] != 0)
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 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
4897 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
4898 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4899 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4900 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4901 pt = specified_pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4902 pixel_value = resy / 720.0 * pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4903 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4904
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4905 /* Set point size of the font. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4906 sprintf (point_size, "%d", (int) pt);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4907 font->fields[XLFD_POINT_SIZE] = point_size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4908 font->numeric[XLFD_POINT_SIZE] = pt;
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 /* Set pixel size. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4911 sprintf (pixel_size, "%d", pixel_value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4912 font->fields[XLFD_PIXEL_SIZE] = pixel_size;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4913 font->numeric[XLFD_PIXEL_SIZE] = pixel_value;
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 /* 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
4916 resolution of the display. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4917 if (font->numeric[XLFD_RESY] == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4918 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4919 char buffer[20];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4920 sprintf (buffer, "%d", (int) resy);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4921 font->fields[XLFD_RESY] = buffer;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4922 font->numeric[XLFD_RESY] = resy;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4923 }
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 if (strcmp (font->fields[XLFD_RESX], "0") == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4926 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4927 char buffer[20];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4928 int resx = FRAME_W32_DISPLAY_INFO (f)->resx;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4929 sprintf (buffer, "%d", resx);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4930 font->fields[XLFD_RESX] = buffer;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4931 font->numeric[XLFD_RESX] = resx;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4932 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4933
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4934 return build_font_name (font);
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4938 /* 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
4939 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
4940 with input blocked. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4941
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4942 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4943 may_use_scalable_font_p (font, name)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4944 struct font_name *font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4945 char *name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4946 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4947 if (EQ (Vscalable_fonts_allowed, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4948 return 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4949 else if (CONSP (Vscalable_fonts_allowed))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4950 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4951 Lisp_Object tail, regexp;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4952
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4953 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
4954 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4955 regexp = XCAR (tail);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4956 if (STRINGP (regexp)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4957 && 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
4958 return 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4959 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4960 }
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 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4963 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4964
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4965 #endif /* SCALABLE_FONTS != 0 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4966
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4967
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4968 /* 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
4969 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
4970 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
4971 the heap. FONTS is freed by this function. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4972
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4973 static char *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4974 best_matching_font (f, attrs, fonts, nfonts)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4975 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4976 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4977 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4978 int nfonts;
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 char *font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4981 struct font_name *best;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4982 int i, pt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4983 int specified[4];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4984 int exact_p;
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 if (nfonts == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4987 return NULL;
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 /* Make specified font attributes available in `specified',
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4990 indexed by sort order. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4991 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
4992 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4993 int xlfd_idx = font_sort_order[i];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4994
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4995 if (xlfd_idx == XLFD_SWIDTH)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4996 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
4997 else if (xlfd_idx == XLFD_POINT_SIZE)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4998 specified[i] = pt = XFASTINT (attrs[LFACE_HEIGHT_INDEX]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
4999 else if (xlfd_idx == XLFD_WEIGHT)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5000 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
5001 else if (xlfd_idx == XLFD_SLANT)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5002 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
5003 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5004 abort ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5005 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5006
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5007 #if SCALABLE_FONTS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5008
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5009 /* Set to 1 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5010 exact_p = 0;
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 /* 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
5013 for (i = 0; i < nfonts; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5014 if (!font_scalable_p (fonts + i))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5015 break;
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 /* 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
5018 if (i < nfonts)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5019 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5020 best = fonts + i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5021
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5022 for (i = 1; i < nfonts; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5023 if (!font_scalable_p (fonts + i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5024 && better_font_p (specified, fonts + i, best, 1))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5025 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5026 best = fonts + i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5027
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5028 exact_p = exact_face_match_p (specified, best);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5029 if (exact_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5030 break;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5033 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5034 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5035 best = NULL;
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 /* 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
5038 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
5039 if (!exact_p)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5040 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5041 /* A scalable font is better if
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5042
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5043 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
5044
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5045 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
5046 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
5047 isn't worse. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5048
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5049 int non_scalable_has_exact_height_p;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5050
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5051 if (best && best->numeric[XLFD_POINT_SIZE] == pt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5052 non_scalable_has_exact_height_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5053 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5054 non_scalable_has_exact_height_p = 0;
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 for (i = 0; i < nfonts; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5057 if (font_scalable_p (fonts + i))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5058 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5059 if (best == NULL
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5060 || better_font_p (specified, fonts + i, best, 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5061 || (!non_scalable_has_exact_height_p
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5062 && !better_font_p (specified, best, fonts + i, 0)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5063 best = fonts + i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5064 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5065 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5066
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5067 if (font_scalable_p (best))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5068 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
5069 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5070 font_name = build_font_name (best);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5071
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5072 #else /* !SCALABLE_FONTS */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5073
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5074 /* Find the best non-scalable font. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5075 best = fonts;
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 for (i = 1; i < nfonts; ++i)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5078 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5079 xassert (!font_scalable_p (fonts + i));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5080 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
5081 best = fonts + i;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5084 font_name = build_font_name (best);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5085
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5086 #endif /* !SCALABLE_FONTS */
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 /* Free font_name structures. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5089 free_font_names (fonts, nfonts);
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 return font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5092 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5093
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5094
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5095 /* 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
5096 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
5097 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
5098 of fonts found. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5099
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5100 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5101 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
5102 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5103 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5104 char *pattern, *family, *registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5105 struct font_name **fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5106 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5107 int nfonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5108
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5109 if (family == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5110 family = LSTRDUPA (attrs[LFACE_FAMILY_INDEX]);
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 nfonts = font_list (f, pattern, family, registry, fonts);
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 if (nfonts == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5115 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5116 Lisp_Object alter;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5117
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5118 /* Try alternative font families from
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5119 Vface_alternative_font_family_alist. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5120 alter = Fassoc (build_string (family),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5121 Vface_alternative_font_family_alist);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5122 if (CONSP (alter))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5123 for (alter = XCDR (alter);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5124 CONSP (alter) && nfonts == 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5125 alter = XCDR (alter))
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 if (STRINGP (XCAR (alter)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5128 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5129 family = LSTRDUPA (XCAR (alter));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5130 nfonts = font_list (f, NULL, family, registry, fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5131 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5132 }
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 /* 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
5135 if (nfonts == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5136 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5137 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
5138 if (dflt)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5139 family = LSTRDUPA (dflt->lface[LFACE_FAMILY_INDEX]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5140 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5141 family = "fixed";
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5142 nfonts = font_list (f, NULL, family, registry, fonts);
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 /* Try any family with the given registry. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5146 if (nfonts == 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5147 nfonts = font_list (f, NULL, "*", registry, fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5148 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5149
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5150 return nfonts;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5151 }
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5152
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5153
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5154 /* 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
5155 should match. Value is allocated from the heap. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5156
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5157 char *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5158 x_charset_registry (charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5159 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5160 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5161 Lisp_Object prop, charset_plist;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5162 char *registry;
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 /* 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
5165 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
5166 prop = Fplist_get (charset_plist, Qx_charset_registry);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5167
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5168 if (STRINGP (prop))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5169 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5170 if (index (XSTRING (prop)->data, '-'))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5171 registry = xstrdup (XSTRING (prop)->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5172 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5173 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5174 /* 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
5175 registry = (char *) xmalloc (STRING_BYTES (XSTRING (prop)) + 5);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5176 strcpy (registry, XSTRING (prop)->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5177 strcat (registry, "*-*");
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 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5180 else if (STRINGP (Vface_default_registry))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5181 registry = xstrdup (XSTRING (Vface_default_registry)->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5182 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5183 registry = xstrdup ("iso8859-1");
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 return registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5186 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5187
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 /* 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
5190 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
5191 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
5192
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5193 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5194 face_fontset (f, attrs)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5195 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5196 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5197 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5198 Lisp_Object name = attrs[LFACE_FAMILY_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5199 int fontset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5200
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5201 name = Fquery_fontset (name, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5202 if (NILP (name))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5203 fontset = -1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5204 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5205 fontset = fs_query_fontset (f, XSTRING (name)->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5206
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5207 return fontset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5208 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5209
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5210
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5211 /* 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
5212 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
5213 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
5214 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
5215 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
5216
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5217 static char *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5218 choose_face_font (f, attrs, charset, unibyte_registry)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5219 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5220 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5221 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5222 Lisp_Object unibyte_registry;
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 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5225 int nfonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5226 char *registry;
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 /* ATTRS must be fully-specified. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5229 xassert (lface_fully_specified_p (attrs));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5230
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5231 if (STRINGP (unibyte_registry))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5232 registry = xstrdup (XSTRING (unibyte_registry)->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5233 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5234 registry = x_charset_registry (charset);
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 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
5237 xfree (registry);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5238 return best_matching_font (f, attrs, fonts, nfonts);
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5241
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5242 /* 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
5243 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
5244 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
5245 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
5246 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
5247 heap and must be freed by the caller. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5248
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5249 static char *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5250 choose_face_fontset_font (f, attrs, fontset, charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5251 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5252 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5253 int fontset, charset;
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 char *pattern;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5256 char *font_name = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5257 struct fontset_info *fontset_info;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5258 struct font_name *fonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5259 int nfonts;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5260
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5261 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
5262
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5263 /* 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
5264 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
5265 this case. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5266 if (charset < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5267 charset = CHARSET_ASCII;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5268
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5269 /* 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
5270 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
5271 pattern = fontset_info->fontname[charset];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5272 if (!pattern)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5273 pattern = fontset_info->fontname[CHARSET_ASCII];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5274 xassert (pattern);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5275
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5276 /* 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
5277 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
5278 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
5279 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
5280 return font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5281 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5282
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5283 #endif /* HAVE_WINDOW_SYSTEM */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5284
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5285
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5286
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5287 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5288 Face Realization
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5289 ***********************************************************************/
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 /* 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
5292 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
5293 face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5294
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5295 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5296 realize_basic_faces (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5297 struct frame *f;
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 int success_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5300
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5301 if (realize_default_face (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5302 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5303 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
5304 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
5305 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
5306 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
5307 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
5308 realize_named_face (f, Qborder, BORDER_FACE_ID);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5309 realize_named_face (f, Qcursor, CURSOR_FACE_ID);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5310 realize_named_face (f, Qmouse, MOUSE_FACE_ID);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5311 realize_named_face (f, Qmenu, MENU_FACE_ID);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5312 success_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5313 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5314
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5315 return success_p;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5319 /* 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
5320 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
5321 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
5322
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5323 static int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5324 realize_default_face (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5325 struct frame *f;
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 struct face_cache *c = FRAME_FACE_CACHE (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5328 Lisp_Object lface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5329 Lisp_Object attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5330 Lisp_Object unibyte_registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5331 Lisp_Object frame_font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5332 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5333 int fontset;
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 /* 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
5336 lface = lface_from_face_name (f, Qdefault, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5337 if (NILP (lface))
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 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5340 XSETFRAME (frame, f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5341 lface = Finternal_make_lisp_face (Qdefault, frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5342 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5343
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5344 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5345 if (FRAME_WINDOW_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5346 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5347 /* 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
5348 frame_font = Fassq (Qfont, f->param_alist);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5349 xassert (CONSP (frame_font) && STRINGP (XCDR (frame_font)));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5350 frame_font = XCDR (frame_font);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5351
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5352 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
5353 if (fontset >= 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5354 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5355 /* 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
5356 determining font-related attributes of the default face
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5357 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
5358 the fontset, instead. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5359 struct font_info *font_info;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5360 struct font_name font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5361
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5362 BLOCK_INPUT;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5363 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
5364 NULL, fontset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5365 UNBLOCK_INPUT;
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 /* Set weight etc. from the ASCII font. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5368 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
5369 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5370
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5371 /* Remember registry and encoding of the frame font. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5372 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
5373 if (STRINGP (unibyte_registry))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5374 Vface_default_registry = unibyte_registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5375 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5376 Vface_default_registry = build_string ("iso8859-1");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5377
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5378 /* 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
5379 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
5380 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
5381 `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
5382 equal to frame_font. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5383 xassert (STRINGP (frame_font));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5384 font.name = LSTRDUPA (frame_font);
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 if (!split_font_name (f, &font, 1)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5387 || xstricmp (font.fields[XLFD_REGISTRY], "fontset") != 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5388 || xstricmp (font.fields[XLFD_ENCODING], "startup") != 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5389 LFACE_FAMILY (lface) = frame_font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5390 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5391 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5392 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5393 /* 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
5394 attributes from that font. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5395 if (!set_lface_from_font_name (f, lface,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5396 XSTRING (frame_font)->data, 0, 0))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5397 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5398
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5399 /* Remember registry and encoding of the frame font. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5400 unibyte_registry
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5401 = deduce_unibyte_registry (f, XSTRING (frame_font)->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5402 if (STRINGP (unibyte_registry))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5403 Vface_default_registry = unibyte_registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5404 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5405 Vface_default_registry = build_string ("iso8859-1");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5406 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5407 }
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5408 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5409
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5410 if (!FRAME_WINDOW_P (f))
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 LFACE_FAMILY (lface) = build_string ("default");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5413 LFACE_SWIDTH (lface) = Qnormal;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5414 LFACE_HEIGHT (lface) = make_number (1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5415 LFACE_WEIGHT (lface) = Qnormal;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5416 LFACE_SLANT (lface) = Qnormal;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5417 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5418
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5419 if (UNSPECIFIEDP (LFACE_UNDERLINE (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5420 LFACE_UNDERLINE (lface) = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5421
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5422 if (UNSPECIFIEDP (LFACE_OVERLINE (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5423 LFACE_OVERLINE (lface) = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5424
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5425 if (UNSPECIFIEDP (LFACE_STRIKE_THROUGH (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5426 LFACE_STRIKE_THROUGH (lface) = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5427
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5428 if (UNSPECIFIEDP (LFACE_BOX (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5429 LFACE_BOX (lface) = Qnil;
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 if (UNSPECIFIEDP (LFACE_INVERSE (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5432 LFACE_INVERSE (lface) = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5433
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5434 if (UNSPECIFIEDP (LFACE_FOREGROUND (lface)))
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 /* 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
5437 set in the frame parameter list. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5438 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
5439
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5440 if (CONSP (color) && STRINGP (XCDR (color)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5441 LFACE_FOREGROUND (lface) = XCDR (color);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5442 else if (FRAME_WINDOW_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5443 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5444 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
5445 LFACE_FOREGROUND (lface) = build_string (unspecified_fg);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5446 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5447 abort ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5448 }
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 if (UNSPECIFIEDP (LFACE_BACKGROUND (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5451 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5452 /* 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
5453 set in the frame parameter list. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5454 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
5455 if (CONSP (color) && STRINGP (XCDR (color)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5456 LFACE_BACKGROUND (lface) = XCDR (color);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5457 else if (FRAME_WINDOW_P (f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5458 return 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5459 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
5460 LFACE_BACKGROUND (lface) = build_string (unspecified_bg);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5461 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5462 abort ();
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 if (UNSPECIFIEDP (LFACE_STIPPLE (lface)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5466 LFACE_STIPPLE (lface) = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5467
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5468 /* 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
5469 xassert (lface_fully_specified_p (XVECTOR (lface)->contents));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5470 check_lface (lface);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5471 bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5472 face = realize_face (c, attrs, CHARSET_ASCII);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5473
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5474 /* Remove the former default face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5475 if (c->used > DEFAULT_FACE_ID)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5476 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5477 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
5478 uncache_face (c, default_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5479 free_realized_face (f, default_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5480 }
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 /* Insert the new default face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5483 cache_face (c, face, lface_hash (attrs));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5484 xassert (face->id == DEFAULT_FACE_ID);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5485 return 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5486 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5487
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5488
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5489 /* 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
5490 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
5491 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
5492
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5493 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5494 realize_named_face (f, symbol, id)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5495 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5496 Lisp_Object symbol;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5497 int id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5498 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5499 struct face_cache *c = FRAME_FACE_CACHE (f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5500 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
5501 Lisp_Object attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5502 Lisp_Object symbol_attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5503 struct face *new_face;
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 /* 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
5506 get_lface_attributes (f, Qdefault, attrs, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5507 check_lface_attrs (attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5508 xassert (lface_fully_specified_p (attrs));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5509
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5510 /* 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
5511 if (NILP (lface))
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 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5514 XSETFRAME (frame, f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5515 lface = Finternal_make_lisp_face (symbol, frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5516 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5517
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5518 /* Merge SYMBOL's face with the default face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5519 get_lface_attributes (f, symbol, symbol_attrs, 1);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5520 merge_face_vectors (symbol_attrs, 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 /* Realize the face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5523 new_face = realize_face (c, attrs, CHARSET_ASCII);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5524
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5525 /* Remove the former face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5526 if (c->used > id)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5527 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5528 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
5529 uncache_face (c, old_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5530 free_realized_face (f, old_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5531 }
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 /* Insert the new face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5534 cache_face (c, new_face, lface_hash (attrs));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5535 xassert (new_face->id == id);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5536 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5537
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5538
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5539 /* 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
5540 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
5541 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
5542
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5543 static struct face *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5544 realize_face (c, attrs, charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5545 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5546 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5547 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5548 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5549 struct face *face;
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 /* LFACE must be fully specified. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5552 xassert (c != NULL);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5553 check_lface_attrs (attrs);
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 if (FRAME_WINDOW_P (c->f))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5556 face = realize_x_face (c, attrs, charset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5557 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
5558 face = realize_tty_face (c, attrs, charset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5559 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5560 abort ();
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5561
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5562 return face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5563 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5564
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5565
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5566 /* 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
5567 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
5568 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
5569 created realized face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5570
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5571 static struct face *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5572 realize_x_face (c, attrs, charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5573 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5574 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5575 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5576 {
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5577 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5578 struct face *face, *default_face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5579 struct frame *f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5580 Lisp_Object stipple, overline, strike_through, box;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5581 Lisp_Object unibyte_registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5582 struct gcpro gcpro1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5583
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5584 xassert (FRAME_WINDOW_P (c->f));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5585
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5586 /* 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
5587 and encoding to use from Vface_default_registry. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5588 if (charset < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5589 unibyte_registry = (STRINGP (Vface_default_registry)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5590 ? Vface_default_registry
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5591 : build_string ("iso8859-1"));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5592 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5593 unibyte_registry = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5594 GCPRO1 (unibyte_registry);
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 /* Allocate a new realized face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5597 face = make_realized_face (attrs, charset, unibyte_registry);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5598
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5599 f = c->f;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5600 /* 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
5601 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
5602 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
5603 if (default_face
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5604 && FACE_SUITABLE_FOR_CHARSET_P (default_face, charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5605 && 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
5606 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5607 face->font = default_face->font;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5608 face->fontset = default_face->fontset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5609 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
5610 face->font_name = default_face->font_name;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5611 face->registry = default_face->registry;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5612 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5613 else if (charset >= 0)
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 /* 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
5616 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
5617 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
5618 fontset determines the font name pattern, otherwise we
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5619 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
5620
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5621 char *font_name = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5622 int fontset = face_fontset (f, attrs);
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 if (fontset < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5625 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
5626 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5627 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5628 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
5629 fontset = -1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5630 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5631
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5632 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
5633 xfree (font_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5634 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5635 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5636 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5637 /* 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
5638 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
5639 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
5640 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
5641 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
5642 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
5643 encoding. */
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 char *font_name = NULL;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5646 int fontset = face_fontset (f, attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5647
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5648 if (fontset < 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5649 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
5650 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5651 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
5652
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5653 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
5654 xfree (font_name);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5655 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5656
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5657 /* Load colors, and set remaining attributes. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5658
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5659 load_face_colors (f, face, attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5660
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5661 /* Set up box. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5662 box = attrs[LFACE_BOX_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5663 if (STRINGP (box))
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 /* 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
5666 the string. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5667 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
5668 LFACE_BOX_INDEX);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5669 face->box = FACE_SIMPLE_BOX;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5670 face->box_line_width = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5671 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5672 else if (INTEGERP (box))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5673 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5674 /* 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
5675 face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5676 xassert (XINT (box) > 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5677 face->box = FACE_SIMPLE_BOX;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5678 face->box_line_width = XFASTINT (box);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5679 face->box_color = face->foreground;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5680 face->box_color_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5681 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5682 else if (CONSP (box))
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 /* `(:width WIDTH :color COLOR :shadow SHADOW)'. SHADOW
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5685 being one of `raised' or `sunken'. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5686 face->box = FACE_SIMPLE_BOX;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5687 face->box_color = face->foreground;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5688 face->box_color_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5689 face->box_line_width = 1;
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 while (CONSP (box))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5692 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5693 Lisp_Object keyword, value;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5694
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5695 keyword = XCAR (box);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5696 box = XCDR (box);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5697
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5698 if (!CONSP (box))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5699 break;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5700 value = XCAR (box);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5701 box = XCDR (box);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5702
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5703 if (EQ (keyword, QCline_width))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5704 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5705 if (INTEGERP (value) && XINT (value) > 0)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5706 face->box_line_width = XFASTINT (value);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5707 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5708 else if (EQ (keyword, QCcolor))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5709 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5710 if (STRINGP (value))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5711 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5712 face->box_color = load_color (f, face, value,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5713 LFACE_BOX_INDEX);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5714 face->use_box_color_for_shadows_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5715 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5716 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5717 else if (EQ (keyword, QCstyle))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5718 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5719 if (EQ (value, Qreleased_button))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5720 face->box = FACE_RAISED_BOX;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5721 else if (EQ (value, Qpressed_button))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5722 face->box = FACE_SUNKEN_BOX;
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 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5725 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5726
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5727 /* Text underline, overline, strike-through. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5728
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5729 if (EQ (attrs[LFACE_UNDERLINE_INDEX], Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5730 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5731 /* Use default color (same as foreground color). */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5732 face->underline_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5733 face->underline_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5734 face->underline_color = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5735 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5736 else if (STRINGP (attrs[LFACE_UNDERLINE_INDEX]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5737 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5738 /* Use specified color. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5739 face->underline_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5740 face->underline_defaulted_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5741 face->underline_color
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5742 = load_color (f, face, attrs[LFACE_UNDERLINE_INDEX],
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5743 LFACE_UNDERLINE_INDEX);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5744 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5745 else if (NILP (attrs[LFACE_UNDERLINE_INDEX]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5746 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5747 face->underline_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5748 face->underline_defaulted_p = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5749 face->underline_color = 0;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5752 overline = attrs[LFACE_OVERLINE_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5753 if (STRINGP (overline))
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 face->overline_color
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5756 = load_color (f, face, attrs[LFACE_OVERLINE_INDEX],
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5757 LFACE_OVERLINE_INDEX);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5758 face->overline_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5759 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5760 else if (EQ (overline, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5761 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5762 face->overline_color = face->foreground;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5763 face->overline_color_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5764 face->overline_p = 1;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5767 strike_through = attrs[LFACE_STRIKE_THROUGH_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5768 if (STRINGP (strike_through))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5769 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5770 face->strike_through_color
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5771 = 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
5772 LFACE_STRIKE_THROUGH_INDEX);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5773 face->strike_through_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5774 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5775 else if (EQ (strike_through, Qt))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5776 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5777 face->strike_through_color = face->foreground;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5778 face->strike_through_color_defaulted_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5779 face->strike_through_p = 1;
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
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5782 stipple = attrs[LFACE_STIPPLE_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5783 if (!NILP (stipple))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5784 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
5785
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5786 UNGCPRO;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5787 xassert (face->fontset < 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5788 xassert (FACE_SUITABLE_FOR_CHARSET_P (face, charset));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5789 return face;
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5790 #endif /* HAVE_WINDOW_SYSTEM */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5791 }
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 /* 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
5795 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
5796 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
5797 created realized face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5798
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5799 static struct face *
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5800 realize_tty_face (c, attrs, charset)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5801 struct face_cache *c;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5802 Lisp_Object *attrs;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5803 int charset;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5804 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5805 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5806 int weight, slant;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5807 Lisp_Object color;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5808 Lisp_Object tty_defined_color_alist =
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5809 Fsymbol_value (intern ("tty-defined-color-alist"));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5810 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
5811 Lisp_Object frame;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5812 int face_colors_defaulted = 0;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5813
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5814 /* Frame must be a termcap frame. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5815 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
5816
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5817 /* Allocate a new realized face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5818 face = make_realized_face (attrs, charset, Qnil);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5819 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
5820
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5821 /* 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
5822 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
5823 and because dimmed text is probably used infrequently. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5824 weight = face_numeric_weight (attrs[LFACE_WEIGHT_INDEX]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5825 slant = face_numeric_slant (attrs[LFACE_SLANT_INDEX]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5826
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5827 if (weight > XLFD_WEIGHT_MEDIUM)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5828 face->tty_bold_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5829 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
5830 face->tty_dim_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5831 if (!NILP (attrs[LFACE_UNDERLINE_INDEX]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5832 face->tty_underline_p = 1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5833 if (!NILP (attrs[LFACE_INVERSE_INDEX]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5834 face->tty_reverse_p = 1;
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 /* Map color names to color indices. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5837 face->foreground = FACE_TTY_DEFAULT_FG_COLOR;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5838 face->background = FACE_TTY_DEFAULT_BG_COLOR;
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 XSETFRAME (frame, c->f);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5841 color = attrs[LFACE_FOREGROUND_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5842 if (STRINGP (color)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5843 && XSTRING (color)->size
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5844 && !NILP (tty_defined_color_alist)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5845 && (color = Fassoc (color, call1 (tty_color_alist, frame)),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5846 CONSP (color)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5847 /* 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
5848 (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
5849 face->foreground = XINT (XCAR (XCDR (color)));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5850
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5851 if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5852 && STRINGP (attrs[LFACE_FOREGROUND_INDEX]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5853 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5854 face->foreground = load_color (c->f, face,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5855 attrs[LFACE_FOREGROUND_INDEX],
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5856 LFACE_FOREGROUND_INDEX);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5857
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5858 #if defined (MSDOS) || defined (WINDOWSNT)
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5859 /* If the foreground of the default face is the default color,
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5860 use the foreground color defined by the frame. */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5861 #ifdef MSDOS
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5862 if (FRAME_MSDOS_P (c->f))
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5863 {
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5864 #endif /* MSDOS */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5865
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5866 if (face->foreground == FACE_TTY_DEFAULT_FG_COLOR
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5867 || face->foreground == FACE_TTY_DEFAULT_COLOR)
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5868 {
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5869 face->foreground = FRAME_FOREGROUND_PIXEL (c->f);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5870 attrs[LFACE_FOREGROUND_INDEX] =
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5871 tty_color_name (c->f, face->foreground);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5872 face_colors_defaulted = 1;
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5873 }
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5874 else if (face->foreground == FACE_TTY_DEFAULT_BG_COLOR)
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5875 {
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5876 face->foreground = FRAME_BACKGROUND_PIXEL (c->f);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5877 attrs[LFACE_FOREGROUND_INDEX] =
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5878 tty_color_name (c->f, face->foreground);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5879 face_colors_defaulted = 1;
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5880 }
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5881 #ifdef MSDOS
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5882 }
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5883 #endif /* MSDOS */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5884 #endif /* MSDOS or WINDOWSNT */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5885 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5886
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5887 color = attrs[LFACE_BACKGROUND_INDEX];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5888 if (STRINGP (color)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5889 && XSTRING (color)->size
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5890 && !NILP (tty_defined_color_alist)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5891 && (color = Fassoc (color, call1 (tty_color_alist, frame)),
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5892 CONSP (color)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5893 /* 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
5894 (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
5895 face->background = XINT (XCAR (XCDR (color)));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5896
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5897 if (face->background == FACE_TTY_DEFAULT_BG_COLOR
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5898 && STRINGP (attrs[LFACE_BACKGROUND_INDEX]))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5899 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5900 face->background = load_color (c->f, face,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5901 attrs[LFACE_BACKGROUND_INDEX],
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5902 LFACE_BACKGROUND_INDEX);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5903 #if defined (MSDOS) || defined (WINDOWSNT)
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5904 /* If the background of the default face is the default color,
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5905 use the background color defined by the frame. */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5906 #ifdef MSDOS
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5907 if (FRAME_MSDOS_P (c->f))
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5908 {
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5909 #endif /* MSDOS */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5910
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5911 if (face->background == FACE_TTY_DEFAULT_BG_COLOR
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5912 || face->background == FACE_TTY_DEFAULT_COLOR)
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5913 {
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5914 face->background = FRAME_BACKGROUND_PIXEL (c->f);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5915 attrs[LFACE_BACKGROUND_INDEX] =
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5916 tty_color_name (c->f, face->background);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5917 face_colors_defaulted = 1;
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5918 }
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5919 else if (face->background == FACE_TTY_DEFAULT_FG_COLOR)
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5920 {
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5921 face->background = FRAME_FOREGROUND_PIXEL (c->f);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5922 attrs[LFACE_BACKGROUND_INDEX] =
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5923 tty_color_name (c->f, face->background);
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5924 face_colors_defaulted = 1;
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5925 }
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5926 #ifdef MSDOS
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5927 }
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5928 #endif /* MSDOS */
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
5929 #endif /* MSDOS or WINDOWSNT */
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5930 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5931
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5932 /* 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
5933 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
5934 frame-creation function calls x-handle-reverse-video. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5935 if (face->tty_reverse_p && !face_colors_defaulted)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5936 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5937 unsigned long tem = face->foreground;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5938
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5939 face->foreground = face->background;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5940 face->background = tem;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5941 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5942
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5943 return face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5944 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5945
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5946
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5947
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5948 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5949 Computing Faces
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5950 ***********************************************************************/
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5951
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5952 /* 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
5953 property PROP on frame F in current_buffer. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5954
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5955 int
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5956 compute_char_face (f, ch, prop)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
5957 struct frame *f;
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5958 int ch;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5959 Lisp_Object prop;
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 int face_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5962 int charset = (NILP (current_buffer->enable_multibyte_characters)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5963 ? -1
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5964 : CHAR_CHARSET (ch));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5965
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5966 if (NILP (prop))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5967 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
5968 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5969 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5970 Lisp_Object attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5971 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
5972 bcopy (default_face->lface, attrs, sizeof attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5973 merge_face_vector_with_property (f, attrs, prop);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5974 face_id = lookup_face (f, attrs, charset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5975 }
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 return face_id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5978 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5979
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 /* 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
5982 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
5983 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
5984 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
5985
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5986 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
5987 highlighted.
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5988
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5989 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
5990 this function can take.
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5991
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5992 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
5993
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5994 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
5995 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
5996 the face is suitable for displaying unibyte text. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5997
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5998 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
5999 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
6000 endptr, limit, mouse)
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6001 struct window *w;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6002 int pos;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6003 int region_beg, region_end;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6004 int *endptr;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6005 int limit;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6006 int mouse;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6007 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6008 struct frame *f = XFRAME (w->frame);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6009 Lisp_Object attrs[LFACE_VECTOR_SIZE];
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6010 Lisp_Object prop, position;
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6011 int i, noverlays;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6012 Lisp_Object *overlay_vec;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6013 Lisp_Object frame;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6014 int endpos;
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6015 Lisp_Object propname = mouse ? Qmouse_face : Qface;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6016 Lisp_Object limit1, end;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6017 struct face *default_face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6018 int multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6019
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6020 /* W must display the current buffer. We could write this function
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6021 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
6022 /* xassert (XBUFFER (w->buffer) == current_buffer); */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6023
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6024 XSETFRAME (frame, f);
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6025 XSETFASTINT (position, pos);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6026
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6027 endpos = ZV;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6028 if (pos < region_beg && region_beg < endpos)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6029 endpos = region_beg;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6030
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6031 /* 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
6032 determine the next position at which the property changes. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6033 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
6034 XSETFASTINT (limit1, (limit < endpos ? limit : endpos));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6035 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
6036 if (INTEGERP (end))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6037 endpos = XINT (end);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6038
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6039 /* Look at properties from overlays. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6040 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6041 int next_overlay;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6042 int len;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6043
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6044 /* First try with room for 40 overlays. */
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6045 len = 40;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6046 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6047 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
6048 &next_overlay, NULL);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6049
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6050 /* 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
6051 again. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6052 if (noverlays > len)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6053 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6054 len = noverlays;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6055 overlay_vec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6056 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
6057 &next_overlay, NULL);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6058 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6059
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6060 if (next_overlay < endpos)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6061 endpos = next_overlay;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6062 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6063
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6064 *endptr = endpos;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6065
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6066 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
6067
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6068 /* 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
6069 if (noverlays == 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6070 && NILP (prop)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6071 && !(pos >= region_beg && pos < region_end)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6072 && (multibyte_p
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6073 || !FRAME_WINDOW_P (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6074 || FACE_SUITABLE_FOR_CHARSET_P (default_face, -1)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6075 return DEFAULT_FACE_ID;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6076
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6077 /* Begin with attributes from the default face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6078 bcopy (default_face->lface, attrs, sizeof attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6079
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6080 /* Merge in attributes specified via text properties. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6081 if (!NILP (prop))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6082 merge_face_vector_with_property (f, attrs, prop);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6083
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6084 /* Now merge the overlay data. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6085 noverlays = sort_overlays (overlay_vec, noverlays, w);
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6086 for (i = 0; i < noverlays; i++)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6087 {
21607
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6088 Lisp_Object oend;
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6089 int oendpos;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6090
21607
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6091 prop = Foverlay_get (overlay_vec[i], propname);
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6092 if (!NILP (prop))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6093 merge_face_vector_with_property (f, attrs, prop);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6094
21607
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6095 oend = OVERLAY_END (overlay_vec[i]);
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6096 oendpos = OVERLAY_POSITION (oend);
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6097 if (oendpos < endpos)
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6098 endpos = oendpos;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6099 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6100
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6101 /* If in the region, merge in the region face. */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6102 if (pos >= region_beg && pos < region_end)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6103 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6104 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
6105 merge_face_vectors (XVECTOR (region_face)->contents, attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6106
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6107 if (region_end < endpos)
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6108 endpos = region_end;
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6109 }
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6110
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6111 *endptr = endpos;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6112
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6113 /* 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
6114 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
6115 return lookup_face (f, attrs, multibyte_p ? CHARSET_ASCII : -1);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6116 }
21607
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6117
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6118
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6119 /* 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
6120 window W, for charset CHARSET_ASCII.
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6121
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6122 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
6123 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
6124 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
6125 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
6126 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
6127 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
6128 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
6129 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
6130
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6131 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
6132 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
6133 string.
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6134
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6135 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
6136 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
6137 the face is suitable for displaying unibyte text. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6138
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6139 int
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6140 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
6141 region_end, endptr, base_face_id)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6142 struct window *w;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6143 Lisp_Object string;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6144 int pos, bufpos;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6145 int region_beg, region_end;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6146 int *endptr;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6147 enum face_id base_face_id;
21607
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6148 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6149 Lisp_Object prop, position, end, limit;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6150 struct frame *f = XFRAME (WINDOW_FRAME (w));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6151 Lisp_Object attrs[LFACE_VECTOR_SIZE];
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6152 struct face *base_face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6153 int multibyte_p = STRING_MULTIBYTE (string);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6154
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6155 /* 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
6156 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
6157 XSETFASTINT (position, pos);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6158 prop = Fget_text_property (position, Qface, string);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6159
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6160 /* 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
6161 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
6162 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
6163 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
6164 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
6165 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
6166 XSETFASTINT (limit, XSTRING (string)->size);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6167 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
6168 if (INTEGERP (end))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6169 *endptr = XFASTINT (end);
21607
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6170 else
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6171 *endptr = -1;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6172
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6173 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
6174 xassert (base_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6175
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6176 /* 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
6177 are not in the region. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6178 if (NILP (prop)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6179 && (base_face_id != DEFAULT_FACE_ID
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6180 /* 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
6181 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
6182 || bufpos <= 0
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6183 || bufpos < region_beg
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6184 || bufpos >= region_end)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6185 && (multibyte_p
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6186 /* 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
6187 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
6188 on a window-system frame. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6189 || !FRAME_WINDOW_P (f)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6190 || FACE_SUITABLE_FOR_CHARSET_P (base_face, -1)))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6191 return base_face->id;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6192
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6193 /* Begin with attributes from the base face. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6194 bcopy (base_face->lface, attrs, sizeof attrs);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6195
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6196 /* Merge in attributes specified via text properties. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6197 if (!NILP (prop))
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6198 merge_face_vector_with_property (f, attrs, prop);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6199
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6200 /* 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
6201 if (bufpos
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6202 && bufpos >= region_beg
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6203 && bufpos < region_end)
21607
59159a81b101 (Qforeground_color, Qbackground_color): Declare.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16884
diff changeset
6204 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6205 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
6206 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
6207 }
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6208
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6209 /* 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
6210 or realize a new one. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6211 return lookup_face (f, attrs, multibyte_p ? CHARSET_ASCII : -1);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6212 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6213
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6214
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6215
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6216 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6217 Tests
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6218 ***********************************************************************/
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6219
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6220 #if GLYPH_DEBUG
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6221
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6222 /* 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
6223
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6224 static void
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6225 dump_realized_face (face)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6226 struct face *face;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6227 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6228 fprintf (stderr, "ID: %d\n", face->id);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
6229 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6230 fprintf (stderr, "gc: %d\n", (int) face->gc);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
6231 #endif
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6232 fprintf (stderr, "foreground: 0x%lx (%s)\n",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6233 face->foreground,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6234 XSTRING (face->lface[LFACE_FOREGROUND_INDEX])->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6235 fprintf (stderr, "background: 0x%lx (%s)\n",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6236 face->background,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6237 XSTRING (face->lface[LFACE_BACKGROUND_INDEX])->data);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6238 fprintf (stderr, "font_name: %s (%s)\n",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6239 face->font_name,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6240 XSTRING (face->lface[LFACE_FAMILY_INDEX])->data);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
6241 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6242 fprintf (stderr, "font = %p\n", face->font);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
6243 #endif
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6244 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
6245 fprintf (stderr, "fontset: %d\n", face->fontset);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6246 fprintf (stderr, "underline: %d (%s)\n",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6247 face->underline_p,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6248 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
6249 fprintf (stderr, "hash: %d\n", face->hash);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6250 fprintf (stderr, "charset: %d\n", face->charset);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6251 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6252
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6253
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6254 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
6255 (n)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6256 Lisp_Object n;
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6257 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6258 if (NILP (n))
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6259 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6260 int i;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6261
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6262 fprintf (stderr, "font selection order: ");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6263 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
6264 fprintf (stderr, "%d ", font_sort_order[i]);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6265 fprintf (stderr, "\n");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6266
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6267 fprintf (stderr, "alternative fonts: ");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6268 debug_print (Vface_alternative_font_family_alist);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6269 fprintf (stderr, "\n");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6270
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6271 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
6272 Fdump_face (make_number (i));
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6273 }
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6274 else
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6275 {
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6276 struct face *face;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6277 CHECK_NUMBER (n, 0);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6278 face = FACE_FROM_ID (SELECTED_FRAME (), XINT (n));
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6279 if (face == NULL)
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6280 error ("Not a valid face");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6281 dump_realized_face (face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6282 }
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6283
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6284 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6285 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6286
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6287
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6288 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
6289 0, 0, 0, "")
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6290 ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6291 {
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6292 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
6293 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
6294 fprintf (stderr, "number of GCs = %d\n", ngcs);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6295 return Qnil;
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6296 }
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6297
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6298 #endif /* GLYPH_DEBUG != 0 */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6299
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6300
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6301
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6302 /***********************************************************************
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6303 Initialization
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6304 ***********************************************************************/
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6305
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6306 void
16588
481b7874a1e9 Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents: 16051
diff changeset
6307 syms_of_w32faces ()
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6308 {
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6309 Qface = intern ("face");
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6310 staticpro (&Qface);
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6311 Qbitmap_spec_p = intern ("bitmap-spec-p");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6312 staticpro (&Qbitmap_spec_p);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6313 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
6314 staticpro (&Qframe_update_face_colors);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6315
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6316 /* Lisp face attribute keywords. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6317 QCfamily = intern (":family");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6318 staticpro (&QCfamily);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6319 QCheight = intern (":height");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6320 staticpro (&QCheight);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6321 QCweight = intern (":weight");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6322 staticpro (&QCweight);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6323 QCslant = intern (":slant");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6324 staticpro (&QCslant);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6325 QCunderline = intern (":underline");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6326 staticpro (&QCunderline);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6327 QCinverse_video = intern (":inverse-video");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6328 staticpro (&QCinverse_video);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6329 QCreverse_video = intern (":reverse-video");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6330 staticpro (&QCreverse_video);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6331 QCforeground = intern (":foreground");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6332 staticpro (&QCforeground);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6333 QCbackground = intern (":background");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6334 staticpro (&QCbackground);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6335 QCstipple = intern (":stipple");;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6336 staticpro (&QCstipple);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6337 QCwidth = intern (":width");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6338 staticpro (&QCwidth);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6339 QCfont = intern (":font");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6340 staticpro (&QCfont);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6341 QCbold = intern (":bold");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6342 staticpro (&QCbold);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6343 QCitalic = intern (":italic");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6344 staticpro (&QCitalic);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6345 QCoverline = intern (":overline");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6346 staticpro (&QCoverline);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6347 QCstrike_through = intern (":strike-through");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6348 staticpro (&QCstrike_through);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6349 QCbox = intern (":box");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6350 staticpro (&QCbox);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6351
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6352 /* Symbols used for Lisp face attribute values. */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6353 QCcolor = intern (":color");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6354 staticpro (&QCcolor);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6355 QCline_width = intern (":line-width");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6356 staticpro (&QCline_width);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6357 QCstyle = intern (":style");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6358 staticpro (&QCstyle);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6359 Qreleased_button = intern ("released-button");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6360 staticpro (&Qreleased_button);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6361 Qpressed_button = intern ("pressed-button");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6362 staticpro (&Qpressed_button);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6363 Qnormal = intern ("normal");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6364 staticpro (&Qnormal);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6365 Qultra_light = intern ("ultra-light");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6366 staticpro (&Qultra_light);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6367 Qextra_light = intern ("extra-light");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6368 staticpro (&Qextra_light);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6369 Qlight = intern ("light");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6370 staticpro (&Qlight);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6371 Qsemi_light = intern ("semi-light");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6372 staticpro (&Qsemi_light);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6373 Qsemi_bold = intern ("semi-bold");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6374 staticpro (&Qsemi_bold);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6375 Qbold = intern ("bold");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6376 staticpro (&Qbold);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6377 Qextra_bold = intern ("extra-bold");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6378 staticpro (&Qextra_bold);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6379 Qultra_bold = intern ("ultra-bold");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6380 staticpro (&Qultra_bold);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6381 Qoblique = intern ("oblique");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6382 staticpro (&Qoblique);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6383 Qitalic = intern ("italic");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6384 staticpro (&Qitalic);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6385 Qreverse_oblique = intern ("reverse-oblique");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6386 staticpro (&Qreverse_oblique);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6387 Qreverse_italic = intern ("reverse-italic");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6388 staticpro (&Qreverse_italic);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6389 Qultra_condensed = intern ("ultra-condensed");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6390 staticpro (&Qultra_condensed);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6391 Qextra_condensed = intern ("extra-condensed");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6392 staticpro (&Qextra_condensed);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6393 Qcondensed = intern ("condensed");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6394 staticpro (&Qcondensed);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6395 Qsemi_condensed = intern ("semi-condensed");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6396 staticpro (&Qsemi_condensed);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6397 Qsemi_expanded = intern ("semi-expanded");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6398 staticpro (&Qsemi_expanded);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6399 Qexpanded = intern ("expanded");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6400 staticpro (&Qexpanded);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6401 Qextra_expanded = intern ("extra-expanded");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6402 staticpro (&Qextra_expanded);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6403 Qultra_expanded = intern ("ultra-expanded");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6404 staticpro (&Qultra_expanded);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6405 Qbackground_color = intern ("background-color");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6406 staticpro (&Qbackground_color);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6407 Qforeground_color = intern ("foreground-color");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6408 staticpro (&Qforeground_color);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6409 Qunspecified = intern ("unspecified");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6410 staticpro (&Qunspecified);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6411
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6412 Qx_charset_registry = intern ("x-charset-registry");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6413 staticpro (&Qx_charset_registry);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6414 Qface_alias = intern ("face-alias");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6415 staticpro (&Qface_alias);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6416 Qdefault = intern ("default");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6417 staticpro (&Qdefault);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6418 Qtool_bar = intern ("tool-bar");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6419 staticpro (&Qtool_bar);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6420 Qregion = intern ("region");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6421 staticpro (&Qregion);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6422 Qfringe = intern ("fringe");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6423 staticpro (&Qfringe);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6424 Qheader_line = intern ("header-line");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6425 staticpro (&Qheader_line);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6426 Qscroll_bar = intern ("scroll-bar");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6427 staticpro (&Qscroll_bar);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6428 Qmenu = intern ("menu");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6429 staticpro (&Qmenu);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6430 Qcursor = intern ("cursor");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6431 staticpro (&Qcursor);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6432 Qborder = intern ("border");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6433 staticpro (&Qborder);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6434 Qmouse = intern ("mouse");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6435 staticpro (&Qmouse);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6436 Qtty_color_desc = intern ("tty-color-desc");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6437 staticpro (&Qtty_color_desc);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6438 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
6439 staticpro (&Qtty_color_by_index);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6440
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6441 defsubr (&Sinternal_make_lisp_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6442 defsubr (&Sinternal_lisp_face_p);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6443 defsubr (&Sinternal_set_lisp_face_attribute);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
6444 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6445 defsubr (&Sinternal_set_lisp_face_attribute_from_resource);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
6446 #endif
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6447 defsubr (&Scolor_gray_p);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6448 defsubr (&Scolor_supported_p);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6449 defsubr (&Sinternal_get_lisp_face_attribute);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6450 defsubr (&Sinternal_lisp_face_attribute_values);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6451 defsubr (&Sinternal_lisp_face_equal_p);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6452 defsubr (&Sinternal_lisp_face_empty_p);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6453 defsubr (&Sinternal_copy_lisp_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6454 defsubr (&Sinternal_merge_in_global_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6455 defsubr (&Sface_font);
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6456 defsubr (&Sframe_face_alist);
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6457 defsubr (&Sinternal_set_font_selection_order);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6458 defsubr (&Sinternal_set_alternative_font_family_alist);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6459 #if GLYPH_DEBUG
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6460 defsubr (&Sdump_face);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6461 defsubr (&Sshow_face_resources);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6462 #endif /* GLYPH_DEBUG */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6463 defsubr (&Sclear_face_cache);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6464
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6465 DEFVAR_LISP ("font-list-limit", &Vfont_list_limit,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6466 "*Limit for font matching.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6467 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
6468 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
6469 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
6470
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6471 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
6472 "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
6473 Vface_new_frame_defaults = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6474
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6475 DEFVAR_LISP ("face-default-stipple", &Vface_default_stipple,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6476 "*Default stipple pattern used on monochrome displays.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6477 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
6478 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
6479 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
6480 Vface_default_stipple = build_string ("gray3");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6481
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6482 DEFVAR_LISP ("face-default-registry", &Vface_default_registry,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6483 "Default registry and encoding to use.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6484 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
6485 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
6486 Vface_default_registry = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6487
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6488 DEFVAR_LISP ("face-alternative-font-family-alist",
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6489 &Vface_alternative_font_family_alist, "");
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6490 Vface_alternative_font_family_alist = Qnil;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6491
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6492 #if SCALABLE_FONTS
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6493
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6494 DEFVAR_LISP ("scalable-fonts-allowed", &Vscalable_fonts_allowed,
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6495 "Allowed scalable fonts.\n\
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6496 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
6497 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
6498 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
6499 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
6500 Vscalable_fonts_allowed = Qt;
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6501
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6502 #endif /* SCALABLE_FONTS */
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6503
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
6504 #ifdef HAVE_WINDOW_SYSTEM
27396
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6505 defsubr (&Sbitmap_spec_p);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6506 defsubr (&Sx_list_fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6507 defsubr (&Sinternal_face_x_get_resource);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6508 defsubr (&Sx_family_fonts);
323eb9ca333f Complete rewrite based on xfaces.c
Jason Rumney <jasonr@gnu.org>
parents: 26088
diff changeset
6509 defsubr (&Sx_font_family_list);
27517
d0c413d1b2c2 Merge more of DOS and X specifics in preparation for merge with xfaces.c.
Jason Rumney <jasonr@gnu.org>
parents: 27396
diff changeset
6510 #endif /* HAVE_WINDOW_SYSTEM */
13434
53ba95a88cf2 Initial revision
Geoff Voelker <voelker@cs.washington.edu>
parents:
diff changeset
6511 }