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.
788
+ − 5 Copyright (C) 1995, 1996, 2000, 2001, 2002 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 {
771
+ − 53 const Char_ASCII *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 {
771
+ − 731 const Char_ASCII *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 }
771
+ − 967 else if (!qxestrncmp_c (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 {
867
+ − 993 Ibyte *nospaces = (Ibyte *) ALLOCA (qxestrlen (name) + 1);
+ − 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++)
771
+ − 1003 if (!qxestrcasecmp_c (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;
771
+ − 1013 Char_ASCII 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)
771
+ − 1060 qxestrcat_c (qxestrcat (fontname, c1), ":");
428
+ − 1061 }
+ − 1062 else if (fontname)
+ − 1063 {
771
+ − 1064 if (c2 && c2[0] != '\0')
+ − 1065 qxestrcat_c (qxestrcat (fontname, c2), ":");
428
+ − 1066 else
771
+ − 1067 qxestrcat_c (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 {
771
+ − 1137 qxestrcat_c (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
771
+ − 1158 font_enum_callback_1 (ENUMLOGFONTEXW *lpelfe, NEWTEXTMETRICEXW *lpntme,
428
+ − 1159 int FontType, struct font_enum_t *font_enum)
+ − 1160 {
+ − 1161 /* This function gets called once per facename per character set.
+ − 1162 * We call a second callback to enumerate the fonts in each facename */
771
+ − 1163 return qxeEnumFontFamiliesEx (font_enum->hdc, &lpelfe->elfLogFont,
+ − 1164 (FONTENUMPROCW) font_enum_callback_2,
+ − 1165 (LPARAM) font_enum, 0);
428
+ − 1166 }
+ − 1167
872
+ − 1168 /* Function for sorting lists of fonts as obtained from
+ − 1169 mswindows_enumerate_fonts(). These come in a known format:
+ − 1170 "family::::charset" for TrueType fonts, "family::size::charset"
+ − 1171 otherwise. */
+ − 1172
+ − 1173 static int
+ − 1174 sort_font_list_function (Lisp_Object obj1, Lisp_Object obj2,
+ − 1175 Lisp_Object pred)
+ − 1176 {
+ − 1177 Ibyte *font1, *font2;
+ − 1178 Ibyte *c1, *c2;
+ − 1179 int t1, t2;
+ − 1180
+ − 1181 /*
+ − 1182 1. fixed over proportional.
+ − 1183 2. Western over other charsets.
+ − 1184 3. TrueType over non-TrueType.
+ − 1185 4. Within non-TrueType, sizes closer to 10pt over sizes farther from 10pt.
+ − 1186 5. Courier New over other families.
+ − 1187 */
+ − 1188
+ − 1189 /* The sort function should return > 0 if OBJ1 < OBJ2, < 0 otherwise.
+ − 1190 NOTE: This is backwards from the way qsort() works. */
+ − 1191
+ − 1192 t1 = !NILP (XCDR (obj1));
+ − 1193 t2 = !NILP (XCDR (obj2));
+ − 1194
+ − 1195 if (t1 && !t2)
+ − 1196 return 1;
+ − 1197 if (t2 && !t1)
+ − 1198 return -1;
+ − 1199
+ − 1200 font1 = XSTRING_DATA (XCAR (obj1));
+ − 1201 font2 = XSTRING_DATA (XCAR (obj2));
+ − 1202
+ − 1203 c1 = qxestrrchr (font1, ':');
+ − 1204 c2 = qxestrrchr (font2, ':');
+ − 1205
+ − 1206 t1 = !qxestrcasecmp_c (c1 + 1, "western");
+ − 1207 t2 = !qxestrcasecmp_c (c2 + 1, "western");
+ − 1208
+ − 1209 if (t1 && !t2)
+ − 1210 return 1;
+ − 1211 if (t2 && !t1)
+ − 1212 return -1;
+ − 1213
+ − 1214 c1 -= 2;
+ − 1215 c2 -= 2;
+ − 1216 t1 = *c1 == ':';
+ − 1217 t2 = *c2 == ':';
+ − 1218
+ − 1219 if (t1 && !t2)
+ − 1220 return 1;
+ − 1221 if (t2 && !t1)
+ − 1222 return -1;
+ − 1223
+ − 1224 if (!t1 && !t2)
+ − 1225 {
+ − 1226 while (isdigit (*c1))
+ − 1227 c1--;
+ − 1228 while (isdigit (*c2))
+ − 1229 c2--;
+ − 1230
+ − 1231 t1 = qxeatoi (c1 + 1) - 10;
+ − 1232 t2 = qxeatoi (c2 + 1) - 10;
+ − 1233
+ − 1234 if (abs (t1) < abs (t2))
+ − 1235 return 1;
+ − 1236 else if (abs (t2) < abs (t1))
+ − 1237 return -1;
+ − 1238 else if (t1 < t2)
+ − 1239 /* Prefer a smaller font over a larger one just as far away
+ − 1240 because the smaller one won't upset the total line height if it's
+ − 1241 just a few chars. */
+ − 1242 return 1;
+ − 1243 }
+ − 1244
+ − 1245 t1 = !qxestrncasecmp_c (font1, "courier new:", 12);
+ − 1246 t2 = !qxestrncasecmp_c (font2, "courier new:", 12);
+ − 1247
+ − 1248 if (t1 && !t2)
+ − 1249 return 1;
+ − 1250 if (t2 && !t1)
+ − 1251 return -1;
+ − 1252
+ − 1253 return -1;
+ − 1254 }
+ − 1255
428
+ − 1256 /*
440
+ − 1257 * Enumerate the available on the HDC fonts and return a list of string
+ − 1258 * font names.
428
+ − 1259 */
440
+ − 1260 Lisp_Object
+ − 1261 mswindows_enumerate_fonts (HDC hdc)
428
+ − 1262 {
771
+ − 1263 /* This cannot GC */
+ − 1264 LOGFONTW logfont;
428
+ − 1265 struct font_enum_t font_enum;
+ − 1266
771
+ − 1267 assert (hdc != NULL);
428
+ − 1268 logfont.lfCharSet = DEFAULT_CHARSET;
+ − 1269 logfont.lfFaceName[0] = '\0';
+ − 1270 logfont.lfPitchAndFamily = DEFAULT_PITCH;
+ − 1271 font_enum.hdc = hdc;
440
+ − 1272 font_enum.list = Qnil;
771
+ − 1273 /* EnumFontFamilies seems to enumerate only one charset per font, which
+ − 1274 is not what we want. We aren't supporting NT 3.5x, so no need to
+ − 1275 worry about this not existing. */
+ − 1276 qxeEnumFontFamiliesEx (hdc, &logfont, (FONTENUMPROCW) font_enum_callback_1,
+ − 1277 (LPARAM) (&font_enum), 0);
442
+ − 1278
872
+ − 1279 return list_sort (font_enum.list, Qnil, sort_font_list_function);
428
+ − 1280 }
+ − 1281
442
+ − 1282 static HFONT
771
+ − 1283 mswindows_create_font_variant (Lisp_Font_Instance *f,
440
+ − 1284 int under, int strike)
+ − 1285 {
+ − 1286 /* Cannot GC */
771
+ − 1287 LOGFONTW lf;
440
+ − 1288 HFONT hfont;
+ − 1289
+ − 1290 assert (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) == NULL);
+ − 1291
771
+ − 1292 if (qxeGetObject (FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0),
+ − 1293 sizeof (lf), (void *) &lf) == 0)
440
+ − 1294 {
+ − 1295 hfont = MSWINDOWS_BAD_HFONT;
+ − 1296 }
+ − 1297 else
+ − 1298 {
+ − 1299 lf.lfUnderline = under;
+ − 1300 lf.lfStrikeOut = strike;
+ − 1301
771
+ − 1302 hfont = qxeCreateFontIndirect (&lf);
440
+ − 1303 if (hfont == NULL)
+ − 1304 hfont = MSWINDOWS_BAD_HFONT;
+ − 1305 }
+ − 1306
+ − 1307 FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike) = hfont;
442
+ − 1308 return hfont;
440
+ − 1309 }
+ − 1310
+ − 1311 HFONT
771
+ − 1312 mswindows_get_hfont (Lisp_Font_Instance *f,
440
+ − 1313 int under, int strike)
+ − 1314 {
+ − 1315 /* Cannot GC */
442
+ − 1316 HFONT hfont = FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, under, strike);
440
+ − 1317
442
+ − 1318 if (hfont == NULL)
+ − 1319 hfont = mswindows_create_font_variant (f, under, strike);
440
+ − 1320
+ − 1321 /* If strikeout/underline variant of the font could not be
+ − 1322 created, then use the base version of the font */
+ − 1323 if (hfont == MSWINDOWS_BAD_HFONT)
+ − 1324 hfont = FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0);
+ − 1325
+ − 1326 assert (hfont != NULL && hfont != MSWINDOWS_BAD_HFONT);
+ − 1327
+ − 1328 return hfont;
+ − 1329 }
428
+ − 1330
+ − 1331 /************************************************************************/
+ − 1332 /* methods */
+ − 1333 /************************************************************************/
+ − 1334
+ − 1335 static int
440
+ − 1336 mswindows_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name,
647
+ − 1337 Lisp_Object device, Error_Behavior errb)
428
+ − 1338 {
+ − 1339 COLORREF color;
+ − 1340
771
+ − 1341 color = mswindows_string_to_color (XSTRING_DATA (name));
647
+ − 1342 if (color != (COLORREF) -1)
428
+ − 1343 {
+ − 1344 c->data = xnew (struct mswindows_color_instance_data);
+ − 1345 COLOR_INSTANCE_MSWINDOWS_COLOR (c) = color;
+ − 1346 return 1;
+ − 1347 }
563
+ − 1348 maybe_signal_error (Qinvalid_constant,
771
+ − 1349 "Unrecognized color", name, Qcolor, errb);
428
+ − 1350 return(0);
+ − 1351 }
+ − 1352
+ − 1353 #if 0
+ − 1354 static void
440
+ − 1355 mswindows_mark_color_instance (Lisp_Color_Instance *c)
428
+ − 1356 {
+ − 1357 }
+ − 1358 #endif
+ − 1359
+ − 1360 static void
440
+ − 1361 mswindows_print_color_instance (Lisp_Color_Instance *c,
+ − 1362 Lisp_Object printcharfun,
+ − 1363 int escapeflag)
428
+ − 1364 {
+ − 1365 COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c);
793
+ − 1366 write_fmt_string (printcharfun,
+ − 1367 " %06ld=(%04X,%04X,%04X)", color & 0xffffff,
+ − 1368 GetRValue (color) * 257, GetGValue (color) * 257,
+ − 1369 GetBValue (color) * 257);
428
+ − 1370 }
+ − 1371
+ − 1372 static void
440
+ − 1373 mswindows_finalize_color_instance (Lisp_Color_Instance *c)
428
+ − 1374 {
+ − 1375 if (c->data)
+ − 1376 {
+ − 1377 xfree (c->data);
+ − 1378 c->data = 0;
+ − 1379 }
+ − 1380 }
+ − 1381
+ − 1382 static int
440
+ − 1383 mswindows_color_instance_equal (Lisp_Color_Instance *c1,
+ − 1384 Lisp_Color_Instance *c2,
+ − 1385 int depth)
428
+ − 1386 {
793
+ − 1387 return (COLOR_INSTANCE_MSWINDOWS_COLOR (c1) ==
+ − 1388 COLOR_INSTANCE_MSWINDOWS_COLOR (c2));
428
+ − 1389 }
+ − 1390
+ − 1391 static unsigned long
440
+ − 1392 mswindows_color_instance_hash (Lisp_Color_Instance *c, int depth)
428
+ − 1393 {
793
+ − 1394 return (unsigned long) COLOR_INSTANCE_MSWINDOWS_COLOR (c);
428
+ − 1395 }
+ − 1396
+ − 1397 static Lisp_Object
440
+ − 1398 mswindows_color_instance_rgb_components (Lisp_Color_Instance *c)
428
+ − 1399 {
+ − 1400 COLORREF color = COLOR_INSTANCE_MSWINDOWS_COLOR (c);
+ − 1401 return list3 (make_int (GetRValue (color) * 257),
+ − 1402 make_int (GetGValue (color) * 257),
+ − 1403 make_int (GetBValue (color) * 257));
+ − 1404 }
+ − 1405
+ − 1406 static int
+ − 1407 mswindows_valid_color_name_p (struct device *d, Lisp_Object color)
+ − 1408 {
771
+ − 1409 return (mswindows_string_to_color (XSTRING_DATA (color)) != (COLORREF) -1);
428
+ − 1410 }
+ − 1411
+ − 1412
+ − 1413
+ − 1414 static void
440
+ − 1415 mswindows_finalize_font_instance (Lisp_Font_Instance *f);
428
+ − 1416
872
+ − 1417 /* Parse the font spec in NAMESTR. Maybe issue errors, according to ERRB;
+ − 1418 NAME_FOR_ERRORS is the Lisp string to use when issuing errors. Store
+ − 1419 the five parts of the font spec into the given strings, which should be
+ − 1420 declared as
+ − 1421
+ − 1422 Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], points[8];
+ − 1423 Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE];
+ − 1424
+ − 1425 If LOGFONT is given, store the necessary information in LOGFONT to
+ − 1426 create a font object. If LOGFONT is given, HDC must also be given;
+ − 1427 else, NULL can be given for both.
+ − 1428
+ − 1429 Return 1 if ok, 0 if error.
+ − 1430 */
+ − 1431 static int
+ − 1432 parse_font_spec (const Ibyte *namestr,
+ − 1433 HDC hdc,
+ − 1434 Lisp_Object name_for_errors,
+ − 1435 Error_Behavior errb,
+ − 1436 LOGFONTW *logfont,
+ − 1437 Ibyte *fontname,
+ − 1438 Ibyte *weight,
+ − 1439 Ibyte *points,
+ − 1440 Ibyte *effects,
+ − 1441 Ibyte *charset)
428
+ − 1442 {
+ − 1443 int fields, i;
+ − 1444 int pt;
872
+ − 1445 Ibyte *style;
867
+ − 1446 Ibyte *c;
428
+ − 1447
+ − 1448 /*
+ − 1449 * mswindows fonts look like:
+ − 1450 * fontname[:[weight ][style][:pointsize[:effects]]][:charset]
+ − 1451 * The font name field shouldn't be empty.
+ − 1452 *
+ − 1453 * ie:
+ − 1454 * Lucida Console:Regular:10
+ − 1455 * minimal:
+ − 1456 * Courier New
+ − 1457 * maximal:
+ − 1458 * Courier New:Bold Italic:10:underline strikeout:western
+ − 1459 */
+ − 1460
872
+ − 1461 fontname[0] = 0;
+ − 1462 weight[0] = 0;
+ − 1463 points[0] = 0;
+ − 1464 effects[0] = 0;
+ − 1465 charset[0] = 0;
+ − 1466
+ − 1467 if (logfont)
+ − 1468 xzero (*logfont);
+ − 1469
867
+ − 1470 fields = sscanf ((CIbyte *) namestr, "%31[^:]:%31[^:]:%7[^:]:%31[^:]:%31s",
428
+ − 1471 fontname, weight, points, effects, charset);
+ − 1472
+ − 1473 /* This function is implemented in a fairly ad-hoc manner.
+ − 1474 * The general idea is to validate and canonicalize each of the above fields
+ − 1475 * at the same time as we build up the win32 LOGFONT structure. This enables
+ − 1476 * us to use match_font() on a canonicalized font string to check the
+ − 1477 * availability of the requested font */
+ − 1478
+ − 1479 if (fields < 0)
771
+ − 1480 {
788
+ − 1481 maybe_signal_error (Qinvalid_argument, "Invalid font", name_for_errors,
771
+ − 1482 Qfont, errb);
872
+ − 1483 return 0;
771
+ − 1484 }
+ − 1485
+ − 1486 if (fields > 0 && qxestrlen (fontname))
+ − 1487 {
+ − 1488 Extbyte *extfontname;
428
+ − 1489
771
+ − 1490 C_STRING_TO_TSTR (fontname, extfontname);
872
+ − 1491 if (logfont)
+ − 1492 {
+ − 1493 xetcsncpy ((Extbyte *) logfont->lfFaceName, extfontname,
+ − 1494 LF_FACESIZE - 1);
+ − 1495 logfont->lfFaceName[LF_FACESIZE - 1] = 0;
+ − 1496 }
771
+ − 1497 }
428
+ − 1498
+ − 1499 /* weight */
+ − 1500 if (fields < 2)
771
+ − 1501 qxestrcpy_c (weight, fontweight_map[0].name);
428
+ − 1502
+ − 1503 /* Maybe split weight into weight and style */
771
+ − 1504 if ((c = qxestrchr (weight, ' ')))
872
+ − 1505 {
+ − 1506 *c = '\0';
+ − 1507 style = c + 1;
+ − 1508 }
428
+ − 1509 else
+ − 1510 style = NULL;
+ − 1511
771
+ − 1512 for (i = 0; i < countof (fontweight_map); i++)
+ − 1513 if (!qxestrcasecmp_c (weight, fontweight_map[i].name))
442
+ − 1514 {
872
+ − 1515 if (logfont)
+ − 1516 logfont->lfWeight = fontweight_map[i].value;
428
+ − 1517 break;
+ − 1518 }
+ − 1519 if (i == countof (fontweight_map)) /* No matching weight */
+ − 1520 {
+ − 1521 if (!style)
+ − 1522 {
872
+ − 1523 if (logfont)
+ − 1524 logfont->lfWeight = FW_REGULAR;
428
+ − 1525 style = weight; /* May have specified style without weight */
+ − 1526 }
+ − 1527 else
+ − 1528 {
788
+ − 1529 maybe_signal_error (Qinvalid_constant, "Invalid font weight",
+ − 1530 name_for_errors, Qfont, errb);
872
+ − 1531 return 0;
428
+ − 1532 }
+ − 1533 }
+ − 1534
+ − 1535 if (style)
+ − 1536 {
+ − 1537 /* #### what about oblique? */
771
+ − 1538 if (qxestrcasecmp_c (style, "italic") == 0)
872
+ − 1539 {
+ − 1540 if (logfont)
+ − 1541 logfont->lfItalic = TRUE;
+ − 1542 }
428
+ − 1543 else
788
+ − 1544 {
+ − 1545 maybe_signal_error (Qinvalid_constant,
+ − 1546 "Invalid font weight or style",
+ − 1547 name_for_errors, Qfont, errb);
872
+ − 1548 return 0;
428
+ − 1549 }
+ − 1550
+ − 1551 /* Glue weight and style together again */
+ − 1552 if (weight != style)
+ − 1553 *c = ' ';
+ − 1554 }
872
+ − 1555 else if (logfont)
+ − 1556 logfont->lfItalic = FALSE;
428
+ − 1557
872
+ − 1558 if (fields < 3 || !qxestrcmp_c (points, ""))
+ − 1559 ;
+ − 1560 else if (points[0] == '0' ||
+ − 1561 qxestrspn (points, "0123456789") < qxestrlen (points))
428
+ − 1562 {
788
+ − 1563 maybe_signal_error (Qinvalid_argument, "Invalid font pointsize",
+ − 1564 name_for_errors, Qfont, errb);
872
+ − 1565 return 0;
+ − 1566 }
+ − 1567 else
+ − 1568 {
+ − 1569 pt = qxeatoi (points);
+ − 1570
+ − 1571 if (logfont)
+ − 1572 {
+ − 1573 /* Formula for pointsize->height from LOGFONT docs in MSVC5 Platform
+ − 1574 SDK */
+ − 1575 logfont->lfHeight = -MulDiv (pt, GetDeviceCaps (hdc, LOGPIXELSY),
+ − 1576 72);
+ − 1577 logfont->lfWidth = 0;
+ − 1578 }
428
+ − 1579 }
+ − 1580
872
+ − 1581 /* Effects */
+ − 1582 if (logfont)
+ − 1583 {
+ − 1584 logfont->lfUnderline = FALSE;
+ − 1585 logfont->lfStrikeOut = FALSE;
+ − 1586 }
428
+ − 1587
+ − 1588 if (fields >= 4 && effects[0] != '\0')
+ − 1589 {
867
+ − 1590 Ibyte *effects2;
872
+ − 1591 int underline = FALSE, strikeout = FALSE;
428
+ − 1592
+ − 1593 /* Maybe split effects into effects and effects2 */
771
+ − 1594 if ((c = qxestrchr (effects, ' ')))
428
+ − 1595 {
+ − 1596 *c = '\0';
771
+ − 1597 effects2 = c + 1;
428
+ − 1598 }
+ − 1599 else
+ − 1600 effects2 = NULL;
+ − 1601
771
+ − 1602 if (qxestrcasecmp_c (effects, "underline") == 0)
872
+ − 1603 underline = TRUE;
771
+ − 1604 else if (qxestrcasecmp_c (effects, "strikeout") == 0)
872
+ − 1605 strikeout = TRUE;
428
+ − 1606 else
+ − 1607 {
788
+ − 1608 maybe_signal_error (Qinvalid_constant, "Invalid font effect",
+ − 1609 name_for_errors, Qfont, errb);
872
+ − 1610 return 0;
428
+ − 1611 }
+ − 1612
+ − 1613 if (effects2 && effects2[0] != '\0')
+ − 1614 {
771
+ − 1615 if (qxestrcasecmp_c (effects2, "underline") == 0)
872
+ − 1616 underline = TRUE;
771
+ − 1617 else if (qxestrcasecmp_c (effects2, "strikeout") == 0)
872
+ − 1618 strikeout = TRUE;
428
+ − 1619 else
+ − 1620 {
771
+ − 1621 maybe_signal_error (Qinvalid_constant, "Invalid font effect",
788
+ − 1622 name_for_errors, Qfont, errb);
872
+ − 1623 return 0;
428
+ − 1624 }
+ − 1625 }
+ − 1626
872
+ − 1627 /* Regenerate sanitized effects string */
+ − 1628 if (underline)
428
+ − 1629 {
872
+ − 1630 if (strikeout)
771
+ − 1631 qxestrcpy_c (effects, "underline strikeout");
428
+ − 1632 else
771
+ − 1633 qxestrcpy_c (effects, "underline");
428
+ − 1634 }
872
+ − 1635 else if (strikeout)
771
+ − 1636 qxestrcpy_c (effects, "strikeout");
872
+ − 1637
+ − 1638 if (logfont)
+ − 1639 {
+ − 1640 logfont->lfUnderline = underline;
+ − 1641 logfont->lfStrikeOut = strikeout;
+ − 1642 }
428
+ − 1643 }
+ − 1644
+ − 1645 /* Charset */
442
+ − 1646 /* charset can be specified even if earlier fields haven't been */
428
+ − 1647 if (fields < 5)
+ − 1648 {
771
+ − 1649 if ((c = qxestrchr (namestr, ':')) && (c = qxestrchr (c + 1, ':')) &&
+ − 1650 (c = qxestrchr (c + 1, ':')) && (c = qxestrchr (c + 1, ':')))
428
+ − 1651 {
771
+ − 1652 qxestrncpy (charset, c + 1, LF_FACESIZE);
+ − 1653 charset[LF_FACESIZE - 1] = '\0';
428
+ − 1654 }
+ − 1655 }
+ − 1656
872
+ − 1657 /* NOTE: If you give a blank charset spec, we will normally not get here
+ − 1658 under Mule unless we explicitly call `make-font-instance'! This is
+ − 1659 because the C code instantiates fonts using particular charsets, by
+ − 1660 way of specifier_matching_instance(). Before instantiating the font,
+ − 1661 font_instantiate() calls the devmeth find_matching_font(), which gets
+ − 1662 a truename font spec with the registry (i.e. the charset spec) filled
+ − 1663 in appropriately to the charset. */
+ − 1664 if (!qxestrcmp_c (charset, ""))
+ − 1665 ;
+ − 1666 else
+ − 1667 {
+ − 1668 for (i = 0; i < countof (charset_map); i++)
+ − 1669 if (!qxestrcasecmp_c (charset, charset_map[i].name))
+ − 1670 {
+ − 1671 if (logfont)
+ − 1672 logfont->lfCharSet = charset_map[i].value;
+ − 1673 break;
+ − 1674 }
428
+ − 1675
872
+ − 1676 if (i == countof (charset_map)) /* No matching charset */
+ − 1677 {
+ − 1678 maybe_signal_error (Qinvalid_argument, "Invalid charset",
+ − 1679 name_for_errors, Qfont, errb);
+ − 1680 return 0;
+ − 1681 }
+ − 1682 }
+ − 1683
+ − 1684 if (logfont)
428
+ − 1685 {
872
+ − 1686 /* Misc crud */
+ − 1687 #if 1
+ − 1688 logfont->lfOutPrecision = OUT_DEFAULT_PRECIS;
+ − 1689 logfont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ − 1690 logfont->lfQuality = DEFAULT_QUALITY;
+ − 1691 #else
+ − 1692 logfont->lfOutPrecision = OUT_STROKE_PRECIS;
+ − 1693 logfont->lfClipPrecision = CLIP_STROKE_PRECIS;
+ − 1694 logfont->lfQuality = PROOF_QUALITY;
+ − 1695 #endif
+ − 1696 /* Default to monospaced if the specified fontname doesn't exist. */
+ − 1697 logfont->lfPitchAndFamily = FF_MODERN;
428
+ − 1698 }
+ − 1699
872
+ − 1700 return 1;
+ − 1701 }
+ − 1702
+ − 1703 /*
+ − 1704 mswindows fonts look like:
+ − 1705 [fontname[:style[:pointsize[:effects]]]][:charset]
+ − 1706 A maximal mswindows font spec looks like:
+ − 1707 Courier New:Bold Italic:10:underline strikeout:Western
+ − 1708
+ − 1709 A missing weight/style field is the same as Regular, and a missing
+ − 1710 effects field is left alone, and means no effects; but a missing
+ − 1711 fontname, pointsize or charset field means any will do. We prefer
+ − 1712 Courier New, 10, Western. See sort function above. */
428
+ − 1713
872
+ − 1714 static HFONT
+ − 1715 create_hfont_from_font_spec (const Ibyte *namestr,
+ − 1716 HDC hdc,
+ − 1717 Lisp_Object name_for_errors,
+ − 1718 Lisp_Object device_font_list,
+ − 1719 Error_Behavior errb,
+ − 1720 Lisp_Object *truename_ret)
+ − 1721 {
+ − 1722 LOGFONTW logfont;
+ − 1723 HFONT hfont;
+ − 1724 Ibyte fontname[LF_FACESIZE], weight[LF_FACESIZE], points[8];
+ − 1725 Ibyte effects[LF_FACESIZE], charset[LF_FACESIZE];
+ − 1726 Ibyte truename[MSW_FONTSIZE];
+ − 1727 Ibyte truername[MSW_FONTSIZE];
+ − 1728
+ − 1729 /* Windows will silently substitute a default font if the fontname
+ − 1730 specifies a non-existent font. This is bad for screen fonts because
+ − 1731 it doesn't allow higher-level code to see the error and to act
+ − 1732 appropriately. For instance complex_vars_of_faces() sets up a
+ − 1733 fallback list of fonts for the default face. Instead, we look at all
+ − 1734 the possibilities and pick one that works, handling missing pointsize
+ − 1735 and charset fields appropriately.
+ − 1736
+ − 1737 For printer fonts, we used to go ahead and let Windows choose the
+ − 1738 font, and for those devices, then, DEVICE_FONT_LIST would be nil.
+ − 1739 However, this causes problems with the font-matching code below, which
+ − 1740 needs a list of fonts so it can pick the right one for Mule.
+ − 1741
+ − 1742 Thus, the code below to handle a nil DEVICE_FONT_LIST is not currently
+ − 1743 used. */
440
+ − 1744
+ − 1745 if (!NILP (device_font_list))
+ − 1746 {
872
+ − 1747 Lisp_Object fonttail = Qnil;
+ − 1748
+ − 1749 if (!parse_font_spec (namestr, 0, name_for_errors,
+ − 1750 errb, 0, fontname, weight, points,
+ − 1751 effects, charset))
+ − 1752 return 0;
+ − 1753
+ − 1754 /* The fonts in the device font list always specify fontname and
+ − 1755 charset, but often times not the size; so if we don't have the
+ − 1756 size specified either, do a round with size 10 so we'll always end
+ − 1757 up with a size in the truename (if we fail this one but succeed
+ − 1758 the next one, we'll have chosen a non-TrueType font, and in those
+ − 1759 cases the size is specified in the font list item. */
+ − 1760
+ − 1761 if (!points[0])
+ − 1762 {
+ − 1763 qxesprintf (truename, "%s:%s:10:%s:%s",
+ − 1764 fontname, weight, effects, charset);
428
+ − 1765
872
+ − 1766 LIST_LOOP (fonttail, device_font_list)
+ − 1767 {
+ − 1768 if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))),
+ − 1769 truename, truername))
+ − 1770 break;
+ − 1771 }
+ − 1772 }
+ − 1773
+ − 1774 if (NILP (fonttail))
440
+ − 1775 {
872
+ − 1776 qxesprintf (truename, "%s:%s:%s:%s:%s",
+ − 1777 fontname, weight, points, effects, charset);
+ − 1778
+ − 1779 LIST_LOOP (fonttail, device_font_list)
+ − 1780 {
+ − 1781 if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))),
+ − 1782 truename, truername))
+ − 1783 break;
+ − 1784 }
440
+ − 1785 }
872
+ − 1786
440
+ − 1787 if (NILP (fonttail))
+ − 1788 {
788
+ − 1789 maybe_signal_error (Qinvalid_argument, "No matching font",
+ − 1790 name_for_errors, Qfont, errb);
872
+ − 1791 return 0;
440
+ − 1792 }
872
+ − 1793
+ − 1794 if (!parse_font_spec (truername, hdc, name_for_errors,
+ − 1795 ERROR_ME_DEBUG_WARN, &logfont, fontname, weight,
+ − 1796 points, effects, charset))
+ − 1797 signal_error (Qinternal_error, "Bad value in device font list?",
+ − 1798 build_intstring (truername));
440
+ − 1799 }
872
+ − 1800 else if (!parse_font_spec (namestr, hdc, name_for_errors,
+ − 1801 errb, &logfont, fontname, weight, points,
+ − 1802 effects, charset))
+ − 1803 return 0;
440
+ − 1804
771
+ − 1805 if ((hfont = qxeCreateFontIndirect (&logfont)) == NULL)
788
+ − 1806 {
+ − 1807 maybe_signal_error (Qgui_error, "Couldn't create font",
+ − 1808 name_for_errors, Qfont, errb);
872
+ − 1809 return 0;
788
+ − 1810 }
+ − 1811
872
+ − 1812 /* #### Truename will not have all its fields filled in when we have no
+ − 1813 list of fonts. Doesn't really matter now, since we always have one.
+ − 1814 See above. */
+ − 1815 qxesprintf (truename, "%s:%s:%s:%s:%s", fontname, weight,
+ − 1816 points, effects, charset);
+ − 1817
+ − 1818 *truename_ret = build_intstring (truename);
788
+ − 1819 return hfont;
+ − 1820 }
+ − 1821
+ − 1822 /*
+ − 1823 * This is a work horse for both mswindows_initialize_font_instance and
+ − 1824 * msprinter_initialize_font_instance.
+ − 1825 */
+ − 1826 static int
+ − 1827 initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name,
+ − 1828 Lisp_Object device_font_list, HDC hdc,
+ − 1829 Error_Behavior errb)
+ − 1830 {
+ − 1831 HFONT hfont, hfont2;
+ − 1832 TEXTMETRICW metrics;
867
+ − 1833 Ibyte *namestr = XSTRING_DATA (name);
872
+ − 1834 Lisp_Object truename;
788
+ − 1835
+ − 1836 hfont = create_hfont_from_font_spec (namestr, hdc, name, device_font_list,
872
+ − 1837 errb, &truename);
+ − 1838 f->truename = truename;
440
+ − 1839 f->data = xnew_and_zero (struct mswindows_font_instance_data);
872
+ − 1840 FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0) = hfont;
442
+ − 1841
+ − 1842 /* Some underlined fonts have the descent of one pixel more than their
+ − 1843 non-underlined counterparts. Font variants though are assumed to have
+ − 1844 identical metrics. So get the font metrics from the underlined variant
+ − 1845 of the font */
+ − 1846 hfont2 = mswindows_create_font_variant (f, 1, 0);
+ − 1847 if (hfont2 != MSWINDOWS_BAD_HFONT)
+ − 1848 hfont = hfont2;
+ − 1849
+ − 1850 hfont2 = (HFONT) SelectObject (hdc, hfont);
+ − 1851 if (!hfont2)
428
+ − 1852 {
440
+ − 1853 mswindows_finalize_font_instance (f);
563
+ − 1854 maybe_signal_error (Qgui_error, "Couldn't map font", name, Qfont, errb);
440
+ − 1855 return 0;
+ − 1856 }
771
+ − 1857 qxeGetTextMetrics (hdc, &metrics);
+ − 1858 SelectObject (hdc, hfont2);
440
+ − 1859
+ − 1860 f->width = (unsigned short) metrics.tmAveCharWidth;
+ − 1861 f->height = (unsigned short) metrics.tmHeight;
442
+ − 1862 f->ascent = (unsigned short) metrics.tmAscent;
+ − 1863 f->descent = (unsigned short) metrics.tmDescent;
440
+ − 1864 f->proportional_p = (metrics.tmPitchAndFamily & TMPF_FIXED_PITCH);
+ − 1865
+ − 1866 return 1;
+ − 1867 }
+ − 1868
+ − 1869 static int
+ − 1870 mswindows_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name,
578
+ − 1871 Lisp_Object device, Error_Behavior errb)
440
+ − 1872 {
+ − 1873 HDC hdc = CreateCompatibleDC (NULL);
+ − 1874 Lisp_Object font_list = DEVICE_MSWINDOWS_FONTLIST (XDEVICE (device));
+ − 1875 int res = initialize_font_instance (f, name, font_list, hdc, errb);
+ − 1876 DeleteDC (hdc);
+ − 1877 return res;
+ − 1878 }
+ − 1879
+ − 1880 static int
+ − 1881 msprinter_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object name,
578
+ − 1882 Lisp_Object device, Error_Behavior errb)
440
+ − 1883 {
+ − 1884 HDC hdc = DEVICE_MSPRINTER_HDC (XDEVICE (device));
+ − 1885 Lisp_Object font_list = DEVICE_MSPRINTER_FONTLIST (XDEVICE (device));
+ − 1886 return initialize_font_instance (f, name, font_list, hdc, errb);
+ − 1887 }
+ − 1888
+ − 1889 static void
+ − 1890 mswindows_finalize_font_instance (Lisp_Font_Instance *f)
+ − 1891 {
+ − 1892 int i;
+ − 1893
+ − 1894 if (f->data)
+ − 1895 {
+ − 1896 for (i = 0; i < MSWINDOWS_NUM_FONT_VARIANTS; i++)
428
+ − 1897 {
440
+ − 1898 if (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i) != NULL
+ − 1899 && FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i) != MSWINDOWS_BAD_HFONT)
+ − 1900 DeleteObject (FONT_INSTANCE_MSWINDOWS_HFONT_I (f, i));
428
+ − 1901 }
440
+ − 1902
+ − 1903 xfree (f->data);
+ − 1904 f->data = 0;
+ − 1905 }
428
+ − 1906 }
+ − 1907
+ − 1908 #if 0
+ − 1909 static void
440
+ − 1910 mswindows_mark_font_instance (Lisp_Font_Instance *f)
428
+ − 1911 {
+ − 1912 }
+ − 1913 #endif
+ − 1914
+ − 1915 static void
440
+ − 1916 mswindows_print_font_instance (Lisp_Font_Instance *f,
+ − 1917 Lisp_Object printcharfun,
+ − 1918 int escapeflag)
428
+ − 1919 {
793
+ − 1920 write_fmt_string (printcharfun, " 0x%lx",
+ − 1921 (unsigned long)
+ − 1922 FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0));
+ − 1923
428
+ − 1924 }
+ − 1925
+ − 1926 static Lisp_Object
+ − 1927 mswindows_list_fonts (Lisp_Object pattern, Lisp_Object device)
+ − 1928 {
771
+ − 1929 struct device *d = XDEVICE (device);
+ − 1930 Lisp_Object font_list = Qnil, fonttail, result = Qnil;
428
+ − 1931
771
+ − 1932 if (DEVICE_MSWINDOWS_P (d))
+ − 1933 font_list = DEVICE_MSWINDOWS_FONTLIST (d);
+ − 1934 else if (DEVICE_MSPRINTER_P (d))
+ − 1935 font_list = DEVICE_MSPRINTER_FONTLIST (d);
+ − 1936 else
+ − 1937 abort ();
440
+ − 1938
771
+ − 1939 LIST_LOOP (fonttail, font_list)
428
+ − 1940 {
867
+ − 1941 Ibyte fontname[MSW_FONTSIZE];
771
+ − 1942
872
+ − 1943 if (match_font (XSTRING_DATA (XCAR (XCAR (fonttail))),
+ − 1944 XSTRING_DATA (pattern),
771
+ − 1945 fontname))
+ − 1946 result = Fcons (build_intstring (fontname), result);
428
+ − 1947 }
+ − 1948
+ − 1949 return Fnreverse (result);
+ − 1950 }
+ − 1951
+ − 1952 static Lisp_Object
578
+ − 1953 mswindows_font_instance_truename (Lisp_Font_Instance *f, Error_Behavior errb)
428
+ − 1954 {
872
+ − 1955 return f->truename;
428
+ − 1956 }
+ − 1957
+ − 1958 #ifdef MULE
+ − 1959
+ − 1960 static int
872
+ − 1961 mswindows_font_spec_matches_charset_stage_1 (struct device *d,
+ − 1962 Lisp_Object charset,
+ − 1963 const Ibyte *nonreloc,
+ − 1964 Lisp_Object reloc,
+ − 1965 Bytecount offset,
+ − 1966 Bytecount length)
428
+ − 1967 {
872
+ − 1968 int i;
+ − 1969 Lisp_Object charset_registry;
+ − 1970 const Ibyte *font_charset;
867
+ − 1971 const Ibyte *the_nonreloc = nonreloc;
+ − 1972 const Ibyte *c;
788
+ − 1973 Bytecount the_length = length;
+ − 1974
+ − 1975 if (UNBOUNDP (charset))
+ − 1976 return 1;
+ − 1977
+ − 1978 if (!the_nonreloc)
+ − 1979 the_nonreloc = XSTRING_DATA (reloc);
+ − 1980 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
+ − 1981 the_nonreloc += offset;
+ − 1982
+ − 1983 c = the_nonreloc;
+ − 1984 for (i = 0; i < 4; i++)
+ − 1985 {
867
+ − 1986 Ibyte *newc = (Ibyte *) memchr (c, ':', the_length);
788
+ − 1987 if (!newc)
+ − 1988 break;
+ − 1989 newc++;
+ − 1990 the_length -= (newc - c);
+ − 1991 c = newc;
+ − 1992 }
+ − 1993
872
+ − 1994 if (i < 4)
+ − 1995 return 0;
+ − 1996
+ − 1997 font_charset = c;
+ − 1998
+ − 1999 /* For border-glyph use */
+ − 2000 if (!qxestrcasecmp_c (font_charset, "symbol"))
+ − 2001 font_charset = (const Ibyte *) "western";
+ − 2002
+ − 2003 /* Get code page for the charset */
+ − 2004 charset_registry = Fmswindows_charset_registry (charset);
+ − 2005 if (!STRINGP (charset_registry))
+ − 2006 return 0;
+ − 2007
+ − 2008 return !qxestrcasecmp (XSTRING_DATA (charset_registry), font_charset);
+ − 2009 }
+ − 2010
+ − 2011 /*
+ − 2012
+ − 2013 1. handle standard mapping and inheritance vectors properly in Face-frob-property.
+ − 2014 2. finish impl of mswindows-charset-registry.
+ − 2015 3. see if everything works under fixup, now that i copied the stuff over.
+ − 2016 4. consider generalizing Face-frob-property to frob-specifier.
+ − 2017 5. maybe extract some of the flets out of Face-frob-property as useful specifier frobbing.
+ − 2018 6. eventually this stuff's got to be checked in!!!!
+ − 2019 */
+ − 2020
+ − 2021 static int
+ − 2022 mswindows_font_spec_matches_charset_stage_2 (struct device *d,
+ − 2023 Lisp_Object charset,
+ − 2024 const Ibyte *nonreloc,
+ − 2025 Lisp_Object reloc,
+ − 2026 Bytecount offset,
+ − 2027 Bytecount length)
+ − 2028 {
+ − 2029 const Ibyte *the_nonreloc = nonreloc;
+ − 2030 FONTSIGNATURE fs;
+ − 2031 FONTSIGNATURE *fsp = &fs;
+ − 2032 struct gcpro gcpro1;
+ − 2033 Lisp_Object fontsig;
+ − 2034 Bytecount the_length = length;
+ − 2035 int i;
+ − 2036
+ − 2037 if (UNBOUNDP (charset))
788
+ − 2038 return 1;
+ − 2039
872
+ − 2040 if (!the_nonreloc)
+ − 2041 the_nonreloc = XSTRING_DATA (reloc);
+ − 2042 fixup_internal_substring (nonreloc, reloc, offset, &the_length);
+ − 2043 the_nonreloc += offset;
+ − 2044
+ − 2045 /* Get the list of Unicode subranges corresponding to the font. This
+ − 2046 is contained inside of FONTSIGNATURE data, obtained by calling
+ − 2047 GetTextCharsetInfo on a font object, which we need to create from the
+ − 2048 spec. See if the FONTSIGNATURE data is already cached. If not, get
+ − 2049 it and cache it. */
+ − 2050 if (!STRINGP (reloc) || the_nonreloc != XSTRING_DATA (reloc))
+ − 2051 reloc = build_intstring (the_nonreloc);
+ − 2052 GCPRO1 (reloc);
+ − 2053 fontsig = Fgethash (reloc, Vfont_signature_data, Qunbound);
+ − 2054
+ − 2055 if (!UNBOUNDP (fontsig))
+ − 2056 {
+ − 2057 fsp = (FONTSIGNATURE *) XOPAQUE_DATA (fontsig);
+ − 2058 UNGCPRO;
+ − 2059 }
+ − 2060 else
+ − 2061 {
+ − 2062 HDC hdc = CreateCompatibleDC (NULL);
+ − 2063 Lisp_Object font_list = DEVICE_MSWINDOWS_FONTLIST (d);
+ − 2064 Lisp_Object truename;
+ − 2065 HFONT hfont = create_hfont_from_font_spec (the_nonreloc, hdc, Qnil,
+ − 2066 font_list,
+ − 2067 ERROR_ME_DEBUG_WARN,
+ − 2068 &truename);
788
+ − 2069
872
+ − 2070 if (!hfont || !(hfont = (HFONT) SelectObject (hdc, hfont)))
+ − 2071 {
+ − 2072 nope:
+ − 2073 DeleteDC (hdc);
+ − 2074 UNGCPRO;
+ − 2075 return 0;
+ − 2076 }
+ − 2077
+ − 2078 if (GetTextCharsetInfo (hdc, &fs, 0) == DEFAULT_CHARSET)
+ − 2079 {
+ − 2080 SelectObject (hdc, hfont);
+ − 2081 goto nope;
+ − 2082 }
+ − 2083 SelectObject (hdc, hfont);
+ − 2084 DeleteDC (hdc);
+ − 2085 Fputhash (reloc, make_opaque (&fs, sizeof (fs)), Vfont_signature_data);
+ − 2086 UNGCPRO;
+ − 2087 }
788
+ − 2088
872
+ − 2089 {
+ − 2090 int lowlim, highlim;
+ − 2091 int dim, j, cp = -1;
+ − 2092
+ − 2093 /* Try to find a Unicode char in the charset. #### This is somewhat
+ − 2094 bogus. See below.
+ − 2095
+ − 2096 #### Cache me baby!!!!!!!!!!!!!
+ − 2097 */
+ − 2098 get_charset_limits (charset, &lowlim, &highlim);
+ − 2099 dim = XCHARSET_DIMENSION (charset);
+ − 2100
+ − 2101 if (dim == 1)
788
+ − 2102 {
872
+ − 2103 for (i = lowlim; i <= highlim; i++)
+ − 2104 if ((cp = ichar_to_unicode (make_ichar (charset, i, 0))) >= 0)
+ − 2105 break;
788
+ − 2106 }
+ − 2107 else
+ − 2108 {
872
+ − 2109 for (i = lowlim; i <= highlim; i++)
+ − 2110 for (j = lowlim; j <= highlim; j++)
+ − 2111 if ((cp = ichar_to_unicode (make_ichar (charset, i, j))) >= 0)
+ − 2112 break;
+ − 2113 }
+ − 2114
+ − 2115 if (cp < 0)
+ − 2116 return 0;
788
+ − 2117
872
+ − 2118 /* Check to see, for each subrange supported by the font,
+ − 2119 whether the Unicode char is within that subrange. If any match,
+ − 2120 the font supports the char (whereby, the charset, bogusly). */
+ − 2121
+ − 2122 for (i = 0; i < 128; i++)
+ − 2123 {
+ − 2124 if (fsp->fsUsb[i >> 5] & (1 << (i & 32)))
788
+ − 2125 {
872
+ − 2126 for (j = 0; j < unicode_subrange_table[i].no_subranges; j++)
+ − 2127 if (cp >= unicode_subrange_table[i].subranges[j].start &&
+ − 2128 cp <= unicode_subrange_table[i].subranges[j].end)
+ − 2129 return 1;
788
+ − 2130 }
+ − 2131 }
+ − 2132
872
+ − 2133 return 0;
788
+ − 2134 }
+ − 2135 }
+ − 2136
872
+ − 2137 /*
+ − 2138 Given a truename font spec, does it match CHARSET?
+ − 2139
+ − 2140 We try two stages:
+ − 2141
+ − 2142 -- First see if the charset corresponds to one of the predefined Windows
+ − 2143 charsets; if so, we see if the registry (that's the last element of the
+ − 2144 font spec) is that same charset. If so, this means that the font is
+ − 2145 specifically designed for the charset, and we prefer it.
+ − 2146
+ − 2147 -- However, there are only a limited number of defined Windows charsets,
+ − 2148 and new ones aren't being defined; so if we fail the first stage, we find
+ − 2149 a character from the charset with a Unicode equivalent, and see if the
+ − 2150 font can display this character. we do that by retrieving the Unicode
+ − 2151 ranges that the font supports, to see if the character comes from that
+ − 2152 subrange.
+ − 2153
+ − 2154 #### Note: We really want to be doing all these checks at the character
+ − 2155 level, not the charset level. There's no guarantee that a charset covers
+ − 2156 a single Unicode range. Furthermore, this is extremely wasteful. We
+ − 2157 should be doing this when we're about to redisplay and already have the
+ − 2158 Unicode codepoints in hand.
+ − 2159 */
+ − 2160
+ − 2161 static int
+ − 2162 mswindows_font_spec_matches_charset (struct device *d, Lisp_Object charset,
+ − 2163 const Ibyte *nonreloc,
+ − 2164 Lisp_Object reloc,
+ − 2165 Bytecount offset, Bytecount length,
+ − 2166 int stage)
+ − 2167 {
+ − 2168 return stage ?
+ − 2169 mswindows_font_spec_matches_charset_stage_2 (d, charset, nonreloc,
+ − 2170 reloc, offset, length)
+ − 2171 : mswindows_font_spec_matches_charset_stage_1 (d, charset, nonreloc,
+ − 2172 reloc, offset, length);
+ − 2173 }
+ − 2174
+ − 2175
+ − 2176 /* Find a font spec that matches font spec FONT and also matches
428
+ − 2177 (the registry of) CHARSET. */
872
+ − 2178
428
+ − 2179 static Lisp_Object
+ − 2180 mswindows_find_charset_font (Lisp_Object device, Lisp_Object font,
872
+ − 2181 Lisp_Object charset, int stage)
428
+ − 2182 {
771
+ − 2183 Lisp_Object fontlist, fonttail;
+ − 2184
872
+ − 2185 /* If FONT specifies a particular charset, this will only list fonts with
+ − 2186 that charset; otherwise, it will list fonts with all charsets. */
771
+ − 2187 fontlist = mswindows_list_fonts (font, device);
872
+ − 2188
+ − 2189 if (!stage)
771
+ − 2190 {
872
+ − 2191 LIST_LOOP (fonttail, fontlist)
+ − 2192 {
+ − 2193 if (mswindows_font_spec_matches_charset_stage_1
+ − 2194 (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1))
+ − 2195 return XCAR (fonttail);
+ − 2196 }
771
+ − 2197 }
872
+ − 2198 else
+ − 2199 {
+ − 2200 LIST_LOOP (fonttail, fontlist)
+ − 2201 {
+ − 2202 if (mswindows_font_spec_matches_charset_stage_2
+ − 2203 (XDEVICE (device), charset, 0, XCAR (fonttail), 0, -1))
+ − 2204 return XCAR (fonttail);
+ − 2205 }
+ − 2206 }
+ − 2207
771
+ − 2208 return Qnil;
428
+ − 2209 }
+ − 2210
+ − 2211 #endif /* MULE */
+ − 2212
+ − 2213
+ − 2214 /************************************************************************/
+ − 2215 /* non-methods */
+ − 2216 /************************************************************************/
+ − 2217
+ − 2218 DEFUN ("mswindows-color-list", Fmswindows_color_list, 0, 0, 0, /*
+ − 2219 Return a list of the colors available on mswindows devices.
+ − 2220 */
+ − 2221 ())
+ − 2222 {
+ − 2223 Lisp_Object result = Qnil;
+ − 2224 int i;
+ − 2225
771
+ − 2226 for (i = 0; i < countof (mswindows_X_color_map); i++)
428
+ − 2227 result = Fcons (build_string (mswindows_X_color_map[i].name), result);
+ − 2228
+ − 2229 return Fnreverse (result);
+ − 2230 }
+ − 2231
+ − 2232
+ − 2233
+ − 2234 /************************************************************************/
+ − 2235 /* initialization */
+ − 2236 /************************************************************************/
+ − 2237
+ − 2238 void
+ − 2239 syms_of_objects_mswindows (void)
+ − 2240 {
+ − 2241 DEFSUBR (Fmswindows_color_list);
+ − 2242 }
+ − 2243
+ − 2244 void
+ − 2245 console_type_create_objects_mswindows (void)
+ − 2246 {
+ − 2247 /* object methods */
+ − 2248 CONSOLE_HAS_METHOD (mswindows, initialize_color_instance);
+ − 2249 /* CONSOLE_HAS_METHOD (mswindows, mark_color_instance); */
+ − 2250 CONSOLE_HAS_METHOD (mswindows, print_color_instance);
+ − 2251 CONSOLE_HAS_METHOD (mswindows, finalize_color_instance);
+ − 2252 CONSOLE_HAS_METHOD (mswindows, color_instance_equal);
+ − 2253 CONSOLE_HAS_METHOD (mswindows, color_instance_hash);
+ − 2254 CONSOLE_HAS_METHOD (mswindows, color_instance_rgb_components);
+ − 2255 CONSOLE_HAS_METHOD (mswindows, valid_color_name_p);
+ − 2256
+ − 2257 CONSOLE_HAS_METHOD (mswindows, initialize_font_instance);
+ − 2258 /* CONSOLE_HAS_METHOD (mswindows, mark_font_instance); */
+ − 2259 CONSOLE_HAS_METHOD (mswindows, print_font_instance);
+ − 2260 CONSOLE_HAS_METHOD (mswindows, finalize_font_instance);
442
+ − 2261 CONSOLE_HAS_METHOD (mswindows, font_instance_truename);
428
+ − 2262 CONSOLE_HAS_METHOD (mswindows, list_fonts);
+ − 2263 #ifdef MULE
+ − 2264 CONSOLE_HAS_METHOD (mswindows, font_spec_matches_charset);
+ − 2265 CONSOLE_HAS_METHOD (mswindows, find_charset_font);
+ − 2266 #endif
440
+ − 2267
+ − 2268 /* Printer methods - delegate most to windows methods,
+ − 2269 since graphical objects behave the same way. */
+ − 2270
+ − 2271 CONSOLE_INHERITS_METHOD (msprinter, mswindows, initialize_color_instance);
+ − 2272 /* CONSOLE_INHERITS_METHOD (msprinter, mswindows, mark_color_instance); */
+ − 2273 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_color_instance);
+ − 2274 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_color_instance);
+ − 2275 CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_equal);
+ − 2276 CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_hash);
+ − 2277 CONSOLE_INHERITS_METHOD (msprinter, mswindows, color_instance_rgb_components);
+ − 2278 CONSOLE_INHERITS_METHOD (msprinter, mswindows, valid_color_name_p);
+ − 2279
+ − 2280 CONSOLE_HAS_METHOD (msprinter, initialize_font_instance);
+ − 2281 /* CONSOLE_INHERITS_METHOD (msprinter, mswindows, mark_font_instance); */
+ − 2282 CONSOLE_INHERITS_METHOD (msprinter, mswindows, print_font_instance);
+ − 2283 CONSOLE_INHERITS_METHOD (msprinter, mswindows, finalize_font_instance);
442
+ − 2284 CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_instance_truename);
440
+ − 2285 CONSOLE_INHERITS_METHOD (msprinter, mswindows, list_fonts);
+ − 2286 #ifdef MULE
+ − 2287 CONSOLE_INHERITS_METHOD (msprinter, mswindows, font_spec_matches_charset);
+ − 2288 CONSOLE_INHERITS_METHOD (msprinter, mswindows, find_charset_font);
+ − 2289 #endif
428
+ − 2290 }
+ − 2291
+ − 2292 void
788
+ − 2293 reinit_vars_of_object_mswindows (void)
+ − 2294 {
+ − 2295 #ifdef MULE
+ − 2296 int i;
+ − 2297
+ − 2298 unicode_subrange_table = xnew_array_and_zero (unicode_subrange_t, 128);
+ − 2299 for (i = 0; i < countof (unicode_subrange_raw_map); i++)
+ − 2300 {
+ − 2301 const unicode_subrange_raw_t *el = &unicode_subrange_raw_map[i];
+ − 2302 if (unicode_subrange_table[el->subrange_bit].subranges == 0)
+ − 2303 unicode_subrange_table[el->subrange_bit].subranges = el;
+ − 2304 unicode_subrange_table[el->subrange_bit].no_subranges++;
+ − 2305 }
+ − 2306
+ − 2307 Fclrhash (Vfont_signature_data);
+ − 2308 #endif /* MULE */
+ − 2309 }
+ − 2310
+ − 2311 void
428
+ − 2312 vars_of_objects_mswindows (void)
+ − 2313 {
788
+ − 2314 #ifdef MULE
+ − 2315 Vfont_signature_data =
+ − 2316 make_lisp_hash_table (100, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL);
+ − 2317 staticpro (&Vfont_signature_data);
+ − 2318 #endif /* MULE */
+ − 2319
+ − 2320 reinit_vars_of_object_mswindows ();
428
+ − 2321 }