Mercurial > hg > xemacs-beta
comparison src/objects-x.c @ 380:8626e4521993 r21-2-5
Import from CVS: tag r21-2-5
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:07:10 +0200 |
parents | cc15677e0335 |
children | 74fd4e045ea6 |
comparison
equal
deleted
inserted
replaced
379:76b7d63099ad | 380:8626e4521993 |
---|---|
112 color_def->blue = color_def->blue >> (16 - bbits); | 112 color_def->blue = color_def->blue >> (16 - bbits); |
113 if (XAllocColor (display, colormap, color_def) != 0) | 113 if (XAllocColor (display, colormap, color_def) != 0) |
114 status = 1; | 114 status = 1; |
115 else | 115 else |
116 { | 116 { |
117 int rd, gr, bl; | 117 int rd, gr, bl; |
118 /* ### JH: I'm punting here, knowing that doing this will at | 118 /* ### JH: I'm punting here, knowing that doing this will at |
119 least draw the color correctly. However, unless we convert | 119 least draw the color correctly. However, unless we convert |
120 all of the functions that allocate colors (graphics | 120 all of the functions that allocate colors (graphics |
121 libraries, etc) to use this function doing this is very | 121 libraries, etc) to use this function doing this is very |
122 likely to cause problems later... */ | 122 likely to cause problems later... */ |
207 int | 207 int |
208 x_parse_nearest_color (struct device *d, XColor *color, Bufbyte *name, | 208 x_parse_nearest_color (struct device *d, XColor *color, Bufbyte *name, |
209 Bytecount len, Error_behavior errb) | 209 Bytecount len, Error_behavior errb) |
210 { | 210 { |
211 Display *dpy; | 211 Display *dpy; |
212 Screen *xs; | |
213 Colormap cmap; | 212 Colormap cmap; |
214 Visual *visual; | 213 Visual *visual; |
215 int result; | 214 int result; |
216 | 215 |
217 dpy = DEVICE_X_DISPLAY (d); | 216 dpy = DEVICE_X_DISPLAY (d); |
218 xs = DefaultScreenOfDisplay (dpy); | |
219 cmap = DEVICE_X_COLORMAP(d); | 217 cmap = DEVICE_X_COLORMAP(d); |
220 visual = DEVICE_X_VISUAL (d); | 218 visual = DEVICE_X_VISUAL (d); |
221 | 219 |
222 xzero (*color); | 220 xzero (*color); |
223 { | 221 { |
227 GET_CHARPTR_EXT_BINARY_DATA_ALLOCA (name, len, extname, extnamelen); | 225 GET_CHARPTR_EXT_BINARY_DATA_ALLOCA (name, len, extname, extnamelen); |
228 result = XParseColor (dpy, cmap, (char *) extname, color); | 226 result = XParseColor (dpy, cmap, (char *) extname, color); |
229 } | 227 } |
230 if (!result) | 228 if (!result) |
231 { | 229 { |
232 maybe_signal_simple_error ("unrecognized color", make_string (name, len), | 230 maybe_signal_simple_error ("Unrecognized color", make_string (name, len), |
233 Qcolor, errb); | 231 Qcolor, errb); |
234 return 0; | 232 return 0; |
235 } | 233 } |
236 result = allocate_nearest_color (dpy, cmap, visual, color); | 234 result = allocate_nearest_color (dpy, cmap, visual, color); |
237 if (!result) | 235 if (!result) |
238 { | 236 { |
239 maybe_signal_simple_error ("couldn't allocate color", | 237 maybe_signal_simple_error ("Couldn't allocate color", |
240 make_string (name, len), Qcolor, errb); | 238 make_string (name, len), Qcolor, errb); |
241 return 0; | 239 return 0; |
242 } | 240 } |
243 | 241 |
244 return result; | 242 return result; |
365 GET_C_STRING_CTEXT_DATA_ALLOCA (f->name, extname); | 363 GET_C_STRING_CTEXT_DATA_ALLOCA (f->name, extname); |
366 xf = XLoadQueryFont (dpy, extname); | 364 xf = XLoadQueryFont (dpy, extname); |
367 | 365 |
368 if (!xf) | 366 if (!xf) |
369 { | 367 { |
370 maybe_signal_simple_error ("couldn't load font", f->name, | 368 maybe_signal_simple_error ("Couldn't load font", f->name, |
371 Qfont, errb); | 369 Qfont, errb); |
372 return 0; | 370 return 0; |
373 } | 371 } |
374 | 372 |
375 if (!xf->max_bounds.width) | 373 if (!xf->max_bounds.width) |
450 | 448 |
451 static void | 449 static void |
452 x_mark_font_instance (struct Lisp_Font_Instance *f, | 450 x_mark_font_instance (struct Lisp_Font_Instance *f, |
453 void (*markobj) (Lisp_Object)) | 451 void (*markobj) (Lisp_Object)) |
454 { | 452 { |
455 ((markobj) (FONT_INSTANCE_X_TRUENAME (f))); | 453 markobj (FONT_INSTANCE_X_TRUENAME (f)); |
456 } | 454 } |
457 | 455 |
458 static void | 456 static void |
459 x_print_font_instance (struct Lisp_Font_Instance *f, | 457 x_print_font_instance (struct Lisp_Font_Instance *f, |
460 Lisp_Object printcharfun, | 458 Lisp_Object printcharfun, |
496 smallest font which matches the name (thus picking "adobe" fonts before | 494 smallest font which matches the name (thus picking "adobe" fonts before |
497 "bitstream" fonts even if the bitstream fonts are earlier in the path, and | 495 "bitstream" fonts even if the bitstream fonts are earlier in the path, and |
498 also picking 100dpi adobe fonts over 75dpi adobe fonts even though the | 496 also picking 100dpi adobe fonts over 75dpi adobe fonts even though the |
499 75dpi are in the path earlier) but sometimes appears to be doing something | 497 75dpi are in the path earlier) but sometimes appears to be doing something |
500 else entirely (for example, removing the bitsream fonts from the path will | 498 else entirely (for example, removing the bitsream fonts from the path will |
501 cause the 75dpi adobe fonts to be used instead of the100dpi, even though | 499 cause the 75dpi adobe fonts to be used instead of the 100dpi, even though |
502 their relative positions in the path (and their names!) have not changed). | 500 their relative positions in the path (and their names!) have not changed). |
503 | 501 |
504 The documentation for XSetFontPath() seems to indicate that the order of | 502 The documentation for XSetFontPath() seems to indicate that the order of |
505 entries in the font path means something, but it's pretty noncommital about | 503 entries in the font path means something, but it's pretty noncommital about |
506 it, and the spirit of the law is apparently not being obeyed... | 504 it, and the spirit of the law is apparently not being obeyed... |
507 | 505 |
508 All the fonts I've seen have a property named `FONT' which contains the | 506 All the fonts I've seen have a property named `FONT' which contains the |
509 truename of the font. However, there are two problems with using this: the | 507 truename of the font. However, there are two problems with using this: the |
510 first is that the X Protocol Document is quite explicit that all properties | 508 first is that the X Protocol Document is quite explicit that all properties |
511 are optional, so we can't depend on it being there. The second is that | 509 are optional, so we can't depend on it being there. The second is that |
512 it's concievable that this alleged truename isn't actually accessible as a | 510 it's conceivable that this alleged truename isn't actually accessible as a |
513 font, due to some difference of opinion between the font designers and | 511 font, due to some difference of opinion between the font designers and |
514 whoever installed the font on the system. | 512 whoever installed the font on the system. |
515 | 513 |
516 So, our first attempt is to look for a FONT property, and then verify that | 514 So, our first attempt is to look for a FONT property, and then verify that |
517 the name there is a valid name by running XListFonts on it. There's still | 515 the name there is a valid name by running XListFonts on it. There's still |
564 that the various servers are actually doing, please let me know! -- jwz. */ | 562 that the various servers are actually doing, please let me know! -- jwz. */ |
565 | 563 |
566 static int | 564 static int |
567 valid_x_font_name_p (Display *dpy, char *name) | 565 valid_x_font_name_p (Display *dpy, char *name) |
568 { | 566 { |
569 /* Maybe this should be implemented by callign XLoadFont and trapping | 567 /* Maybe this should be implemented by calling XLoadFont and trapping |
570 the error. That would be a lot of work, and wasteful as hell, but | 568 the error. That would be a lot of work, and wasteful as hell, but |
571 might be more correct. | 569 might be more correct. |
572 */ | 570 */ |
573 int nnames = 0; | 571 int nnames = 0; |
574 char **names = 0; | 572 char **names = 0; |
781 if (NILP (FONT_INSTANCE_X_TRUENAME (f))) | 779 if (NILP (FONT_INSTANCE_X_TRUENAME (f))) |
782 { | 780 { |
783 Lisp_Object font_instance; | 781 Lisp_Object font_instance; |
784 XSETFONT_INSTANCE (font_instance, f); | 782 XSETFONT_INSTANCE (font_instance, f); |
785 | 783 |
786 maybe_signal_simple_error ("couldn't determine font truename", | 784 maybe_signal_simple_error ("Couldn't determine font truename", |
787 font_instance, Qfont, errb); | 785 font_instance, Qfont, errb); |
788 /* Ok, just this once, return the font name as the truename. | 786 /* Ok, just this once, return the font name as the truename. |
789 (This is only used by Fequal() right now.) */ | 787 (This is only used by Fequal() right now.) */ |
790 return f->name; | 788 return f->name; |
791 } | 789 } |