comparison src/objects-x.c @ 444:576fb035e263 r21-2-37

Import from CVS: tag r21-2-37
author cvs
date Mon, 13 Aug 2007 11:36:19 +0200
parents abe6d1db359e
children 183866b06e0b
comparison
equal deleted inserted replaced
443:a8296e22da4e 444:576fb035e263
282 static void 282 static void
283 x_print_color_instance (Lisp_Color_Instance *c, 283 x_print_color_instance (Lisp_Color_Instance *c,
284 Lisp_Object printcharfun, 284 Lisp_Object printcharfun,
285 int escapeflag) 285 int escapeflag)
286 { 286 {
287 Bufbyte buf[100]; 287 char buf[100];
288 XColor color = COLOR_INSTANCE_X_COLOR (c); 288 XColor color = COLOR_INSTANCE_X_COLOR (c);
289 sprintf (buf, " %ld=(%X,%X,%X)", 289 sprintf (buf, " %ld=(%X,%X,%X)",
290 color.pixel, color.red, color.green, color.blue); 290 color.pixel, color.red, color.green, color.blue);
291 write_c_string (buf, printcharfun); 291 write_c_string (buf, printcharfun);
292 } 292 }
464 static void 464 static void
465 x_print_font_instance (Lisp_Font_Instance *f, 465 x_print_font_instance (Lisp_Font_Instance *f,
466 Lisp_Object printcharfun, 466 Lisp_Object printcharfun,
467 int escapeflag) 467 int escapeflag)
468 { 468 {
469 Bufbyte buf[200]; 469 char buf[200];
470 sprintf (buf, " 0x%lx", (unsigned long) FONT_INSTANCE_X_FONT (f)->fid); 470 sprintf (buf, " 0x%lx", (unsigned long) FONT_INSTANCE_X_FONT (f)->fid);
471 write_c_string (buf, printcharfun); 471 write_c_string (buf, printcharfun);
472 } 472 }
473 473
474 static void 474 static void
575 /* Maybe this should be implemented by calling XLoadFont and trapping 575 /* Maybe this should be implemented by calling XLoadFont and trapping
576 the error. That would be a lot of work, and wasteful as hell, but 576 the error. That would be a lot of work, and wasteful as hell, but
577 might be more correct. 577 might be more correct.
578 */ 578 */
579 int nnames = 0; 579 int nnames = 0;
580 SExtbyte **names = 0; 580 Extbyte **names = 0;
581 if (! name) 581 if (! name)
582 return 0; 582 return 0;
583 names = XListFonts (dpy, name, 1, &nnames); 583 names = XListFonts (dpy, name, 1, &nnames);
584 if (names) 584 if (names)
585 XFreeFontNames (names); 585 XFreeFontNames (names);
685 685
686 static Extbyte * 686 static Extbyte *
687 truename_via_XListFonts (Display *dpy, Extbyte *font_name) 687 truename_via_XListFonts (Display *dpy, Extbyte *font_name)
688 { 688 {
689 Extbyte *result = 0; 689 Extbyte *result = 0;
690 SExtbyte **names; 690 Extbyte **names;
691 int count = 0; 691 int count = 0;
692 692
693 #ifndef XOPENFONT_SORTS 693 #ifndef XOPENFONT_SORTS
694 /* In a sensible world, the first font returned by XListFonts() 694 /* In a sensible world, the first font returned by XListFonts()
695 would be the font that XOpenFont() would use. */ 695 would be the font that XOpenFont() would use. */
797 /* Ok, just this once, return the font name as the truename. 797 /* Ok, just this once, return the font name as the truename.
798 (This is only used by Fequal() right now.) */ 798 (This is only used by Fequal() right now.) */
799 return f->name; 799 return f->name;
800 } 800 }
801 } 801 }
802 return (FONT_INSTANCE_X_TRUENAME (f)); 802 return FONT_INSTANCE_X_TRUENAME (f);
803 } 803 }
804 804
805 static Lisp_Object 805 static Lisp_Object
806 x_font_instance_properties (Lisp_Font_Instance *f) 806 x_font_instance_properties (Lisp_Font_Instance *f)
807 { 807 {
808 struct device *d = XDEVICE (f->device); 808 struct device *d = XDEVICE (f->device);
809 int i; 809 int i;
810 Lisp_Object result = Qnil; 810 Lisp_Object result = Qnil;
811 XFontProp *props; 811 Display *dpy = DEVICE_X_DISPLAY (d);
812 Display *dpy; 812 XFontProp *props = FONT_INSTANCE_X_FONT (f)->properties;
813 813
814 dpy = DEVICE_X_DISPLAY (d);
815 props = FONT_INSTANCE_X_FONT (f)->properties;
816 for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--) 814 for (i = FONT_INSTANCE_X_FONT (f)->n_properties - 1; i >= 0; i--)
817 { 815 {
818 Lisp_Object name, value; 816 Lisp_Object name, value;
819 Atom atom = props [i].name; 817 Atom atom = props [i].name;
820 Bufbyte *name_str = 0; 818 Bufbyte *name_str = 0;
819 size_t name_len;
821 Extbyte *namestrext = XGetAtomName (dpy, atom); 820 Extbyte *namestrext = XGetAtomName (dpy, atom);
822 821
823 if (namestrext) 822 if (namestrext)
824 EXTERNAL_TO_C_STRING (namestrext, name_str, Qx_atom_name_encoding); 823 TO_INTERNAL_FORMAT (C_STRING, namestrext,
825 824 ALLOCA, (name_str, name_len),
826 name = (name_str ? intern (name_str) : Qnil); 825 Qx_atom_name_encoding);
826
827 name = (name_str ? intern ((char *) name_str) : Qnil);
827 if (name_str && 828 if (name_str &&
828 (atom == XA_FONT || 829 (atom == XA_FONT ||
829 atom == DEVICE_XATOM_FOUNDRY (d) || 830 atom == DEVICE_XATOM_FOUNDRY (d) ||
830 atom == DEVICE_XATOM_FAMILY_NAME (d) || 831 atom == DEVICE_XATOM_FAMILY_NAME (d) ||
831 atom == DEVICE_XATOM_WEIGHT_NAME (d) || 832 atom == DEVICE_XATOM_WEIGHT_NAME (d) ||
833 atom == DEVICE_XATOM_SETWIDTH_NAME (d) || 834 atom == DEVICE_XATOM_SETWIDTH_NAME (d) ||
834 atom == DEVICE_XATOM_ADD_STYLE_NAME (d) || 835 atom == DEVICE_XATOM_ADD_STYLE_NAME (d) ||
835 atom == DEVICE_XATOM_SPACING (d) || 836 atom == DEVICE_XATOM_SPACING (d) ||
836 atom == DEVICE_XATOM_CHARSET_REGISTRY (d) || 837 atom == DEVICE_XATOM_CHARSET_REGISTRY (d) ||
837 atom == DEVICE_XATOM_CHARSET_ENCODING (d) || 838 atom == DEVICE_XATOM_CHARSET_ENCODING (d) ||
838 !strcmp (name_str, "CHARSET_COLLECTIONS") || 839 !bufbyte_strcmp (name_str, "CHARSET_COLLECTIONS") ||
839 !strcmp (name_str, "FONTNAME_REGISTRY") || 840 !bufbyte_strcmp (name_str, "FONTNAME_REGISTRY") ||
840 !strcmp (name_str, "CLASSIFICATION") || 841 !bufbyte_strcmp (name_str, "CLASSIFICATION") ||
841 !strcmp (name_str, "COPYRIGHT") || 842 !bufbyte_strcmp (name_str, "COPYRIGHT") ||
842 !strcmp (name_str, "DEVICE_FONT_NAME") || 843 !bufbyte_strcmp (name_str, "DEVICE_FONT_NAME") ||
843 !strcmp (name_str, "FULL_NAME") || 844 !bufbyte_strcmp (name_str, "FULL_NAME") ||
844 !strcmp (name_str, "MONOSPACED") || 845 !bufbyte_strcmp (name_str, "MONOSPACED") ||
845 !strcmp (name_str, "QUALITY") || 846 !bufbyte_strcmp (name_str, "QUALITY") ||
846 !strcmp (name_str, "RELATIVE_SET") || 847 !bufbyte_strcmp (name_str, "RELATIVE_SET") ||
847 !strcmp (name_str, "RELATIVE_WEIGHT") || 848 !bufbyte_strcmp (name_str, "RELATIVE_WEIGHT") ||
848 !strcmp (name_str, "STYLE"))) 849 !bufbyte_strcmp (name_str, "STYLE")))
849 { 850 {
850 Extbyte *val_str = XGetAtomName (dpy, props [i].card32); 851 Extbyte *val_str = XGetAtomName (dpy, props [i].card32);
851 852
852 value = (val_str ? build_ext_string (val_str, Qx_atom_name_encoding) 853 value = (val_str ? build_ext_string (val_str, Qx_atom_name_encoding)
853 : Qnil); 854 : Qnil);
861 } 862 }
862 863
863 static Lisp_Object 864 static Lisp_Object
864 x_list_fonts (Lisp_Object pattern, Lisp_Object device) 865 x_list_fonts (Lisp_Object pattern, Lisp_Object device)
865 { 866 {
866 SExtbyte **names; 867 Extbyte **names;
867 int count = 0; 868 int count = 0;
868 Lisp_Object result = Qnil; 869 Lisp_Object result = Qnil;
869 const Extbyte *patternext; 870 const Extbyte *patternext;
870 871
871 LISP_STRING_TO_EXTERNAL (pattern, patternext, Qx_font_name_encoding); 872 LISP_STRING_TO_EXTERNAL (pattern, patternext, Qx_font_name_encoding);
934 /* find a font spec that matches font spec FONT and also matches 935 /* find a font spec that matches font spec FONT and also matches
935 (the registry of) CHARSET. */ 936 (the registry of) CHARSET. */
936 static Lisp_Object 937 static Lisp_Object
937 x_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset) 938 x_find_charset_font (Lisp_Object device, Lisp_Object font, Lisp_Object charset)
938 { 939 {
939 SExtbyte **names; 940 Extbyte **names;
940 int count = 0; 941 int count = 0;
941 Lisp_Object result = Qnil; 942 Lisp_Object result = Qnil;
942 const Extbyte *patternext; 943 const Extbyte *patternext;
943 int i; 944 int i;
944 945
948 patternext, MAX_FONT_COUNT, &count); 949 patternext, MAX_FONT_COUNT, &count);
949 /* #### This code seems awfully bogus -- mrb */ 950 /* #### This code seems awfully bogus -- mrb */
950 for (i = 0; i < count; i ++) 951 for (i = 0; i < count; i ++)
951 { 952 {
952 const Bufbyte *intname; 953 const Bufbyte *intname;
953 954 Bytecount intlen;
954 EXTERNAL_TO_C_STRING (names[i], intname, Qx_font_name_encoding); 955
956 TO_INTERNAL_FORMAT (C_STRING, names[i],
957 ALLOCA, (intname, intlen),
958 Qx_font_name_encoding);
955 if (x_font_spec_matches_charset (XDEVICE (device), charset, 959 if (x_font_spec_matches_charset (XDEVICE (device), charset,
956 intname, Qnil, 0, -1)) 960 intname, Qnil, 0, -1))
957 { 961 {
958 result = build_string (intname); 962 result = make_string (intname, intlen);
959 break; 963 break;
960 } 964 }
961 } 965 }
962 966
963 if (names) 967 if (names)