Mercurial > hg > xemacs-beta
comparison src/objects-x.c @ 4969:cbe181529c34
Automatic merge
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 03 Feb 2010 21:46:21 -0600 |
parents | 304aebb79cd3 a6c778975d7d |
children | 16112448d484 4aebb0131297 |
comparison
equal
deleted
inserted
replaced
4968:4d35e52790f8 | 4969:cbe181529c34 |
---|---|
37 | 37 |
38 #include "console-x-impl.h" | 38 #include "console-x-impl.h" |
39 #include "objects-x-impl.h" | 39 #include "objects-x-impl.h" |
40 #include "elhash.h" | 40 #include "elhash.h" |
41 | 41 |
42 #ifdef USE_XFT | 42 #ifdef HAVE_XFT |
43 #include "font-mgr.h" | 43 #include "font-mgr.h" |
44 #endif | 44 #endif |
45 | 45 |
46 int x_handle_non_fully_specified_fonts; | 46 int x_handle_non_fully_specified_fonts; |
47 | 47 |
90 static int | 90 static int |
91 x_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, | 91 x_initialize_color_instance (Lisp_Color_Instance *c, Lisp_Object name, |
92 Lisp_Object device, Error_Behavior errb) | 92 Lisp_Object device, Error_Behavior errb) |
93 { | 93 { |
94 XColor color; | 94 XColor color; |
95 #ifdef USE_XFT | 95 #ifdef HAVE_XFT |
96 XftColor xftColor; | 96 XftColor xftColor; |
97 #endif | 97 #endif |
98 int result; | 98 int result; |
99 | 99 |
100 result = x_parse_nearest_color (XDEVICE (device), &color, name, errb); | 100 result = x_parse_nearest_color (XDEVICE (device), &color, name, errb); |
109 COLOR_INSTANCE_X_DEALLOC (c) = 0; | 109 COLOR_INSTANCE_X_DEALLOC (c) = 0; |
110 else | 110 else |
111 COLOR_INSTANCE_X_DEALLOC (c) = 1; | 111 COLOR_INSTANCE_X_DEALLOC (c) = 1; |
112 COLOR_INSTANCE_X_COLOR (c) = color; | 112 COLOR_INSTANCE_X_COLOR (c) = color; |
113 | 113 |
114 #ifdef USE_XFT | 114 #ifdef HAVE_XFT |
115 xftColor.pixel = color.pixel; | 115 xftColor.pixel = color.pixel; |
116 xftColor.color.red = color.red; | 116 xftColor.color.red = color.red; |
117 xftColor.color.green = color.green; | 117 xftColor.color.green = color.green; |
118 xftColor.color.blue = color.blue; | 118 xftColor.color.blue = color.blue; |
119 xftColor.color.alpha = 0xffff; | 119 xftColor.color.alpha = 0xffff; |
216 Lisp_Object device, Error_Behavior errb) | 216 Lisp_Object device, Error_Behavior errb) |
217 { | 217 { |
218 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device)); | 218 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (device)); |
219 Extbyte *extname; | 219 Extbyte *extname; |
220 XFontStruct *fs = NULL; /* _F_ont _S_truct */ | 220 XFontStruct *fs = NULL; /* _F_ont _S_truct */ |
221 #ifdef USE_XFT | 221 #ifdef HAVE_XFT |
222 XftFont *rf = NULL; /* _R_ender _F_ont (X Render extension) */ | 222 XftFont *rf = NULL; /* _R_ender _F_ont (X Render extension) */ |
223 #else | 223 #else |
224 #define rf (0) | 224 #define rf (0) |
225 #endif | 225 #endif |
226 | 226 |
227 #ifdef USE_XFT | 227 #ifdef HAVE_XFT |
228 DEBUG_XFT1 (2, "attempting to initialize font spec %s\n", | 228 DEBUG_XFT1 (2, "attempting to initialize font spec %s\n", |
229 XSTRING_DATA(f->name)); | 229 XSTRING_DATA(f->name)); |
230 /* #### serialize (optimize) these later... */ | 230 /* #### serialize (optimize) these later... */ |
231 /* #### This function really needs to go away. | 231 /* #### This function really needs to go away. |
232 The problem is that the fontconfig/Xft functions work much too hard | 232 The problem is that the fontconfig/Xft functions work much too hard |
270 | 270 |
271 /* Now that we're sure that we will succeed, we can allocate data without | 271 /* Now that we're sure that we will succeed, we can allocate data without |
272 fear that the finalize method may get fucked. */ | 272 fear that the finalize method may get fucked. */ |
273 f->data = xnew (struct x_font_instance_data); | 273 f->data = xnew (struct x_font_instance_data); |
274 | 274 |
275 #ifdef USE_XFT | 275 #ifdef HAVE_XFT |
276 FONT_INSTANCE_X_XFTFONT (f) = rf; | 276 FONT_INSTANCE_X_XFTFONT (f) = rf; |
277 if (rf) | 277 if (rf) |
278 /* Have an Xft font, initialize font info from it. */ | 278 /* Have an Xft font, initialize font info from it. */ |
279 { | 279 { |
280 DEBUG_XFT4 (2, "pre-initial ascent %d descent %d width %d height %d\n", | 280 DEBUG_XFT4 (2, "pre-initial ascent %d descent %d width %d height %d\n", |
377 f->proportional_p = (fs->min_bounds.width != fs->max_bounds.width || | 377 f->proportional_p = (fs->min_bounds.width != fs->max_bounds.width || |
378 (x_handle_non_fully_specified_fonts && | 378 (x_handle_non_fully_specified_fonts && |
379 !fs->all_chars_exist)); | 379 !fs->all_chars_exist)); |
380 } | 380 } |
381 | 381 |
382 #ifdef USE_XFT | 382 #ifdef HAVE_XFT |
383 if (debug_xft > 0) | 383 if (debug_xft > 0) |
384 { | 384 { |
385 int n = 3, d = 5; | 385 int n = 3, d = 5; |
386 /* check for weirdness */ | 386 /* check for weirdness */ |
387 if (n * f->height < d * f->width) | 387 if (n * f->height < d * f->width) |
409 unfortunately. */ | 409 unfortunately. */ |
410 if (FONT_INSTANCE_X_FONT (f)) | 410 if (FONT_INSTANCE_X_FONT (f)) |
411 write_fmt_string (printcharfun, " font id: 0x%lx,", | 411 write_fmt_string (printcharfun, " font id: 0x%lx,", |
412 (unsigned long) FONT_INSTANCE_X_FONT (f)->fid); | 412 (unsigned long) FONT_INSTANCE_X_FONT (f)->fid); |
413 | 413 |
414 #ifdef USE_XFT | 414 #ifdef HAVE_XFT |
415 /* #### What should we do here? For now, print the address. */ | 415 /* #### What should we do here? For now, print the address. */ |
416 if (FONT_INSTANCE_X_XFTFONT (f)) | 416 if (FONT_INSTANCE_X_XFTFONT (f)) |
417 write_fmt_string (printcharfun, " xft font: 0x%lx", | 417 write_fmt_string (printcharfun, " xft font: 0x%lx", |
418 (unsigned long) FONT_INSTANCE_X_XFTFONT (f)); | 418 (unsigned long) FONT_INSTANCE_X_XFTFONT (f)); |
419 #endif | 419 #endif |
421 | 421 |
422 static void | 422 static void |
423 x_finalize_font_instance (Lisp_Font_Instance *f) | 423 x_finalize_font_instance (Lisp_Font_Instance *f) |
424 { | 424 { |
425 | 425 |
426 #ifdef USE_XFT | 426 #ifdef HAVE_XFT |
427 DEBUG_XFT1 (0, "finalizing %s\n", (STRINGP (f->name) | 427 DEBUG_XFT1 (0, "finalizing %s\n", (STRINGP (f->name) |
428 ? (char *) XSTRING_DATA (f->name) | 428 ? (char *) XSTRING_DATA (f->name) |
429 : "(unnamed font)")); | 429 : "(unnamed font)")); |
430 #endif | 430 #endif |
431 | 431 |
435 { | 435 { |
436 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device)); | 436 Display *dpy = DEVICE_X_DISPLAY (XDEVICE (f->device)); |
437 | 437 |
438 if (FONT_INSTANCE_X_FONT (f)) | 438 if (FONT_INSTANCE_X_FONT (f)) |
439 XFreeFont (dpy, FONT_INSTANCE_X_FONT (f)); | 439 XFreeFont (dpy, FONT_INSTANCE_X_FONT (f)); |
440 #ifdef USE_XFT | 440 #ifdef HAVE_XFT |
441 if (FONT_INSTANCE_X_XFTFONT (f)) | 441 if (FONT_INSTANCE_X_XFTFONT (f)) |
442 XftFontClose (dpy, FONT_INSTANCE_X_XFTFONT (f)); | 442 XftFontClose (dpy, FONT_INSTANCE_X_XFTFONT (f)); |
443 #endif | 443 #endif |
444 } | 444 } |
445 xfree (f->data, void *); | 445 xfree (f->data, void *); |
750 | 750 |
751 /* #### restructure this so that we return a valid truename at the end, | 751 /* #### restructure this so that we return a valid truename at the end, |
752 and otherwise only return when we return something desperate that | 752 and otherwise only return when we return something desperate that |
753 doesn't get stored for future use. */ | 753 doesn't get stored for future use. */ |
754 | 754 |
755 #ifdef USE_XFT | 755 #ifdef HAVE_XFT |
756 /* First, try an Xft font. */ | 756 /* First, try an Xft font. */ |
757 if (NILP (FONT_INSTANCE_TRUENAME (f)) && FONT_INSTANCE_X_XFTFONT (f)) | 757 if (NILP (FONT_INSTANCE_TRUENAME (f)) && FONT_INSTANCE_X_XFTFONT (f)) |
758 { | 758 { |
759 /* The font is already open, we just unparse. */ | 759 /* The font is already open, we just unparse. */ |
760 FcChar8 *res = FcNameUnparse (FONT_INSTANCE_X_XFTFONT (f)->pattern); | 760 FcChar8 *res = FcNameUnparse (FONT_INSTANCE_X_XFTFONT (f)->pattern); |
777 "Couldn't unparse Xft font to truename", | 777 "Couldn't unparse Xft font to truename", |
778 wrap_font_instance(f), Qfont, errb); | 778 wrap_font_instance(f), Qfont, errb); |
779 /* used to return Qnil here */ | 779 /* used to return Qnil here */ |
780 } | 780 } |
781 } | 781 } |
782 #endif /* USE_XFT */ | 782 #endif /* HAVE_XFT */ |
783 | 783 |
784 /* OK, fall back to core font. */ | 784 /* OK, fall back to core font. */ |
785 if (NILP (FONT_INSTANCE_TRUENAME (f)) | 785 if (NILP (FONT_INSTANCE_TRUENAME (f)) |
786 && FONT_INSTANCE_X_FONT (f)) | 786 && FONT_INSTANCE_X_FONT (f)) |
787 { | 787 { |
959 fixed-width fonts. Since most people don't use characters which could | 959 fixed-width fonts. Since most people don't use characters which could |
960 cause problems this is set to nil by default. | 960 cause problems this is set to nil by default. |
961 */ ); | 961 */ ); |
962 x_handle_non_fully_specified_fonts = 0; | 962 x_handle_non_fully_specified_fonts = 0; |
963 | 963 |
964 #ifdef USE_XFT | 964 #ifdef HAVE_XFT |
965 Fprovide (intern ("xft-fonts")); | 965 Fprovide (intern ("xft-fonts")); |
966 #endif | 966 #endif |
967 } | 967 } |
968 | 968 |
969 void | 969 void |