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