Mercurial > hg > xemacs-beta
annotate src/fontcolor-x.c @ 5636:07256dcc0c8b
Add missing foreback specifier values to the GUI Element face.
They were missing for an unexplicable reason in my initial patch, leading to
nil color instances in the whole hierarchy of widget faces.
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2012-01-03 Didier Verna <didier@xemacs.org>
* faces.c (complex_vars_of_faces): Add missing foreback specifier
values to the GUI Element face.
author | Didier Verna <didier@lrde.epita.fr> |
---|---|
date | Tue, 03 Jan 2012 11:25:06 +0100 |
parents | 56144c8593a8 |
children | 15b0715c204d |
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. */ | |
758 FcChar8 *res = FcNameUnparse (FONT_INSTANCE_X_XFTFONT (f)->pattern); | |
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
759 if (! FONT_INSTANCE_X_XFTFONT (f)->pattern) |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
760 { |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
761 maybe_signal_error (Qgui_error, |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
762 "Xft font present but lacks pattern", |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
763 wrap_font_instance(f), Qfont, errb); |
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
3659
diff
changeset
|
764 } |
3094 | 765 if (res) |
766 { | |
3174 | 767 FONT_INSTANCE_TRUENAME (f) = |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
768 build_extstring ((Extbyte *) res, Qfc_font_name_encoding); |
3094 | 769 free (res); |
770 return FONT_INSTANCE_TRUENAME (f); | |
771 } | |
772 else | |
773 { | |
774 maybe_signal_error (Qgui_error, | |
775 "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
|
776 wrap_font_instance(f), Qfont, errb); |
3094 | 777 /* used to return Qnil here */ |
778 } | |
779 } | |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
780 #endif /* HAVE_XFT */ |
3094 | 781 |
782 /* OK, fall back to core font. */ | |
783 if (NILP (FONT_INSTANCE_TRUENAME (f)) | |
784 && FONT_INSTANCE_X_FONT (f)) | |
785 { | |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
786 nameext = LISP_STRING_TO_EXTERNAL (f->name, Qx_font_name_encoding); |
3094 | 787 FONT_INSTANCE_TRUENAME (f) = |
788 x_font_truename (dpy, nameext, FONT_INSTANCE_X_FONT (f)); | |
789 } | |
428 | 790 |
872 | 791 if (NILP (FONT_INSTANCE_TRUENAME (f))) |
428 | 792 { |
3094 | 793 /* Urk, no luck. Whine about our bad luck and exit. */ |
794 Lisp_Object font_instance = wrap_font_instance (f); | |
795 | |
796 | |
797 maybe_signal_error (Qgui_error, "Couldn't determine font truename", | |
798 font_instance, Qfont, errb); | |
799 /* Ok, just this once, return the font name as the truename. | |
800 (This is only used by Fequal() right now.) */ | |
801 return f->name; | |
802 } | |
442 | 803 |
3094 | 804 /* Return what we found. */ |
872 | 805 return FONT_INSTANCE_TRUENAME (f); |
428 | 806 } |
807 | |
808 static Lisp_Object | |
440 | 809 x_font_instance_properties (Lisp_Font_Instance *f) |
428 | 810 { |
811 struct device *d = XDEVICE (f->device); | |
812 int i; | |
813 Lisp_Object result = Qnil; | |
444 | 814 Display *dpy = DEVICE_X_DISPLAY (d); |
3094 | 815 XFontProp *props = NULL; |
428 | 816 |
3094 | 817 /* #### really should hack Xft fonts, too |
818 Strategy: fontconfig must have an iterator for this purpose. */ | |
819 if (! FONT_INSTANCE_X_FONT (f)) return result; | |
820 | |
821 props = FONT_INSTANCE_X_FONT (f)->properties; | |
428 | 822 for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--) |
823 { | |
824 Lisp_Object name, value; | |
825 Atom atom = props [i].name; | |
867 | 826 Ibyte *name_str = 0; |
647 | 827 Bytecount name_len; |
442 | 828 Extbyte *namestrext = XGetAtomName (dpy, atom); |
829 | |
830 if (namestrext) | |
444 | 831 TO_INTERNAL_FORMAT (C_STRING, namestrext, |
832 ALLOCA, (name_str, name_len), | |
833 Qx_atom_name_encoding); | |
442 | 834 |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
835 name = (name_str ? intern_istring (name_str) : Qnil); |
428 | 836 if (name_str && |
837 (atom == XA_FONT || | |
838 atom == DEVICE_XATOM_FOUNDRY (d) || | |
839 atom == DEVICE_XATOM_FAMILY_NAME (d) || | |
840 atom == DEVICE_XATOM_WEIGHT_NAME (d) || | |
841 atom == DEVICE_XATOM_SLANT (d) || | |
842 atom == DEVICE_XATOM_SETWIDTH_NAME (d) || | |
843 atom == DEVICE_XATOM_ADD_STYLE_NAME (d) || | |
844 atom == DEVICE_XATOM_SPACING (d) || | |
845 atom == DEVICE_XATOM_CHARSET_REGISTRY (d) || | |
846 atom == DEVICE_XATOM_CHARSET_ENCODING (d) || | |
2367 | 847 !qxestrcmp_ascii (name_str, "CHARSET_COLLECTIONS") || |
848 !qxestrcmp_ascii (name_str, "FONTNAME_REGISTRY") || | |
849 !qxestrcmp_ascii (name_str, "CLASSIFICATION") || | |
850 !qxestrcmp_ascii (name_str, "COPYRIGHT") || | |
851 !qxestrcmp_ascii (name_str, "DEVICE_FONT_NAME") || | |
852 !qxestrcmp_ascii (name_str, "FULL_NAME") || | |
853 !qxestrcmp_ascii (name_str, "MONOSPACED") || | |
854 !qxestrcmp_ascii (name_str, "QUALITY") || | |
855 !qxestrcmp_ascii (name_str, "RELATIVE_SET") || | |
856 !qxestrcmp_ascii (name_str, "RELATIVE_WEIGHT") || | |
857 !qxestrcmp_ascii (name_str, "STYLE"))) | |
428 | 858 { |
442 | 859 Extbyte *val_str = XGetAtomName (dpy, props [i].card32); |
860 | |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
861 value = (val_str ? build_extstring (val_str, Qx_atom_name_encoding) |
442 | 862 : Qnil); |
428 | 863 } |
864 else | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
865 value = make_fixnum (props [i].card32); |
442 | 866 if (namestrext) XFree (namestrext); |
428 | 867 result = Fcons (Fcons (name, value), result); |
868 } | |
869 return result; | |
870 } | |
871 | |
872 static Lisp_Object | |
2527 | 873 x_font_list (Lisp_Object pattern, Lisp_Object device, Lisp_Object maxnumber) |
428 | 874 { |
444 | 875 Extbyte **names; |
428 | 876 int count = 0; |
1701 | 877 int max_number = MAX_FONT_COUNT; |
428 | 878 Lisp_Object result = Qnil; |
442 | 879 const Extbyte *patternext; |
428 | 880 |
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4969
diff
changeset
|
881 patternext = LISP_STRING_TO_EXTERNAL (pattern, Qx_font_name_encoding); |
428 | 882 |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
883 if (!NILP(maxnumber) && FIXNUMP(maxnumber)) |
1701 | 884 { |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
885 max_number = XFIXNUM(maxnumber); |
1701 | 886 } |
887 | |
428 | 888 names = XListFonts (DEVICE_X_DISPLAY (XDEVICE (device)), |
1701 | 889 patternext, max_number, &count); |
428 | 890 while (count--) |
4953
304aebb79cd3
function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
891 result = Fcons (build_extstring (names[count], Qx_font_name_encoding), |
442 | 892 result); |
428 | 893 if (names) |
894 XFreeFontNames (names); | |
895 return result; | |
896 } | |
897 | |
3659 | 898 /* Include the charset support, shared, for the moment, with GTK. */ |
899 #define THIS_IS_X | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
900 #include "fontcolor-xlike-inc.c" |
428 | 901 |
902 | |
903 /************************************************************************/ | |
904 /* initialization */ | |
905 /************************************************************************/ | |
906 | |
907 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
908 syms_of_fontcolor_x (void) |
428 | 909 { |
910 } | |
911 | |
912 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
913 console_type_create_fontcolor_x (void) |
428 | 914 { |
915 /* object methods */ | |
916 | |
917 CONSOLE_HAS_METHOD (x, initialize_color_instance); | |
918 CONSOLE_HAS_METHOD (x, print_color_instance); | |
919 CONSOLE_HAS_METHOD (x, finalize_color_instance); | |
920 CONSOLE_HAS_METHOD (x, color_instance_equal); | |
921 CONSOLE_HAS_METHOD (x, color_instance_hash); | |
922 CONSOLE_HAS_METHOD (x, color_instance_rgb_components); | |
923 CONSOLE_HAS_METHOD (x, valid_color_name_p); | |
2527 | 924 CONSOLE_HAS_METHOD (x, color_list); |
428 | 925 |
926 CONSOLE_HAS_METHOD (x, initialize_font_instance); | |
927 CONSOLE_HAS_METHOD (x, print_font_instance); | |
928 CONSOLE_HAS_METHOD (x, finalize_font_instance); | |
929 CONSOLE_HAS_METHOD (x, font_instance_truename); | |
930 CONSOLE_HAS_METHOD (x, font_instance_properties); | |
2527 | 931 CONSOLE_HAS_METHOD (x, font_list); |
428 | 932 #ifdef MULE |
933 CONSOLE_HAS_METHOD (x, find_charset_font); | |
934 CONSOLE_HAS_METHOD (x, font_spec_matches_charset); | |
935 #endif | |
936 } | |
937 | |
938 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
939 vars_of_fontcolor_x (void) |
428 | 940 { |
3659 | 941 #ifdef DEBUG_XEMACS |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5176
diff
changeset
|
942 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
|
943 If non-zero, display debug information about X fonts |
3659 | 944 */ ); |
5189
b65692aa90d8
Cosmetic XFT-code fixes, some variable renamings
Ben Wing <ben@xemacs.org>
parents:
5176
diff
changeset
|
945 debug_x_fonts = 0; |
3659 | 946 #endif |
947 | |
428 | 948 DEFVAR_BOOL ("x-handle-non-fully-specified-fonts", |
949 &x_handle_non_fully_specified_fonts /* | |
950 If this is true then fonts which do not have all characters specified | |
951 will be considered to be proportional width even if they are actually | |
952 fixed-width. If this is not done then characters which are supposed to | |
953 have 0 width may appear to actually have some width. | |
954 | |
955 Note: While setting this to t guarantees correct output in all | |
956 circumstances, it also causes a noticeable performance hit when using | |
957 fixed-width fonts. Since most people don't use characters which could | |
958 cause problems this is set to nil by default. | |
959 */ ); | |
960 x_handle_non_fully_specified_fonts = 0; | |
3094 | 961 |
4916
a6c778975d7d
split USE_XFT into HAVE_XFT/USE_XFT
Ben Wing <ben@xemacs.org>
parents:
4757
diff
changeset
|
962 #ifdef HAVE_XFT |
3094 | 963 Fprovide (intern ("xft-fonts")); |
964 #endif | |
428 | 965 } |
966 | |
967 void | |
5176
8b2f75cecb89
rename objects* (.c, .h and .el files) to fontcolor*
Ben Wing <ben@xemacs.org>
parents:
4982
diff
changeset
|
968 Xatoms_of_fontcolor_x (struct device *d) |
428 | 969 { |
970 Display *D = DEVICE_X_DISPLAY (d); | |
971 | |
972 DEVICE_XATOM_FOUNDRY (d) = XInternAtom (D, "FOUNDRY", False); | |
973 DEVICE_XATOM_FAMILY_NAME (d) = XInternAtom (D, "FAMILY_NAME", False); | |
974 DEVICE_XATOM_WEIGHT_NAME (d) = XInternAtom (D, "WEIGHT_NAME", False); | |
975 DEVICE_XATOM_SLANT (d) = XInternAtom (D, "SLANT", False); | |
976 DEVICE_XATOM_SETWIDTH_NAME (d) = XInternAtom (D, "SETWIDTH_NAME", False); | |
977 DEVICE_XATOM_ADD_STYLE_NAME (d) = XInternAtom (D, "ADD_STYLE_NAME", False); | |
978 DEVICE_XATOM_PIXEL_SIZE (d) = XInternAtom (D, "PIXEL_SIZE", False); | |
979 DEVICE_XATOM_POINT_SIZE (d) = XInternAtom (D, "POINT_SIZE", False); | |
980 DEVICE_XATOM_RESOLUTION_X (d) = XInternAtom (D, "RESOLUTION_X", False); | |
981 DEVICE_XATOM_RESOLUTION_Y (d) = XInternAtom (D, "RESOLUTION_Y", False); | |
982 DEVICE_XATOM_SPACING (d) = XInternAtom (D, "SPACING", False); | |
983 DEVICE_XATOM_AVERAGE_WIDTH (d) = XInternAtom (D, "AVERAGE_WIDTH", False); | |
984 DEVICE_XATOM_CHARSET_REGISTRY(d) = XInternAtom (D, "CHARSET_REGISTRY",False); | |
985 DEVICE_XATOM_CHARSET_ENCODING(d) = XInternAtom (D, "CHARSET_ENCODING",False); | |
986 } |