comparison src/fontcolor-xlike-inc.c @ 5189:b65692aa90d8

Cosmetic XFT-code fixes, some variable renamings -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-04-04 Ben Wing <ben@xemacs.org> * font-mgr.c: * font-mgr.c (fc_standard_properties): * font-mgr.c (Ffc_pattern_p): * font-mgr.c (Ffc_pattern_create): * font-mgr.c (Ffc_name_parse): * font-mgr.c (Ffc_name_unparse): * font-mgr.c (Ffc_pattern_duplicate): * font-mgr.c (Ffc_pattern_add): * font-mgr.c (Ffc_pattern_del): * font-mgr.c (Ffc_pattern_get): * font-mgr.c (fc_config_create_using): * font-mgr.c (fc_strlist_to_lisp_using): * font-mgr.c (fontset_to_list): * font-mgr.c (Ffc_config_p): * font-mgr.c (Ffc_config_create): * font-mgr.c (Ffc_config_destroy): * font-mgr.c (Ffc_config_up_to_date): * font-mgr.c (Ffc_config_build_fonts): * font-mgr.c (Ffc_config_get_config_dirs): * font-mgr.c (Ffc_config_get_font_dirs): * font-mgr.c (Ffc_config_get_config_files): * font-mgr.c (Ffc_config_get_cache): * font-mgr.c (Ffc_config_get_fonts): * font-mgr.c (Ffc_config_set_current): * font-mgr.c (Ffc_config_get_blanks): * font-mgr.c (Ffc_config_get_rescan_interval): * font-mgr.c (Ffc_config_set_rescan_interval): * font-mgr.c (Ffc_config_app_font_add_file): * font-mgr.c (Ffc_config_app_font_add_dir): * font-mgr.c (Ffc_config_app_font_clear): * font-mgr.c (Ffc_init_load_config): * font-mgr.c (Ffc_init_load_config_and_fonts): * font-mgr.c (Ffc_config_get_current): * font-mgr.c (size): * font-mgr.c (Ffc_font_render_prepare): * font-mgr.c (Ffc_font_match): * font-mgr.c (Ffc_font_sort): * font-mgr.c (Ffc_init): * font-mgr.c (Ffc_get_version): * font-mgr.c (Ffc_init_reinitialize): * font-mgr.c (Ffc_init_bring_up_to_date): * font-mgr.c (Fxlfd_font_name_p): * font-mgr.c (make_xlfd_font_regexp): * font-mgr.c (syms_of_font_mgr): * font-mgr.c (vars_of_font_mgr): * font-mgr.c (complex_vars_of_font_mgr): Fix the code to conform to GNU style standards. Rename xft-debug-level to debug-xft. * fontcolor-x.c: * fontcolor-x.c (vars_of_fontcolor_x): Rename debug-x-objects to debug-x-fonts. * fontcolor-xlike-inc.c: * fontcolor-xlike-inc.c (DEBUG_FONTS1): * fontcolor-xlike-inc.c (DEBUG_FONTS2): * fontcolor-xlike-inc.c (DEBUG_FONTS3): * fontcolor-xlike-inc.c (DEBUG_FONTS4): * fontcolor-xlike-inc.c (DEBUG_FONTS_LISP1): * fontcolor-xlike-inc.c (count_hyphens): * fontcolor-xlike-inc.c (XFUN): * fontcolor-xlike-inc.c (xlistfonts_checking_charset): * fontcolor-xlike-inc.c (xft_find_charset_font): Misc. code fixes, mostly cosmetic. Get rid of some warnings. Fix the code to conform to GNU style standards. * lisp.h: * print.c: * print.c (debug_out_lisp): New function for doing printf-like formatting involving Lisp objects and outputting to the debug output.
author Ben Wing <ben@xemacs.org>
date Sun, 04 Apr 2010 23:46:50 -0500
parents 8b2f75cecb89
children c87ec061e8cc
comparison
equal deleted inserted replaced
5181:a00bfbd64e0a 5189:b65692aa90d8
32 people should be using that. Oh well. (Aidan Kehoe, Sat Nov 4 12:41:12 32 people should be using that. Oh well. (Aidan Kehoe, Sat Nov 4 12:41:12
33 CET 2006) */ 33 CET 2006) */
34 34
35 #include "console-xlike-inc.h" 35 #include "console-xlike-inc.h"
36 36
37 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) 37 #define DEBUG_FONTS1(format, arg) \
38 38 do { \
39 #ifdef DEBUG_XEMACS 39 if (debug_x_fonts) \
40 # define DEBUG_OBJECTS(FORMAT, ...) \ 40 debug_out (format, arg); \
41 do { if (debug_x_objects) stderr_out(FORMAT, __VA_ARGS__); } while (0) 41 } while (0)
42 #else /* DEBUG_XEMACS */ 42
43 # define DEBUG_OBJECTS(format, ...) 43 #define DEBUG_FONTS2(format, arg1, arg2) \
44 #endif /* DEBUG_XEMACS */ 44 do { \
45 45 if (debug_x_fonts) \
46 #elif defined(__GNUC__) 46 debug_out (format, arg1, arg2); \
47 47 } while (0)
48 #ifdef DEBUG_XEMACS 48
49 # define DEBUG_OBJECTS(format, args...) \ 49 #define DEBUG_FONTS3(format, arg1, arg2, arg3) \
50 do { if (debug_x_objects) stderr_out(format, args ); } while (0) 50 do { \
51 #else /* DEBUG_XEMACS */ 51 if (debug_x_fonts) \
52 # define DEBUG_OBJECTS(format, args...) 52 debug_out (format, arg1, arg2, arg3); \
53 #endif /* DEBUG_XEMACS */ 53 } while (0)
54 54
55 #else /* defined(__STDC_VERSION__) [...] */ 55 #define DEBUG_FONTS4(format, arg1, arg2, arg3, arg4) \
56 # define DEBUG_OBJECTS (void) 56 do { \
57 #endif 57 if (debug_x_fonts) \
58 debug_out (format, arg1, arg2, arg3, arg4); \
59 } while (0)
60
61 #define DEBUG_FONTS_LISP1(format, arg) \
62 do { \
63 if (debug_x_fonts) \
64 debug_out_lisp (format, 1, arg); \
65 } while (0)
66
67 #define DEBUG_FONTS_LISP2(format, arg1, arg2) \
68 do { \
69 if (debug_x_fonts) \
70 debug_out_lisp (format, 2, arg1, arg2); \
71 } while (0)
72
73 #define DEBUG_FONTS_LISP3(format, arg1, arg2, arg3) \
74 do { \
75 if (debug_x_fonts) \
76 debug_out_lisp (format, 3, arg1, arg2, arg3); \
77 } while (0)
78
79 #define DEBUG_FONTS_LISP4(format, arg1, arg2, arg3, arg4) \
80 do { \
81 if (debug_x_fonts) \
82 debug_out_lisp (format, 4, arg1, arg2, arg3, arg4); \
83 } while (0)
58 84
59 #ifdef MULE 85 #ifdef MULE
60 86
61 /* For some code it's reasonable to have only one copy and conditionalize 87 /* For some code it's reasonable to have only one copy and conditionalize
62 at run-time. For other code it isn't. */ 88 at run-time. For other code it isn't. */
63 89
64 static int 90 static int
65 count_hyphens(const Ibyte *str, Bytecount length, Ibyte **last_hyphen) 91 count_hyphens (const Ibyte *str, Bytecount length, Ibyte **last_hyphen)
66 { 92 {
67 int hyphen_count = 0; 93 int hyphen_count = 0;
68 const Ibyte *hyphening = str; 94 const Ibyte *hyphening = str;
69 const Ibyte *new_hyphening; 95 const Ibyte *new_hyphening;
70 96
71 for (hyphen_count = 0; 97 for (hyphen_count = 0;
72 NULL != (new_hyphening = (Ibyte *) memchr((const void *)hyphening, '-', length)); 98 NULL != (new_hyphening = (Ibyte *) memchr ((const void *)hyphening, '-', length));
73 hyphen_count++) 99 hyphen_count++)
74 { 100 {
75 ++new_hyphening; 101 ++new_hyphening;
76 length -= new_hyphening - hyphening; 102 length -= new_hyphening - hyphening;
77 hyphening = new_hyphening; 103 hyphening = new_hyphening;
109 if (stage == STAGE_FINAL) 135 if (stage == STAGE_FINAL)
110 { 136 {
111 Display *dpy = DEVICE_X_DISPLAY (d); 137 Display *dpy = DEVICE_X_DISPLAY (d);
112 Extbyte *extname; 138 Extbyte *extname;
113 XftFont *rf; 139 XftFont *rf;
114 const Ibyte *the_nonreloc; 140
115 141 if (!NILP (reloc))
116 if (!NILP(reloc))
117 { 142 {
118 the_nonreloc = XSTRING_DATA (reloc); 143 the_nonreloc = XSTRING_DATA (reloc);
119 extname = LISP_STRING_TO_EXTERNAL (reloc, Qx_font_name_encoding); 144 extname = LISP_STRING_TO_EXTERNAL (reloc, Qx_font_name_encoding);
120 rf = xft_open_font_by_name (dpy, extname); 145 rf = xft_open_font_by_name (dpy, extname);
121 return 0; /* #### maybe this will compile and run ;) */ 146 return 0; /* #### maybe this will compile and run ;) */
139 between faces and fonts? No - it looks like that would be an abuse 164 between faces and fonts? No - it looks like that would be an abuse
140 (fontconfig doesn't know about colors, although Xft does). 165 (fontconfig doesn't know about colors, although Xft does).
141 */ 166 */
142 if (EQ (charset, Vcharset_ascii) && 167 if (EQ (charset, Vcharset_ascii) &&
143 (!memchr (the_nonreloc, '*', the_length)) 168 (!memchr (the_nonreloc, '*', the_length))
144 && (5 > (count_hyphens(the_nonreloc, the_length, NULL)))) 169 && (5 > (count_hyphens (the_nonreloc, the_length, NULL))))
145 { 170 {
146 return 1; 171 return 1;
147 } 172 }
148 173
149 if (STAGE_FINAL == stage) 174 if (STAGE_FINAL == stage)
151 registries = Qunicode_registries; 176 registries = Qunicode_registries;
152 } 177 }
153 else if (STAGE_INITIAL == stage) 178 else if (STAGE_INITIAL == stage)
154 { 179 {
155 registries = XCHARSET_REGISTRIES (charset); 180 registries = XCHARSET_REGISTRIES (charset);
156 if (NILP(registries)) 181 if (NILP (registries))
157 { 182 {
158 return 0; 183 return 0;
159 } 184 }
160 } 185 }
161 else assert(0); 186 else assert (0);
162 187
163 CHECK_VECTOR (registries); 188 CHECK_VECTOR (registries);
164 registries_len = XVECTOR_LENGTH(registries); 189 registries_len = XVECTOR_LENGTH (registries);
165 190
166 for (i = 0; i < registries_len; ++i) 191 for (i = 0; i < registries_len; ++i)
167 { 192 {
168 if (!(STRINGP(XVECTOR_DATA(registries)[i])) 193 if (!(STRINGP (XVECTOR_DATA (registries)[i]))
169 || (XSTRING_LENGTH(XVECTOR_DATA(registries)[i]) > the_length)) 194 || (XSTRING_LENGTH (XVECTOR_DATA (registries)[i]) > the_length))
170 { 195 {
171 continue; 196 continue;
172 } 197 }
173 198
174 /* Check if the font spec ends in the registry specified. X11 says 199 /* Check if the font spec ends in the registry specified. X11 says
175 this comparison is case insensitive: XLFD, section 3.11: 200 this comparison is case insensitive: XLFD, section 3.11:
176 201
177 "Alphabetic case distinctions are allowed but are for human 202 "Alphabetic case distinctions are allowed but are for human
178 readability concerns only. Conforming X servers will perform 203 readability concerns only. Conforming X servers will perform
179 matching on font name query or open requests independent of case." */ 204 matching on font name query or open requests independent of case." */
180 if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[i]), 205 if (0 == qxestrcasecmp (XSTRING_DATA (XVECTOR_DATA (registries)[i]),
181 the_nonreloc + (the_length - 206 the_nonreloc + (the_length -
182 XSTRING_LENGTH 207 XSTRING_LENGTH
183 (XVECTOR_DATA(registries)[i])))) 208 (XVECTOR_DATA (registries)[i]))))
184 { 209 {
185 return 1; 210 return 1;
186 } 211 }
187 } 212 }
188 return 0; 213 return 0;
189 } 214 }
190 215
191 static Lisp_Object 216 static Lisp_Object
192 xlistfonts_checking_charset (Lisp_Object device, const Extbyte *xlfd, 217 xlistfonts_checking_charset (Lisp_Object device, const Ibyte *xlfd,
193 Lisp_Object charset, 218 Lisp_Object charset,
194 enum font_specifier_matchspec_stages stage) 219 enum font_specifier_matchspec_stages stage)
195 { 220 {
196 Extbyte **names; 221 Extbyte **names;
197 Lisp_Object result = Qnil; 222 Lisp_Object result = Qnil;
198 int count = 0, i; 223 int count = 0, i;
199 DECLARE_EISTRING(ei_single_result); 224 DECLARE_EISTRING (ei_single_result);
200 225 Extbyte *fontext;
226
227 DEBUG_FONTS2 ("xlistfonts_checking_charset called, XLFD %s stage %s",
228 xlfd, stage == STAGE_INITIAL ? "initial" : "final");
229 DEBUG_FONTS_LISP1 (" charset %s\n", charset);
230 fontext = ITEXT_TO_EXTERNAL (xlfd, Qx_font_name_encoding);
201 names = XListFonts (GET_XLIKE_DISPLAY (XDEVICE (device)), 231 names = XListFonts (GET_XLIKE_DISPLAY (XDEVICE (device)),
202 xlfd, MAX_FONT_COUNT, &count); 232 fontext, MAX_FONT_COUNT, &count);
203 233
204 for (i = 0; i < count; ++i) 234 for (i = 0; i < count; ++i)
205 { 235 {
206 eireset(ei_single_result); 236 eireset (ei_single_result);
207 eicpy_ext(ei_single_result, names[i], Qx_font_name_encoding); 237 eicpy_ext (ei_single_result, names[i], Qx_font_name_encoding);
208 238
209 if (DEVMETH_OR_GIVEN(XDEVICE (device), font_spec_matches_charset, 239 if (DEVMETH_OR_GIVEN (XDEVICE (device), font_spec_matches_charset,
210 (XDEVICE (device), charset, 240 (XDEVICE (device), charset,
211 eidata(ei_single_result), Qnil, 0, 241 eidata (ei_single_result), Qnil, 0,
212 -1, stage), 0)) 242 -1, stage), 0))
213 { 243 {
214 result = eimake_string(ei_single_result); 244 result = eimake_string (ei_single_result);
215 DEBUG_OBJECTS ("in xlistfonts_checking_charset, returning %s\n",
216 eidata(ei_single_result));
217 break; 245 break;
218 } 246 }
219 } 247 }
220 248
221 if (names) 249 if (names)
222 { 250 {
223 XFreeFontNames (names); 251 XFreeFontNames (names);
224 } 252 }
225 253
254 DEBUG_FONTS_LISP1 ("xlistfonts_checking_charset returns %s\n", result);
226 return result; 255 return result;
227 } 256 }
228 257
229 #ifdef USE_XFT 258 #ifdef USE_XFT
230 /* #### debug functions: find a better place for us */ 259 /* #### debug functions: find a better place for us */
395 /* Fontconfig converts all FreeType names to UTF-8 before passing them 424 /* Fontconfig converts all FreeType names to UTF-8 before passing them
396 back to callers---see fcfreetype.c (FcFreeTypeQuery). 425 back to callers---see fcfreetype.c (FcFreeTypeQuery).
397 I don't believe this is documented. */ 426 I don't believe this is documented. */
398 427
399 DEBUG_XFT1 (1, "confirming charset for font instance %s\n", 428 DEBUG_XFT1 (1, "confirming charset for font instance %s\n",
400 XSTRING_DATA(font)); 429 XSTRING_DATA (font));
401 430
402 /* #### this looks like a fair amount of work, but the basic design 431 /* #### this looks like a fair amount of work, but the basic design
403 has never been rethought, and it should be 432 has never been rethought, and it should be
404 433
405 what really should happen here is that we use FcFontSort (FcFontList?) 434 what really should happen here is that we use FcFontSort (FcFontList?)
533 ; 562 ;
534 563
535 if (cr->rfc3066) 564 if (cr->rfc3066)
536 { 565 {
537 DECLARE_DEBUG_FONTNAME (name); 566 DECLARE_DEBUG_FONTNAME (name);
538 CHECKING_LANG (0, eidata(name), cr->language); 567 CHECKING_LANG (0, eidata (name), cr->language);
539 lang = cr->rfc3066; 568 lang = cr->rfc3066;
540 } 569 }
541 else if (cr->charset) 570 else if (cr->charset)
542 { 571 {
543 /* what the hey, build 'em on the fly */ 572 /* what the hey, build 'em on the fly */
579 should have the full thing internally as truename, and 608 should have the full thing internally as truename, and
580 filter stuff the client doesn't want to see on output. 609 filter stuff the client doesn't want to see on output.
581 Should we just store it into the truename right here? */ 610 Should we just store it into the truename right here? */
582 DECLARE_DEBUG_FONTNAME (name); 611 DECLARE_DEBUG_FONTNAME (name);
583 DEBUG_XFT2 (0, "Xft font %s supports %s\n", 612 DEBUG_XFT2 (0, "Xft font %s supports %s\n",
584 eidata(name), lang); 613 eidata (name), lang);
585 #ifdef RETURN_LONG_FONTCONFIG_NAMES 614 #ifdef RETURN_LONG_FONTCONFIG_NAMES
586 result = eimake_string(eistr_fullname); 615 result = eimake_string (eistr_fullname);
587 #else 616 #else
588 result = eimake_string(eistr_longname); 617 result = eimake_string (eistr_longname);
589 #endif 618 #endif
590 } 619 }
591 else 620 else
592 { 621 {
593 DECLARE_DEBUG_FONTNAME (name); 622 DECLARE_DEBUG_FONTNAME (name);
594 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", 623 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
595 eidata(name), lang); 624 eidata (name), lang);
596 result = Qnil; 625 result = Qnil;
597 } 626 }
598 627
599 /* clean up */ 628 /* clean up */
600 FcCharSetDestroy (fccs); 629 FcCharSetDestroy (fccs);
609 638
610 if (r == FcResultMatch) 639 if (r == FcResultMatch)
611 { 640 {
612 if (v.type != FcTypeLangSet) /* excessive paranoia */ 641 if (v.type != FcTypeLangSet) /* excessive paranoia */
613 { 642 {
614 ASSERT_ASCTEXT_ASCII(FcTypeOfValueToString(v)); 643 ASSERT_ASCTEXT_ASCII (FcTypeOfValueToString (v));
615 /* Urk! Fall back and punt to core font. */ 644 /* Urk! Fall back and punt to core font. */
616 DEBUG_XFT1 (0, "Unexpected type of lang value (%s)\n", 645 DEBUG_XFT1 (0, "Unexpected type of lang value (%s)\n",
617 FcTypeOfValueToString (v)); 646 FcTypeOfValueToString (v));
618 result = Qnil; 647 result = Qnil;
619 } 648 }
620 else if (FcLangSetHasLang (v.u.l, (FcChar8 *) lang) 649 else if (FcLangSetHasLang (v.u.l, (FcChar8 *) lang)
621 != FcLangDifferentLang) 650 != FcLangDifferentLang)
622 { 651 {
623 DECLARE_DEBUG_FONTNAME (name); 652 DECLARE_DEBUG_FONTNAME (name);
624 DEBUG_XFT2 (0, "Xft font %s supports %s\n", 653 DEBUG_XFT2 (0, "Xft font %s supports %s\n",
625 eidata(name), lang); 654 eidata (name), lang);
626 #ifdef RETURN_LONG_FONTCONFIG_NAMES 655 #ifdef RETURN_LONG_FONTCONFIG_NAMES
627 result = eimake_string(eistr_fullname); 656 result = eimake_string (eistr_fullname);
628 #else 657 #else
629 result = eimake_string(eistr_longname); 658 result = eimake_string (eistr_longname);
630 #endif 659 #endif
631 } 660 }
632 else 661 else
633 { 662 {
634 DECLARE_DEBUG_FONTNAME (name); 663 DECLARE_DEBUG_FONTNAME (name);
635 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", 664 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
636 eidata(name), lang); 665 eidata (name), lang);
637 result = Qnil; 666 result = Qnil;
638 } 667 }
639 } 668 }
640 else 669 else
641 { 670 {
642 ASSERT_ASCTEXT_ASCII(FcResultToString(r)); 671 ASSERT_ASCTEXT_ASCII (FcResultToString (r));
643 DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n", 672 DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n",
644 FcResultToString (r)); 673 FcResultToString (r));
645 result = Qnil; 674 result = Qnil;
646 } 675 }
647 } 676 }
668 Lisp_Object result = Qnil, registries = Qnil; 697 Lisp_Object result = Qnil, registries = Qnil;
669 int j, hyphen_count, registries_len = 0; 698 int j, hyphen_count, registries_len = 0;
670 Ibyte *hyphening, *new_hyphening; 699 Ibyte *hyphening, *new_hyphening;
671 Bytecount xlfd_length; 700 Bytecount xlfd_length;
672 701
673 DECLARE_EISTRING(ei_xlfd_without_registry); 702 DECLARE_EISTRING (ei_xlfd_without_registry);
674 DECLARE_EISTRING(ei_xlfd); 703 DECLARE_EISTRING (ei_xlfd);
675 704
676 #ifdef USE_XFT 705 #ifdef USE_XFT
677 result = xft_find_charset_font(font, charset, stage); 706 result = xft_find_charset_font (font, charset, stage);
678 if (!NILP(result)) 707 if (!NILP (result))
679 { 708 {
680 return result; 709 return result;
681 } 710 }
682 #endif 711 #endif
683 712
684 switch (stage) 713 switch (stage)
685 { 714 {
686 case STAGE_INITIAL: 715 case STAGE_INITIAL:
687 { 716 {
688 if (!(NILP(XCHARSET_REGISTRIES(charset))) 717 if (!(NILP (XCHARSET_REGISTRIES (charset)))
689 && VECTORP(XCHARSET_REGISTRIES(charset))) 718 && VECTORP (XCHARSET_REGISTRIES (charset)))
690 { 719 {
691 registries_len = XVECTOR_LENGTH(XCHARSET_REGISTRIES(charset)); 720 registries_len = XVECTOR_LENGTH (XCHARSET_REGISTRIES (charset));
692 registries = XCHARSET_REGISTRIES(charset); 721 registries = XCHARSET_REGISTRIES (charset);
693 } 722 }
694 break; 723 break;
695 } 724 }
696 case STAGE_FINAL: 725 case STAGE_FINAL:
697 { 726 {
699 registries = Qunicode_registries; 728 registries = Qunicode_registries;
700 break; 729 break;
701 } 730 }
702 default: 731 default:
703 { 732 {
704 assert(0); 733 assert (0);
705 break; 734 break;
706 } 735 }
707 } 736 }
708 737
709 eicpy_lstr(ei_xlfd, font); 738 eicpy_lstr (ei_xlfd, font);
710 hyphening = eidata(ei_xlfd); 739 hyphening = eidata (ei_xlfd);
711 xlfd_length = eilen(ei_xlfd); 740 xlfd_length = eilen (ei_xlfd);
712 741
713 /* Count the hyphens in the string, moving new_hyphening to just after the 742 /* Count the hyphens in the string, moving new_hyphening to just after the
714 last one. */ 743 last one. */
715 hyphen_count = count_hyphens(hyphening, xlfd_length, &new_hyphening); 744 hyphen_count = count_hyphens (hyphening, xlfd_length, &new_hyphening);
716 745
717 if (0 == registries_len || (5 > hyphen_count && 746 if (0 == registries_len || (5 > hyphen_count &&
718 !(1 == xlfd_length && '*' == *hyphening))) 747 !(1 == xlfd_length && '*' == *hyphening)))
719 { 748 {
720 /* No proper XLFD specified, or we can't modify the pattern to change 749 /* No proper XLFD specified, or we can't modify the pattern to change
721 the registry and encoding to match what we want, or we have no 750 the registry and encoding to match what we want, or we have no
722 information on the registry needed. */ 751 information on the registry needed. */
723 eito_external(ei_xlfd, Qx_font_name_encoding); 752 result = xlistfonts_checking_charset (device, eidata (ei_xlfd),
724 DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n",
725 eidata(ei_xlfd));
726 result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd),
727 charset, stage); 753 charset, stage);
728 /* No need to loop through the available registries; return 754 /* No need to loop through the available registries; return
729 immediately. */ 755 immediately. */
730 return result; 756 return result;
731 } 757 }
732 else if (1 == xlfd_length && '*' == *hyphening) 758 else if (1 == xlfd_length && '*' == *hyphening)
733 { 759 {
734 /* It's a single asterisk. We can add the registry directly to the 760 /* It's a single asterisk. We can add the registry directly to the
735 end. */ 761 end. */
736 eicpy_ch(ei_xlfd_without_registry, '*'); 762 eicpy_ch (ei_xlfd_without_registry, '*');
737 } 763 }
738 else 764 else
739 { 765 {
740 /* It's a fully-specified XLFD. Work out where the registry and 766 /* It's a fully-specified XLFD. Work out where the registry and
741 encoding are, and initialise ei_xlfd_without_registry to the string 767 encoding are, and initialise ei_xlfd_without_registry to the string
747 for (new_hyphening -= 2; new_hyphening > hyphening 773 for (new_hyphening -= 2; new_hyphening > hyphening
748 && '-' != *new_hyphening; --new_hyphening) 774 && '-' != *new_hyphening; --new_hyphening)
749 ; 775 ;
750 ++new_hyphening; 776 ++new_hyphening;
751 777
752 eicpy_ei(ei_xlfd_without_registry, ei_xlfd); 778 eicpy_ei (ei_xlfd_without_registry, ei_xlfd);
753 779
754 /* Manipulate ei_xlfd_without_registry, using the information about 780 /* Manipulate ei_xlfd_without_registry, using the information about
755 ei_xlfd, to which it's identical. */ 781 ei_xlfd, to which it's identical. */
756 eidel(ei_xlfd_without_registry, new_hyphening - hyphening, -1, 782 eidel (ei_xlfd_without_registry, new_hyphening - hyphening, -1,
757 eilen(ei_xlfd) - (new_hyphening - hyphening), -1); 783 eilen (ei_xlfd) - (new_hyphening - hyphening), -1);
758 784
759 } 785 }
760 786
761 /* Now, loop through the registries and encodings defined for this 787 /* Now, loop through the registries and encodings defined for this
762 charset, doing an XListFonts each time with the pattern modified to 788 charset, doing an XListFonts each time with the pattern modified to
763 specify the regisry and encoding. This avoids huge amounts of IPC and 789 specify the regisry and encoding. This avoids huge amounts of IPC and
764 duplicated searching; now we use the searching the X server was doing 790 duplicated searching; now we use the searching the X server was doing
765 anyway, where before the X server did its search, transferred huge 791 anyway, where before the X server did its search, transferred huge
766 amounts of data, and then we proceeded to do a regexp search on that 792 amounts of data, and then we proceeded to do a regexp search on that
767 data. */ 793 data. */
768 for (j = 0; j < registries_len && NILP(result); ++j) 794 for (j = 0; j < registries_len && NILP (result); ++j)
769 { 795 {
770 eireset(ei_xlfd); 796 eireset (ei_xlfd);
771 eicpy_ei(ei_xlfd, ei_xlfd_without_registry); 797 eicpy_ei (ei_xlfd, ei_xlfd_without_registry);
772 798
773 eicat_lstr(ei_xlfd, XVECTOR_DATA(registries)[j]); 799 eicat_lstr (ei_xlfd, XVECTOR_DATA (registries)[j]);
774 800
775 eito_external(ei_xlfd, Qx_font_name_encoding); 801 result = xlistfonts_checking_charset (device, eidata (ei_xlfd),
776
777 DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n",
778 eidata(ei_xlfd));
779 result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd),
780 charset, stage); 802 charset, stage);
781 } 803 }
782 804
783 /* In the event that the charset is ASCII and we haven't matched 805 /* In the event that the charset is ASCII and we haven't matched
784 anything up to now, even with a pattern of "*", add "iso8859-1" 806 anything up to now, even with a pattern of "*", add "iso8859-1"
785 to the charset's registry and try again. Not returning a result 807 to the charset's registry and try again. Not returning a result
786 for ASCII means our frame geometry calculations are 808 for ASCII means our frame geometry calculations are
787 inconsistent, and that we may crash. */ 809 inconsistent, and that we may crash. */
788 810
789 if (1 == xlfd_length && EQ(charset, Vcharset_ascii) && NILP(result) 811 if (1 == xlfd_length && EQ (charset, Vcharset_ascii) && NILP (result)
790 && ('*' == eigetch(ei_xlfd_without_registry, 0))) 812 && ('*' == eigetch (ei_xlfd_without_registry, 0)))
791 813
792 { 814 {
793 int have_latin1 = 0; 815 int have_latin1 = 0;
794 816
795 /* Set this to, for example, is08859-1 if you want to see the 817 /* Set this to, for example, is08859-1 if you want to see the
797 819
798 #define FALLBACK_ASCII_REGISTRY "iso8859-1" 820 #define FALLBACK_ASCII_REGISTRY "iso8859-1"
799 821
800 for (j = 0; j < registries_len; ++j) 822 for (j = 0; j < registries_len; ++j)
801 { 823 {
802 if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[j]), 824 if (0 == qxestrcasecmp (XSTRING_DATA (XVECTOR_DATA (registries)[j]),
803 (Ibyte *) FALLBACK_ASCII_REGISTRY)) 825 (Ibyte *) FALLBACK_ASCII_REGISTRY))
804 { 826 {
805 have_latin1 = 1; 827 have_latin1 = 1;
806 break; 828 break;
807 } 829 }
808 } 830 }
809 831
810 if (!have_latin1) 832 if (!have_latin1)
811 { 833 {
812 Lisp_Object new_registries = make_vector(registries_len + 1, Qnil); 834 Lisp_Object new_registries = make_vector (registries_len + 1, Qnil);
813 835
814 XVECTOR_DATA(new_registries)[0] 836 XVECTOR_DATA (new_registries)[0]
815 = build_ascstring(FALLBACK_ASCII_REGISTRY); 837 = build_ascstring (FALLBACK_ASCII_REGISTRY);
816 838
817 memcpy(XVECTOR_DATA(new_registries) + 1, 839 memcpy (XVECTOR_DATA (new_registries) + 1,
818 XVECTOR_DATA(registries), 840 XVECTOR_DATA (registries),
819 sizeof XVECTOR_DATA(registries)[0] * 841 sizeof XVECTOR_DATA (registries)[0] *
820 XVECTOR_LENGTH(registries)); 842 XVECTOR_LENGTH (registries));
821 843
822 /* Calling set_charset_registries instead of overwriting the 844 /* Calling set_charset_registries instead of overwriting the
823 value directly, to allow the charset font caches to be 845 value directly, to allow the charset font caches to be
824 invalidated and a change to the default face to be 846 invalidated and a change to the default face to be
825 noted. */ 847 noted. */
826 set_charset_registries(charset, new_registries); 848 set_charset_registries (charset, new_registries);
827 849
828 warn_when_safe (Qface, Qwarning, 850 warn_when_safe (Qface, Qwarning,
829 "Your ASCII charset registries contain nothing " 851 "Your ASCII charset registries contain nothing "
830 "sensible. Adding `" FALLBACK_ASCII_REGISTRY "'."); 852 "sensible. Adding `" FALLBACK_ASCII_REGISTRY "'.");
831 853
840 DECLARE_EISTRING (ei_connection_name); 862 DECLARE_EISTRING (ei_connection_name);
841 863
842 /* We preserve a copy of the connection name for the error message 864 /* We preserve a copy of the connection name for the error message
843 after the device is deleted. */ 865 after the device is deleted. */
844 eicpy_lstr (ei_connection_name, 866 eicpy_lstr (ei_connection_name,
845 DEVICE_CONNECTION (XDEVICE(device))); 867 DEVICE_CONNECTION (XDEVICE (device)));
846 868
847 stderr_out ("Cannot find a font for ASCII, deleting device on %s\n", 869 stderr_out ("Cannot find a font for ASCII, deleting device on %s\n",
848 eidata (ei_connection_name)); 870 eidata (ei_connection_name));
849 871
850 io_error_delete_device (device); 872 io_error_delete_device (device);