Mercurial > hg > xemacs-beta
comparison src/objects-gtk.c @ 3659:98af8a976fc3
[xemacs-hg @ 2006-11-05 22:31:31 by aidan]
Support specifying fonts for particular character sets in Mule; support
translation to ISO 10646-1 for Mule character sets without an otherwise
matching font; move to a vector of X11-charset-X11-registry instead of a
regex for the charset-registry property.
author | aidan |
---|---|
date | Sun, 05 Nov 2006 22:31:46 +0000 |
parents | 5bfedec8927e |
children | 3ef0aaf3dc34 |
comparison
equal
deleted
inserted
replaced
3658:0db1aaedbbef | 3659:98af8a976fc3 |
---|---|
37 #include "console-gtk-impl.h" | 37 #include "console-gtk-impl.h" |
38 #include "objects-gtk-impl.h" | 38 #include "objects-gtk-impl.h" |
39 | 39 |
40 /* sigh */ | 40 /* sigh */ |
41 #include <gdk/gdkx.h> | 41 #include <gdk/gdkx.h> |
42 | |
43 /* XListFonts doesn't allocate memory unconditionally based on this. (For | |
44 XFree86 in 2005, at least. */ | |
45 #define MAX_FONT_COUNT INT_MAX | |
46 | |
47 #ifdef DEBUG_XEMACS | |
48 Fixnum debug_x_objects; | |
49 #endif /* DEBUG_XEMACS */ | |
42 | 50 |
43 | 51 |
44 /************************************************************************/ | 52 /************************************************************************/ |
45 /* color instances */ | 53 /* color instances */ |
46 /************************************************************************/ | 54 /************************************************************************/ |
377 TO_EXTERNAL_FORMAT (LISP_STRING, pattern, C_STRING_ALLOCA, patternext, Qbinary); | 385 TO_EXTERNAL_FORMAT (LISP_STRING, pattern, C_STRING_ALLOCA, patternext, Qbinary); |
378 | 386 |
379 return (__gtk_font_list_internal (patternext)); | 387 return (__gtk_font_list_internal (patternext)); |
380 } | 388 } |
381 | 389 |
382 #ifdef MULE | 390 /* Include the charset support, shared, for the moment, with X11. */ |
383 | 391 #define THIS_IS_GTK |
384 static int | 392 #include "objects-xlike-inc.c" |
385 gtk_font_spec_matches_charset (struct device *UNUSED (d), Lisp_Object charset, | |
386 const Ibyte *nonreloc, Lisp_Object reloc, | |
387 Bytecount offset, Bytecount length, | |
388 int stage) | |
389 { | |
390 if (stage) | |
391 return 0; | |
392 | |
393 if (UNBOUNDP (charset)) | |
394 return 1; | |
395 /* Hack! Short font names don't have the registry in them, | |
396 so we just assume the user knows what they're doing in the | |
397 case of ASCII. For other charsets, you gotta give the | |
398 long form; sorry buster. | |
399 */ | |
400 if (EQ (charset, Vcharset_ascii)) | |
401 { | |
402 const Ibyte *the_nonreloc = nonreloc; | |
403 int i; | |
404 Bytecount the_length = length; | |
405 | |
406 if (!the_nonreloc) | |
407 the_nonreloc = XSTRING_DATA (reloc); | |
408 fixup_internal_substring (nonreloc, reloc, offset, &the_length); | |
409 the_nonreloc += offset; | |
410 if (!memchr (the_nonreloc, '*', the_length)) | |
411 { | |
412 for (i = 0;; i++) | |
413 { | |
414 const Ibyte *new_nonreloc = (const Ibyte *) | |
415 memchr (the_nonreloc, '-', the_length); | |
416 if (!new_nonreloc) | |
417 break; | |
418 new_nonreloc++; | |
419 the_length -= new_nonreloc - the_nonreloc; | |
420 the_nonreloc = new_nonreloc; | |
421 } | |
422 | |
423 /* If it has less than 5 dashes, it's a short font. | |
424 Of course, long fonts always have 14 dashes or so, but short | |
425 fonts never have more than 1 or 2 dashes, so this is some | |
426 sort of reasonable heuristic. */ | |
427 if (i < 5) | |
428 return 1; | |
429 } | |
430 } | |
431 | |
432 return (fast_string_match (XCHARSET_REGISTRY (charset), | |
433 nonreloc, reloc, offset, length, 1, | |
434 ERROR_ME, 0) >= 0); | |
435 } | |
436 | |
437 /* find a font spec that matches font spec FONT and also matches | |
438 (the registry of) CHARSET. */ | |
439 static Lisp_Object gtk_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset, int stage); | |
440 | |
441 #endif /* MULE */ | |
442 | 393 |
443 | 394 |
444 /************************************************************************/ | 395 /************************************************************************/ |
445 /* initialization */ | 396 /* initialization */ |
446 /************************************************************************/ | 397 /************************************************************************/ |
477 } | 428 } |
478 | 429 |
479 void | 430 void |
480 vars_of_objects_gtk (void) | 431 vars_of_objects_gtk (void) |
481 { | 432 { |
482 } | 433 #ifdef DEBUG_XEMACS |
483 | 434 DEFVAR_INT ("debug-x-objects", &debug_x_objects /* |
484 /* #### BILL!!! Try to make this go away eventually */ | 435 If non-zero, display debug information about X objects |
485 /* X Specific stuff */ | 436 */ ); |
486 #include <X11/Xatom.h> | 437 debug_x_objects = 0; |
487 | 438 #endif |
488 #define MAX_FONT_COUNT INT_MAX | 439 } |
489 | |
490 #ifdef MULE | |
491 /* find a font spec that matches font spec FONT and also matches | |
492 (the registry of) CHARSET. */ | |
493 static Lisp_Object | |
494 gtk_find_charset_font (Lisp_Object device, Lisp_Object font, | |
495 Lisp_Object charset, int stage) | |
496 { | |
497 char **names; | |
498 int count = 0; | |
499 Lisp_Object result = Qnil; | |
500 const char *patternext; | |
501 int i; | |
502 | |
503 if (stage) | |
504 return Qnil; | |
505 | |
506 TO_EXTERNAL_FORMAT (LISP_STRING, font, C_STRING_ALLOCA, patternext, Qbinary); | |
507 | |
508 names = XListFonts (GDK_DISPLAY (), | |
509 patternext, MAX_FONT_COUNT, &count); | |
510 /* #### This code seems awfully bogus -- mrb */ | |
511 for (i = 0; i < count; i ++) | |
512 { | |
513 const Ibyte *intname; | |
514 Bytecount intlen; | |
515 | |
516 TO_INTERNAL_FORMAT (C_STRING, names[i], ALLOCA, (intname, intlen), | |
517 Qctext); | |
518 if (gtk_font_spec_matches_charset (XDEVICE (device), charset, | |
519 intname, Qnil, 0, -1, 0)) | |
520 { | |
521 result = make_string (intname, intlen); | |
522 break; | |
523 } | |
524 } | |
525 | |
526 if (names) | |
527 XFreeFontNames (names); | |
528 | |
529 /* Check for a short font name. */ | |
530 if (NILP (result) | |
531 && gtk_font_spec_matches_charset (XDEVICE (device), charset, 0, | |
532 font, 0, -1, 0)) | |
533 return font; | |
534 | |
535 return result; | |
536 } | |
537 #endif /* MULE */ | |
538 | 440 |
539 static int | 441 static int |
540 valid_font_name_p (Display *dpy, char *name) | 442 valid_font_name_p (Display *dpy, char *name) |
541 { | 443 { |
542 /* Maybe this should be implemented by callign XLoadFont and trapping | 444 /* Maybe this should be implemented by callign XLoadFont and trapping |