Mercurial > hg > xemacs-beta
annotate src/fontcolor-x.c @ 5936:574f0cded429 cygwin
try to replace all nnnL or nnnUL constants with EMACS_[U]INT
author | Henry Thompson <ht@markup.co.uk> |
---|---|
date | Sun, 13 Dec 2015 13:22:58 +0000 |
parents | 6928877dbc26 |
children |
rev | line source |
---|---|
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5176
diff
changeset
|
1 /* X-specific fonts and colors. |
428 | 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. | |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5176
diff
changeset
|
5 Copyright (C) 1995, 1996, 2000, 2001, 2002, 2004, 2010 Ben Wing. |
428 | 6 Copyright (C) 1995 Sun Microsystems, Inc. |
7 | |
8 This file is part of XEmacs. | |
9 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5189
diff
changeset
|
10 XEmacs is free software: you can redistribute it and/or modify it |
428 | 11 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5189
diff
changeset
|
12 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5189
diff
changeset
|
13 option) any later version. |
428 | 14 |
15 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
18 for more details. | |
19 | |
20 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5189
diff
changeset
|
21 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 22 |
23 /* Synched up with: Not in FSF. */ | |
24 | |
25 /* Authors: Jamie Zawinski, Chuck Thompson, Ben Wing */ | |
26 | |
442 | 27 /* This file Mule-ized by Ben Wing, 7-10-00. */ |
28 | |
428 | 29 #include <config.h> |
30 #include "lisp.h" | |
31 | |
872 | 32 #include "charset.h" |
33 #include "device-impl.h" | |
34 #include "insdel.h" | |
428 | 35 |
872 | 36 #include "console-x-impl.h" |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
37 #include "fontcolor-x-impl.h" |
3659 | 38 #include "elhash.h" |
428 | 39 |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
40 #ifdef HAVE_XFT |
3354 | 41 #include "font-mgr.h" |
3094 | 42 #endif |
43 | |
428 | 44 int x_handle_non_fully_specified_fonts; |
45 | |
3659 | 46 #ifdef DEBUG_XEMACS |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5176
diff
changeset
|
47 Fixnum debug_x_fonts; |
3659 | 48 #endif /* DEBUG_XEMACS */ |
49 | |
428 | 50 |
51 /************************************************************************/ | |
52 /* color instances */ | |
53 /************************************************************************/ | |
54 | |
442 | 55 static int |
56 x_parse_nearest_color (struct device *d, XColor *color, Lisp_Object name, | |
578 | 57 Error_Behavior errb) |
428 | 58 { |
59 Display *dpy = DEVICE_X_DISPLAY (d); | |
60 Colormap cmap = DEVICE_X_COLORMAP (d); | |
61 Visual *visual = DEVICE_X_VISUAL (d); | |
62 int result; | |
63 | |
64 xzero (*color); | |
65 { | |
442 | 66 const Extbyte *extname; |
428 | 67 |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
68 extname = LISP_STRING_TO_EXTERNAL (name, Qx_color_name_encoding); |
442 | 69 result = XParseColor (dpy, cmap, extname, color); |
428 | 70 } |
71 if (!result) | |
72 { | |
563 | 73 maybe_signal_error (Qgui_error, "Unrecognized color", |
74 name, Qcolor, errb); | |
428 | 75 return 0; |
76 } | |
3094 | 77 result = x_allocate_nearest_color (dpy, cmap, visual, color); |
428 | 78 if (!result) |
79 { | |
563 | 80 maybe_signal_error (Qgui_error, "Couldn't allocate color", |
81 name, Qcolor, errb); | |
428 | 82 return 0; |
83 } | |
84 | |
85 return result; | |
86 } | |
87 | |
88 static int | |
440 | 89 x_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, |
578 | 90 Lisp_Object device, Error_Behavior errb) |
428 | 91 { |
92 XColor color; | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
93 #ifdef HAVE_XFT |
3094 | 94 XftColor xftColor; |
95 #endif | |
428 | 96 int result; |
97 | |
442 | 98 result = x_parse_nearest_color (XDEVICE (device), &color, name, errb); |
428 | 99 |
100 if (!result) | |
101 return 0; | |
102 | |
103 /* Don't allocate the data until we're sure that we will succeed, | |
104 or the finalize method may get fucked. */ | |
105 c->data = xnew (struct x_color_instance_data); | |
106 if (result == 3) | |
107 COLOR_INSTANCE_X_DEALLOC (c) = 0; | |
108 else | |
109 COLOR_INSTANCE_X_DEALLOC (c) = 1; | |
110 COLOR_INSTANCE_X_COLOR (c) = color; | |
3094 | 111 |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
112 #ifdef HAVE_XFT |
3094 | 113 xftColor.pixel = color.pixel; |
114 xftColor.color.red = color.red; | |
115 xftColor.color.green = color.green; | |
116 xftColor.color.blue = color.blue; | |
117 xftColor.color.alpha = 0xffff; | |
118 | |
119 COLOR_INSTANCE_X_XFTCOLOR (c) = xftColor; | |
120 #endif | |
121 | |
428 | 122 return 1; |
123 } | |
124 | |
125 static void | |
440 | 126 x_print_color_instance (Lisp_Color_Instance *c, |
428 | 127 Lisp_Object printcharfun, |
2286 | 128 int UNUSED (escapeflag)) |
428 | 129 { |
130 XColor color = COLOR_INSTANCE_X_COLOR (c); | |
800 | 131 write_fmt_string (printcharfun, " %ld=(%X,%X,%X)", |
132 color.pixel, color.red, color.green, color.blue); | |
428 | 133 } |
134 | |
135 static void | |
440 | 136 x_finalize_color_instance (Lisp_Color_Instance *c) |
428 | 137 { |
138 if (c->data) | |
139 { | |
140 if (DEVICE_LIVE_P (XDEVICE (c->device))) | |
141 { | |
142 if (COLOR_INSTANCE_X_DEALLOC (c)) | |
143 { | |
442 | 144 XFreeColors (DEVICE_X_DISPLAY (XDEVICE (c->device)), |
145 DEVICE_X_COLORMAP (XDEVICE (c->device)), | |
428 | 146 &COLOR_INSTANCE_X_COLOR (c).pixel, 1, 0); |
147 } | |
148 } | |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
149 xfree (c->data); |
428 | 150 c->data = 0; |
151 } | |
152 } | |
153 | |
154 /* Color instances are equal if they resolve to the same color on the | |
155 screen (have the same RGB values). I imagine that | |
156 "same RGB values" == "same cell in the colormap." Arguably we should | |
157 be comparing their names or pixel values instead. */ | |
158 | |
159 static int | |
440 | 160 x_color_instance_equal (Lisp_Color_Instance *c1, |
161 Lisp_Color_Instance *c2, | |
2286 | 162 int UNUSED (depth)) |
428 | 163 { |
164 XColor color1 = COLOR_INSTANCE_X_COLOR (c1); | |
165 XColor color2 = COLOR_INSTANCE_X_COLOR (c2); | |
166 return ((color1.red == color2.red) && | |
167 (color1.green == color2.green) && | |
168 (color1.blue == color2.blue)); | |
169 } | |
170 | |
2515 | 171 static Hashcode |
2286 | 172 x_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth)) |
428 | 173 { |
174 XColor color = COLOR_INSTANCE_X_COLOR (c); | |
175 return HASH3 (color.red, color.green, color.blue); | |
176 } | |
177 | |
178 static Lisp_Object | |
440 | 179 x_color_instance_rgb_components (Lisp_Color_Instance *c) |
428 | 180 { |
181 XColor color = COLOR_INSTANCE_X_COLOR (c); | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
182 return (list3 (make_fixnum (color.red), |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
183 make_fixnum (color.green), |
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
184 make_fixnum (color.blue))); |
428 | 185 } |
186 | |
187 static int | |
188 x_valid_color_name_p (struct device *d, Lisp_Object color) | |
189 { | |
190 XColor c; | |
191 Display *dpy = DEVICE_X_DISPLAY (d); | |
192 Colormap cmap = DEVICE_X_COLORMAP (d); | |
442 | 193 const Extbyte *extname; |
428 | 194 |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
195 extname = LISP_STRING_TO_EXTERNAL (color, Qx_color_name_encoding); |
428 | 196 |
440 | 197 return XParseColor (dpy, cmap, extname, &c); |
428 | 198 } |
199 | |
2527 | 200 static Lisp_Object |
201 x_color_list (void) | |
202 { | |
203 return call0 (intern ("x-color-list-internal")); | |
204 } | |
205 | |
428 | 206 |
207 /************************************************************************/ | |
208 /* font instances */ | |
209 /************************************************************************/ | |
210 | |
3094 | 211 |
428 | 212 static int |
2286 | 213 x_initialize_font_instance (Lisp_Font_Instance *f, Lisp_Object UNUSED (name), |
578 | 214 Lisp_Object device, Error_Behavior errb) |
428 | 215 { |
440 | 216 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device)); |
3094 | 217 Extbyte *extname; |
218 XFontStruct *fs = NULL; /* _F_ont _S_truct */ | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
219 #ifdef HAVE_XFT |
3094 | 220 XftFont *rf = NULL; /* _R_ender _F_ont (X Render extension) */ |
221 #else | |
222 #define rf (0) | |
223 #endif | |
428 | 224 |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
225 #ifdef HAVE_XFT |
3094 | 226 DEBUG_XFT1 (2, "attempting to initialize font spec %s\n", |
227 XSTRING_DATA(f->name)); | |
228 /* #### serialize (optimize) these later... */ | |
229 /* #### This function really needs to go away. | |
230 The problem is that the fontconfig/Xft functions work much too hard | |
231 to ensure that something is returned; but that something need not be | |
232 at all close to what we asked for. */ | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
233 extname = LISP_STRING_TO_EXTERNAL (f->name, Qfc_font_name_encoding); |
3094 | 234 rf = xft_open_font_by_name (dpy, extname); |
235 #endif | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
236 extname = LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding); |
3659 | 237 /* With XFree86 4.0's fonts, XListFonts returns an entry for |
238 -isas-fangsong ti-medium-r-normal--16-160-72-72-c-160-gb2312.1980-0 but | |
239 an XLoadQueryFont on the corresponding XLFD returns NULL. | |
240 | |
241 XListFonts is not trustworthy (of course, this is news to exactly | |
242 no-one used to reading XEmacs source.) */ | |
3094 | 243 fs = XLoadQueryFont (dpy, extname); |
244 | |
245 if (!fs && !rf) | |
428 | 246 { |
3094 | 247 /* #### should this refer to X and/or Xft? */ |
248 maybe_signal_error (Qgui_error, "Couldn't load font", f->name, | |
249 Qfont, errb); | |
428 | 250 return 0; |
251 } | |
252 | |
3389 | 253 if (rf && fs) |
254 { | |
255 XFreeFont (dpy, fs); | |
256 fs = NULL; /* we don' need no steenkin' X font */ | |
257 } | |
258 | |
3094 | 259 if (fs && !fs->max_bounds.width) |
260 { | |
261 /* yes, this has been known to happen. */ | |
262 XFreeFont (dpy, fs); | |
263 fs = NULL; | |
264 maybe_signal_error (Qgui_error, "X font is too small", f->name, Qfont, | |
265 errb); | |
3389 | 266 return 0; |
3094 | 267 } |
268 | |
269 /* Now that we're sure that we will succeed, we can allocate data without | |
270 fear that the finalize method may get fucked. */ | |
428 | 271 f->data = xnew (struct x_font_instance_data); |
272 | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
273 #ifdef HAVE_XFT |
3094 | 274 FONT_INSTANCE_X_XFTFONT (f) = rf; |
275 if (rf) | |
276 /* Have an Xft font, initialize font info from it. */ | |
277 { | |
278 DEBUG_XFT4 (2, "pre-initial ascent %d descent %d width %d height %d\n", | |
279 f->ascent, f->descent, f->width, f->height); | |
428 | 280 |
3094 | 281 /* #### This shit is just plain wrong unless we have a character cell |
282 font. It really hoses us on large repertoire Unicode fonts with | |
283 "double-width" characters. */ | |
284 f->ascent = rf->ascent; | |
285 f->descent = rf->descent; | |
428 | 286 { |
3094 | 287 /* This is an approximation that AFAIK only gets used to compute |
288 cell size for estimating window dimensions. The test_string8 | |
289 is an ASCII string whose characters should approximate the | |
290 distribution of widths expected in real text. */ | |
3469 | 291 static const FcChar8 test_string8[] = "Mmneei"; |
3094 | 292 static const int len = sizeof (test_string8) - 1; |
293 XGlyphInfo glyphinfo; | |
294 | |
295 XftTextExtents8 (dpy, rf, test_string8, len, &glyphinfo); | |
296 /* #### maybe should be glyphinfo.xOff - glyphinfo.x? */ | |
297 f->width = (2*glyphinfo.width + len)/(2*len); | |
428 | 298 } |
3094 | 299 f->height = rf->height; |
300 f->proportional_p = 1; /* we can't recognize monospaced fonts! */ | |
301 | |
3389 | 302 /* #### This message appears wa-a-ay too often! |
303 We probably need to cache truenames or something? | |
304 Even if Xft does it for us, we cons too many font instances. */ | |
305 DEBUG_XFT4 (0, | |
306 "initialized metrics ascent %d descent %d width %d height %d\n", | |
307 f->ascent, f->descent, f->width, f->height); | |
3094 | 308 } |
309 else | |
310 { | |
311 DEBUG_XFT1 (0, "couldn't initialize Xft font %s\n", | |
312 XSTRING_DATA(f->name)); | |
313 } | |
314 #endif | |
315 | |
316 FONT_INSTANCE_X_FONT (f) = fs; | |
317 if (fs) | |
318 /* Have to use a core font, initialize font info from it. */ | |
319 { | |
320 f->ascent = fs->ascent; | |
321 f->descent = fs->descent; | |
322 f->height = fs->ascent + fs->descent; | |
323 { | |
324 /* following change suggested by Ted Phelps <phelps@dstc.edu.au> */ | |
325 int def_char = 'n'; /*fs->default_char;*/ | |
326 int byte1, byte2; | |
428 | 327 |
3094 | 328 once_more: |
329 byte1 = def_char >> 8; | |
330 byte2 = def_char & 0xFF; | |
331 | |
332 if (fs->per_char) | |
333 { | |
334 /* Old versions of the R5 font server have garbage (>63k) as | |
335 def_char. 'n' might not be a valid character. */ | |
336 if (byte1 < (int) fs->min_byte1 || | |
337 byte1 > (int) fs->max_byte1 || | |
338 byte2 < (int) fs->min_char_or_byte2 || | |
339 byte2 > (int) fs->max_char_or_byte2) | |
340 f->width = 0; | |
341 else | |
342 f->width = fs->per_char[(byte1 - fs->min_byte1) * | |
343 (fs->max_char_or_byte2 - | |
344 fs->min_char_or_byte2 + 1) + | |
345 (byte2 - fs->min_char_or_byte2)].width; | |
346 } | |
428 | 347 else |
3094 | 348 f->width = fs->max_bounds.width; |
349 | |
350 /* Some fonts have a default char whose width is 0. This is no good. | |
351 If that's the case, first try 'n' as the default char, and if n has | |
352 0 width too (unlikely) then just use the max width. */ | |
353 if (f->width == 0) | |
428 | 354 { |
3094 | 355 if (def_char == (int) fs->default_char) |
356 f->width = fs->max_bounds.width; | |
357 else | |
358 { | |
359 def_char = fs->default_char; | |
360 goto once_more; | |
361 } | |
428 | 362 } |
363 } | |
3094 | 364 |
365 /* If all characters don't exist then there could potentially be | |
366 0-width characters lurking out there. Not setting this flag | |
367 trips an optimization that would make them appear to have width | |
368 to redisplay. This is bad. So we set it if not all characters | |
369 have the same width or if not all characters are defined. */ | |
370 /* #### This sucks. There is a measurable performance increase | |
371 when using proportional width fonts if this flag is not set. | |
372 Unfortunately so many of the fucking X fonts are not fully | |
373 defined that we could almost just get rid of this damn flag and | |
374 make it an assertion. */ | |
375 f->proportional_p = (fs->min_bounds.width != fs->max_bounds.width || | |
376 (x_handle_non_fully_specified_fonts && | |
377 !fs->all_chars_exist)); | |
378 } | |
379 | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
380 #ifdef HAVE_XFT |
3094 | 381 if (debug_xft > 0) |
382 { | |
383 int n = 3, d = 5; | |
384 /* check for weirdness */ | |
385 if (n * f->height < d * f->width) | |
386 stderr_out ("font %s: width:height is %d:%d, larger than %d:%d\n", | |
387 XSTRING_DATA(f->name), f->width, f->height, n, d); | |
388 if (f->height <= 0 || f->width <= 0) | |
389 stderr_out ("bogus dimensions of font %s: width = %d, height = %d\n", | |
390 XSTRING_DATA(f->name), f->width, f->height); | |
391 stderr_out ("initialized font %s\n", XSTRING_DATA(f->name)); | |
392 } | |
393 #else | |
394 #undef rf | |
395 #endif | |
428 | 396 |
397 return 1; | |
398 } | |
399 | |
400 static void | |
440 | 401 x_print_font_instance (Lisp_Font_Instance *f, |
428 | 402 Lisp_Object printcharfun, |
2286 | 403 int UNUSED (escapeflag)) |
428 | 404 { |
3659 | 405 /* We should print information here about initial vs. final stages; we |
406 can't rely on the device charset stage cache for that, | |
407 unfortunately. */ | |
3094 | 408 if (FONT_INSTANCE_X_FONT (f)) |
3659 | 409 write_fmt_string (printcharfun, " font id: 0x%lx,", |
410 (unsigned long) FONT_INSTANCE_X_FONT (f)->fid); | |
411 | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
412 #ifdef HAVE_XFT |
3094 | 413 /* #### What should we do here? For now, print the address. */ |
414 if (FONT_INSTANCE_X_XFTFONT (f)) | |
415 write_fmt_string (printcharfun, " xft font: 0x%lx", | |
416 (unsigned long) FONT_INSTANCE_X_XFTFONT (f)); | |
417 #endif | |
428 | 418 } |
419 | |
420 static void | |
440 | 421 x_finalize_font_instance (Lisp_Font_Instance *f) |
428 | 422 { |
423 | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
424 #ifdef HAVE_XFT |
3094 | 425 DEBUG_XFT1 (0, "finalizing %s\n", (STRINGP (f->name) |
426 ? (char *) XSTRING_DATA (f->name) | |
427 : "(unnamed font)")); | |
428 #endif | |
429 | |
428 | 430 if (f->data) |
431 { | |
432 if (DEVICE_LIVE_P (XDEVICE (f->device))) | |
433 { | |
434 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device)); | |
435 | |
3094 | 436 if (FONT_INSTANCE_X_FONT (f)) |
437 XFreeFont (dpy, FONT_INSTANCE_X_FONT (f)); | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
438 #ifdef HAVE_XFT |
3094 | 439 if (FONT_INSTANCE_X_XFTFONT (f)) |
440 XftFontClose (dpy, FONT_INSTANCE_X_XFTFONT (f)); | |
441 #endif | |
428 | 442 } |
4976
16112448d484
Rename xfree(FOO, TYPE) -> xfree(FOO)
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
443 xfree (f->data); |
428 | 444 f->data = 0; |
445 } | |
446 } | |
447 | |
448 /* Determining the truename of a font is hard. (Big surprise.) | |
449 | |
3094 | 450 This is not true for fontconfig. Each font has a (nearly) canonical |
451 representation up to permutation of the order of properties. It is | |
452 possible to construct a name which exactly identifies the properties of | |
453 the current font. However, it is theoretically possible that there exists | |
454 another font with a super set of those properties that would happen to get | |
455 selected. -- sjt | |
456 | |
428 | 457 By "truename" we mean an XLFD-form name which contains no wildcards, yet |
458 which resolves to *exactly* the same font as the one which we already have | |
459 the (probably wildcarded) name and `XFontStruct' of. | |
460 | |
461 One might think that the first font returned by XListFonts would be the one | |
462 that XOpenFont would pick. Apparently this is the case on some servers, | |
463 but not on others. It would seem not to be specified. | |
464 | |
465 The MIT R5 server sometimes appears to be picking the lexicographically | |
466 smallest font which matches the name (thus picking "adobe" fonts before | |
467 "bitstream" fonts even if the bitstream fonts are earlier in the path, and | |
468 also picking 100dpi adobe fonts over 75dpi adobe fonts even though the | |
469 75dpi are in the path earlier) but sometimes appears to be doing something | |
442 | 470 else entirely (for example, removing the bitstream fonts from the path will |
428 | 471 cause the 75dpi adobe fonts to be used instead of the 100dpi, even though |
472 their relative positions in the path (and their names!) have not changed). | |
473 | |
474 The documentation for XSetFontPath() seems to indicate that the order of | |
442 | 475 entries in the font path means something, but it's pretty noncommittal about |
428 | 476 it, and the spirit of the law is apparently not being obeyed... |
477 | |
478 All the fonts I've seen have a property named `FONT' which contains the | |
479 truename of the font. However, there are two problems with using this: the | |
480 first is that the X Protocol Document is quite explicit that all properties | |
481 are optional, so we can't depend on it being there. The second is that | |
482 it's conceivable that this alleged truename isn't actually accessible as a | |
483 font, due to some difference of opinion between the font designers and | |
484 whoever installed the font on the system. | |
485 | |
486 So, our first attempt is to look for a FONT property, and then verify that | |
487 the name there is a valid name by running XListFonts on it. There's still | |
488 the potential that this could be true but we could still be being lied to, | |
489 but that seems pretty remote. | |
490 | |
491 Late breaking news: I've gotten reports that SunOS 4.1.3U1 | |
492 with OpenWound 3.0 has a font whose truename is really | |
493 "-Adobe-Courier-Medium-R-Normal--12-120-75-75-M-70-ISO8859-1" | |
494 but whose FONT property contains "Courier". | |
495 | |
496 So we disbelieve the FONT property unless it begins with a dash and | |
497 is more than 30 characters long. X Windows: The defacto substandard. | |
498 X Windows: Complex nonsolutions to simple nonproblems. X Windows: | |
499 Live the nightmare. | |
500 | |
501 If the FONT property doesn't exist, then we try and construct an XLFD name | |
502 out of the other font properties (FOUNDRY, FAMILY_NAME, WEIGHT_NAME, etc). | |
503 This is necessary at least for some versions of OpenWound. But who knows | |
504 what the future will bring. | |
505 | |
506 If that doesn't work, then we use XListFonts and either take the first font | |
507 (which I think is the most sensible thing) or we find the lexicographically | |
508 least, depending on whether the preprocessor constant `XOPENFONT_SORTS' is | |
509 defined. This sucks because the two behaviors are a property of the server | |
510 being used, not the architecture on which emacs has been compiled. Also, | |
511 as I described above, sorting isn't ALWAYS what the server does. Really it | |
512 does something seemingly random. There is no reliable way to win if the | |
513 FONT property isn't present. | |
514 | |
515 Another possibility which I haven't bothered to implement would be to map | |
516 over all of the matching fonts and find the first one that has the same | |
517 character metrics as the font we already have loaded. Even if this didn't | |
518 return exactly the same font, it would at least return one whose characters | |
519 were the same sizes, which would probably be good enough. | |
520 | |
521 More late-breaking news: on RS/6000 AIX 3.2.4, the expression | |
522 XLoadQueryFont (dpy, "-*-Fixed-Medium-R-*-*-*-130-75-75-*-*-ISO8859-1") | |
523 actually returns the font | |
524 -Misc-Fixed-Medium-R-Normal--13-120-75-75-C-80-ISO8859-1 | |
525 which is crazy, because that font doesn't even match that pattern! It is | |
526 also not included in the output produced by `xlsfonts' with that pattern. | |
527 | |
528 So this is yet another example of XListFonts() and XOpenFont() using | |
529 completely different algorithms. This, however, is a goofier example of | |
530 this bug, because in this case, it's not just the search order that is | |
531 different -- the sets don't even intersect. | |
532 | |
533 If anyone has any better ideas how to do this, or any insights on what it is | |
534 that the various servers are actually doing, please let me know! -- jwz. */ | |
535 | |
536 static int | |
442 | 537 valid_x_font_name_p (Display *dpy, Extbyte *name) |
428 | 538 { |
539 /* Maybe this should be implemented by calling XLoadFont and trapping | |
540 the error. That would be a lot of work, and wasteful as hell, but | |
541 might be more correct. | |
542 */ | |
543 int nnames = 0; | |
444 | 544 Extbyte **names = 0; |
428 | 545 if (! name) |
546 return 0; | |
547 names = XListFonts (dpy, name, 1, &nnames); | |
548 if (names) | |
549 XFreeFontNames (names); | |
550 return (nnames != 0); | |
551 } | |
552 | |
442 | 553 static Extbyte * |
428 | 554 truename_via_FONT_prop (Display *dpy, XFontStruct *font) |
555 { | |
556 unsigned long value = 0; | |
442 | 557 Extbyte *result = 0; |
428 | 558 if (XGetFontProperty (font, XA_FONT, &value)) |
559 result = XGetAtomName (dpy, value); | |
560 /* result is now 0, or the string value of the FONT property. */ | |
561 if (result) | |
562 { | |
563 /* Verify that result is an XLFD name (roughly...) */ | |
647 | 564 if (result [0] != '-' || strlen (result) < 30) |
428 | 565 { |
566 XFree (result); | |
567 result = 0; | |
568 } | |
569 } | |
570 return result; /* this must be freed by caller if non-0 */ | |
571 } | |
572 | |
442 | 573 static Extbyte * |
428 | 574 truename_via_random_props (Display *dpy, XFontStruct *font) |
575 { | |
576 struct device *d = get_device_from_display (dpy); | |
577 unsigned long value = 0; | |
442 | 578 Extbyte *foundry, *family, *weight, *slant, *setwidth, *add_style; |
428 | 579 unsigned long pixel, point, res_x, res_y; |
442 | 580 Extbyte *spacing; |
428 | 581 unsigned long avg_width; |
442 | 582 Extbyte *registry, *encoding; |
583 Extbyte composed_name [2048]; | |
428 | 584 int ok = 0; |
442 | 585 Extbyte *result; |
428 | 586 |
587 #define get_string(atom,var) \ | |
588 if (XGetFontProperty (font, (atom), &value)) \ | |
589 var = XGetAtomName (dpy, value); \ | |
590 else { \ | |
591 var = 0; \ | |
592 goto FAIL; } | |
593 #define get_number(atom,var) \ | |
594 if (!XGetFontProperty (font, (atom), &var) || \ | |
595 var > 999) \ | |
596 goto FAIL; | |
597 | |
598 foundry = family = weight = slant = setwidth = 0; | |
599 add_style = spacing = registry = encoding = 0; | |
600 | |
601 get_string (DEVICE_XATOM_FOUNDRY (d), foundry); | |
602 get_string (DEVICE_XATOM_FAMILY_NAME (d), family); | |
603 get_string (DEVICE_XATOM_WEIGHT_NAME (d), weight); | |
604 get_string (DEVICE_XATOM_SLANT (d), slant); | |
605 get_string (DEVICE_XATOM_SETWIDTH_NAME (d), setwidth); | |
606 get_string (DEVICE_XATOM_ADD_STYLE_NAME (d), add_style); | |
607 get_number (DEVICE_XATOM_PIXEL_SIZE (d), pixel); | |
608 get_number (DEVICE_XATOM_POINT_SIZE (d), point); | |
609 get_number (DEVICE_XATOM_RESOLUTION_X (d), res_x); | |
610 get_number (DEVICE_XATOM_RESOLUTION_Y (d), res_y); | |
611 get_string (DEVICE_XATOM_SPACING (d), spacing); | |
612 get_number (DEVICE_XATOM_AVERAGE_WIDTH (d), avg_width); | |
613 get_string (DEVICE_XATOM_CHARSET_REGISTRY (d), registry); | |
614 get_string (DEVICE_XATOM_CHARSET_ENCODING (d), encoding); | |
615 #undef get_number | |
616 #undef get_string | |
617 | |
618 sprintf (composed_name, | |
619 "-%s-%s-%s-%s-%s-%s-%ld-%ld-%ld-%ld-%s-%ld-%s-%s", | |
620 foundry, family, weight, slant, setwidth, add_style, pixel, | |
621 point, res_x, res_y, spacing, avg_width, registry, encoding); | |
622 ok = 1; | |
623 | |
624 FAIL: | |
625 if (ok) | |
626 { | |
627 int L = strlen (composed_name) + 1; | |
2367 | 628 result = xnew_extbytes (L); |
428 | 629 strncpy (result, composed_name, L); |
630 } | |
631 else | |
632 result = 0; | |
633 | |
634 if (foundry) XFree (foundry); | |
635 if (family) XFree (family); | |
636 if (weight) XFree (weight); | |
637 if (slant) XFree (slant); | |
638 if (setwidth) XFree (setwidth); | |
639 if (add_style) XFree (add_style); | |
640 if (spacing) XFree (spacing); | |
641 if (registry) XFree (registry); | |
642 if (encoding) XFree (encoding); | |
643 | |
644 return result; | |
645 } | |
646 | |
3169 | 647 /* XListFonts doesn't allocate memory unconditionally based on this. (For |
648 XFree86 in 2005, at least. */ | |
649 #define MAX_FONT_COUNT INT_MAX | |
428 | 650 |
442 | 651 static Extbyte * |
652 truename_via_XListFonts (Display *dpy, Extbyte *font_name) | |
428 | 653 { |
442 | 654 Extbyte *result = 0; |
444 | 655 Extbyte **names; |
428 | 656 int count = 0; |
657 | |
658 #ifndef XOPENFONT_SORTS | |
659 /* In a sensible world, the first font returned by XListFonts() | |
660 would be the font that XOpenFont() would use. */ | |
661 names = XListFonts (dpy, font_name, 1, &count); | |
662 if (count) result = names [0]; | |
663 #else | |
664 /* But the world I live in is much more perverse. */ | |
665 names = XListFonts (dpy, font_name, MAX_FONT_COUNT, &count); | |
3094 | 666 /* Find the lexicographic minimum of names[]. |
667 (#### Should we be comparing case-insensitively?) */ | |
428 | 668 while (count--) |
3094 | 669 /* [[ !!#### Not Mule-friendly ]] |
670 Doesn't matter, XLFDs are HPC (old) or Latin1 (modern). If they | |
671 aren't, who knows what they are? -- sjt */ | |
428 | 672 if (result == 0 || (strcmp (result, names [count]) < 0)) |
673 result = names [count]; | |
674 #endif | |
675 | |
676 if (result) | |
677 result = xstrdup (result); | |
678 if (names) | |
679 XFreeFontNames (names); | |
680 | |
681 return result; /* this must be freed by caller if non-0 */ | |
682 } | |
683 | |
684 static Lisp_Object | |
442 | 685 x_font_truename (Display *dpy, Extbyte *name, XFontStruct *font) |
428 | 686 { |
442 | 687 Extbyte *truename_FONT = 0; |
688 Extbyte *truename_random = 0; | |
689 Extbyte *truename = 0; | |
428 | 690 |
691 /* The search order is: | |
692 - if FONT property exists, and is a valid name, return it. | |
693 - if the other props exist, and add up to a valid name, return it. | |
694 - if we find a matching name with XListFonts, return it. | |
695 - if FONT property exists, return it regardless. | |
696 - if other props exist, return the resultant name regardless. | |
697 - else return 0. | |
698 */ | |
699 | |
700 truename = truename_FONT = truename_via_FONT_prop (dpy, font); | |
701 if (truename && !valid_x_font_name_p (dpy, truename)) | |
702 truename = 0; | |
703 if (!truename) | |
704 truename = truename_random = truename_via_random_props (dpy, font); | |
705 if (truename && !valid_x_font_name_p (dpy, truename)) | |
706 truename = 0; | |
707 if (!truename && name) | |
708 truename = truename_via_XListFonts (dpy, name); | |
709 | |
710 if (!truename) | |
711 { | |
712 /* Gag - we weren't able to find a seemingly-valid truename. | |
713 Well, maybe we're on one of those braindead systems where | |
714 XListFonts() and XLoadFont() are in violent disagreement. | |
715 If we were able to compute a truename, try using that even | |
716 if evidence suggests that it's not a valid name - because | |
717 maybe it is, really, and that's better than nothing. | |
718 X Windows: You'll envy the dead. | |
719 */ | |
720 if (truename_FONT) | |
721 truename = truename_FONT; | |
722 else if (truename_random) | |
723 truename = truename_random; | |
724 } | |
725 | |
726 /* One or both of these are not being used - free them. */ | |
727 if (truename_FONT && truename_FONT != truename) | |
728 XFree (truename_FONT); | |
729 if (truename_random && truename_random != truename) | |
730 XFree (truename_random); | |
731 | |
732 if (truename) | |
733 { | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
734 Lisp_Object result = build_extstring (truename, Qx_font_name_encoding); |
428 | 735 XFree (truename); |
736 return result; | |
737 } | |
738 else | |
739 return Qnil; | |
740 } | |
741 | |
742 static Lisp_Object | |
578 | 743 x_font_instance_truename (Lisp_Font_Instance *f, Error_Behavior errb) |
428 | 744 { |
745 struct device *d = XDEVICE (f->device); | |
3094 | 746 Display *dpy = DEVICE_X_DISPLAY (d); |
747 Extbyte *nameext; | |
748 | |
749 /* #### restructure this so that we return a valid truename at the end, | |
750 and otherwise only return when we return something desperate that | |
751 doesn't get stored for future use. */ | |
752 | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
753 #ifdef HAVE_XFT |
3094 | 754 /* First, try an Xft font. */ |
755 if (NILP (FONT_INSTANCE_TRUENAME (f)) && FONT_INSTANCE_X_XFTFONT (f)) | |
756 { | |
757 /* The font is already open, we just unparse. */ | |
5818
15b0715c204d
Avoid passing patterns to with charset property to FcNameUnparse.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5581
diff
changeset
|
758 FcPattern* pattern = FONT_INSTANCE_X_XFTFONT (f)->pattern; |
15b0715c204d
Avoid passing patterns to with charset property to FcNameUnparse.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5581
diff
changeset
|
759 FcChar8 *res; |
15b0715c204d
Avoid passing patterns to with charset property to FcNameUnparse.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
5581
diff
changeset
|
760 if (!pattern) |
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
761 { |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
762 maybe_signal_error (Qgui_error, |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
763 "Xft font present but lacks pattern", |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
764 wrap_font_instance(f), Qfont, errb); |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
765 } |
5824
6928877dbc26
Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents:
5818
diff
changeset
|
766 { |
6928877dbc26
Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents:
5818
diff
changeset
|
767 FcPattern* temp = FcPatternDuplicate (pattern); |
6928877dbc26
Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents:
5818
diff
changeset
|
768 FcPatternDel (temp, FC_CHARSET); /* FcNameUnparse may choke */ |
6928877dbc26
Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents:
5818
diff
changeset
|
769 res = FcNameUnparse (temp); |
6928877dbc26
Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents:
5818
diff
changeset
|
770 FcPatternDestroy (temp); |
6928877dbc26
Fix breakage caused by previous commit.
Mike Sperber <sperber@deinprogramm.de>
parents:
5818
diff
changeset
|
771 } |
3094 | 772 if (res) |
773 { | |
3174 | 774 FONT_INSTANCE_TRUENAME (f) = |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
775 build_extstring ((Extbyte *) res, Qfc_font_name_encoding); |
3094 | 776 free (res); |
777 return FONT_INSTANCE_TRUENAME (f); | |
778 } | |
779 else | |
780 { | |
781 maybe_signal_error (Qgui_error, | |
782 "Couldn't unparse Xft font to truename", | |
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
783 wrap_font_instance(f), Qfont, errb); |
3094 | 784 /* used to return Qnil here */ |
785 } | |
786 } | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
787 #endif /* HAVE_XFT */ |
3094 | 788 |
789 /* OK, fall back to core font. */ | |
790 if (NILP (FONT_INSTANCE_TRUENAME (f)) | |
791 && FONT_INSTANCE_X_FONT (f)) | |
792 { | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
793 nameext = LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding); |
3094 | 794 FONT_INSTANCE_TRUENAME (f) = |
795 x_font_truename (dpy, nameext, FONT_INSTANCE_X_FONT (f)); | |
796 } | |
428 | 797 |
872 | 798 if (NILP (FONT_INSTANCE_TRUENAME (f))) |
428 | 799 { |
3094 | 800 /* Urk, no luck. Whine about our bad luck and exit. */ |
801 Lisp_Object font_instance = wrap_font_instance (f); | |
802 | |
803 | |
804 maybe_signal_error (Qgui_error, "Couldn't determine font truename", | |
805 font_instance, Qfont, errb); | |
806 /* Ok, just this once, return the font name as the truename. | |
807 (This is only used by Fequal() right now.) */ | |
808 return f->name; | |
809 } | |
442 | 810 |
3094 | 811 /* Return what we found. */ |
872 | 812 return FONT_INSTANCE_TRUENAME (f); |
428 | 813 } |
814 | |
815 static Lisp_Object | |
440 | 816 x_font_instance_properties (Lisp_Font_Instance *f) |
428 | 817 { |
818 struct device *d = XDEVICE (f->device); | |
819 int i; | |
820 Lisp_Object result = Qnil; | |
444 | 821 Display *dpy = DEVICE_X_DISPLAY (d); |
3094 | 822 XFontProp *props = NULL; |
428 | 823 |
3094 | 824 /* #### really should hack Xft fonts, too |
825 Strategy: fontconfig must have an iterator for this purpose. */ | |
826 if (! FONT_INSTANCE_X_FONT (f)) return result; | |
827 | |
828 props = FONT_INSTANCE_X_FONT (f)->properties; | |
428 | 829 for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--) |
830 { | |
831 Lisp_Object name, value; | |
832 Atom atom = props [i].name; | |
867 | 833 Ibyte *name_str = 0; |
647 | 834 Bytecount name_len; |
442 | 835 Extbyte *namestrext = XGetAtomName (dpy, atom); |
836 | |
837 if (namestrext) | |
444 | 838 TO_INTERNAL_FORMAT (C_STRING, namestrext, |
839 ALLOCA, (name_str, name_len), | |
840 Qx_atom_name_encoding); | |
442 | 841 |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
842 name = (name_str ? intern_istring (name_str) : Qnil); |
428 | 843 if (name_str && |
844 (atom == XA_FONT || | |
845 atom == DEVICE_XATOM_FOUNDRY (d) || | |
846 atom == DEVICE_XATOM_FAMILY_NAME (d) || | |
847 atom == DEVICE_XATOM_WEIGHT_NAME (d) || | |
848 atom == DEVICE_XATOM_SLANT (d) || | |
849 atom == DEVICE_XATOM_SETWIDTH_NAME (d) || | |
850 atom == DEVICE_XATOM_ADD_STYLE_NAME (d) || | |
851 atom == DEVICE_XATOM_SPACING (d) || | |
852 atom == DEVICE_XATOM_CHARSET_REGISTRY (d) || | |
853 atom == DEVICE_XATOM_CHARSET_ENCODING (d) || | |
2367 | 854 !qxestrcmp_ascii (name_str, "CHARSET_COLLECTIONS") || |
855 !qxestrcmp_ascii (name_str, "FONTNAME_REGISTRY") || | |
856 !qxestrcmp_ascii (name_str, "CLASSIFICATION") || | |
857 !qxestrcmp_ascii (name_str, "COPYRIGHT") || | |
858 !qxestrcmp_ascii (name_str, "DEVICE_FONT_NAME") || | |
859 !qxestrcmp_ascii (name_str, "FULL_NAME") || | |
860 !qxestrcmp_ascii (name_str, "MONOSPACED") || | |
861 !qxestrcmp_ascii (name_str, "QUALITY") || | |
862 !qxestrcmp_ascii (name_str, "RELATIVE_SET") || | |
863 !qxestrcmp_ascii (name_str, "RELATIVE_WEIGHT") || | |
864 !qxestrcmp_ascii (name_str, "STYLE"))) | |
428 | 865 { |
442 | 866 Extbyte *val_str = XGetAtomName (dpy, props [i].card32); |
867 | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
868 value = (val_str ? build_extstring (val_str, Qx_atom_name_encoding) |
442 | 869 : Qnil); |
428 | 870 } |
871 else | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
872 value = make_fixnum (props [i].card32); |
442 | 873 if (namestrext) XFree (namestrext); |
428 | 874 result = Fcons (Fcons (name, value), result); |
875 } | |
876 return result; | |
877 } | |
878 | |
879 static Lisp_Object | |
2527 | 880 x_font_list (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber) |
428 | 881 { |
444 | 882 Extbyte **names; |
428 | 883 int count = 0; |
1701 | 884 int max_number = MAX_FONT_COUNT; |
428 | 885 Lisp_Object result = Qnil; |
442 | 886 const Extbyte *patternext; |
428 | 887 |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
888 patternext = LISP_STRING_TO_EXTERNAL (pattern, Qx_font_name_encoding); |
428 | 889 |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
890 if (!NILP(maxnumber) && FIXNUMP(maxnumber)) |
1701 | 891 { |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
892 max_number = XFIXNUM(maxnumber); |
1701 | 893 } |
894 | |
428 | 895 names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)), |
1701 | 896 patternext, max_number, &count); |
428 | 897 while (count--) |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
898 result = Fcons (build_extstring (names[count], Qx_font_name_encoding), |
442 | 899 result); |
428 | 900 if (names) |
901 XFreeFontNames (names); | |
902 return result; | |
903 } | |
904 | |
3659 | 905 /* Include the charset support, shared, for the moment, with GTK. */ |
906 #define THIS_IS_X | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
907 #include "fontcolor-xlike-inc.c" |
428 | 908 |
909 | |
910 /************************************************************************/ | |
911 /* initialization */ | |
912 /************************************************************************/ | |
913 | |
914 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
915 syms_of_fontcolor_x (void) |
428 | 916 { |
917 } | |
918 | |
919 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
920 console_type_create_fontcolor_x (void) |
428 | 921 { |
922 /* object methods */ | |
923 | |
924 CONSOLE_HAS_METHOD (x, initialize_color_instance); | |
925 CONSOLE_HAS_METHOD (x, print_color_instance); | |
926 CONSOLE_HAS_METHOD (x, finalize_color_instance); | |
927 CONSOLE_HAS_METHOD (x, color_instance_equal); | |
928 CONSOLE_HAS_METHOD (x, color_instance_hash); | |
929 CONSOLE_HAS_METHOD (x, color_instance_rgb_components); | |
930 CONSOLE_HAS_METHOD (x, valid_color_name_p); | |
2527 | 931 CONSOLE_HAS_METHOD (x, color_list); |
428 | 932 |
933 CONSOLE_HAS_METHOD (x, initialize_font_instance); | |
934 CONSOLE_HAS_METHOD (x, print_font_instance); | |
935 CONSOLE_HAS_METHOD (x, finalize_font_instance); | |
936 CONSOLE_HAS_METHOD (x, font_instance_truename); | |
937 CONSOLE_HAS_METHOD (x, font_instance_properties); | |
2527 | 938 CONSOLE_HAS_METHOD (x, font_list); |
428 | 939 #ifdef MULE |
940 CONSOLE_HAS_METHOD (x, find_charset_font); | |
941 CONSOLE_HAS_METHOD (x, font_spec_matches_charset); | |
942 #endif | |
943 } | |
944 | |
945 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
946 vars_of_fontcolor_x (void) |
428 | 947 { |
3659 | 948 #ifdef DEBUG_XEMACS |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5176
diff
changeset
|
949 DEFVAR_INT ("debug-x-fonts", &debug_x_fonts /* |
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5176
diff
changeset
|
950 If non-zero, display debug information about X fonts |
3659 | 951 */ ); |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5176
diff
changeset
|
952 debug_x_fonts = 0; |
3659 | 953 #endif |
954 | |
428 | 955 DEFVAR_BOOL ("x-handle-non-fully-specified-fonts", |
956 &x_handle_non_fully_specified_fonts /* | |
957 If this is true then fonts which do not have all characters specified | |
958 will be considered to be proportional width even if they are actually | |
959 fixed-width. If this is not done then characters which are supposed to | |
960 have 0 width may appear to actually have some width. | |
961 | |
962 Note: While setting this to t guarantees correct output in all | |
963 circumstances, it also causes a noticeable performance hit when using | |
964 fixed-width fonts. Since most people don't use characters which could | |
965 cause problems this is set to nil by default. | |
966 */ ); | |
967 x_handle_non_fully_specified_fonts = 0; | |
3094 | 968 |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
969 #ifdef HAVE_XFT |
3094 | 970 Fprovide (intern ("xft-fonts")); |
971 #endif | |
428 | 972 } |
973 | |
974 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
975 Xatoms_of_fontcolor_x (struct device *d) |
428 | 976 { |
977 Display *D = DEVICE_X_DISPLAY (d); | |
978 | |
979 DEVICE_XATOM_FOUNDRY (d) = XInternAtom (D, "FOUNDRY", False); | |
980 DEVICE_XATOM_FAMILY_NAME (d) = XInternAtom (D, "FAMILY_NAME", False); | |
981 DEVICE_XATOM_WEIGHT_NAME (d) = XInternAtom (D, "WEIGHT_NAME", False); | |
982 DEVICE_XATOM_SLANT (d) = XInternAtom (D, "SLANT", False); | |
983 DEVICE_XATOM_SETWIDTH_NAME (d) = XInternAtom (D, "SETWIDTH_NAME", False); | |
984 DEVICE_XATOM_ADD_STYLE_NAME (d) = XInternAtom (D, "ADD_STYLE_NAME", False); | |
985 DEVICE_XATOM_PIXEL_SIZE (d) = XInternAtom (D, "PIXEL_SIZE", False); | |
986 DEVICE_XATOM_POINT_SIZE (d) = XInternAtom (D, "POINT_SIZE", False); | |
987 DEVICE_XATOM_RESOLUTION_X (d) = XInternAtom (D, "RESOLUTION_X", False); | |
988 DEVICE_XATOM_RESOLUTION_Y (d) = XInternAtom (D, "RESOLUTION_Y", False); | |
989 DEVICE_XATOM_SPACING (d) = XInternAtom (D, "SPACING", False); | |
990 DEVICE_XATOM_AVERAGE_WIDTH (d) = XInternAtom (D, "AVERAGE_WIDTH", False); | |
991 DEVICE_XATOM_CHARSET_REGISTRY(d) = XInternAtom (D, "CHARSET_REGISTRY",False); | |
992 DEVICE_XATOM_CHARSET_ENCODING(d) = XInternAtom (D, "CHARSET_ENCODING",False); | |
993 } |