Mercurial > hg > xemacs-beta
annotate src/fontcolor-msw.c @ 5182:2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
lisp/ChangeLog addition:
2010-04-01 Aidan Kehoe <kehoea@parhasard.net>
* cl-seq.el (fill, sort*, merge): Move these functions to fns.c.
(stable-sort): Make this docstring reflect the argument names used
in the #'sort* docstring.
* cl-macs.el (stable-sort): Make #'stable-sort exactly equivalent
to #'sort* in compiled code.
* bytecomp.el (byte-compile-maybe-add-*):
New macro, for functions like #'sort and #'mapcar that, to be
strictly compatible, should only take two args, but in our
implementation can take more, because they're aliases of #'sort*
and #'mapcar*.
(byte-compile-mapcar, byte-compile-sort, byte-compile-fillarray):
Use this new macro.
(map-into): Add a byte-compile method for #'map-into in passing.
* apropos.el (apropos-print): Use #'sort* with a :key argument,
now it's in C.
* compat.el (extent-at): Ditto.
* register.el (list-registers): Ditto.
* package-ui.el (pui-list-packages): Ditto.
* help.el (sorted-key-descriptions): Ditto.
src/ChangeLog addition:
2010-03-31 Aidan Kehoe <kehoea@parhasard.net>
* fns.c (STRING_DATA_TO_OBJECT_ARRAY)
(BIT_VECTOR_TO_OBJECT_ARRAY, c_merge_predicate_key)
(c_merge_predicate_nokey, list_merge, array_merge)
(list_array_merge_into_list, list_list_merge_into_array)
(list_array_merge_into_array, CHECK_KEY_ARGUMENT, Fmerge)
(list_sort, array_sort, FsortX):
Move #'sort*, #'fill, #'merge from cl-seq.el to C, extending the
implementations of Fsort, Ffillarray, and merge() to do so.
* keymap.c (keymap_submaps, map_keymap_sort_predicate)
(describe_map_sort_predicate):
Change the calling semantics of the C sort predicates to return a
non-nil Lisp object if the first argument is less than the second,
rather than C integers.
* fontcolor-msw.c (sort_font_list_function):
* fileio.c (build_annotations):
* dired.c (Fdirectory_files):
* abbrev.c (Finsert_abbrev_table_description):
Call list_sort instead of Fsort, list_merge instead of merge() in
these functions.
man/ChangeLog addition:
2010-04-01 Aidan Kehoe <kehoea@parhasard.net>
* lispref/lists.texi (Rearrangement):
Update the documentation of #'sort here, now that it accepts any
type of sequence and the KEY keyword argument. (Though this is
probably now the wrong place for this function, given that.)
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Thu, 01 Apr 2010 20:22:50 +0100 |
parents | 8b2f75cecb89 |
children | 71ee43b8a74d |
rev | line source |
---|---|
428 | 1 /* mswindows-specific Lisp objects. |
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc. | |
3 Copyright (C) 1995 Board of Trustees, University of Illinois. | |
4 Copyright (C) 1995 Tinker Systems. | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
5 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004, 2005, 2010 Ben Wing. |
428 | 6 Copyright (C) 1995 Sun Microsystems, Inc. |
7 Copyright (C) 1997 Jonathan Harris. | |
8 | |
9 This file is part of XEmacs. | |
10 | |
11 XEmacs is free software; you can redistribute it and/or modify it | |
12 under the terms of the GNU General Public License as published by the | |
13 Free Software Foundation; either version 2, or (at your option) any | |
14 later version. | |
15 | |
16 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
19 for more details. | |
20 | |
21 You should have received a copy of the GNU General Public License | |
22 along with XEmacs; see the file COPYING. If not, write to | |
23 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 Boston, MA 02111-1307, USA. */ | |
25 | |
26 /* Synched up with: Not in FSF. */ | |
27 | |
28 /* Authorship: | |
29 | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
30 This file created by Jonathan Harris, November 1997 for 21.0; based |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5024
diff
changeset
|
31 heavily on fontcolor-x.c (see authorship there). Much further work |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
32 by Ben Wing. |
428 | 33 */ |
34 | |
793 | 35 /* This function Mule-ized by Ben Wing, 3-24-02. */ |
428 | 36 |
37 /* TODO: palette handling */ | |
38 | |
39 #include <config.h> | |
40 #include "lisp.h" | |
41 | |
872 | 42 #include "console-msw-impl.h" |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5024
diff
changeset
|
43 #include "fontcolor-msw-impl.h" |
800 | 44 |
428 | 45 #include "buffer.h" |
771 | 46 #include "charset.h" |
872 | 47 #include "device-impl.h" |
788 | 48 #include "elhash.h" |
428 | 49 #include "insdel.h" |
788 | 50 #include "opaque.h" |
428 | 51 |
442 | 52 typedef struct colormap_t |
428 | 53 { |
2367 | 54 const Ascbyte *name; |
442 | 55 COLORREF colorref; |
428 | 56 } colormap_t; |
57 | |
58 /* Colors from X11R6 "XConsortium: rgb.txt,v 10.41 94/02/20 18:39:36 rws Exp" */ | |
771 | 59 /* MSWindows tends to round up the numbers in its palette, ie where X uses |
442 | 60 * 127, MSWindows uses 128. Colors commented as "Adjusted" are tweaked to |
61 * match the Windows standard palette to increase the likelihood of | |
62 * mswindows_color_to_string() finding a named match. | |
63 */ | |
64 static const colormap_t mswindows_X_color_map[] = | |
428 | 65 { |
442 | 66 {"white" , PALETTERGB (255, 255, 255) }, |
67 {"black" , PALETTERGB (0, 0, 0) }, | |
68 {"snow" , PALETTERGB (255, 250, 250) }, | |
69 {"GhostWhite" , PALETTERGB (248, 248, 255) }, | |
70 {"WhiteSmoke" , PALETTERGB (245, 245, 245) }, | |
71 {"gainsboro" , PALETTERGB (220, 220, 220) }, | |
72 {"FloralWhite" , PALETTERGB (255, 250, 240) }, | |
73 {"OldLace" , PALETTERGB (253, 245, 230) }, | |
74 {"linen" , PALETTERGB (250, 240, 230) }, | |
75 {"AntiqueWhite" , PALETTERGB (250, 235, 215) }, | |
76 {"PapayaWhip" , PALETTERGB (255, 239, 213) }, | |
77 {"BlanchedAlmond" , PALETTERGB (255, 235, 205) }, | |
78 {"bisque" , PALETTERGB (255, 228, 196) }, | |
79 {"PeachPuff" , PALETTERGB (255, 218, 185) }, | |
80 {"NavajoWhite" , PALETTERGB (255, 222, 173) }, | |
81 {"moccasin" , PALETTERGB (255, 228, 181) }, | |
82 {"cornsilk" , PALETTERGB (255, 248, 220) }, | |
83 {"ivory" , PALETTERGB (255, 255, 240) }, | |
84 {"LemonChiffon" , PALETTERGB (255, 250, 205) }, | |
85 {"seashell" , PALETTERGB (255, 245, 238) }, | |
86 {"honeydew" , PALETTERGB (240, 255, 240) }, | |
87 {"MintCream" , PALETTERGB (245, 255, 250) }, | |
88 {"azure" , PALETTERGB (240, 255, 255) }, | |
89 {"AliceBlue" , PALETTERGB (240, 248, 255) }, | |
90 {"lavender" , PALETTERGB (230, 230, 250) }, | |
91 {"LavenderBlush" , PALETTERGB (255, 240, 245) }, | |
92 {"MistyRose" , PALETTERGB (255, 228, 225) }, | |
93 {"DarkSlateGray" , PALETTERGB (47, 79, 79) }, | |
94 {"DarkSlateGrey" , PALETTERGB (47, 79, 79) }, | |
95 {"DimGray" , PALETTERGB (105, 105, 105) }, | |
96 {"DimGrey" , PALETTERGB (105, 105, 105) }, | |
97 {"SlateGray" , PALETTERGB (112, 128, 144) }, | |
98 {"SlateGrey" , PALETTERGB (112, 128, 144) }, | |
99 {"LightSlateGray" , PALETTERGB (119, 136, 153) }, | |
100 {"LightSlateGrey" , PALETTERGB (119, 136, 153) }, | |
101 {"gray" , PALETTERGB (190, 190, 190) }, | |
102 {"grey" , PALETTERGB (190, 190, 190) }, | |
103 {"LightGrey" , PALETTERGB (211, 211, 211) }, | |
104 {"LightGray" , PALETTERGB (211, 211, 211) }, | |
105 {"MidnightBlue" , PALETTERGB (25, 25, 112) }, | |
106 {"navy" , PALETTERGB (0, 0, 128) }, | |
107 {"NavyBlue" , PALETTERGB (0, 0, 128) }, | |
108 {"CornflowerBlue" , PALETTERGB (100, 149, 237) }, | |
109 {"DarkSlateBlue" , PALETTERGB (72, 61, 139) }, | |
110 {"SlateBlue" , PALETTERGB (106, 90, 205) }, | |
111 {"MediumSlateBlue" , PALETTERGB (123, 104, 238) }, | |
112 {"LightSlateBlue" , PALETTERGB (132, 112, 255) }, | |
113 {"MediumBlue" , PALETTERGB (0, 0, 205) }, | |
114 {"RoyalBlue" , PALETTERGB (65, 105, 225) }, | |
115 {"blue" , PALETTERGB (0, 0, 255) }, | |
116 {"DodgerBlue" , PALETTERGB (30, 144, 255) }, | |
117 {"DeepSkyBlue" , PALETTERGB (0, 191, 255) }, | |
118 {"SkyBlue" , PALETTERGB (135, 206, 235) }, | |
119 {"LightSkyBlue" , PALETTERGB (135, 206, 250) }, | |
120 {"SteelBlue" , PALETTERGB (70, 130, 180) }, | |
121 {"LightSteelBlue" , PALETTERGB (176, 196, 222) }, | |
122 {"LightBlue" , PALETTERGB (173, 216, 230) }, | |
123 {"PowderBlue" , PALETTERGB (176, 224, 230) }, | |
124 {"PaleTurquoise" , PALETTERGB (175, 238, 238) }, | |
125 {"DarkTurquoise" , PALETTERGB (0, 206, 209) }, | |
126 {"MediumTurquoise" , PALETTERGB (72, 209, 204) }, | |
127 {"turquoise" , PALETTERGB (64, 224, 208) }, | |
128 {"cyan" , PALETTERGB (0, 255, 255) }, | |
129 {"LightCyan" , PALETTERGB (224, 255, 255) }, | |
130 {"CadetBlue" , PALETTERGB (95, 158, 160) }, | |
131 {"MediumAquamarine" , PALETTERGB (102, 205, 170) }, | |
132 {"aquamarine" , PALETTERGB (127, 255, 212) }, | |
133 {"DarkGreen" , PALETTERGB (0, 128, 0) }, /* Adjusted */ | |
134 {"DarkOliveGreen" , PALETTERGB (85, 107, 47) }, | |
135 {"DarkSeaGreen" , PALETTERGB (143, 188, 143) }, | |
136 {"SeaGreen" , PALETTERGB (46, 139, 87) }, | |
137 {"MediumSeaGreen" , PALETTERGB (60, 179, 113) }, | |
138 {"LightSeaGreen" , PALETTERGB (32, 178, 170) }, | |
139 {"PaleGreen" , PALETTERGB (152, 251, 152) }, | |
140 {"SpringGreen" , PALETTERGB (0, 255, 127) }, | |
141 {"LawnGreen" , PALETTERGB (124, 252, 0) }, | |
142 {"green" , PALETTERGB (0, 255, 0) }, | |
143 {"chartreuse" , PALETTERGB (127, 255, 0) }, | |
144 {"MediumSpringGreen" , PALETTERGB (0, 250, 154) }, | |
145 {"GreenYellow" , PALETTERGB (173, 255, 47) }, | |
146 {"LimeGreen" , PALETTERGB (50, 205, 50) }, | |
147 {"YellowGreen" , PALETTERGB (154, 205, 50) }, | |
148 {"ForestGreen" , PALETTERGB (34, 139, 34) }, | |
149 {"OliveDrab" , PALETTERGB (107, 142, 35) }, | |
150 {"DarkKhaki" , PALETTERGB (189, 183, 107) }, | |
151 {"khaki" , PALETTERGB (240, 230, 140) }, | |
152 {"PaleGoldenrod" , PALETTERGB (238, 232, 170) }, | |
153 {"LightGoldenrodYellow", PALETTERGB (250, 250, 210) }, | |
154 {"LightYellow" , PALETTERGB (255, 255, 224) }, | |
155 {"LightYellow" , PALETTERGB (255, 255, 225) }, /* Adjusted */ | |
156 {"yellow" , PALETTERGB (255, 255, 0) }, | |
157 {"gold" , PALETTERGB (255, 215, 0) }, | |
158 {"LightGoldenrod" , PALETTERGB (238, 221, 130) }, | |
159 {"goldenrod" , PALETTERGB (218, 165, 32) }, | |
160 {"DarkGoldenrod" , PALETTERGB (184, 134, 11) }, | |
161 {"RosyBrown" , PALETTERGB (188, 143, 143) }, | |
162 {"IndianRed" , PALETTERGB (205, 92, 92) }, | |
163 {"SaddleBrown" , PALETTERGB (139, 69, 19) }, | |
164 {"sienna" , PALETTERGB (160, 82, 45) }, | |
165 {"peru" , PALETTERGB (205, 133, 63) }, | |
166 {"burlywood" , PALETTERGB (222, 184, 135) }, | |
167 {"beige" , PALETTERGB (245, 245, 220) }, | |
168 {"wheat" , PALETTERGB (245, 222, 179) }, | |
169 {"SandyBrown" , PALETTERGB (244, 164, 96) }, | |
170 {"tan" , PALETTERGB (210, 180, 140) }, | |
171 {"chocolate" , PALETTERGB (210, 105, 30) }, | |
172 {"firebrick" , PALETTERGB (178, 34, 34) }, | |
173 {"brown" , PALETTERGB (165, 42, 42) }, | |
174 {"DarkSalmon" , PALETTERGB (233, 150, 122) }, | |
175 {"salmon" , PALETTERGB (250, 128, 114) }, | |
176 {"LightSalmon" , PALETTERGB (255, 160, 122) }, | |
177 {"orange" , PALETTERGB (255, 165, 0) }, | |
178 {"DarkOrange" , PALETTERGB (255, 140, 0) }, | |
179 {"coral" , PALETTERGB (255, 127, 80) }, | |
180 {"LightCoral" , PALETTERGB (240, 128, 128) }, | |
181 {"tomato" , PALETTERGB (255, 99, 71) }, | |
182 {"OrangeRed" , PALETTERGB (255, 69, 0) }, | |
183 {"red" , PALETTERGB (255, 0, 0) }, | |
184 {"HotPink" , PALETTERGB (255, 105, 180) }, | |
185 {"DeepPink" , PALETTERGB (255, 20, 147) }, | |
186 {"pink" , PALETTERGB (255, 192, 203) }, | |
187 {"LightPink" , PALETTERGB (255, 182, 193) }, | |
188 {"PaleVioletRed" , PALETTERGB (219, 112, 147) }, | |
189 {"maroon" , PALETTERGB (176, 48, 96) }, | |
190 {"MediumVioletRed" , PALETTERGB (199, 21, 133) }, | |
191 {"VioletRed" , PALETTERGB (208, 32, 144) }, | |
192 {"magenta" , PALETTERGB (255, 0, 255) }, | |
193 {"violet" , PALETTERGB (238, 130, 238) }, | |
194 {"plum" , PALETTERGB (221, 160, 221) }, | |
195 {"orchid" , PALETTERGB (218, 112, 214) }, | |
196 {"MediumOrchid" , PALETTERGB (186, 85, 211) }, | |
197 {"DarkOrchid" , PALETTERGB (153, 50, 204) }, | |
198 {"DarkViolet" , PALETTERGB (148, 0, 211) }, | |
199 {"BlueViolet" , PALETTERGB (138, 43, 226) }, | |
200 {"purple" , PALETTERGB (160, 32, 240) }, | |
201 {"MediumPurple" , PALETTERGB (147, 112, 219) }, | |
202 {"thistle" , PALETTERGB (216, 191, 216) }, | |
203 {"snow1" , PALETTERGB (255, 250, 250) }, | |
204 {"snow2" , PALETTERGB (238, 233, 233) }, | |
205 {"snow3" , PALETTERGB (205, 201, 201) }, | |
206 {"snow4" , PALETTERGB (139, 137, 137) }, | |
207 {"seashell1" , PALETTERGB (255, 245, 238) }, | |
208 {"seashell2" , PALETTERGB (238, 229, 222) }, | |
209 {"seashell3" , PALETTERGB (205, 197, 191) }, | |
210 {"seashell4" , PALETTERGB (139, 134, 130) }, | |
211 {"AntiqueWhite1" , PALETTERGB (255, 239, 219) }, | |
212 {"AntiqueWhite2" , PALETTERGB (238, 223, 204) }, | |
213 {"AntiqueWhite3" , PALETTERGB (205, 192, 176) }, | |
214 {"AntiqueWhite4" , PALETTERGB (139, 131, 120) }, | |
215 {"bisque1" , PALETTERGB (255, 228, 196) }, | |
216 {"bisque2" , PALETTERGB (238, 213, 183) }, | |
217 {"bisque3" , PALETTERGB (205, 183, 158) }, | |
218 {"bisque4" , PALETTERGB (139, 125, 107) }, | |
219 {"PeachPuff1" , PALETTERGB (255, 218, 185) }, | |
220 {"PeachPuff2" , PALETTERGB (238, 203, 173) }, | |
221 {"PeachPuff3" , PALETTERGB (205, 175, 149) }, | |
222 {"PeachPuff4" , PALETTERGB (139, 119, 101) }, | |
223 {"NavajoWhite1" , PALETTERGB (255, 222, 173) }, | |
224 {"NavajoWhite2" , PALETTERGB (238, 207, 161) }, | |
225 {"NavajoWhite3" , PALETTERGB (205, 179, 139) }, | |
226 {"NavajoWhite4" , PALETTERGB (139, 121, 94) }, | |
227 {"LemonChiffon1" , PALETTERGB (255, 250, 205) }, | |
228 {"LemonChiffon2" , PALETTERGB (238, 233, 191) }, | |
229 {"LemonChiffon3" , PALETTERGB (205, 201, 165) }, | |
230 {"LemonChiffon4" , PALETTERGB (139, 137, 112) }, | |
231 {"cornsilk1" , PALETTERGB (255, 248, 220) }, | |
232 {"cornsilk2" , PALETTERGB (238, 232, 205) }, | |
233 {"cornsilk3" , PALETTERGB (205, 200, 177) }, | |
234 {"cornsilk4" , PALETTERGB (139, 136, 120) }, | |
235 {"ivory1" , PALETTERGB (255, 255, 240) }, | |
236 {"ivory2" , PALETTERGB (240, 240, 208) }, /* Adjusted */ | |
237 {"ivory3" , PALETTERGB (205, 205, 193) }, | |
238 {"ivory4" , PALETTERGB (139, 139, 131) }, | |
239 {"honeydew1" , PALETTERGB (240, 255, 240) }, | |
240 {"honeydew2" , PALETTERGB (224, 238, 224) }, | |
241 {"honeydew3" , PALETTERGB (193, 205, 193) }, | |
242 {"honeydew4" , PALETTERGB (131, 139, 131) }, | |
243 {"LavenderBlush1" , PALETTERGB (255, 240, 245) }, | |
244 {"LavenderBlush2" , PALETTERGB (238, 224, 229) }, | |
245 {"LavenderBlush3" , PALETTERGB (205, 193, 197) }, | |
246 {"LavenderBlush4" , PALETTERGB (139, 131, 134) }, | |
247 {"MistyRose1" , PALETTERGB (255, 228, 225) }, | |
248 {"MistyRose2" , PALETTERGB (238, 213, 210) }, | |
249 {"MistyRose3" , PALETTERGB (205, 183, 181) }, | |
250 {"MistyRose4" , PALETTERGB (139, 125, 123) }, | |
251 {"azure1" , PALETTERGB (240, 255, 255) }, | |
252 {"azure2" , PALETTERGB (224, 238, 238) }, | |
253 {"azure3" , PALETTERGB (193, 205, 205) }, | |
254 {"azure4" , PALETTERGB (131, 139, 139) }, | |
255 {"SlateBlue1" , PALETTERGB (131, 111, 255) }, | |
256 {"SlateBlue2" , PALETTERGB (122, 103, 238) }, | |
257 {"SlateBlue3" , PALETTERGB (105, 89, 205) }, | |
258 {"SlateBlue4" , PALETTERGB (71, 60, 139) }, | |
259 {"RoyalBlue1" , PALETTERGB (72, 118, 255) }, | |
260 {"RoyalBlue2" , PALETTERGB (67, 110, 238) }, | |
261 {"RoyalBlue3" , PALETTERGB (58, 95, 205) }, | |
262 {"RoyalBlue4" , PALETTERGB (39, 64, 139) }, | |
263 {"blue1" , PALETTERGB (0, 0, 255) }, | |
264 {"blue2" , PALETTERGB (0, 0, 238) }, | |
265 {"blue3" , PALETTERGB (0, 0, 205) }, | |
266 {"blue4" , PALETTERGB (0, 0, 139) }, | |
267 {"DodgerBlue1" , PALETTERGB (30, 144, 255) }, | |
268 {"DodgerBlue2" , PALETTERGB (28, 134, 238) }, | |
269 {"DodgerBlue3" , PALETTERGB (24, 116, 205) }, | |
270 {"DodgerBlue4" , PALETTERGB (16, 78, 139) }, | |
271 {"SteelBlue1" , PALETTERGB (99, 184, 255) }, | |
272 {"SteelBlue2" , PALETTERGB (92, 172, 238) }, | |
273 {"SteelBlue3" , PALETTERGB (79, 148, 205) }, | |
274 {"SteelBlue4" , PALETTERGB (54, 100, 139) }, | |
275 {"DeepSkyBlue1" , PALETTERGB (0, 191, 255) }, | |
276 {"DeepSkyBlue2" , PALETTERGB (0, 178, 238) }, | |
277 {"DeepSkyBlue3" , PALETTERGB (0, 154, 205) }, | |
278 {"DeepSkyBlue4" , PALETTERGB (0, 104, 139) }, | |
279 {"SkyBlue1" , PALETTERGB (135, 206, 255) }, | |
280 {"SkyBlue2" , PALETTERGB (126, 192, 238) }, | |
281 {"SkyBlue3" , PALETTERGB (108, 166, 205) }, | |
282 {"SkyBlue4" , PALETTERGB (74, 112, 139) }, | |
283 {"LightSkyBlue1" , PALETTERGB (176, 226, 255) }, | |
284 {"LightSkyBlue2" , PALETTERGB (164, 211, 238) }, | |
285 {"LightSkyBlue3" , PALETTERGB (141, 182, 205) }, | |
286 {"LightSkyBlue4" , PALETTERGB (96, 123, 139) }, | |
287 {"SlateGray1" , PALETTERGB (198, 226, 255) }, | |
288 {"SlateGray2" , PALETTERGB (185, 211, 238) }, | |
289 {"SlateGray3" , PALETTERGB (159, 182, 205) }, | |
290 {"SlateGray4" , PALETTERGB (108, 123, 139) }, | |
291 {"LightSteelBlue1" , PALETTERGB (202, 225, 255) }, | |
292 {"LightSteelBlue2" , PALETTERGB (188, 210, 238) }, | |
293 {"LightSteelBlue3" , PALETTERGB (162, 181, 205) }, | |
294 {"LightSteelBlue4" , PALETTERGB (110, 123, 139) }, | |
295 {"LightBlue1" , PALETTERGB (191, 239, 255) }, | |
296 {"LightBlue2" , PALETTERGB (178, 223, 238) }, | |
297 {"LightBlue3" , PALETTERGB (154, 192, 205) }, | |
298 {"LightBlue4" , PALETTERGB (104, 131, 139) }, | |
299 {"LightCyan1" , PALETTERGB (224, 255, 255) }, | |
300 {"LightCyan2" , PALETTERGB (209, 238, 238) }, | |
301 {"LightCyan3" , PALETTERGB (180, 205, 205) }, | |
302 {"LightCyan4" , PALETTERGB (122, 139, 139) }, | |
303 {"PaleTurquoise1" , PALETTERGB (187, 255, 255) }, | |
304 {"PaleTurquoise2" , PALETTERGB (174, 238, 238) }, | |
305 {"PaleTurquoise3" , PALETTERGB (150, 205, 205) }, | |
306 {"PaleTurquoise4" , PALETTERGB (102, 139, 139) }, | |
307 {"CadetBlue1" , PALETTERGB (152, 245, 255) }, | |
308 {"CadetBlue2" , PALETTERGB (144, 220, 240) }, /* Adjusted */ | |
309 {"CadetBlue3" , PALETTERGB (122, 197, 205) }, | |
310 {"CadetBlue4" , PALETTERGB (83, 134, 139) }, | |
311 {"turquoise1" , PALETTERGB (0, 245, 255) }, | |
312 {"turquoise2" , PALETTERGB (0, 229, 238) }, | |
313 {"turquoise3" , PALETTERGB (0, 197, 205) }, | |
314 {"turquoise4" , PALETTERGB (0, 134, 139) }, | |
315 {"cyan1" , PALETTERGB (0, 255, 255) }, | |
316 {"cyan2" , PALETTERGB (0, 238, 238) }, | |
317 {"cyan3" , PALETTERGB (0, 205, 205) }, | |
318 {"cyan4" , PALETTERGB (0, 139, 139) }, | |
319 {"DarkSlateGray1" , PALETTERGB (151, 255, 255) }, | |
320 {"DarkSlateGray2" , PALETTERGB (141, 238, 238) }, | |
321 {"DarkSlateGray3" , PALETTERGB (121, 205, 205) }, | |
322 {"DarkSlateGray4" , PALETTERGB (82, 139, 139) }, | |
323 {"aquamarine1" , PALETTERGB (127, 255, 212) }, | |
324 {"aquamarine2" , PALETTERGB (118, 238, 198) }, | |
325 {"aquamarine3" , PALETTERGB (102, 205, 170) }, | |
326 {"aquamarine4" , PALETTERGB (69, 139, 116) }, | |
327 {"DarkSeaGreen1" , PALETTERGB (193, 255, 193) }, | |
328 {"DarkSeaGreen2" , PALETTERGB (180, 238, 180) }, | |
329 {"DarkSeaGreen3" , PALETTERGB (155, 205, 155) }, | |
330 {"DarkSeaGreen4" , PALETTERGB (105, 139, 105) }, | |
331 {"SeaGreen1" , PALETTERGB (84, 255, 159) }, | |
332 {"SeaGreen2" , PALETTERGB (78, 238, 148) }, | |
333 {"SeaGreen3" , PALETTERGB (67, 205, 128) }, | |
334 {"SeaGreen4" , PALETTERGB (46, 139, 87) }, | |
335 {"PaleGreen1" , PALETTERGB (154, 255, 154) }, | |
336 {"PaleGreen2" , PALETTERGB (144, 238, 144) }, | |
337 {"PaleGreen3" , PALETTERGB (124, 205, 124) }, | |
338 {"PaleGreen4" , PALETTERGB (84, 139, 84) }, | |
339 {"SpringGreen1" , PALETTERGB (0, 255, 127) }, | |
340 {"SpringGreen2" , PALETTERGB (0, 238, 118) }, | |
341 {"SpringGreen3" , PALETTERGB (0, 205, 102) }, | |
342 {"SpringGreen4" , PALETTERGB (0, 139, 69) }, | |
343 {"green1" , PALETTERGB (0, 255, 0) }, | |
344 {"green2" , PALETTERGB (0, 238, 0) }, | |
345 {"green3" , PALETTERGB (0, 205, 0) }, | |
346 {"green4" , PALETTERGB (0, 139, 0) }, | |
347 {"chartreuse1" , PALETTERGB (127, 255, 0) }, | |
348 {"chartreuse2" , PALETTERGB (118, 238, 0) }, | |
349 {"chartreuse3" , PALETTERGB (102, 205, 0) }, | |
350 {"chartreuse4" , PALETTERGB (69, 139, 0) }, | |
351 {"OliveDrab1" , PALETTERGB (192, 255, 62) }, | |
352 {"OliveDrab2" , PALETTERGB (179, 238, 58) }, | |
353 {"OliveDrab3" , PALETTERGB (154, 205, 50) }, | |
354 {"OliveDrab4" , PALETTERGB (105, 139, 34) }, | |
355 {"DarkOliveGreen1" , PALETTERGB (202, 255, 112) }, | |
356 {"DarkOliveGreen2" , PALETTERGB (188, 238, 104) }, | |
357 {"DarkOliveGreen3" , PALETTERGB (162, 205, 90) }, | |
358 {"DarkOliveGreen4" , PALETTERGB (110, 139, 61) }, | |
359 {"khaki1" , PALETTERGB (255, 246, 143) }, | |
360 {"khaki2" , PALETTERGB (238, 230, 133) }, | |
361 {"khaki3" , PALETTERGB (205, 198, 115) }, | |
362 {"khaki4" , PALETTERGB (139, 134, 78) }, | |
363 {"LightGoldenrod1" , PALETTERGB (255, 236, 139) }, | |
364 {"LightGoldenrod2" , PALETTERGB (238, 220, 130) }, | |
365 {"LightGoldenrod3" , PALETTERGB (205, 190, 112) }, | |
366 {"LightGoldenrod4" , PALETTERGB (139, 129, 76) }, | |
367 {"LightYellow1" , PALETTERGB (255, 255, 224) }, | |
368 {"LightYellow2" , PALETTERGB (238, 238, 209) }, | |
369 {"LightYellow3" , PALETTERGB (205, 205, 180) }, | |
370 {"LightYellow4" , PALETTERGB (139, 139, 122) }, | |
371 {"yellow1" , PALETTERGB (255, 255, 0) }, | |
372 {"yellow2" , PALETTERGB (238, 238, 0) }, | |
373 {"yellow3" , PALETTERGB (205, 205, 0) }, | |
374 {"yellow4" , PALETTERGB (139, 139, 0) }, | |
375 {"gold1" , PALETTERGB (255, 215, 0) }, | |
376 {"gold2" , PALETTERGB (238, 201, 0) }, | |
377 {"gold3" , PALETTERGB (205, 173, 0) }, | |
378 {"gold4" , PALETTERGB (139, 117, 0) }, | |
379 {"goldenrod1" , PALETTERGB (255, 193, 37) }, | |
380 {"goldenrod2" , PALETTERGB (238, 180, 34) }, | |
381 {"goldenrod3" , PALETTERGB (205, 155, 29) }, | |
382 {"goldenrod4" , PALETTERGB (139, 105, 20) }, | |
383 {"DarkGoldenrod1" , PALETTERGB (255, 185, 15) }, | |
384 {"DarkGoldenrod2" , PALETTERGB (238, 173, 14) }, | |
385 {"DarkGoldenrod3" , PALETTERGB (205, 149, 12) }, | |
386 {"DarkGoldenrod4" , PALETTERGB (139, 101, 8) }, | |
387 {"RosyBrown1" , PALETTERGB (255, 193, 193) }, | |
388 {"RosyBrown2" , PALETTERGB (238, 180, 180) }, | |
389 {"RosyBrown3" , PALETTERGB (205, 155, 155) }, | |
390 {"RosyBrown4" , PALETTERGB (139, 105, 105) }, | |
391 {"IndianRed1" , PALETTERGB (255, 106, 106) }, | |
392 {"IndianRed2" , PALETTERGB (238, 99, 99) }, | |
393 {"IndianRed3" , PALETTERGB (205, 85, 85) }, | |
394 {"IndianRed4" , PALETTERGB (139, 58, 58) }, | |
395 {"sienna1" , PALETTERGB (255, 130, 71) }, | |
396 {"sienna2" , PALETTERGB (238, 121, 66) }, | |
397 {"sienna3" , PALETTERGB (205, 104, 57) }, | |
398 {"sienna4" , PALETTERGB (139, 71, 38) }, | |
399 {"burlywood1" , PALETTERGB (255, 211, 155) }, | |
400 {"burlywood2" , PALETTERGB (238, 197, 145) }, | |
401 {"burlywood3" , PALETTERGB (205, 170, 125) }, | |
402 {"burlywood4" , PALETTERGB (139, 115, 85) }, | |
403 {"wheat1" , PALETTERGB (255, 231, 186) }, | |
404 {"wheat2" , PALETTERGB (238, 216, 174) }, | |
405 {"wheat3" , PALETTERGB (205, 186, 150) }, | |
406 {"wheat4" , PALETTERGB (139, 126, 102) }, | |
407 {"tan1" , PALETTERGB (255, 165, 79) }, | |
408 {"tan2" , PALETTERGB (238, 154, 73) }, | |
409 {"tan3" , PALETTERGB (205, 133, 63) }, | |
410 {"tan4" , PALETTERGB (139, 90, 43) }, | |
411 {"chocolate1" , PALETTERGB (255, 127, 36) }, | |
412 {"chocolate2" , PALETTERGB (238, 118, 33) }, | |
413 {"chocolate3" , PALETTERGB (205, 102, 29) }, | |
414 {"chocolate4" , PALETTERGB (139, 69, 19) }, | |
415 {"firebrick1" , PALETTERGB (255, 48, 48) }, | |
416 {"firebrick2" , PALETTERGB (238, 44, 44) }, | |
417 {"firebrick3" , PALETTERGB (205, 38, 38) }, | |
418 {"firebrick4" , PALETTERGB (139, 26, 26) }, | |
419 {"brown1" , PALETTERGB (255, 64, 64) }, | |
420 {"brown2" , PALETTERGB (238, 59, 59) }, | |
421 {"brown3" , PALETTERGB (205, 51, 51) }, | |
422 {"brown4" , PALETTERGB (139, 35, 35) }, | |
423 {"salmon1" , PALETTERGB (255, 140, 105) }, | |
424 {"salmon2" , PALETTERGB (238, 130, 98) }, | |
425 {"salmon3" , PALETTERGB (205, 112, 84) }, | |
426 {"salmon4" , PALETTERGB (139, 76, 57) }, | |
427 {"LightSalmon1" , PALETTERGB (255, 160, 122) }, | |
428 {"LightSalmon2" , PALETTERGB (238, 149, 114) }, | |
429 {"LightSalmon3" , PALETTERGB (205, 129, 98) }, | |
430 {"LightSalmon4" , PALETTERGB (139, 87, 66) }, | |
431 {"orange1" , PALETTERGB (255, 165, 0) }, | |
432 {"orange2" , PALETTERGB (238, 154, 0) }, | |
433 {"orange3" , PALETTERGB (205, 133, 0) }, | |
434 {"orange4" , PALETTERGB (139, 90, 0) }, | |
435 {"DarkOrange1" , PALETTERGB (255, 127, 0) }, | |
436 {"DarkOrange2" , PALETTERGB (238, 118, 0) }, | |
437 {"DarkOrange3" , PALETTERGB (205, 102, 0) }, | |
438 {"DarkOrange4" , PALETTERGB (139, 69, 0) }, | |
439 {"coral1" , PALETTERGB (255, 114, 86) }, | |
440 {"coral2" , PALETTERGB (238, 106, 80) }, | |
441 {"coral3" , PALETTERGB (205, 91, 69) }, | |
442 {"coral4" , PALETTERGB (139, 62, 47) }, | |
443 {"tomato1" , PALETTERGB (255, 99, 71) }, | |
444 {"tomato2" , PALETTERGB (238, 92, 66) }, | |
445 {"tomato3" , PALETTERGB (205, 79, 57) }, | |
446 {"tomato4" , PALETTERGB (139, 54, 38) }, | |
447 {"OrangeRed1" , PALETTERGB (255, 69, 0) }, | |
448 {"OrangeRed2" , PALETTERGB (238, 64, 0) }, | |
449 {"OrangeRed3" , PALETTERGB (205, 55, 0) }, | |
450 {"OrangeRed4" , PALETTERGB (139, 37, 0) }, | |
451 {"red1" , PALETTERGB (255, 0, 0) }, | |
452 {"red2" , PALETTERGB (238, 0, 0) }, | |
453 {"red3" , PALETTERGB (205, 0, 0) }, | |
454 {"red4" , PALETTERGB (139, 0, 0) }, | |
455 {"DeepPink1" , PALETTERGB (255, 20, 147) }, | |
456 {"DeepPink2" , PALETTERGB (238, 18, 137) }, | |
457 {"DeepPink3" , PALETTERGB (205, 16, 118) }, | |
458 {"DeepPink4" , PALETTERGB (139, 10, 80) }, | |
459 {"HotPink1" , PALETTERGB (255, 110, 180) }, | |
460 {"HotPink2" , PALETTERGB (238, 106, 167) }, | |
461 {"HotPink3" , PALETTERGB (205, 96, 144) }, | |
462 {"HotPink4" , PALETTERGB (139, 58, 98) }, | |
463 {"pink1" , PALETTERGB (255, 181, 197) }, | |
464 {"pink2" , PALETTERGB (238, 169, 184) }, | |
465 {"pink3" , PALETTERGB (205, 145, 158) }, | |
466 {"pink4" , PALETTERGB (139, 99, 108) }, | |
467 {"LightPink1" , PALETTERGB (255, 174, 185) }, | |
468 {"LightPink2" , PALETTERGB (238, 162, 173) }, | |
469 {"LightPink3" , PALETTERGB (205, 140, 149) }, | |
470 {"LightPink4" , PALETTERGB (139, 95, 101) }, | |
471 {"PaleVioletRed1" , PALETTERGB (255, 130, 171) }, | |
472 {"PaleVioletRed2" , PALETTERGB (238, 121, 159) }, | |
473 {"PaleVioletRed3" , PALETTERGB (205, 104, 137) }, | |
474 {"PaleVioletRed4" , PALETTERGB (139, 71, 93) }, | |
475 {"maroon1" , PALETTERGB (255, 52, 179) }, | |
476 {"maroon2" , PALETTERGB (238, 48, 167) }, | |
477 {"maroon3" , PALETTERGB (205, 41, 144) }, | |
478 {"maroon4" , PALETTERGB (139, 28, 98) }, | |
479 {"VioletRed1" , PALETTERGB (255, 62, 150) }, | |
480 {"VioletRed2" , PALETTERGB (238, 58, 140) }, | |
481 {"VioletRed3" , PALETTERGB (205, 50, 120) }, | |
482 {"VioletRed4" , PALETTERGB (139, 34, 82) }, | |
483 {"magenta1" , PALETTERGB (255, 0, 255) }, | |
484 {"magenta2" , PALETTERGB (238, 0, 238) }, | |
485 {"magenta3" , PALETTERGB (205, 0, 205) }, | |
486 {"magenta4" , PALETTERGB (139, 0, 139) }, | |
487 {"orchid1" , PALETTERGB (255, 131, 250) }, | |
488 {"orchid2" , PALETTERGB (238, 122, 233) }, | |
489 {"orchid3" , PALETTERGB (205, 105, 201) }, | |
490 {"orchid4" , PALETTERGB (139, 71, 137) }, | |
491 {"plum1" , PALETTERGB (255, 187, 255) }, | |
492 {"plum2" , PALETTERGB (238, 174, 238) }, | |
493 {"plum3" , PALETTERGB (205, 150, 205) }, | |
494 {"plum4" , PALETTERGB (139, 102, 139) }, | |
495 {"MediumOrchid1" , PALETTERGB (224, 102, 255) }, | |
496 {"MediumOrchid2" , PALETTERGB (209, 95, 238) }, | |
497 {"MediumOrchid3" , PALETTERGB (180, 82, 205) }, | |
498 {"MediumOrchid4" , PALETTERGB (122, 55, 139) }, | |
499 {"DarkOrchid1" , PALETTERGB (191, 62, 255) }, | |
500 {"DarkOrchid2" , PALETTERGB (178, 58, 238) }, | |
501 {"DarkOrchid3" , PALETTERGB (154, 50, 205) }, | |
502 {"DarkOrchid4" , PALETTERGB (104, 34, 139) }, | |
503 {"purple1" , PALETTERGB (155, 48, 255) }, | |
504 {"purple2" , PALETTERGB (145, 44, 238) }, | |
505 {"purple3" , PALETTERGB (125, 38, 205) }, | |
506 {"purple4" , PALETTERGB (85, 26, 139) }, | |
507 {"MediumPurple1" , PALETTERGB (171, 130, 255) }, | |
508 {"MediumPurple2" , PALETTERGB (159, 121, 238) }, | |
509 {"MediumPurple3" , PALETTERGB (137, 104, 205) }, | |
510 {"MediumPurple4" , PALETTERGB (93, 71, 139) }, | |
511 {"thistle1" , PALETTERGB (255, 225, 255) }, | |
512 {"thistle2" , PALETTERGB (238, 210, 238) }, | |
513 {"thistle3" , PALETTERGB (205, 181, 205) }, | |
514 {"thistle4" , PALETTERGB (139, 123, 139) }, | |
515 {"gray0" , PALETTERGB (0, 0, 0) }, | |
516 {"grey0" , PALETTERGB (0, 0, 0) }, | |
517 {"gray1" , PALETTERGB (3, 3, 3) }, | |
518 {"grey1" , PALETTERGB (3, 3, 3) }, | |
519 {"gray2" , PALETTERGB (5, 5, 5) }, | |
520 {"grey2" , PALETTERGB (5, 5, 5) }, | |
521 {"gray3" , PALETTERGB (8, 8, 8) }, | |
522 {"grey3" , PALETTERGB (8, 8, 8) }, | |
523 {"gray4" , PALETTERGB (10, 10, 10) }, | |
524 {"grey4" , PALETTERGB (10, 10, 10) }, | |
525 {"gray5" , PALETTERGB (13, 13, 13) }, | |
526 {"grey5" , PALETTERGB (13, 13, 13) }, | |
527 {"gray6" , PALETTERGB (15, 15, 15) }, | |
528 {"grey6" , PALETTERGB (15, 15, 15) }, | |
529 {"gray7" , PALETTERGB (18, 18, 18) }, | |
530 {"grey7" , PALETTERGB (18, 18, 18) }, | |
531 {"gray8" , PALETTERGB (20, 20, 20) }, | |
532 {"grey8" , PALETTERGB (20, 20, 20) }, | |
533 {"gray9" , PALETTERGB (23, 23, 23) }, | |
534 {"grey9" , PALETTERGB (23, 23, 23) }, | |
535 {"gray10" , PALETTERGB (26, 26, 26) }, | |
536 {"grey10" , PALETTERGB (26, 26, 26) }, | |
537 {"gray11" , PALETTERGB (28, 28, 28) }, | |
538 {"grey11" , PALETTERGB (28, 28, 28) }, | |
539 {"gray12" , PALETTERGB (31, 31, 31) }, | |
540 {"grey12" , PALETTERGB (31, 31, 31) }, | |
541 {"gray13" , PALETTERGB (33, 33, 33) }, | |
542 {"grey13" , PALETTERGB (33, 33, 33) }, | |
543 {"gray14" , PALETTERGB (36, 36, 36) }, | |
544 {"grey14" , PALETTERGB (36, 36, 36) }, | |
545 {"gray15" , PALETTERGB (38, 38, 38) }, | |
546 {"grey15" , PALETTERGB (38, 38, 38) }, | |
547 {"gray16" , PALETTERGB (41, 41, 41) }, | |
548 {"grey16" , PALETTERGB (41, 41, 41) }, | |
549 {"gray17" , PALETTERGB (43, 43, 43) }, | |
550 {"grey17" , PALETTERGB (43, 43, 43) }, | |
551 {"gray18" , PALETTERGB (46, 46, 46) }, | |
552 {"grey18" , PALETTERGB (46, 46, 46) }, | |
553 {"gray19" , PALETTERGB (48, 48, 48) }, | |
554 {"grey19" , PALETTERGB (48, 48, 48) }, | |
555 {"gray20" , PALETTERGB (51, 51, 51) }, | |
556 {"grey20" , PALETTERGB (51, 51, 51) }, | |
557 {"gray21" , PALETTERGB (54, 54, 54) }, | |
558 {"grey21" , PALETTERGB (54, 54, 54) }, | |
559 {"gray22" , PALETTERGB (56, 56, 56) }, | |
560 {"grey22" , PALETTERGB (56, 56, 56) }, | |
561 {"gray23" , PALETTERGB (59, 59, 59) }, | |
562 {"grey23" , PALETTERGB (59, 59, 59) }, | |
563 {"gray24" , PALETTERGB (61, 61, 61) }, | |
564 {"grey24" , PALETTERGB (61, 61, 61) }, | |
565 {"gray25" , PALETTERGB (64, 64, 64) }, | |
566 {"grey25" , PALETTERGB (64, 64, 64) }, | |
567 {"gray26" , PALETTERGB (66, 66, 66) }, | |
568 {"grey26" , PALETTERGB (66, 66, 66) }, | |
569 {"gray27" , PALETTERGB (69, 69, 69) }, | |
570 {"grey27" , PALETTERGB (69, 69, 69) }, | |
571 {"gray28" , PALETTERGB (71, 71, 71) }, | |
572 {"grey28" , PALETTERGB (71, 71, 71) }, | |
573 {"gray29" , PALETTERGB (74, 74, 74) }, | |
574 {"grey29" , PALETTERGB (74, 74, 74) }, | |
575 {"gray30" , PALETTERGB (77, 77, 77) }, | |
576 {"grey30" , PALETTERGB (77, 77, 77) }, | |
577 {"gray31" , PALETTERGB (79, 79, 79) }, | |
578 {"grey31" , PALETTERGB (79, 79, 79) }, | |
579 {"gray32" , PALETTERGB (82, 82, 82) }, | |
580 {"grey32" , PALETTERGB (82, 82, 82) }, | |
581 {"gray33" , PALETTERGB (84, 84, 84) }, | |
582 {"grey33" , PALETTERGB (84, 84, 84) }, | |
583 {"gray34" , PALETTERGB (87, 87, 87) }, | |
584 {"grey34" , PALETTERGB (87, 87, 87) }, | |
585 {"gray35" , PALETTERGB (89, 89, 89) }, | |
586 {"grey35" , PALETTERGB (89, 89, 89) }, | |
587 {"gray36" , PALETTERGB (92, 92, 92) }, | |
588 {"grey36" , PALETTERGB (92, 92, 92) }, | |
589 {"gray37" , PALETTERGB (94, 94, 94) }, | |
590 {"grey37" , PALETTERGB (94, 94, 94) }, | |
591 {"gray38" , PALETTERGB (97, 97, 97) }, | |
592 {"grey38" , PALETTERGB (97, 97, 97) }, | |
593 {"gray39" , PALETTERGB (99, 99, 99) }, | |
594 {"grey39" , PALETTERGB (99, 99, 99) }, | |
595 {"gray40" , PALETTERGB (102, 102, 102) }, | |
596 {"grey40" , PALETTERGB (102, 102, 102) }, | |
597 {"gray41" , PALETTERGB (105, 105, 105) }, | |
598 {"grey41" , PALETTERGB (105, 105, 105) }, | |
599 {"gray42" , PALETTERGB (107, 107, 107) }, | |
600 {"grey42" , PALETTERGB (107, 107, 107) }, | |
601 {"gray43" , PALETTERGB (110, 110, 110) }, | |
602 {"grey43" , PALETTERGB (110, 110, 110) }, | |
603 {"gray44" , PALETTERGB (112, 112, 112) }, | |
604 {"grey44" , PALETTERGB (112, 112, 112) }, | |
605 {"gray45" , PALETTERGB (115, 115, 115) }, | |
606 {"grey45" , PALETTERGB (115, 115, 115) }, | |
607 {"gray46" , PALETTERGB (117, 117, 117) }, | |
608 {"grey46" , PALETTERGB (117, 117, 117) }, | |
609 {"gray47" , PALETTERGB (120, 120, 120) }, | |
610 {"grey47" , PALETTERGB (120, 120, 120) }, | |
611 {"gray48" , PALETTERGB (122, 122, 122) }, | |
612 {"grey48" , PALETTERGB (122, 122, 122) }, | |
613 {"gray49" , PALETTERGB (125, 125, 125) }, | |
614 {"grey49" , PALETTERGB (125, 125, 125) }, | |
615 {"gray50" , PALETTERGB (128, 128, 128) }, /* Adjusted */ | |
616 {"grey50" , PALETTERGB (128, 128, 128) }, /* Adjusted */ | |
617 {"gray51" , PALETTERGB (130, 130, 130) }, | |
618 {"grey51" , PALETTERGB (130, 130, 130) }, | |
619 {"gray52" , PALETTERGB (133, 133, 133) }, | |
620 {"grey52" , PALETTERGB (133, 133, 133) }, | |
621 {"gray53" , PALETTERGB (135, 135, 135) }, | |
622 {"grey53" , PALETTERGB (135, 135, 135) }, | |
623 {"gray54" , PALETTERGB (138, 138, 138) }, | |
624 {"grey54" , PALETTERGB (138, 138, 138) }, | |
625 {"gray55" , PALETTERGB (140, 140, 140) }, | |
626 {"grey55" , PALETTERGB (140, 140, 140) }, | |
627 {"gray56" , PALETTERGB (143, 143, 143) }, | |
628 {"grey56" , PALETTERGB (143, 143, 143) }, | |
629 {"gray57" , PALETTERGB (145, 145, 145) }, | |
630 {"grey57" , PALETTERGB (145, 145, 145) }, | |
631 {"gray58" , PALETTERGB (148, 148, 148) }, | |
632 {"grey58" , PALETTERGB (148, 148, 148) }, | |
633 {"gray59" , PALETTERGB (150, 150, 150) }, | |
634 {"grey59" , PALETTERGB (150, 150, 150) }, | |
635 {"gray60" , PALETTERGB (153, 153, 153) }, | |
636 {"grey60" , PALETTERGB (153, 153, 153) }, | |
637 {"gray61" , PALETTERGB (156, 156, 156) }, | |
638 {"grey61" , PALETTERGB (156, 156, 156) }, | |
639 {"gray62" , PALETTERGB (158, 158, 158) }, | |
640 {"grey62" , PALETTERGB (158, 158, 158) }, | |
641 {"gray63" , PALETTERGB (161, 161, 161) }, | |
642 {"grey63" , PALETTERGB (161, 161, 161) }, | |
643 {"gray64" , PALETTERGB (163, 163, 163) }, | |
644 {"grey64" , PALETTERGB (163, 163, 163) }, | |
645 {"gray65" , PALETTERGB (166, 166, 166) }, | |
646 {"grey65" , PALETTERGB (166, 166, 166) }, | |
647 {"gray66" , PALETTERGB (168, 168, 168) }, | |
648 {"grey66" , PALETTERGB (168, 168, 168) }, | |
649 {"gray67" , PALETTERGB (171, 171, 171) }, | |
650 {"grey67" , PALETTERGB (171, 171, 171) }, | |
651 {"gray68" , PALETTERGB (173, 173, 173) }, | |
652 {"grey68" , PALETTERGB (173, 173, 173) }, | |
653 {"gray69" , PALETTERGB (176, 176, 176) }, | |
654 {"grey69" , PALETTERGB (176, 176, 176) }, | |
655 {"gray70" , PALETTERGB (179, 179, 179) }, | |
656 {"grey70" , PALETTERGB (179, 179, 179) }, | |
657 {"gray71" , PALETTERGB (181, 181, 181) }, | |
658 {"grey71" , PALETTERGB (181, 181, 181) }, | |
659 {"gray72" , PALETTERGB (184, 184, 184) }, | |
660 {"grey72" , PALETTERGB (184, 184, 184) }, | |
661 {"gray73" , PALETTERGB (186, 186, 186) }, | |
662 {"grey73" , PALETTERGB (186, 186, 186) }, | |
663 {"gray74" , PALETTERGB (189, 189, 189) }, | |
664 {"grey74" , PALETTERGB (189, 189, 189) }, | |
665 {"gray75" , PALETTERGB (192, 192, 192) }, /* Adjusted */ | |
666 {"grey75" , PALETTERGB (192, 192, 192) }, /* Adjusted */ | |
667 {"gray76" , PALETTERGB (194, 194, 194) }, | |
668 {"grey76" , PALETTERGB (194, 194, 194) }, | |
669 {"gray77" , PALETTERGB (196, 196, 196) }, | |
670 {"grey77" , PALETTERGB (196, 196, 196) }, | |
671 {"gray78" , PALETTERGB (199, 199, 199) }, | |
672 {"grey78" , PALETTERGB (199, 199, 199) }, | |
673 {"gray79" , PALETTERGB (201, 201, 201) }, | |
674 {"grey79" , PALETTERGB (201, 201, 201) }, | |
675 {"gray80" , PALETTERGB (204, 204, 204) }, | |
676 {"grey80" , PALETTERGB (204, 204, 204) }, | |
677 {"gray81" , PALETTERGB (207, 207, 207) }, | |
678 {"grey81" , PALETTERGB (207, 207, 207) }, | |
679 {"gray82" , PALETTERGB (209, 209, 209) }, | |
680 {"grey82" , PALETTERGB (209, 209, 209) }, | |
681 {"gray83" , PALETTERGB (212, 212, 212) }, | |
682 {"grey83" , PALETTERGB (212, 212, 212) }, | |
683 {"gray84" , PALETTERGB (214, 214, 214) }, | |
684 {"grey84" , PALETTERGB (214, 214, 214) }, | |
685 {"gray85" , PALETTERGB (217, 217, 217) }, | |
686 {"grey85" , PALETTERGB (217, 217, 217) }, | |
687 {"gray86" , PALETTERGB (219, 219, 219) }, | |
688 {"grey86" , PALETTERGB (219, 219, 219) }, | |
689 {"gray87" , PALETTERGB (222, 222, 222) }, | |
690 {"grey87" , PALETTERGB (222, 222, 222) }, | |
691 {"gray88" , PALETTERGB (224, 224, 224) }, | |
692 {"grey88" , PALETTERGB (224, 224, 224) }, | |
693 {"gray89" , PALETTERGB (227, 227, 227) }, | |
694 {"grey89" , PALETTERGB (227, 227, 227) }, | |
695 {"gray90" , PALETTERGB (229, 229, 229) }, | |
696 {"grey90" , PALETTERGB (229, 229, 229) }, | |
697 {"gray91" , PALETTERGB (232, 232, 232) }, | |
698 {"grey91" , PALETTERGB (232, 232, 232) }, | |
699 {"gray92" , PALETTERGB (235, 235, 235) }, | |
700 {"grey92" , PALETTERGB (235, 235, 235) }, | |
701 {"gray93" , PALETTERGB (237, 237, 237) }, | |
702 {"grey93" , PALETTERGB (237, 237, 237) }, | |
703 {"gray94" , PALETTERGB (240, 240, 240) }, | |
704 {"grey94" , PALETTERGB (240, 240, 240) }, | |
705 {"gray95" , PALETTERGB (242, 242, 242) }, | |
706 {"grey95" , PALETTERGB (242, 242, 242) }, | |
707 {"gray96" , PALETTERGB (245, 245, 245) }, | |
708 {"grey96" , PALETTERGB (245, 245, 245) }, | |
709 {"gray97" , PALETTERGB (247, 247, 247) }, | |
710 {"grey97" , PALETTERGB (247, 247, 247) }, | |
711 {"gray98" , PALETTERGB (250, 250, 250) }, | |
712 {"grey98" , PALETTERGB (250, 250, 250) }, | |
713 {"gray99" , PALETTERGB (252, 252, 252) }, | |
714 {"grey99" , PALETTERGB (252, 252, 252) }, | |
715 {"gray100" , PALETTERGB (255, 255, 255) }, | |
716 {"grey100" , PALETTERGB (255, 255, 255) }, | |
717 {"DarkGrey" , PALETTERGB (169, 169, 169) }, | |
718 {"DarkGray" , PALETTERGB (169, 169, 169) }, | |
719 {"DarkBlue" , PALETTERGB (0, 0, 128) }, /* Adjusted == Navy */ | |
720 {"DarkCyan" , PALETTERGB (0, 128, 128) }, /* Adjusted */ | |
721 {"DarkMagenta" , PALETTERGB (128, 0, 128) }, /* Adjusted */ | |
722 {"DarkRed" , PALETTERGB (128, 0, 0) }, /* Adjusted */ | |
723 {"LightGreen" , PALETTERGB (144, 238, 144) }, | |
724 /* Added to match values in the default Windows palette: */ | |
725 {"DarkYellow" , PALETTERGB (128, 128, 0) }, | |
726 {"PaleYellow" , PALETTERGB (255, 255, 128) } | |
428 | 727 }; |
728 | |
729 | |
442 | 730 typedef struct fontmap_t |
428 | 731 { |
2367 | 732 const Ascbyte *name; |
442 | 733 int value; |
428 | 734 } fontmap_t; |
735 | |
736 /* Default weight first, preferred names listed before synonyms */ | |
442 | 737 static const fontmap_t fontweight_map[] = |
428 | 738 { |
739 {"Regular" , FW_REGULAR}, /* The standard font weight */ | |
740 {"Thin" , FW_THIN}, | |
741 {"Extra Light" , FW_EXTRALIGHT}, | |
742 {"Ultra Light" , FW_ULTRALIGHT}, | |
743 {"Light" , FW_LIGHT}, | |
744 {"Normal" , FW_NORMAL}, | |
745 {"Medium" , FW_MEDIUM}, | |
746 {"Semi Bold" , FW_SEMIBOLD}, | |
747 {"Demi Bold" , FW_DEMIBOLD}, | |
748 {"Bold" , FW_BOLD}, /* The standard bold font weight */ | |
749 {"Extra Bold" , FW_EXTRABOLD}, | |
750 {"Ultra Bold" , FW_ULTRABOLD}, | |
751 {"Heavy" , FW_HEAVY}, | |
752 {"Black" , FW_BLACK} | |
753 }; | |
754 | |
872 | 755 /* Default charset must be listed first, no synonyms allowed because these |
756 * names are matched against the names reported by win32 by match_font() */ | |
442 | 757 static const fontmap_t charset_map[] = |
428 | 758 { |
771 | 759 {"Western" , ANSI_CHARSET}, /* Latin 1 */ |
760 {"Central European" , EASTEUROPE_CHARSET}, | |
761 {"Cyrillic" , RUSSIAN_CHARSET}, | |
428 | 762 {"Greek" , GREEK_CHARSET}, |
763 {"Turkish" , TURKISH_CHARSET}, | |
771 | 764 {"Hebrew" , HEBREW_CHARSET}, |
765 {"Arabic" , ARABIC_CHARSET}, | |
766 {"Baltic" , BALTIC_CHARSET}, | |
767 {"Viet Nam" , VIETNAMESE_CHARSET}, | |
768 {"Thai" , THAI_CHARSET}, | |
769 {"Japanese" , SHIFTJIS_CHARSET}, | |
770 {"Korean" , HANGEUL_CHARSET}, | |
771 {"Simplified Chinese" , GB2312_CHARSET}, | |
772 {"Traditional Chinese", CHINESEBIG5_CHARSET}, | |
773 | |
774 {"Symbol" , SYMBOL_CHARSET}, | |
428 | 775 {"Mac" , MAC_CHARSET}, |
771 | 776 {"Korean Johab" , JOHAB_CHARSET}, |
428 | 777 {"OEM/DOS" , OEM_CHARSET} |
778 }; | |
779 | |
788 | 780 #ifdef MULE |
781 | |
782 typedef struct unicode_subrange_raw_t | |
783 { | |
784 int subrange_bit; | |
785 int start; /* first Unicode codepoint */ | |
786 int end; /* last Unicode codepoint */ | |
787 } unicode_subrange_raw_t; | |
788 | |
789 /* This table comes from MSDN, Unicode Subset Bitfields [Platform SDK | |
790 Documentation, Base Services, International Features, Unicode and | |
791 Character Sets, Unicode and Character Set Reference, Unicode and | |
792 Character Set Constants]. We preprocess it at startup time into an | |
793 array of unicode_subrange_t. | |
794 */ | |
795 | |
796 static const unicode_subrange_raw_t unicode_subrange_raw_map[] = | |
797 { | |
798 {0, 0x0020, 0x007e}, /* Basic Latin */ | |
799 {1, 0x00a0, 0x00ff}, /* Latin-1 Supplement */ | |
800 {2, 0x0100, 0x017f}, /* Latin Extended-A */ | |
801 {3, 0x0180, 0x024f}, /* Latin Extended-B */ | |
802 {4, 0x0250, 0x02af}, /* IPA Extensions */ | |
803 {5, 0x02b0, 0x02ff}, /* Spacing Modifier Letters */ | |
804 {6, 0x0300, 0x036f}, /* Combining Diacritical Marks */ | |
805 {7, 0x0370, 0x03ff}, /* Basic Greek */ | |
806 /* 8 Reserved */ | |
807 {9, 0x0400, 0x04ff}, /* Cyrillic */ | |
808 {10, 0x0530, 0x058f}, /* Armenian */ | |
809 {11, 0x0590, 0x05ff}, /* Basic Hebrew */ | |
810 /* 12 Reserved */ | |
811 {13, 0x0600, 0x06ff}, /* Basic Arabic */ | |
812 /* 14 Reserved */ | |
813 {15, 0x0900, 0x097f}, /* Devanagari */ | |
814 {16, 0x0980, 0x09ff}, /* Bengali */ | |
815 {17, 0x0a00, 0x0a7f}, /* Gurmukhi */ | |
816 {18, 0x0a80, 0x0aff}, /* Gujarati */ | |
817 {19, 0x0b00, 0x0b7f}, /* Oriya */ | |
818 {20, 0x0b80, 0x0bff}, /* Tamil */ | |
819 {21, 0x0c00, 0x0c7f}, /* Telugu */ | |
820 {22, 0x0c80, 0x0cff}, /* Kannada */ | |
821 {23, 0x0d00, 0x0d7f}, /* Malayalam */ | |
822 {24, 0x0e00, 0x0e7f}, /* Thai */ | |
823 {25, 0x0e80, 0x0eff}, /* Lao */ | |
824 {26, 0x10a0, 0x10ff}, /* Basic Georgian */ | |
825 /* 27 Reserved */ | |
826 {28, 0x1100, 0x11ff}, /* Hangul Jamo */ | |
827 {29, 0x1e00, 0x1eff}, /* Latin Extended Additional */ | |
828 {30, 0x1f00, 0x1fff}, /* Greek Extended */ | |
829 {31, 0x2000, 0x206f}, /* General Punctuation */ | |
830 {32, 0x2070, 0x209f}, /* Subscripts and Superscripts */ | |
831 {33, 0x20a0, 0x20cf}, /* Currency Symbols */ | |
832 {34, 0x20d0, 0x20ff}, /* Combining Diacritical Marks for Symbols */ | |
833 {35, 0x2100, 0x214f}, /* Letter-like Symbols */ | |
834 {36, 0x2150, 0x218f}, /* Number Forms */ | |
835 {37, 0x2190, 0x21ff}, /* Arrows */ | |
836 {38, 0x2200, 0x22ff}, /* Mathematical Operators */ | |
837 {39, 0x2300, 0x23ff}, /* Miscellaneous Technical */ | |
838 {40, 0x2400, 0x243f}, /* Control Pictures */ | |
839 {41, 0x2440, 0x245f}, /* Optical Character Recognition */ | |
840 {42, 0x2460, 0x24ff}, /* Enclosed Alphanumerics */ | |
841 {43, 0x2500, 0x257f}, /* Box Drawing */ | |
842 {44, 0x2580, 0x259f}, /* Block Elements */ | |
843 {45, 0x25a0, 0x25ff}, /* Geometric Shapes */ | |
844 {46, 0x2600, 0x26ff}, /* Miscellaneous Symbols */ | |
845 {47, 0x2700, 0x27bf}, /* Dingbats */ | |
846 {48, 0x3000, 0x303f}, /* Chinese, Japanese, and Korean (CJK) Symbols and Punctuation */ | |
847 {49, 0x3040, 0x309f}, /* Hiragana */ | |
848 {50, 0x30a0, 0x30ff}, /* Katakana */ | |
849 {51, 0x3100, 0x312f}, /* Bopomofo */ | |
850 {51, 0x31a0, 0x31bf}, /* Extended Bopomofo */ | |
851 {52, 0x3130, 0x318f}, /* Hangul Compatibility Jamo */ | |
852 {53, 0x3190, 0x319f}, /* CJK Miscellaneous */ | |
853 {54, 0x3200, 0x32ff}, /* Enclosed CJK Letters and Months */ | |
854 {55, 0x3300, 0x33ff}, /* CJK Compatibility */ | |
855 {56, 0xac00, 0xd7a3}, /* Hangul */ | |
856 {57, 0xd800, 0xdfff}, /* Surrogates. Note that setting this bit implies that there is at least one codepoint beyond the Basic Multilingual Plane that is supported by this font. */ | |
857 /* 58 Reserved */ | |
858 {59, 0x4e00, 0x9fff}, /* CJK Unified Ideographs */ | |
859 {59, 0x2e80, 0x2eff}, /* CJK Radicals Supplement */ | |
860 {59, 0x2f00, 0x2fdf}, /* Kangxi Radicals */ | |
861 {59, 0x2ff0, 0x2fff}, /* Ideographic Description */ | |
862 {59, 0x3400, 0x4dbf}, /* CJK Unified Ideograph Extension A */ | |
863 {60, 0xe000, 0xf8ff}, /* Private Use Area */ | |
864 {61, 0xf900, 0xfaff}, /* CJK Compatibility Ideographs */ | |
865 {62, 0xfb00, 0xfb4f}, /* Alphabetic Presentation Forms */ | |
866 {63, 0xfb50, 0xfdff}, /* Arabic Presentation Forms-A */ | |
867 {64, 0xfe20, 0xfe2f}, /* Combining Half Marks */ | |
868 {65, 0xfe30, 0xfe4f}, /* CJK Compatibility Forms */ | |
869 {66, 0xfe50, 0xfe6f}, /* Small Form Variants */ | |
870 {67, 0xfe70, 0xfefe}, /* Arabic Presentation Forms-B */ | |
871 {68, 0xff00, 0xffef}, /* Halfwidth and Fullwidth Forms */ | |
872 {69, 0xfff0, 0xfffd}, /* Specials */ | |
873 {70, 0x0f00, 0x0fcf}, /* Tibetan */ | |
874 {71, 0x0700, 0x074f}, /* Syriac */ | |
875 {72, 0x0780, 0x07bf}, /* Thaana */ | |
876 {73, 0x0d80, 0x0dff}, /* Sinhala */ | |
877 {74, 0x1000, 0x109f}, /* Myanmar */ | |
878 {75, 0x1200, 0x12bf}, /* Ethiopic */ | |
879 {76, 0x13a0, 0x13ff}, /* Cherokee */ | |
880 {77, 0x1400, 0x14df}, /* Canadian Aboriginal Syllabics */ | |
881 {78, 0x1680, 0x169f}, /* Ogham */ | |
882 {79, 0x16a0, 0x16ff}, /* Runic */ | |
883 {80, 0x1780, 0x17ff}, /* Khmer */ | |
884 {81, 0x1800, 0x18af}, /* Mongolian */ | |
885 {82, 0x2800, 0x28ff}, /* Braille */ | |
886 {83, 0xa000, 0xa48c}, /* Yi, Yi Radicals */ | |
887 /* 84-122 Reserved */ | |
888 /* 123 Windows 2000/XP: Layout progress: horizontal from right to left */ | |
889 /* 124 Windows 2000/XP: Layout progress: vertical before horizontal */ | |
890 /* 125 Windows 2000/XP: Layout progress: vertical bottom to top */ | |
891 /* 126 Reserved; must be 0 */ | |
892 /* 127 Reserved; must be 1 */ | |
893 }; | |
894 | |
895 typedef struct unicode_subrange_t | |
896 { | |
897 int no_subranges; | |
898 const unicode_subrange_raw_t *subranges; | |
899 } unicode_subrange_t; | |
900 | |
901 unicode_subrange_t *unicode_subrange_table; | |
902 | |
903 /* Hash table mapping font specs (strings) to font signature data | |
904 (FONTSIGNATURE structures stored in opaques), as determined by | |
905 GetTextCharsetInfo(). I presume this is somewhat expensive because it | |
906 involves creating a font object. At the very least, with no hashing, it | |
907 definitely took awhile (a few seconds) when encountering characters from | |
908 charsets needing stage 2 processing. */ | |
909 Lisp_Object Vfont_signature_data; | |
910 | |
911 #endif /* MULE */ | |
912 | |
428 | 913 |
914 /************************************************************************/ | |
915 /* helpers */ | |
916 /************************************************************************/ | |
917 | |
918 static int | |
867 | 919 hexval (Ibyte c) |
428 | 920 { |
771 | 921 /* assumes ASCII and isxdigit (c) */ |
428 | 922 if (c >= 'a') |
771 | 923 return c - 'a' + 10; |
428 | 924 else if (c >= 'A') |
771 | 925 return c - 'A' + 10; |
428 | 926 else |
771 | 927 return c - '0'; |
428 | 928 } |
929 | |
930 COLORREF | |
867 | 931 mswindows_string_to_color (const Ibyte *name) |
428 | 932 { |
933 int i; | |
934 | |
935 if (*name == '#') | |
936 { | |
937 /* numeric names look like "#RRGGBB", "#RRRGGGBBB" or "#RRRRGGGGBBBB" | |
938 or "rgb:rrrr/gggg/bbbb" */ | |
939 unsigned int r, g, b; | |
442 | 940 |
771 | 941 for (i = 1; i < qxestrlen (name); i++) |
428 | 942 { |
826 | 943 if (!byte_ascii_p (name[i]) || !isxdigit ((int) name[i])) |
428 | 944 return (COLORREF) -1; |
945 } | |
771 | 946 if (qxestrlen (name) == 7) |
428 | 947 { |
948 r = hexval (name[1]) * 16 + hexval (name[2]); | |
949 g = hexval (name[3]) * 16 + hexval (name[4]); | |
950 b = hexval (name[5]) * 16 + hexval (name[6]); | |
951 return (PALETTERGB (r, g, b)); | |
952 } | |
771 | 953 else if (qxestrlen (name) == 10) |
428 | 954 { |
955 r = hexval (name[1]) * 16 + hexval (name[2]); | |
956 g = hexval (name[4]) * 16 + hexval (name[5]); | |
957 b = hexval (name[7]) * 16 + hexval (name[8]); | |
958 return (PALETTERGB (r, g, b)); | |
959 } | |
771 | 960 else if (qxestrlen (name) == 13) |
428 | 961 { |
962 r = hexval (name[1]) * 16 + hexval (name[2]); | |
963 g = hexval (name[5]) * 16 + hexval (name[6]); | |
964 b = hexval (name[9]) * 16 + hexval (name[10]); | |
965 return (PALETTERGB (r, g, b)); | |
966 } | |
967 } | |
2367 | 968 else if (!qxestrncmp_ascii (name, "rgb:", 4)) |
428 | 969 { |
771 | 970 unsigned int r, g, b; |
428 | 971 |
867 | 972 if (sscanf ((CIbyte *) name, "rgb:%04x/%04x/%04x", &r, &g, &b) == 3) |
428 | 973 { |
771 | 974 int len = qxestrlen (name); |
428 | 975 if (len == 18) |
976 { | |
977 r /= 257; | |
978 g /= 257; | |
979 b /= 257; | |
980 } | |
981 else if (len == 15) | |
982 { | |
983 r /= 17; | |
984 g /= 17; | |
985 b /= 17; | |
986 } | |
987 return (PALETTERGB (r, g, b)); | |
988 } | |
442 | 989 else |
428 | 990 return (COLORREF) -1; |
991 } | |
992 else if (*name) /* Can't be an empty string */ | |
993 { | |
2367 | 994 Ibyte *nospaces = alloca_ibytes (qxestrlen (name) + 1); |
867 | 995 Ibyte *c = nospaces; |
428 | 996 while (*name) |
997 if (*name != ' ') | |
442 | 998 *c++ = *name++; |
428 | 999 else |
1000 name++; | |
1001 *c = '\0'; | |
1002 | |
442 | 1003 for (i = 0; i < countof (mswindows_X_color_map); i++) |
2367 | 1004 if (!qxestrcasecmp_ascii (nospaces, mswindows_X_color_map[i].name)) |
428 | 1005 return (mswindows_X_color_map[i].colorref); |
1006 } | |
1007 return (COLORREF) -1; | |
1008 } | |
1009 | |
442 | 1010 Lisp_Object |
1011 mswindows_color_to_string (COLORREF color) | |
1012 { | |
1013 int i; | |
2367 | 1014 Ascbyte buf[8]; |
442 | 1015 COLORREF pcolor = PALETTERGB (GetRValue (color), GetGValue (color), |
1016 GetBValue (color)); | |
1017 | |
771 | 1018 for (i = 0; i < countof (mswindows_X_color_map); i++) |
442 | 1019 if (pcolor == (mswindows_X_color_map[i].colorref)) |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1020 return build_ascstring (mswindows_X_color_map[i].name); |
442 | 1021 |
1022 sprintf (buf, "#%02X%02X%02X", | |
1023 GetRValue (color), GetGValue (color), GetBValue (color)); | |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
1024 return build_ascstring (buf); |
442 | 1025 } |
1026 | |
428 | 1027 /* |
1028 * Returns non-zero if the two supplied font patterns match. | |
1029 * If they match and fontname is not NULL, copies the logical OR of the | |
1030 * patterns to fontname (which is assumed to be at least MSW_FONTSIZE in size). | |
1031 * | |
1032 * The patterns 'match' iff for each field that is not blank in either pattern, | |
1033 * the corresponding field in the other pattern is either identical or blank. | |
1034 */ | |
1035 static int | |
867 | 1036 match_font (Ibyte *pattern1, Ibyte *pattern2, |
1037 Ibyte *fontname) | |
428 | 1038 { |
867 | 1039 Ibyte *c1 = pattern1, *c2 = pattern2, *e1 = 0, *e2 = 0; |
428 | 1040 int i; |
1041 | |
1042 if (fontname) | |
1043 fontname[0] = '\0'; | |
1044 | |
771 | 1045 for (i = 0; i < 5; i++) |
428 | 1046 { |
771 | 1047 if (c1 && (e1 = qxestrchr (c1, ':'))) |
428 | 1048 *(e1) = '\0'; |
771 | 1049 if (c2 && (e2 = qxestrchr (c2, ':'))) |
428 | 1050 *(e2) = '\0'; |
1051 | |
771 | 1052 if (c1 && c1[0] != '\0') |
428 | 1053 { |
771 | 1054 if (c2 && c2[0] != '\0' && qxestrcasecmp (c1, c2)) |
428 | 1055 { |
1056 if (e1) *e1 = ':'; | |
1057 if (e2) *e2 = ':'; | |
1058 return 0; | |
1059 } | |
1060 else if (fontname) | |
2367 | 1061 qxestrcat_ascii (qxestrcat (fontname, c1), ":"); |
428 | 1062 } |
1063 else if (fontname) | |
1064 { | |
771 | 1065 if (c2 && c2[0] != '\0') |
2367 | 1066 qxestrcat_ascii (qxestrcat (fontname, c2), ":"); |
428 | 1067 else |
2367 | 1068 qxestrcat_ascii (fontname, ":"); |
428 | 1069 } |
1070 | |
1071 if (e1) *(e1++) = ':'; | |
1072 if (e2) *(e2++) = ':'; | |
771 | 1073 c1 = e1; |
1074 c2 = e2; | |
428 | 1075 } |
1076 | |
1077 if (fontname) | |
771 | 1078 fontname[qxestrlen (fontname) - 1] = '\0'; /* Trim trailing ':' */ |
428 | 1079 return 1; |
1080 } | |
1081 | |
1082 | |
1083 /************************************************************************/ | |
1084 /* exports */ | |
1085 /************************************************************************/ | |
1086 | |
1087 struct font_enum_t | |
1088 { | |
1089 HDC hdc; | |
440 | 1090 Lisp_Object list; |
428 | 1091 }; |
1092 | |
1093 static int CALLBACK | |
771 | 1094 font_enum_callback_2 (ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEXW *lpntme, |
1095 int FontType, struct font_enum_t *font_enum) | |
442 | 1096 { |
867 | 1097 Ibyte fontname[MSW_FONTSIZE * 2 * MAX_ICHAR_LEN]; /* should be enough :)*/ |
442 | 1098 Lisp_Object fontname_lispstr; |
1099 int i; | |
867 | 1100 Ibyte *facename; |
428 | 1101 |
1102 /* | |
1103 * The enumerated font weights are not to be trusted because: | |
1104 * a) lpelfe->elfStyle is only filled in for TrueType fonts. | |
442 | 1105 * b) Not all Bold and Italic styles of all fonts (including some Vector, |
428 | 1106 * Truetype and Raster fonts) are enumerated. |
1107 * I guess that fonts for which Bold and Italic styles are generated | |
1108 * 'on-the-fly' are not enumerated. It would be overly restrictive to | |
1109 * disallow Bold And Italic weights for these fonts, so we just leave | |
1110 * weights unspecified. This means that we have to weed out duplicates of | |
1111 * those fonts that do get enumerated with different weights. | |
1112 */ | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
1113 facename = TSTR_TO_ITEXT (lpelfe->elfLogFont.lfFaceName); |
867 | 1114 if (itext_ichar (facename) == '@') |
771 | 1115 /* This is a font for writing vertically. We ignore it. */ |
1116 return 1; | |
1117 | |
1118 if (FontType == 0 /*vector*/ || FontType & TRUETYPE_FONTTYPE) | |
428 | 1119 /* Scalable, so leave pointsize blank */ |
771 | 1120 qxesprintf (fontname, "%s::::", facename); |
428 | 1121 else |
1122 /* Formula for pointsize->height from LOGFONT docs in Platform SDK */ | |
771 | 1123 qxesprintf (fontname, "%s::%d::", facename, |
1124 MulDiv (lpntme->ntmTm.tmHeight - | |
1125 lpntme->ntmTm.tmInternalLeading, | |
1126 72, GetDeviceCaps (font_enum->hdc, LOGPIXELSY))); | |
428 | 1127 |
1128 /* | |
1129 * The enumerated font character set strings are not to be trusted because | |
1130 * lpelfe->elfScript is returned in the host language and not in English. | |
1131 * We can't know a priori the translations of "Western", "Central European" | |
1132 * etc into the host language, so we must use English. The same argument | |
1133 * applies to the font weight string when matching fonts. | |
1134 */ | |
771 | 1135 for (i = 0; i < countof (charset_map); i++) |
428 | 1136 if (lpelfe->elfLogFont.lfCharSet == charset_map[i].value) |
1137 { | |
2367 | 1138 qxestrcat_ascii (fontname, charset_map[i].name); |
428 | 1139 break; |
1140 } | |
771 | 1141 if (i == countof (charset_map)) |
1142 return 1; | |
428 | 1143 |
440 | 1144 /* Add the font name to the list if not already there */ |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1145 fontname_lispstr = build_istring (fontname); |
872 | 1146 if (NILP (Fassoc (fontname_lispstr, font_enum->list))) |
1147 font_enum->list = | |
1148 Fcons (Fcons (fontname_lispstr, | |
1149 /* TMPF_FIXED_PITCH is backwards from what you expect! | |
1150 If set, it means NOT fixed pitch. */ | |
1151 (lpntme->ntmTm.tmPitchAndFamily & TMPF_FIXED_PITCH) ? | |
1152 Qnil : Qt), | |
1153 font_enum->list); | |
428 | 1154 |
1155 return 1; | |
1156 } | |
1157 | |
1158 static int CALLBACK | |
2286 | 1159 font_enum_callback_1 (ENUMLOGFONTEXW *lpelfe, |
1160 NEWTEXTMETRICEXW *UNUSED (lpntme), | |
1161 int UNUSED (FontType), struct font_enum_t *font_enum) | |
428 | 1162 { |
1163 /* This function gets called once per facename per character set. | |
1164 * We call a second callback to enumerate the fonts in each facename */ | |
771 | 1165 return qxeEnumFontFamiliesEx (font_enum->hdc, &lpelfe->elfLogFont, |
1166 (FONTENUMPROCW) font_enum_callback_2, | |
1167 (LPARAM) font_enum, 0); | |
428 | 1168 } |
1169 | |
872 | 1170 /* Function for sorting lists of fonts as obtained from |
1171 mswindows_enumerate_fonts(). These come in a known format: | |
1172 "family::::charset" for TrueType fonts, "family::size::charset" | |
1173 otherwise. */ | |
1174 | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1175 static Lisp_Object |
872 | 1176 sort_font_list_function (Lisp_Object obj1, Lisp_Object obj2, |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1177 Lisp_Object UNUSED (pred), |
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1178 Lisp_Object UNUSED (key_function)) |
872 | 1179 { |
1180 Ibyte *font1, *font2; | |
1181 Ibyte *c1, *c2; | |
1182 int t1, t2; | |
1183 | |
1184 /* | |
1185 1. fixed over proportional. | |
1186 2. Western over other charsets. | |
1187 3. TrueType over non-TrueType. | |
1188 4. Within non-TrueType, sizes closer to 10pt over sizes farther from 10pt. | |
1189 5. Courier New over other families. | |
1190 */ | |
1191 | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1192 /* The sort function should return non-nil if OBJ1 < OBJ2, nil otherwise. |
872 | 1193 NOTE: This is backwards from the way qsort() works. */ |
1194 | |
1195 t1 = !NILP (XCDR (obj1)); | |
1196 t2 = !NILP (XCDR (obj2)); | |
1197 | |
1198 if (t1 && !t2) | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1199 return Qt; |
872 | 1200 if (t2 && !t1) |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1201 return Qnil; |
872 | 1202 |
1203 font1 = XSTRING_DATA (XCAR (obj1)); | |
1204 font2 = XSTRING_DATA (XCAR (obj2)); | |
1205 | |
1206 c1 = qxestrrchr (font1, ':'); | |
1207 c2 = qxestrrchr (font2, ':'); | |
1208 | |
2367 | 1209 t1 = !qxestrcasecmp_ascii (c1 + 1, "western"); |
1210 t2 = !qxestrcasecmp_ascii (c2 + 1, "western"); | |
872 | 1211 |
1212 if (t1 && !t2) | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1213 return Qt; |
872 | 1214 if (t2 && !t1) |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1215 return Qnil; |
872 | 1216 |
1217 c1 -= 2; | |
1218 c2 -= 2; | |
1219 t1 = *c1 == ':'; | |
1220 t2 = *c2 == ':'; | |
1221 | |
1222 if (t1 && !t2) | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1223 return Qt; |
872 | 1224 if (t2 && !t1) |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1225 return Qnil; |
872 | 1226 |
1227 if (!t1 && !t2) | |
1228 { | |
1229 while (isdigit (*c1)) | |
1230 c1--; | |
1231 while (isdigit (*c2)) | |
1232 c2--; | |
1233 | |
1234 t1 = qxeatoi (c1 + 1) - 10; | |
1235 t2 = qxeatoi (c2 + 1) - 10; | |
1236 | |
1237 if (abs (t1) < abs (t2)) | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1238 return Qt; |
872 | 1239 else if (abs (t2) < abs (t1)) |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1240 return Qnil; |
872 | 1241 else if (t1 < t2) |
1242 /* Prefer a smaller font over a larger one just as far away | |
1243 because the smaller one won't upset the total line height if it's | |
1244 just a few chars. */ | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1245 return Qt; |
872 | 1246 } |
1247 | |
2367 | 1248 t1 = !qxestrncasecmp_ascii (font1, "courier new:", 12); |
1249 t2 = !qxestrncasecmp_ascii (font2, "courier new:", 12); | |
872 | 1250 |
1251 if (t1 && !t2) | |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1252 return Qt; |
872 | 1253 if (t2 && !t1) |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1254 return Qnil; |
872 | 1255 |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1256 return Qnil; |
872 | 1257 } |
1258 | |
428 | 1259 /* |
440 | 1260 * Enumerate the available on the HDC fonts and return a list of string |
1261 * font names. | |
428 | 1262 */ |
440 | 1263 Lisp_Object |
1264 mswindows_enumerate_fonts (HDC hdc) | |
428 | 1265 { |
771 | 1266 /* This cannot GC */ |
1267 LOGFONTW logfont; | |
428 | 1268 struct font_enum_t font_enum; |
1269 | |
771 | 1270 assert (hdc != NULL); |
428 | 1271 logfont.lfCharSet = DEFAULT_CHARSET; |
1272 logfont.lfFaceName[0] = '\0'; | |
1273 logfont.lfPitchAndFamily = DEFAULT_PITCH; | |
1274 font_enum.hdc = hdc; | |
440 | 1275 font_enum.list = Qnil; |
771 | 1276 /* EnumFontFamilies seems to enumerate only one charset per font, which |
1277 is not what we want. We aren't supporting NT 3.5x, so no need to | |
1278 worry about this not existing. */ | |
1279 qxeEnumFontFamiliesEx (hdc, &logfont, (FONTENUMPROCW) font_enum_callback_1, | |
1280 (LPARAM) (&font_enum), 0); | |
442 | 1281 |
5182
2e528066e2fc
Move #'sort*, #'fill, #'merge to C from cl-seq.el.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5176
diff
changeset
|
1282 return list_sort (font_enum.list, sort_font_list_function, Qnil, Qidentity); |
428 | 1283 } |
1284 | |
442 | 1285 static HFONT |
771 | 1286 mswindows_create_font_variant (Lisp_Font_Instance *f, |
440 | 1287 int under, int strike) |
1288 { | |
1289 /* Cannot GC */ | |
771 | 1290 LOGFONTW lf; |
440 | 1291 HFONT hfont; |
1292 | |
1293 assert (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) == NULL); | |
1294 | |
771 | 1295 if (qxeGetObject (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0), |
1296 sizeof (lf), (void *) &lf) == 0) | |
440 | 1297 { |
1298 hfont = MSWINDOWS_BAD_HFONT; | |
1299 } | |
1300 else | |
1301 { | |
1302 lf.lfUnderline = under; | |
1303 lf.lfStrikeOut = strike; | |
1304 | |
771 | 1305 hfont = qxeCreateFontIndirect (&lf); |
440 | 1306 if (hfont == NULL) |
1307 hfont = MSWINDOWS_BAD_HFONT; | |
1308 } | |
1309 | |
1310 FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) = hfont; | |
442 | 1311 return hfont; |
440 | 1312 } |
1313 | |
1314 HFONT | |
771 | 1315 mswindows_get_hfont (Lisp_Font_Instance *f, |
440 | 1316 int under, int strike) |
1317 { | |
1318 /* Cannot GC */ | |
442 | 1319 HFONT hfont = FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike); |
440 | 1320 |
442 | 1321 if (hfont == NULL) |
1322 hfont = mswindows_create_font_variant (f, under, strike); | |
440 | 1323 |
1324 /* If strikeout/underline variant of the font could not be | |
1325 created, then use the base version of the font */ | |
1326 if (hfont == MSWINDOWS_BAD_HFONT) | |
1327 hfont = FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0); | |
1328 | |
1329 assert (hfont != NULL && hfont != MSWINDOWS_BAD_HFONT); | |
1330 | |
1331 return hfont; | |
1332 } | |
428 | 1333 |
1334 /************************************************************************/ | |
1335 /* methods */ | |
1336 /************************************************************************/ | |
1337 | |
1338 static int | |
440 | 1339 mswindows_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, |
2286 | 1340 Lisp_Object UNUSED (device), |
1341 Error_Behavior errb) | |
428 | 1342 { |
1343 COLORREF color; | |
1344 | |
771 | 1345 color = mswindows_string_to_color (XSTRING_DATA (name)); |
647 | 1346 if (color != (COLORREF) -1) |
428 | 1347 { |
1348 c->data = xnew (struct mswindows_color_instance_data); | |
1349 COLOR_INSTANCE_MSWINDOWS_COLOR (c) = color; | |
1350 return 1; | |
1351 } | |
563 | 1352 maybe_signal_error (Qinvalid_constant, |
771 | 1353 "Unrecognized color", name, Qcolor, errb); |
428 | 1354 return(0); |
1355 } | |
1356 | |
1357 #if 0 | |
1358 static void | |
440 | 1359 mswindows_mark_color_instance (Lisp_Color_Instance *c) |
428 | 1360 { |
1361 } | |
1362 #endif | |
1363 | |
1364 static void | |
440 | 1365 mswindows_print_color_instance (Lisp_Color_Instance *c, |
1366 Lisp_Object printcharfun, | |
2286 | 1367 int UNUSED (escapeflag)) |
428 | 1368 { |
1369 COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c); | |
793 | 1370 write_fmt_string (printcharfun, |
1371 " %06ld=(%04X,%04X,%04X)", color & 0xffffff, | |
1372 GetRValue (color) * 257, GetGValue (color) * 257, | |
1373 GetBValue (color) * 257); | |
428 | 1374 } |
1375 | |
1376 static void | |
440 | 1377 mswindows_finalize_color_instance (Lisp_Color_Instance *c) |
428 | 1378 { |
1379 if (c->data) | |
1380 { | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
1381 xfree (c->data); |
428 | 1382 c->data = 0; |
1383 } | |
1384 } | |
1385 | |
1386 static int | |
440 | 1387 mswindows_color_instance_equal (Lisp_Color_Instance *c1, |
1388 Lisp_Color_Instance *c2, | |
2286 | 1389 int UNUSED (depth)) |
428 | 1390 { |
793 | 1391 return (COLOR_INSTANCE_MSWINDOWS_COLOR (c1) == |
1392 COLOR_INSTANCE_MSWINDOWS_COLOR (c2)); | |
428 | 1393 } |
1394 | |
2515 | 1395 static Hashcode |
2286 | 1396 mswindows_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) |
428 | 1397 { |
793 | 1398 return (unsigned long) COLOR_INSTANCE_MSWINDOWS_COLOR (c); |
428 | 1399 } |
1400 | |
1401 static Lisp_Object | |
440 | 1402 mswindows_color_instance_rgb_components (Lisp_Color_Instance *c) |
428 | 1403 { |
1404 COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c); | |
1405 return list3 (make_int (GetRValue (color) * 257), | |
1406 make_int (GetGValue (color) * 257), | |
1407 make_int (GetBValue (color) * 257)); | |
1408 } | |
1409 | |
1410 static int | |
2286 | 1411 mswindows_valid_color_name_p (struct device *UNUSED (d), Lisp_Object color) |
428 | 1412 { |
771 | 1413 return (mswindows_string_to_color (XSTRING_DATA (color)) != (COLORREF) -1); |
428 | 1414 } |
1415 | |
1416 | |
1417 | |
1418 static void | |
440 | 1419 mswindows_finalize_font_instance (Lisp_Font_Instance *f); |
428 | 1420 |
872 | 1421 /* Parse the font spec in NAMESTR. Maybe issue errors, according to ERRB; |
1422 NAME_FOR_ERRORS is the Lisp string to use when issuing errors. Store | |
1423 the five parts of the font spec into the given strings, which should be | |
1424 declared as | |
1425 | |
1426 Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], points[8]; | |
1427 Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE]; | |
1428 | |
1429 If LOGFONT is given, store the necessary information in LOGFONT to | |
1430 create a font object. If LOGFONT is given, HDC must also be given; | |
1431 else, NULL can be given for both. | |
1432 | |
1433 Return 1 if ok, 0 if error. | |
1434 */ | |
1435 static int | |
1436 parse_font_spec (const Ibyte *namestr, | |
1437 HDC hdc, | |
1438 Lisp_Object name_for_errors, | |
1439 Error_Behavior errb, | |
1440 LOGFONTW *logfont, | |
1441 Ibyte *fontname, | |
1442 Ibyte *weight, | |
1443 Ibyte *points, | |
1444 Ibyte *effects, | |
1445 Ibyte *charset) | |
428 | 1446 { |
1447 int fields, i; | |
1448 int pt; | |
872 | 1449 Ibyte *style; |
867 | 1450 Ibyte *c; |
428 | 1451 |
1452 /* | |
1453 * mswindows fonts look like: | |
1454 * fontname[:[weight ][style][:pointsize[:effects]]][:charset] | |
1455 * The font name field shouldn't be empty. | |
1456 * | |
1457 * ie: | |
1458 * Lucida Console:Regular:10 | |
1459 * minimal: | |
1460 * Courier New | |
1461 * maximal: | |
1462 * Courier New:Bold Italic:10:underline strikeout:western | |
1463 */ | |
1464 | |
872 | 1465 fontname[0] = 0; |
1466 weight[0] = 0; | |
1467 points[0] = 0; | |
1468 effects[0] = 0; | |
1469 charset[0] = 0; | |
1470 | |
1471 if (logfont) | |
1472 xzero (*logfont); | |
1473 | |
867 | 1474 fields = sscanf ((CIbyte *) namestr, "%31[^:]:%31[^:]:%7[^:]:%31[^:]:%31s", |
428 | 1475 fontname, weight, points, effects, charset); |
1476 | |
1477 /* This function is implemented in a fairly ad-hoc manner. | |
1478 * The general idea is to validate and canonicalize each of the above fields | |
1479 * at the same time as we build up the win32 LOGFONT structure. This enables | |
1480 * us to use match_font() on a canonicalized font string to check the | |
1481 * availability of the requested font */ | |
1482 | |
1483 if (fields < 0) | |
771 | 1484 { |
788 | 1485 maybe_signal_error (Qinvalid_argument, "Invalid font", name_for_errors, |
771 | 1486 Qfont, errb); |
872 | 1487 return 0; |
771 | 1488 } |
1489 | |
1490 if (fields > 0 && qxestrlen (fontname)) | |
1491 { | |
1492 Extbyte *extfontname; | |
428 | 1493 |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
1494 extfontname = ITEXT_TO_TSTR (fontname); |
872 | 1495 if (logfont) |
1496 { | |
2421 | 1497 qxetcsncpy ((Extbyte *) logfont->lfFaceName, extfontname, |
872 | 1498 LF_FACESIZE - 1); |
1499 logfont->lfFaceName[LF_FACESIZE - 1] = 0; | |
1500 } | |
771 | 1501 } |
428 | 1502 |
1503 /* weight */ | |
1504 if (fields < 2) | |
2367 | 1505 qxestrcpy_ascii (weight, fontweight_map[0].name); |
428 | 1506 |
1507 /* Maybe split weight into weight and style */ | |
771 | 1508 if ((c = qxestrchr (weight, ' '))) |
872 | 1509 { |
1510 *c = '\0'; | |
1511 style = c + 1; | |
1512 } | |
428 | 1513 else |
1514 style = NULL; | |
1515 | |
771 | 1516 for (i = 0; i < countof (fontweight_map); i++) |
2367 | 1517 if (!qxestrcasecmp_ascii (weight, fontweight_map[i].name)) |
442 | 1518 { |
872 | 1519 if (logfont) |
1520 logfont->lfWeight = fontweight_map[i].value; | |
428 | 1521 break; |
1522 } | |
1523 if (i == countof (fontweight_map)) /* No matching weight */ | |
1524 { | |
1525 if (!style) | |
1526 { | |
872 | 1527 if (logfont) |
1528 logfont->lfWeight = FW_REGULAR; | |
428 | 1529 style = weight; /* May have specified style without weight */ |
1530 } | |
1531 else | |
1532 { | |
788 | 1533 maybe_signal_error (Qinvalid_constant, "Invalid font weight", |
1534 name_for_errors, Qfont, errb); | |
872 | 1535 return 0; |
428 | 1536 } |
1537 } | |
1538 | |
1539 if (style) | |
1540 { | |
1541 /* #### what about oblique? */ | |
2367 | 1542 if (qxestrcasecmp_ascii (style, "italic") == 0) |
872 | 1543 { |
1544 if (logfont) | |
1545 logfont->lfItalic = TRUE; | |
1546 } | |
428 | 1547 else |
788 | 1548 { |
1549 maybe_signal_error (Qinvalid_constant, | |
1550 "Invalid font weight or style", | |
1551 name_for_errors, Qfont, errb); | |
872 | 1552 return 0; |
428 | 1553 } |
1554 | |
1555 /* Glue weight and style together again */ | |
1556 if (weight != style) | |
1557 *c = ' '; | |
1558 } | |
872 | 1559 else if (logfont) |
1560 logfont->lfItalic = FALSE; | |
428 | 1561 |
2367 | 1562 if (fields < 3 || !qxestrcmp_ascii (points, "")) |
872 | 1563 ; |
1564 else if (points[0] == '0' || | |
1565 qxestrspn (points, "0123456789") < qxestrlen (points)) | |
428 | 1566 { |
788 | 1567 maybe_signal_error (Qinvalid_argument, "Invalid font pointsize", |
1568 name_for_errors, Qfont, errb); | |
872 | 1569 return 0; |
1570 } | |
1571 else | |
1572 { | |
1573 pt = qxeatoi (points); | |
1574 | |
1575 if (logfont) | |
1576 { | |
1577 /* Formula for pointsize->height from LOGFONT docs in MSVC5 Platform | |
1578 SDK */ | |
1579 logfont->lfHeight = -MulDiv (pt, GetDeviceCaps (hdc, LOGPIXELSY), | |
1580 72); | |
1581 logfont->lfWidth = 0; | |
1582 } | |
428 | 1583 } |
1584 | |
872 | 1585 /* Effects */ |
1586 if (logfont) | |
1587 { | |
1588 logfont->lfUnderline = FALSE; | |
1589 logfont->lfStrikeOut = FALSE; | |
1590 } | |
428 | 1591 |
1592 if (fields >= 4 && effects[0] != '\0') | |
1593 { | |
867 | 1594 Ibyte *effects2; |
872 | 1595 int underline = FALSE, strikeout = FALSE; |
428 | 1596 |
1597 /* Maybe split effects into effects and effects2 */ | |
771 | 1598 if ((c = qxestrchr (effects, ' '))) |
428 | 1599 { |
1600 *c = '\0'; | |
771 | 1601 effects2 = c + 1; |
428 | 1602 } |
1603 else | |
1604 effects2 = NULL; | |
1605 | |
2367 | 1606 if (qxestrcasecmp_ascii (effects, "underline") == 0) |
872 | 1607 underline = TRUE; |
2367 | 1608 else if (qxestrcasecmp_ascii (effects, "strikeout") == 0) |
872 | 1609 strikeout = TRUE; |
428 | 1610 else |
1611 { | |
788 | 1612 maybe_signal_error (Qinvalid_constant, "Invalid font effect", |
1613 name_for_errors, Qfont, errb); | |
872 | 1614 return 0; |
428 | 1615 } |
1616 | |
1617 if (effects2 && effects2[0] != '\0') | |
1618 { | |
2367 | 1619 if (qxestrcasecmp_ascii (effects2, "underline") == 0) |
872 | 1620 underline = TRUE; |
2367 | 1621 else if (qxestrcasecmp_ascii (effects2, "strikeout") == 0) |
872 | 1622 strikeout = TRUE; |
428 | 1623 else |
1624 { | |
771 | 1625 maybe_signal_error (Qinvalid_constant, "Invalid font effect", |
788 | 1626 name_for_errors, Qfont, errb); |
872 | 1627 return 0; |
428 | 1628 } |
1629 } | |
1630 | |
872 | 1631 /* Regenerate sanitized effects string */ |
1632 if (underline) | |
428 | 1633 { |
872 | 1634 if (strikeout) |
2367 | 1635 qxestrcpy_ascii (effects, "underline strikeout"); |
428 | 1636 else |
2367 | 1637 qxestrcpy_ascii (effects, "underline"); |
428 | 1638 } |
872 | 1639 else if (strikeout) |
2367 | 1640 qxestrcpy_ascii (effects, "strikeout"); |
872 | 1641 |
1642 if (logfont) | |
1643 { | |
1644 logfont->lfUnderline = underline; | |
1645 logfont->lfStrikeOut = strikeout; | |
1646 } | |
428 | 1647 } |
1648 | |
1649 /* Charset */ | |
442 | 1650 /* charset can be specified even if earlier fields haven't been */ |
428 | 1651 if (fields < 5) |
1652 { | |
771 | 1653 if ((c = qxestrchr (namestr, ':')) && (c = qxestrchr (c + 1, ':')) && |
1654 (c = qxestrchr (c + 1, ':')) && (c = qxestrchr (c + 1, ':'))) | |
428 | 1655 { |
771 | 1656 qxestrncpy (charset, c + 1, LF_FACESIZE); |
1657 charset[LF_FACESIZE - 1] = '\0'; | |
428 | 1658 } |
1659 } | |
1660 | |
872 | 1661 /* NOTE: If you give a blank charset spec, we will normally not get here |
1662 under Mule unless we explicitly call `make-font-instance'! This is | |
1663 because the C code instantiates fonts using particular charsets, by | |
1664 way of specifier_matching_instance(). Before instantiating the font, | |
1665 font_instantiate() calls the devmeth find_matching_font(), which gets | |
1666 a truename font spec with the registry (i.e. the charset spec) filled | |
1667 in appropriately to the charset. */ | |
2367 | 1668 if (!qxestrcmp_ascii (charset, "")) |
872 | 1669 ; |
1670 else | |
1671 { | |
1672 for (i = 0; i < countof (charset_map); i++) | |
2367 | 1673 if (!qxestrcasecmp_ascii (charset, charset_map[i].name)) |
872 | 1674 { |
1675 if (logfont) | |
1676 logfont->lfCharSet = charset_map[i].value; | |
1677 break; | |
1678 } | |
428 | 1679 |
872 | 1680 if (i == countof (charset_map)) /* No matching charset */ |
1681 { | |
1682 maybe_signal_error (Qinvalid_argument, "Invalid charset", | |
1683 name_for_errors, Qfont, errb); | |
1684 return 0; | |
1685 } | |
1686 } | |
1687 | |
1688 if (logfont) | |
428 | 1689 { |
872 | 1690 /* Misc crud */ |
1691 #if 1 | |
1692 logfont->lfOutPrecision = OUT_DEFAULT_PRECIS; | |
1693 logfont->lfClipPrecision = CLIP_DEFAULT_PRECIS; | |
1694 logfont->lfQuality = DEFAULT_QUALITY; | |
1695 #else | |
1696 logfont->lfOutPrecision = OUT_STROKE_PRECIS; | |
1697 logfont->lfClipPrecision = CLIP_STROKE_PRECIS; | |
1698 logfont->lfQuality = PROOF_QUALITY; | |
1699 #endif | |
1700 /* Default to monospaced if the specified fontname doesn't exist. */ | |
1701 logfont->lfPitchAndFamily = FF_MODERN; | |
428 | 1702 } |
1703 | |
872 | 1704 return 1; |
1705 } | |
1706 | |
1707 /* | |
1708 mswindows fonts look like: | |
1709 [fontname[:style[:pointsize[:effects]]]][:charset] | |
1710 A maximal mswindows font spec looks like: | |
1711 Courier New:Bold Italic:10:underline strikeout:Western | |
1712 | |
1713 A missing weight/style field is the same as Regular, and a missing | |
1714 effects field is left alone, and means no effects; but a missing | |
1715 fontname, pointsize or charset field means any will do. We prefer | |
1716 Courier New, 10, Western. See sort function above. */ | |
428 | 1717 |
872 | 1718 static HFONT |
1719 create_hfont_from_font_spec (const Ibyte *namestr, | |
1720 HDC hdc, | |
1721 Lisp_Object name_for_errors, | |
1722 Lisp_Object device_font_list, | |
1723 Error_Behavior errb, | |
1724 Lisp_Object *truename_ret) | |
1725 { | |
1726 LOGFONTW logfont; | |
1727 HFONT hfont; | |
1728 Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], points[8]; | |
1729 Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE]; | |
1730 Ibyte truename[MSW_FONTSIZE]; | |
1731 Ibyte truername[MSW_FONTSIZE]; | |
1732 | |
1733 /* Windows will silently substitute a default font if the fontname | |
1734 specifies a non-existent font. This is bad for screen fonts because | |
1735 it doesn't allow higher-level code to see the error and to act | |
1736 appropriately. For instance complex_vars_of_faces() sets up a | |
1737 fallback list of fonts for the default face. Instead, we look at all | |
1738 the possibilities and pick one that works, handling missing pointsize | |
1739 and charset fields appropriately. | |
1740 | |
1741 For printer fonts, we used to go ahead and let Windows choose the | |
1742 font, and for those devices, then, DEVICE_FONT_LIST would be nil. | |
1743 However, this causes problems with the font-matching code below, which | |
1744 needs a list of fonts so it can pick the right one for Mule. | |
1745 | |
1746 Thus, the code below to handle a nil DEVICE_FONT_LIST is not currently | |
1747 used. */ | |
440 | 1748 |
1749 if (!NILP (device_font_list)) | |
1750 { | |
872 | 1751 Lisp_Object fonttail = Qnil; |
1752 | |
1753 if (!parse_font_spec (namestr, 0, name_for_errors, | |
1754 errb, 0, fontname, weight, points, | |
1755 effects, charset)) | |
1756 return 0; | |
1757 | |
1758 /* The fonts in the device font list always specify fontname and | |
1759 charset, but often times not the size; so if we don't have the | |
1760 size specified either, do a round with size 10 so we'll always end | |
1761 up with a size in the truename (if we fail this one but succeed | |
1762 the next one, we'll have chosen a non-TrueType font, and in those | |
1763 cases the size is specified in the font list item. */ | |
1764 | |
1765 if (!points[0]) | |
1766 { | |
1767 qxesprintf (truename, "%s:%s:10:%s:%s", | |
1768 fontname, weight, effects, charset); | |
428 | 1769 |
872 | 1770 LIST_LOOP (fonttail, device_font_list) |
1771 { | |
1772 if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), | |
1773 truename, truername)) | |
1774 break; | |
1775 } | |
1776 } | |
1777 | |
1778 if (NILP (fonttail)) | |
440 | 1779 { |
872 | 1780 qxesprintf (truename, "%s:%s:%s:%s:%s", |
1781 fontname, weight, points, effects, charset); | |
1782 | |
1783 LIST_LOOP (fonttail, device_font_list) | |
1784 { | |
1785 if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), | |
1786 truename, truername)) | |
1787 break; | |
1788 } | |
440 | 1789 } |
872 | 1790 |
440 | 1791 if (NILP (fonttail)) |
1792 { | |
788 | 1793 maybe_signal_error (Qinvalid_argument, "No matching font", |
1794 name_for_errors, Qfont, errb); | |
872 | 1795 return 0; |
440 | 1796 } |
872 | 1797 |
1798 if (!parse_font_spec (truername, hdc, name_for_errors, | |
1799 ERROR_ME_DEBUG_WARN, &logfont, fontname, weight, | |
1800 points, effects, charset)) | |
1801 signal_error (Qinternal_error, "Bad value in device font list?", | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1802 build_istring (truername)); |
440 | 1803 } |
872 | 1804 else if (!parse_font_spec (namestr, hdc, name_for_errors, |
1805 errb, &logfont, fontname, weight, points, | |
1806 effects, charset)) | |
1807 return 0; | |
440 | 1808 |
771 | 1809 if ((hfont = qxeCreateFontIndirect (&logfont)) == NULL) |
788 | 1810 { |
1811 maybe_signal_error (Qgui_error, "Couldn't create font", | |
1812 name_for_errors, Qfont, errb); | |
872 | 1813 return 0; |
788 | 1814 } |
1815 | |
872 | 1816 /* #### Truename will not have all its fields filled in when we have no |
1817 list of fonts. Doesn't really matter now, since we always have one. | |
1818 See above. */ | |
1819 qxesprintf (truename, "%s:%s:%s:%s:%s", fontname, weight, | |
1820 points, effects, charset); | |
1821 | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1822 *truename_ret = build_istring (truename); |
788 | 1823 return hfont; |
1824 } | |
1825 | |
1826 /* | |
1827 * This is a work horse for both mswindows_initialize_font_instance and | |
1828 * msprinter_initialize_font_instance. | |
1829 */ | |
1830 static int | |
1831 initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, | |
1832 Lisp_Object device_font_list, HDC hdc, | |
1833 Error_Behavior errb) | |
1834 { | |
1835 HFONT hfont, hfont2; | |
1836 TEXTMETRICW metrics; | |
867 | 1837 Ibyte *namestr = XSTRING_DATA (name); |
872 | 1838 Lisp_Object truename; |
788 | 1839 |
1840 hfont = create_hfont_from_font_spec (namestr, hdc, name, device_font_list, | |
872 | 1841 errb, &truename); |
4932 | 1842 if (!hfont) |
1843 return 0; | |
872 | 1844 f->truename = truename; |
440 | 1845 f->data = xnew_and_zero (struct mswindows_font_instance_data); |
872 | 1846 FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0) = hfont; |
442 | 1847 |
1848 /* Some underlined fonts have the descent of one pixel more than their | |
1849 non-underlined counterparts. Font variants though are assumed to have | |
1850 identical metrics. So get the font metrics from the underlined variant | |
1851 of the font */ | |
1852 hfont2 = mswindows_create_font_variant (f, 1, 0); | |
1853 if (hfont2 != MSWINDOWS_BAD_HFONT) | |
1854 hfont = hfont2; | |
1855 | |
1856 hfont2 = (HFONT) SelectObject (hdc, hfont); | |
1857 if (!hfont2) | |
428 | 1858 { |
440 | 1859 mswindows_finalize_font_instance (f); |
563 | 1860 maybe_signal_error (Qgui_error, "Couldn't map font", name, Qfont, errb); |
440 | 1861 return 0; |
1862 } | |
771 | 1863 qxeGetTextMetrics (hdc, &metrics); |
1864 SelectObject (hdc, hfont2); | |
440 | 1865 |
1866 f->width = (unsigned short) metrics.tmAveCharWidth; | |
1867 f->height = (unsigned short) metrics.tmHeight; | |
442 | 1868 f->ascent = (unsigned short) metrics.tmAscent; |
1869 f->descent = (unsigned short) metrics.tmDescent; | |
440 | 1870 f->proportional_p = (metrics.tmPitchAndFamily & TMPF_FIXED_PITCH); |
1871 | |
1872 return 1; | |
1873 } | |
1874 | |
1875 static int | |
1876 mswindows_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, | |
578 | 1877 Lisp_Object device, Error_Behavior errb) |
440 | 1878 { |
1879 HDC hdc = CreateCompatibleDC (NULL); | |
1880 Lisp_Object font_list = DEVICE_MSWINDOWS_FONTLIST (XDEVICE (device)); | |
1881 int res = initialize_font_instance (f, name, font_list, hdc, errb); | |
1882 DeleteDC (hdc); | |
1883 return res; | |
1884 } | |
1885 | |
1886 static int | |
1887 msprinter_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name, | |
578 | 1888 Lisp_Object device, Error_Behavior errb) |
440 | 1889 { |
1890 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (device)); | |
1891 Lisp_Object font_list = DEVICE_MSPRINTER_FONTLIST (XDEVICE (device)); | |
1892 return initialize_font_instance (f, name, font_list, hdc, errb); | |
1893 } | |
1894 | |
1895 static void | |
1896 mswindows_finalize_font_instance (Lisp_Font_Instance *f) | |
1897 { | |
1898 int i; | |
1899 | |
1900 if (f->data) | |
1901 { | |
1902 for (i = 0; i < MSWINDOWS_NUM_FONT_VARIANTS; i++) | |
428 | 1903 { |
440 | 1904 if (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i) != NULL |
1905 && FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i) != MSWINDOWS_BAD_HFONT) | |
1906 DeleteObject (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i)); | |
428 | 1907 } |
440 | 1908 |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4953
diff
changeset
|
1909 xfree (f->data); |
440 | 1910 f->data = 0; |
1911 } | |
428 | 1912 } |
1913 | |
1914 #if 0 | |
1915 static void | |
440 | 1916 mswindows_mark_font_instance (Lisp_Font_Instance *f) |
428 | 1917 { |
1918 } | |
1919 #endif | |
1920 | |
1921 static void | |
440 | 1922 mswindows_print_font_instance (Lisp_Font_Instance *f, |
1923 Lisp_Object printcharfun, | |
2286 | 1924 int UNUSED (escapeflag)) |
428 | 1925 { |
793 | 1926 write_fmt_string (printcharfun, " 0x%lx", |
1927 (unsigned long) | |
1928 FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0)); | |
1929 | |
428 | 1930 } |
1931 | |
1932 static Lisp_Object | |
2527 | 1933 mswindows_font_list (Lisp_Object pattern, Lisp_Object device, |
2286 | 1934 Lisp_Object UNUSED (maxnumber)) |
428 | 1935 { |
771 | 1936 struct device *d = XDEVICE (device); |
1937 Lisp_Object font_list = Qnil, fonttail, result = Qnil; | |
428 | 1938 |
771 | 1939 if (DEVICE_MSWINDOWS_P (d)) |
1940 font_list = DEVICE_MSWINDOWS_FONTLIST (d); | |
1941 else if (DEVICE_MSPRINTER_P (d)) | |
1942 font_list = DEVICE_MSPRINTER_FONTLIST (d); | |
1943 else | |
2500 | 1944 ABORT (); |
440 | 1945 |
771 | 1946 LIST_LOOP (fonttail, font_list) |
428 | 1947 { |
867 | 1948 Ibyte fontname[MSW_FONTSIZE]; |
771 | 1949 |
872 | 1950 if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))), |
1951 XSTRING_DATA (pattern), | |
771 | 1952 fontname)) |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
1953 result = Fcons (build_istring (fontname), result); |
428 | 1954 } |
1955 | |
1956 return Fnreverse (result); | |
1957 } | |
1958 | |
1959 static Lisp_Object | |
2286 | 1960 mswindows_font_instance_truename (Lisp_Font_Instance *f, |
1961 Error_Behavior UNUSED (errb)) | |
428 | 1962 { |
872 | 1963 return f->truename; |
428 | 1964 } |
1965 | |
1966 #ifdef MULE | |
1967 | |
1968 static int | |
2286 | 1969 mswindows_font_spec_matches_charset_stage_1 (struct device *UNUSED (d), |
872 | 1970 Lisp_Object charset, |
1971 const Ibyte *nonreloc, | |
1972 Lisp_Object reloc, | |
1973 Bytecount offset, | |
1974 Bytecount length) | |
428 | 1975 { |
872 | 1976 int i; |
1977 Lisp_Object charset_registry; | |
1978 const Ibyte *font_charset; | |
867 | 1979 const Ibyte *the_nonreloc = nonreloc; |
1980 const Ibyte *c; | |
788 | 1981 Bytecount the_length = length; |
1982 | |
4353
4143b78d0df0
Merge an old patch of Ben's, involving font instantiation and charsets.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3662
diff
changeset
|
1983 if (NILP (charset)) |
788 | 1984 return 1; |
1985 | |
1986 if (!the_nonreloc) | |
1987 the_nonreloc = XSTRING_DATA (reloc); | |
1988 fixup_internal_substring (nonreloc, reloc, offset, &the_length); | |
1989 the_nonreloc += offset; | |
1990 | |
1991 c = the_nonreloc; | |
1992 for (i = 0; i < 4; i++) | |
1993 { | |
867 | 1994 Ibyte *newc = (Ibyte *) memchr (c, ':', the_length); |
788 | 1995 if (!newc) |
1996 break; | |
1997 newc++; | |
1998 the_length -= (newc - c); | |
1999 c = newc; | |
2000 } | |
2001 | |
872 | 2002 if (i < 4) |
2003 return 0; | |
2004 | |
2005 font_charset = c; | |
2006 | |
2007 /* For border-glyph use */ | |
2367 | 2008 if (!qxestrcasecmp_ascii (font_charset, "symbol")) |
872 | 2009 font_charset = (const Ibyte *) "western"; |
2010 | |
2011 /* Get code page for the charset */ | |
2012 charset_registry = Fmswindows_charset_registry (charset); | |
2013 if (!STRINGP (charset_registry)) | |
2014 return 0; | |
2015 | |
2016 return !qxestrcasecmp (XSTRING_DATA (charset_registry), font_charset); | |
2017 } | |
2018 | |
2019 /* | |
2020 | |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
2021 #### The following comment is old and probably not applicable any longer. |
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
2022 |
872 | 2023 1. handle standard mapping and inheritance vectors properly in Face-frob-property. |
2024 2. finish impl of mswindows-charset-registry. | |
2025 3. see if everything works under fixup, now that i copied the stuff over. | |
2026 4. consider generalizing Face-frob-property to frob-specifier. | |
2027 5. maybe extract some of the flets out of Face-frob-property as useful specifier frobbing. | |
2028 6. eventually this stuff's got to be checked in!!!! | |
2029 */ | |
2030 | |
2031 static int | |
2032 mswindows_font_spec_matches_charset_stage_2 (struct device *d, | |
2033 Lisp_Object charset, | |
2034 const Ibyte *nonreloc, | |
2035 Lisp_Object reloc, | |
2036 Bytecount offset, | |
2037 Bytecount length) | |
2038 { | |
2039 const Ibyte *the_nonreloc = nonreloc; | |
2040 FONTSIGNATURE fs; | |
2041 FONTSIGNATURE *fsp = &fs; | |
2042 struct gcpro gcpro1; | |
2043 Lisp_Object fontsig; | |
2044 Bytecount the_length = length; | |
2045 int i; | |
2046 | |
4353
4143b78d0df0
Merge an old patch of Ben's, involving font instantiation and charsets.
Aidan Kehoe <kehoea@parhasard.net>
parents:
3662
diff
changeset
|
2047 if (NILP (charset)) |
788 | 2048 return 1; |
2049 | |
872 | 2050 if (!the_nonreloc) |
2051 the_nonreloc = XSTRING_DATA (reloc); | |
2052 fixup_internal_substring (nonreloc, reloc, offset, &the_length); | |
2053 the_nonreloc += offset; | |
2054 | |
2055 /* Get the list of Unicode subranges corresponding to the font. This | |
2056 is contained inside of FONTSIGNATURE data, obtained by calling | |
2057 GetTextCharsetInfo on a font object, which we need to create from the | |
2058 spec. See if the FONTSIGNATURE data is already cached. If not, get | |
2059 it and cache it. */ | |
2060 if (!STRINGP (reloc) || the_nonreloc != XSTRING_DATA (reloc)) | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4952
diff
changeset
|
2061 reloc = build_istring (the_nonreloc); |
872 | 2062 GCPRO1 (reloc); |
2063 fontsig = Fgethash (reloc, Vfont_signature_data, Qunbound); | |
2064 | |
2065 if (!UNBOUNDP (fontsig)) | |
2066 { | |
2067 fsp = (FONTSIGNATURE *) XOPAQUE_DATA (fontsig); | |
2068 UNGCPRO; | |
2069 } | |
2070 else | |
2071 { | |
2072 HDC hdc = CreateCompatibleDC (NULL); | |
4579
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2073 Lisp_Object font_list = Qnil, truename; |
5016
2ade80e8c640
enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents:
5015
diff
changeset
|
2074 HFONT hfont; |
4579
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2075 |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2076 if (DEVICE_TYPE_P (d, mswindows)) |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2077 { |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2078 font_list = DEVICE_MSWINDOWS_FONTLIST (d); |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2079 } |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2080 else if (DEVICE_TYPE_P (d, msprinter)) |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2081 { |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2082 font_list = DEVICE_MSPRINTER_FONTLIST (d); |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2083 } |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2084 else |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2085 { |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2086 assert(0); |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2087 } |
68f74b080e94
Accept msprinter and mswindows, mswindows_font_spec_matches_charset_stage_2
Aidan Kehoe <kehoea@parhasard.net>
parents:
4353
diff
changeset
|
2088 |
5016
2ade80e8c640
enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents:
5015
diff
changeset
|
2089 hfont = create_hfont_from_font_spec (the_nonreloc, hdc, Qnil, |
2ade80e8c640
enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents:
5015
diff
changeset
|
2090 font_list, |
2ade80e8c640
enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents:
5015
diff
changeset
|
2091 ERROR_ME_DEBUG_WARN, |
2ade80e8c640
enable more warnings and fix them
Ben Wing <ben@xemacs.org>
parents:
5015
diff
changeset
|
2092 &truename); |
788 | 2093 |
872 | 2094 if (!hfont || !(hfont = (HFONT) SelectObject (hdc, hfont))) |
2095 { | |
2096 nope: | |
2097 DeleteDC (hdc); | |
2098 UNGCPRO; | |
2099 return 0; | |
2100 } | |
5024 | 2101 |
872 | 2102 if (GetTextCharsetInfo (hdc, &fs, 0) == DEFAULT_CHARSET) |
2103 { | |
2104 SelectObject (hdc, hfont); | |
2105 goto nope; | |
2106 } | |
2107 SelectObject (hdc, hfont); | |
2108 DeleteDC (hdc); | |
2109 Fputhash (reloc, make_opaque (&fs, sizeof (fs)), Vfont_signature_data); | |
2110 UNGCPRO; | |
2111 } | |
788 | 2112 |
872 | 2113 { |
2114 int lowlim, highlim; | |
2115 int dim, j, cp = -1; | |
2116 | |
2117 /* Try to find a Unicode char in the charset. #### This is somewhat | |
2118 bogus. See below. | |
2119 | |
2120 #### Cache me baby!!!!!!!!!!!!! | |
2121 */ | |
2122 get_charset_limits (charset, &lowlim, &highlim); | |
2123 dim = XCHARSET_DIMENSION (charset); | |
2124 | |
2125 if (dim == 1) | |
788 | 2126 { |
872 | 2127 for (i = lowlim; i <= highlim; i++) |
2128 if ((cp = ichar_to_unicode (make_ichar (charset, i, 0))) >= 0) | |
2129 break; | |
788 | 2130 } |
2131 else | |
2132 { | |
872 | 2133 for (i = lowlim; i <= highlim; i++) |
2134 for (j = lowlim; j <= highlim; j++) | |
2135 if ((cp = ichar_to_unicode (make_ichar (charset, i, j))) >= 0) | |
2136 break; | |
2137 } | |
2138 | |
2139 if (cp < 0) | |
2140 return 0; | |
788 | 2141 |
872 | 2142 /* Check to see, for each subrange supported by the font, |
2143 whether the Unicode char is within that subrange. If any match, | |
2144 the font supports the char (whereby, the charset, bogusly). */ | |
2145 | |
2146 for (i = 0; i < 128; i++) | |
2147 { | |
2148 if (fsp->fsUsb[i >> 5] & (1 << (i & 32))) | |
788 | 2149 { |
872 | 2150 for (j = 0; j < unicode_subrange_table[i].no_subranges; j++) |
2151 if (cp >= unicode_subrange_table[i].subranges[j].start && | |
2152 cp <= unicode_subrange_table[i].subranges[j].end) | |
2153 return 1; | |
788 | 2154 } |
2155 } | |
2156 | |
872 | 2157 return 0; |
788 | 2158 } |
2159 } | |
2160 | |
872 | 2161 /* |
2162 Given a truename font spec, does it match CHARSET? | |
2163 | |
2164 We try two stages: | |
2165 | |
2166 -- First see if the charset corresponds to one of the predefined Windows | |
2167 charsets; if so, we see if the registry (that's the last element of the | |
2168 font spec) is that same charset. If so, this means that the font is | |
2169 specifically designed for the charset, and we prefer it. | |
2170 | |
2171 -- However, there are only a limited number of defined Windows charsets, | |
2172 and new ones aren't being defined; so if we fail the first stage, we find | |
2173 a character from the charset with a Unicode equivalent, and see if the | |
2174 font can display this character. we do that by retrieving the Unicode | |
2175 ranges that the font supports, to see if the character comes from that | |
2176 subrange. | |
2177 | |
2178 #### Note: We really want to be doing all these checks at the character | |
2179 level, not the charset level. There's no guarantee that a charset covers | |
2180 a single Unicode range. Furthermore, this is extremely wasteful. We | |
2181 should be doing this when we're about to redisplay and already have the | |
2182 Unicode codepoints in hand. | |
2183 */ | |
2184 | |
2185 static int | |
2186 mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset, | |
2187 const Ibyte *nonreloc, | |
2188 Lisp_Object reloc, | |
2189 Bytecount offset, Bytecount length, | |
3662 | 2190 enum font_specifier_matchspec_stages stage) |
872 | 2191 { |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
2192 return stage == STAGE_FINAL ? |
872 | 2193 mswindows_font_spec_matches_charset_stage_2 (d, charset, nonreloc, |
2194 reloc, offset, length) | |
2195 : mswindows_font_spec_matches_charset_stage_1 (d, charset, nonreloc, | |
2196 reloc, offset, length); | |
2197 } | |
2198 | |
2199 | |
2200 /* Find a font spec that matches font spec FONT and also matches | |
428 | 2201 (the registry of) CHARSET. */ |
872 | 2202 |
428 | 2203 static Lisp_Object |
2204 mswindows_find_charset_font (Lisp_Object device, Lisp_Object font, | |
3659 | 2205 Lisp_Object charset, |
2206 enum font_specifier_matchspec_stages stage) | |
428 | 2207 { |
771 | 2208 Lisp_Object fontlist, fonttail; |
2209 | |
872 | 2210 /* If FONT specifies a particular charset, this will only list fonts with |
2211 that charset; otherwise, it will list fonts with all charsets. */ | |
2527 | 2212 fontlist = mswindows_font_list (font, device, Qnil); |
872 | 2213 |
5015
d95c102a96d3
cleanups for specifier font stages, from ben-unicode-internal (preparation for eliminating shadowed warnings)
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
2214 if (stage == STAGE_INITIAL) |
771 | 2215 { |
872 | 2216 LIST_LOOP (fonttail, fontlist) |
2217 { | |
2218 if (mswindows_font_spec_matches_charset_stage_1 | |
2219 (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1)) | |
2220 return XCAR (fonttail); | |
2221 } | |
771 | 2222 } |
872 | 2223 else |
2224 { | |
2225 LIST_LOOP (fonttail, fontlist) | |
2226 { | |
2227 if (mswindows_font_spec_matches_charset_stage_2 | |
2228 (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1)) | |
2229 return XCAR (fonttail); | |
2230 } | |
2231 } | |
2232 | |
771 | 2233 return Qnil; |
428 | 2234 } |
2235 | |
2236 #endif /* MULE */ | |
2237 | |
2238 | |
2239 /************************************************************************/ | |
2240 /* non-methods */ | |
2241 /************************************************************************/ | |
2242 | |
2527 | 2243 static Lisp_Object |
2244 mswindows_color_list (void) | |
428 | 2245 { |
2246 Lisp_Object result = Qnil; | |
2247 int i; | |
2248 | |
771 | 2249 for (i = 0; i < countof (mswindows_X_color_map); i++) |
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
2250 result = Fcons (build_ascstring (mswindows_X_color_map[i].name), result); |
428 | 2251 |
2252 return Fnreverse (result); | |
2253 } | |
2254 | |
2255 | |
2256 /************************************************************************/ | |
2257 /* initialization */ | |
2258 /************************************************************************/ | |
2259 | |
2260 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5024
diff
changeset
|
2261 syms_of_fontcolor_mswindows (void) |
428 | 2262 { |
2263 } | |
2264 | |
2265 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5024
diff
changeset
|
2266 console_type_create_fontcolor_mswindows (void) |
428 | 2267 { |
2268 /* object methods */ | |
2269 CONSOLE_HAS_METHOD (mswindows, initialize_color_instance); | |
2270 /* CONSOLE_HAS_METHOD (mswindows, mark_color_instance); */ | |
2271 CONSOLE_HAS_METHOD (mswindows, print_color_instance); | |
2272 CONSOLE_HAS_METHOD (mswindows, finalize_color_instance); | |
2273 CONSOLE_HAS_METHOD (mswindows, color_instance_equal); | |
2274 CONSOLE_HAS_METHOD (mswindows, color_instance_hash); | |
2275 CONSOLE_HAS_METHOD (mswindows, color_instance_rgb_components); | |
2276 CONSOLE_HAS_METHOD (mswindows, valid_color_name_p); | |
2527 | 2277 CONSOLE_HAS_METHOD (mswindows, color_list); |
428 | 2278 |
2279 CONSOLE_HAS_METHOD (mswindows, initialize_font_instance); | |
2280 /* CONSOLE_HAS_METHOD (mswindows, mark_font_instance); */ | |
2281 CONSOLE_HAS_METHOD (mswindows, print_font_instance); | |
2282 CONSOLE_HAS_METHOD (mswindows, finalize_font_instance); | |
442 | 2283 CONSOLE_HAS_METHOD (mswindows, font_instance_truename); |
2527 | 2284 CONSOLE_HAS_METHOD (mswindows, font_list); |
428 | 2285 #ifdef MULE |
2286 CONSOLE_HAS_METHOD (mswindows, font_spec_matches_charset); | |
2287 CONSOLE_HAS_METHOD (mswindows, find_charset_font); | |
2288 #endif | |
440 | 2289 |
2290 /* Printer methods - delegate most to windows methods, | |
2291 since graphical objects behave the same way. */ | |
2292 | |
2293 CONSOLE_INHERITS_METHOD (msprinter, mswindows, initialize_color_instance); | |
2294 /* CONSOLE_INHERITS_METHOD (msprinter, mswindows, mark_color_instance); */ | |
2295 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_color_instance); | |
2296 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_color_instance); | |
2297 CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_equal); | |
2298 CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_hash); | |
2299 CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_rgb_components); | |
2300 CONSOLE_INHERITS_METHOD (msprinter, mswindows, valid_color_name_p); | |
2527 | 2301 CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_list); |
440 | 2302 |
2303 CONSOLE_HAS_METHOD (msprinter, initialize_font_instance); | |
2304 /* CONSOLE_INHERITS_METHOD (msprinter, mswindows, mark_font_instance); */ | |
2305 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_font_instance); | |
2306 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_font_instance); | |
442 | 2307 CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_instance_truename); |
2527 | 2308 CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_list); |
440 | 2309 #ifdef MULE |
2310 CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_spec_matches_charset); | |
2311 CONSOLE_INHERITS_METHOD (msprinter, mswindows, find_charset_font); | |
2312 #endif | |
428 | 2313 } |
2314 | |
2315 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5024
diff
changeset
|
2316 reinit_vars_of_fontcolor_mswindows (void) |
788 | 2317 { |
2318 #ifdef MULE | |
2319 int i; | |
2320 | |
2321 unicode_subrange_table = xnew_array_and_zero (unicode_subrange_t, 128); | |
2322 for (i = 0; i < countof (unicode_subrange_raw_map); i++) | |
2323 { | |
2324 const unicode_subrange_raw_t *el = &unicode_subrange_raw_map[i]; | |
2325 if (unicode_subrange_table[el->subrange_bit].subranges == 0) | |
2326 unicode_subrange_table[el->subrange_bit].subranges = el; | |
2327 unicode_subrange_table[el->subrange_bit].no_subranges++; | |
2328 } | |
2329 | |
2330 Fclrhash (Vfont_signature_data); | |
2331 #endif /* MULE */ | |
2332 } | |
2333 | |
2334 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
5024
diff
changeset
|
2335 vars_of_fontcolor_mswindows (void) |
428 | 2336 { |
788 | 2337 #ifdef MULE |
2338 Vfont_signature_data = | |
2339 make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL); | |
2340 staticpro (&Vfont_signature_data); | |
2341 #endif /* MULE */ | |
428 | 2342 } |