Mercurial > hg > xemacs-beta
annotate src/objects-xlike-inc.c @ 4985:358aa3bb603f
Automatic merge
| author | Ben Wing <ben@xemacs.org> |
|---|---|
| date | Fri, 05 Feb 2010 12:12:28 -0600 |
| parents | 4aebb0131297 |
| children | d95c102a96d3 |
| rev | line source |
|---|---|
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
1 /* Common code between X and GTK -- fonts and colors. |
| 3659 | 2 Copyright (C) 1991-5, 1997 Free Software Foundation, Inc. |
| 3 Copyright (C) 1995 Sun Microsystems, Inc. | |
| 4 Copyright (C) 1996, 2001, 2002, 2003 Ben Wing. | |
| 5 | |
| 6 This file is part of XEmacs. | |
| 7 | |
| 8 XEmacs is free software; you can redistribute it and/or modify it | |
| 9 under the terms of the GNU General Public License as published by the | |
| 10 Free Software Foundation; either version 2, or (at your option) any | |
| 11 later version. | |
| 12 | |
| 13 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 16 for more details. | |
| 17 | |
| 18 You should have received a copy of the GNU General Public License | |
| 19 along with XEmacs; see the file COPYING. If not, write to | |
| 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
| 21 Boston, MA 02111-1307, USA. */ | |
| 22 | |
| 23 /* Synched up with: Not in FSF. */ | |
| 24 | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
25 /* Before including this file, you need to define either THIS_IS_X or |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
26 THIS_IS_GTK. */ |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
27 |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
28 /* See comment at top of console-xlike-inc.h for an explanation of |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
29 how this file works. */ |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
30 |
| 3659 | 31 /* Pango is ready for prime-time now, as far as I understand it. The GTK |
| 32 people should be using that. Oh well. (Aidan Kehoe, Sat Nov 4 12:41:12 | |
| 33 CET 2006) */ | |
| 34 | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
35 #include "console-xlike-inc.h" |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
36 |
| 3659 | 37 #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) |
| 38 | |
| 39 #ifdef DEBUG_XEMACS | |
| 40 # define DEBUG_OBJECTS(FORMAT, ...) \ | |
| 41 do { if (debug_x_objects) stderr_out(FORMAT, __VA_ARGS__); } while (0) | |
| 42 #else /* DEBUG_XEMACS */ | |
| 43 # define DEBUG_OBJECTS(format, ...) | |
| 44 #endif /* DEBUG_XEMACS */ | |
| 45 | |
| 46 #elif defined(__GNUC__) | |
| 47 | |
| 48 #ifdef DEBUG_XEMACS | |
| 49 # define DEBUG_OBJECTS(format, args...) \ | |
| 50 do { if (debug_x_objects) stderr_out(format, args ); } while (0) | |
| 51 #else /* DEBUG_XEMACS */ | |
| 52 # define DEBUG_OBJECTS(format, args...) | |
| 53 #endif /* DEBUG_XEMACS */ | |
| 54 | |
| 55 #else /* defined(__STDC_VERSION__) [...] */ | |
| 56 # define DEBUG_OBJECTS (void) | |
| 57 #endif | |
| 58 | |
| 59 #ifdef MULE | |
| 60 | |
| 61 /* For some code it's reasonable to have only one copy and conditionalize | |
| 62 at run-time. For other code it isn't. */ | |
| 63 | |
| 64 static int | |
| 65 count_hyphens(const Ibyte *str, Bytecount length, Ibyte **last_hyphen) | |
| 66 { | |
| 67 int hyphen_count = 0; | |
| 68 const Ibyte *hyphening = str; | |
| 69 const Ibyte *new_hyphening; | |
| 70 | |
| 71 for (hyphen_count = 0; | |
| 4124 | 72 NULL != (new_hyphening = (Ibyte *) memchr((const void *)hyphening, '-', length)); |
| 3659 | 73 hyphen_count++) |
| 74 { | |
| 75 ++new_hyphening; | |
| 76 length -= new_hyphening - hyphening; | |
| 77 hyphening = new_hyphening; | |
| 78 } | |
| 79 | |
| 80 if (NULL != last_hyphen) | |
| 81 { | |
| 82 *last_hyphen = (Ibyte *)hyphening; | |
| 83 } | |
| 84 | |
| 85 return hyphen_count; | |
| 86 } | |
| 87 | |
| 88 static int | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
89 XFUN (font_spec_matches_charset) (struct device * USED_IF_XFT (d), |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
90 Lisp_Object charset, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
91 const Ibyte *nonreloc, Lisp_Object reloc, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
92 Bytecount offset, Bytecount length, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
93 enum font_specifier_matchspec_stages stage) |
| 3659 | 94 { |
| 95 Lisp_Object registries = Qnil; | |
| 96 long i, registries_len; | |
| 97 const Ibyte *the_nonreloc; | |
| 98 Bytecount the_length; | |
| 99 | |
| 100 the_nonreloc = nonreloc; | |
| 101 the_length = length; | |
| 102 | |
| 103 if (!the_nonreloc) | |
| 104 the_nonreloc = XSTRING_DATA (reloc); | |
| 105 fixup_internal_substring (nonreloc, reloc, offset, &the_length); | |
| 106 the_nonreloc += offset; | |
| 107 | |
| 108 #ifdef USE_XFT | |
| 109 if (stage) | |
| 110 { | |
| 111 Display *dpy = DEVICE_X_DISPLAY (d); | |
| 112 Extbyte *extname; | |
| 113 XftFont *rf; | |
| 114 const Ibyte *the_nonreloc; | |
| 115 | |
| 116 if (!NILP(reloc)) | |
| 117 { | |
| 118 the_nonreloc = XSTRING_DATA (reloc); | |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
119 extname = LISP_STRING_TO_EXTERNAL (reloc, Qx_font_name_encoding); |
| 3659 | 120 rf = xft_open_font_by_name (dpy, extname); |
| 121 return 0; /* #### maybe this will compile and run ;) */ | |
| 122 /* Jesus, Stephen, what the fuck? */ | |
| 123 } | |
| 124 } | |
| 125 #endif | |
| 126 | |
| 127 /* Hmm, this smells bad. */ | |
|
4353
4143b78d0df0
Merge an old patch of Ben's, involving font instantiation and charsets.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4124
diff
changeset
|
128 if (NILP (charset)) |
| 3659 | 129 return 1; |
| 130 | |
| 131 /* Hack! Short font names don't have the registry in them, | |
| 132 so we just assume the user knows what they're doing in the | |
| 133 case of ASCII. For other charsets, you gotta give the | |
| 134 long form; sorry buster. | |
| 135 #### FMH: this screws fontconfig/Xft? | |
| 136 STRATEGY: use fontconfig's ability to hack languages and character | |
| 137 sets (lang and charset properties). | |
| 138 #### Maybe we can use the fontconfig model to eliminate the difference | |
| 139 between faces and fonts? No - it looks like that would be an abuse | |
| 140 (fontconfig doesn't know about colors, although Xft does). | |
| 141 */ | |
| 142 if (EQ (charset, Vcharset_ascii) && | |
| 143 (!memchr (the_nonreloc, '*', the_length)) | |
| 144 && (5 > (count_hyphens(the_nonreloc, the_length, NULL)))) | |
| 145 { | |
| 146 return 1; | |
| 147 } | |
| 148 | |
| 149 if (final == stage) | |
| 150 { | |
| 151 registries = Qunicode_registries; | |
| 152 } | |
| 153 else if (initial == stage) | |
| 154 { | |
| 155 registries = XCHARSET_REGISTRIES (charset); | |
| 156 if (NILP(registries)) | |
| 157 { | |
| 158 return 0; | |
| 159 } | |
| 160 } | |
| 161 else assert(0); | |
| 162 | |
| 163 CHECK_VECTOR (registries); | |
| 164 registries_len = XVECTOR_LENGTH(registries); | |
| 165 | |
| 166 for (i = 0; i < registries_len; ++i) | |
| 167 { | |
| 168 if (!(STRINGP(XVECTOR_DATA(registries)[i])) | |
| 169 || (XSTRING_LENGTH(XVECTOR_DATA(registries)[i]) > the_length)) | |
| 170 { | |
| 171 continue; | |
| 172 } | |
| 173 | |
| 174 /* Check if the font spec ends in the registry specified. X11 says | |
| 175 this comparison is case insensitive: XLFD, section 3.11: | |
| 176 | |
| 177 "Alphabetic case distinctions are allowed but are for human | |
| 178 readability concerns only. Conforming X servers will perform | |
| 179 matching on font name query or open requests independent of case." */ | |
| 180 if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[i]), | |
| 181 the_nonreloc + (the_length - | |
| 182 XSTRING_LENGTH | |
| 183 (XVECTOR_DATA(registries)[i])))) | |
| 184 { | |
| 185 return 1; | |
| 186 } | |
| 187 } | |
| 188 return 0; | |
| 189 } | |
| 190 | |
| 191 static Lisp_Object | |
| 192 xlistfonts_checking_charset (Lisp_Object device, const Extbyte *xlfd, | |
| 193 Lisp_Object charset, | |
| 194 enum font_specifier_matchspec_stages stage) | |
| 195 { | |
| 196 Extbyte **names; | |
| 197 Lisp_Object result = Qnil; | |
| 198 int count = 0, i; | |
| 199 DECLARE_EISTRING(ei_single_result); | |
| 200 | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
201 names = XListFonts (GET_XLIKE_DISPLAY (XDEVICE (device)), |
| 3659 | 202 xlfd, MAX_FONT_COUNT, &count); |
| 203 | |
| 204 for (i = 0; i < count; ++i) | |
| 205 { | |
| 206 eireset(ei_single_result); | |
| 207 eicpy_ext(ei_single_result, names[i], Qx_font_name_encoding); | |
| 208 | |
| 209 if (DEVMETH_OR_GIVEN(XDEVICE (device), font_spec_matches_charset, | |
| 210 (XDEVICE (device), charset, | |
| 211 eidata(ei_single_result), Qnil, 0, | |
| 212 -1, stage), 0)) | |
| 213 { | |
| 214 result = eimake_string(ei_single_result); | |
| 215 DEBUG_OBJECTS ("in xlistfonts_checking_charset, returning %s\n", | |
| 216 eidata(ei_single_result)); | |
| 217 break; | |
| 218 } | |
| 219 } | |
| 220 | |
| 221 if (names) | |
| 222 { | |
| 223 XFreeFontNames (names); | |
| 224 } | |
| 225 | |
| 226 return result; | |
| 227 } | |
| 228 | |
| 229 #ifdef USE_XFT | |
| 230 /* #### debug functions: find a better place for us */ | |
| 231 const char *FcResultToString (FcResult r); | |
| 232 const char * | |
| 233 FcResultToString (FcResult r) | |
| 234 { | |
| 235 static char buffer[256]; | |
| 236 switch (r) | |
| 237 { | |
| 238 case FcResultMatch: | |
| 239 return "FcResultMatch"; | |
| 240 case FcResultNoMatch: | |
| 241 return "FcResultNoMatch"; | |
| 242 case FcResultTypeMismatch: | |
| 243 return "FcResultTypeMismatch"; | |
| 244 case FcResultNoId: | |
| 245 return "FcResultNoId"; | |
| 246 default: | |
| 247 snprintf (buffer, 255, "FcResultUndocumentedValue (%d)", r); | |
| 248 return buffer; | |
| 249 } | |
| 250 } | |
| 251 | |
| 252 const char *FcTypeOfValueToString (FcValue v); | |
| 253 const char * | |
| 254 FcTypeOfValueToString (FcValue v) | |
| 255 { | |
| 256 static char buffer[256]; | |
| 257 switch (v.type) | |
| 258 { | |
| 259 case FcTypeMatrix: | |
| 260 return "FcTypeMatrix"; | |
| 261 case FcTypeString: | |
| 262 return "FcTypeString"; | |
| 263 case FcTypeVoid: | |
| 264 return "FcTypeVoid"; | |
| 265 case FcTypeDouble: | |
| 266 return "FcTypeDouble"; | |
| 267 case FcTypeInteger: | |
| 268 return "FcTypeInteger"; | |
| 269 case FcTypeBool: | |
| 270 return "FcTypeBool"; | |
| 271 case FcTypeCharSet: | |
| 272 return "FcTypeCharSet"; | |
| 273 case FcTypeLangSet: | |
| 274 return "FcTypeLangSet"; | |
| 275 /* #### There is no union member of this type, but there are void* and | |
| 276 FcPattern* members, as of fontconfig.h FC_VERSION 10002 */ | |
| 277 case FcTypeFTFace: | |
| 278 return "FcTypeFTFace"; | |
| 279 default: | |
| 280 snprintf (buffer, 255, "FcTypeUndocumentedType (%d)", v.type); | |
| 281 return buffer; | |
| 282 } | |
| 283 } | |
| 284 | |
| 285 static FcCharSet * | |
| 286 mule_to_fc_charset (Lisp_Object cs) | |
| 287 { | |
| 288 int ucode, i, j; | |
| 289 FcCharSet *fccs; | |
| 290 | |
| 291 CHECK_CHARSET (cs); | |
| 292 fccs = FcCharSetCreate (); | |
| 293 /* #### do we also need to deal with 94 vs. 96 charsets? | |
| 294 ie, how are SP and DEL treated in ASCII? non-graphic should return -1 */ | |
| 295 if (1 == XCHARSET_DIMENSION (cs)) | |
| 296 /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */ | |
| 297 for (i = 0; i < 96; i++) | |
| 298 { | |
| 299 ucode = ((int *) XCHARSET_TO_UNICODE_TABLE (cs))[i]; | |
| 300 if (ucode >= 0) | |
| 301 /* #### should check for allocation failure */ | |
| 302 FcCharSetAddChar (fccs, (FcChar32) ucode); | |
| 303 } | |
| 304 else if (2 == XCHARSET_DIMENSION (cs)) | |
| 305 /* Unicode tables are indexed by offsets from ASCII SP, not by ASCII */ | |
| 306 for (i = 0; i < 96; i++) | |
| 307 for (j = 0; j < 96; j++) | |
| 308 { | |
| 309 ucode = ((int **) XCHARSET_TO_UNICODE_TABLE (cs))[i][j]; | |
| 310 if (ucode >= 0) | |
| 311 /* #### should check for allocation failure */ | |
| 312 FcCharSetAddChar (fccs, (FcChar32) ucode); | |
| 313 } | |
| 314 else | |
| 315 { | |
| 316 FcCharSetDestroy (fccs); | |
| 317 fccs = NULL; | |
| 318 } | |
| 319 return fccs; | |
| 320 } | |
| 321 | |
| 322 struct charset_reporter { | |
| 323 Lisp_Object *charset; | |
| 324 /* This is a debug facility, require ASCII. */ | |
| 4932 | 325 const Ascbyte *language; /* ASCII, please */ |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
326 /* Technically this is FcChar8, but fsckin' GCC 4 bitches. |
|
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
327 RFC 3066 is a combination of ISO 639 and ISO 3166. */ |
| 4932 | 328 const Ascbyte *rfc3066; /* ASCII, please */ |
| 3659 | 329 }; |
| 330 | |
| 331 static struct charset_reporter charset_table[] = | |
| 332 { | |
| 333 /* #### It's my branch, my favorite charsets get checked first! | |
| 334 That's a joke, Son. | |
| 335 Ie, I don't know what I'm doing, so my charsets first is as good as | |
| 336 any other arbitrary order. If you have a better idea, speak up! */ | |
| 337 { &Vcharset_ascii, "English", "en" }, | |
| 338 { &Vcharset_japanese_jisx0208, "Japanese", "ja" }, | |
| 339 { &Vcharset_japanese_jisx0212, "Japanese", "ja" }, | |
| 340 { &Vcharset_katakana_jisx0201, "Japanese", "ja" }, | |
| 341 { &Vcharset_latin_jisx0201, "Japanese", "ja" }, | |
| 342 { &Vcharset_japanese_jisx0208_1978, "Japanese", "ja" }, | |
| 343 { &Vcharset_greek_iso8859_7, "Greek", "el" }, | |
| 344 /* #### all the Chinese need checking | |
| 345 Damn the blood-sucking ISO anyway. */ | |
|
4756
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
346 { &Vcharset_chinese_gb2312, "simplified Chinese", "zh-cn" }, |
| 3659 | 347 { &Vcharset_korean_ksc5601, "Korean", "ko" }, |
|
4756
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
348 { &Vcharset_chinese_cns11643_1, "traditional Chinese", "zh-tw" }, |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
349 { &Vcharset_chinese_cns11643_2, "traditional Chinese", "zh-tw" }, |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
350 /* #### not obvious how to handle these |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
351 We could (for experimental purposes) make the last element into |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
352 an array of ISO 639 codes, and check for all of them. If a font |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
353 provides some but not others, warn. */ |
| 3659 | 354 { &Vcharset_latin_iso8859_1, NULL, NULL }, |
| 355 { &Vcharset_latin_iso8859_2, NULL, NULL }, | |
| 356 { &Vcharset_latin_iso8859_3, NULL, NULL }, | |
| 357 { &Vcharset_latin_iso8859_4, NULL, NULL }, | |
| 358 { &Vcharset_latin_iso8859_9, NULL, NULL }, | |
| 359 { &Vcharset_latin_iso8859_15, NULL, NULL }, | |
|
4756
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
360 { &Vcharset_thai_tis620, "Thai", "th" }, |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
361 /* We don't have an arabic charset. bidi issues, I guess? */ |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
362 /* { &Vcharset_arabic_iso8859_6, "Arabic", "ar" }, */ |
| 3659 | 363 { &Vcharset_hebrew_iso8859_8, "Hebrew", "he" }, |
|
4756
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
364 /* #### probably close enough for Ukraine? */ |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
365 { &Vcharset_cyrillic_iso8859_5, "Russian", "ru" }, |
| 3659 | 366 /* #### these probably are not quite right */ |
|
4756
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
367 { &Vcharset_chinese_big5_1, "traditional Chinese", "zh-tw" }, |
|
5d67242595a8
Update charset_table used by Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4494
diff
changeset
|
368 { &Vcharset_chinese_big5_2, "traditional Chinese", "zh-tw" }, |
| 3659 | 369 { NULL, NULL, NULL } |
| 370 }; | |
| 371 | |
| 372 /* Choose appropriate font name for debug messages. | |
| 373 Use only in the top half of next function (enforced with #undef). */ | |
| 374 #define DECLARE_DEBUG_FONTNAME(__xemacs_name) \ | |
| 375 Eistring *__xemacs_name; \ | |
| 376 do \ | |
| 377 { \ | |
| 378 __xemacs_name = debug_xft > 2 ? eistr_fullname \ | |
| 379 : debug_xft > 1 ? eistr_longname \ | |
| 380 : eistr_shortname; \ | |
| 381 } while (0) | |
| 382 | |
| 383 static Lisp_Object | |
| 384 xft_find_charset_font (Lisp_Object font, Lisp_Object charset, | |
| 385 enum font_specifier_matchspec_stages stage) | |
| 386 { | |
| 387 const Extbyte *patternext; | |
| 388 Lisp_Object result = Qnil; | |
| 389 | |
| 390 /* #### with Xft need to handle second stage here -- sjt | |
| 391 Hm. Or maybe not. That would be cool. :-) */ | |
| 392 if (stage) | |
| 393 return Qnil; | |
| 394 | |
| 395 /* Fontconfig converts all FreeType names to UTF-8 before passing them | |
| 396 back to callers---see fcfreetype.c (FcFreeTypeQuery). | |
| 397 I don't believe this is documented. */ | |
| 398 | |
| 399 DEBUG_XFT1 (1, "confirming charset for font instance %s\n", | |
| 400 XSTRING_DATA(font)); | |
| 401 | |
| 402 /* #### this looks like a fair amount of work, but the basic design | |
| 403 has never been rethought, and it should be | |
| 404 | |
| 405 what really should happen here is that we use FcFontSort (FcFontList?) | |
| 406 to get a list of matching fonts, then pick the first (best) one that | |
| 407 gives language or repertoire coverage. | |
| 408 */ | |
| 409 | |
| 410 FcInit (); /* No-op if already initialized. | |
| 411 In fontconfig 2.3.2, this cannot return | |
| 412 failure, but that looks like a bug. We | |
| 413 check for it with FcGetCurrentConfig(), | |
| 414 which *can* fail. */ | |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
415 if (!FcConfigGetCurrent()) |
| 3659 | 416 stderr_out ("Failed fontconfig initialization\n"); |
| 417 else | |
| 418 { | |
| 419 FcPattern *fontxft; /* long-lived, freed at end of this block */ | |
| 420 FcResult fcresult; | |
| 421 FcConfig *fcc; | |
| 4932 | 422 const Ascbyte *lang = "en"; |
| 3659 | 423 FcCharSet *fccs = NULL; |
| 424 DECLARE_EISTRING (eistr_shortname); /* user-friendly nickname */ | |
| 425 DECLARE_EISTRING (eistr_longname); /* omit FC_LANG and FC_CHARSET */ | |
| 426 DECLARE_EISTRING (eistr_fullname); /* everything */ | |
| 427 | |
|
4981
4aebb0131297
Cleanups/renaming of EXTERNAL_TO_C_STRING and friends
Ben Wing <ben@xemacs.org>
parents:
4962
diff
changeset
|
428 patternext = LISP_STRING_TO_EXTERNAL (font, Qfc_font_name_encoding); |
| 3659 | 429 fcc = FcConfigGetCurrent (); |
| 430 | |
| 431 /* parse the name, do the substitutions, and match the font */ | |
| 432 | |
| 433 { | |
| 434 FcPattern *p = FcNameParse ((FcChar8 *) patternext); | |
| 435 PRINT_XFT_PATTERN (3, "FcNameParse'ed name is %s\n", p); | |
| 436 /* #### Next two return FcBool, but what does the return mean? */ | |
| 437 /* The order is correct according the fontconfig docs. */ | |
| 438 FcConfigSubstitute (fcc, p, FcMatchPattern); | |
| 439 PRINT_XFT_PATTERN (2, "FcConfigSubstitute'ed name is %s\n", p); | |
| 440 FcDefaultSubstitute (p); | |
| 441 PRINT_XFT_PATTERN (3, "FcDefaultSubstitute'ed name is %s\n", p); | |
| 442 /* #### check fcresult of following match? */ | |
|
4809
0d3ccd5a2509
Initialize the result variable passed to FcFontMatch. See xemacs-patches
Jerry James <james@xemacs.org>
parents:
4758
diff
changeset
|
443 fcresult = FcResultMatch; |
| 3659 | 444 fontxft = FcFontMatch (fcc, p, &fcresult); |
|
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
445 switch (fcresult) |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
446 { |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
447 /* case FcResultOutOfMemory: */ |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
448 case FcResultNoMatch: |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
449 case FcResultTypeMismatch: |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
450 case FcResultNoId: |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
451 break; |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
452 case FcResultMatch: |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
453 /* this prints the long fontconfig name */ |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
454 PRINT_XFT_PATTERN (1, "FcFontMatch'ed name is %s\n", fontxft); |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
455 break; |
|
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
456 } |
| 3659 | 457 FcPatternDestroy (p); |
| 458 } | |
| 459 | |
| 460 /* heuristic to give reasonable-length names for debug reports | |
| 461 | |
| 462 I considered #ifdef SUPPORT_FULL_FONTCONFIG_NAME etc but that's | |
| 463 pointless. We're just going to remove this code once the font/ | |
| 464 face refactoring is done, but until then it could be very useful. | |
| 465 */ | |
| 466 { | |
| 467 FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft); | |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
468 Extbyte *name; |
| 3659 | 469 |
| 470 /* full name, including language coverage and repertoire */ | |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
471 name = (Extbyte *) FcNameUnparse (p); |
|
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
472 eicpy_ext (eistr_fullname, |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
473 (name ? name : "NOT FOUND"), |
|
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
474 Qfc_font_name_encoding); |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
475 if (name) free (name); |
| 3659 | 476 |
| 477 /* long name, omitting coverage and repertoire, plus a number | |
| 478 of rarely useful properties */ | |
| 479 FcPatternDel (p, FC_CHARSET); | |
| 480 FcPatternDel (p, FC_LANG); | |
| 3841 | 481 #ifdef FC_WIDTH |
| 3659 | 482 FcPatternDel (p, FC_WIDTH); |
| 3841 | 483 #endif |
| 3659 | 484 FcPatternDel (p, FC_SPACING); |
| 485 FcPatternDel (p, FC_HINTING); | |
| 486 FcPatternDel (p, FC_VERTICAL_LAYOUT); | |
| 487 FcPatternDel (p, FC_AUTOHINT); | |
| 488 FcPatternDel (p, FC_GLOBAL_ADVANCE); | |
| 489 FcPatternDel (p, FC_INDEX); | |
| 490 FcPatternDel (p, FC_SCALE); | |
| 491 FcPatternDel (p, FC_FONTVERSION); | |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
492 name = (Extbyte *) FcNameUnparse (p); |
|
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
493 eicpy_ext (eistr_longname, |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
494 (name ? name : "NOT FOUND"), |
|
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
495 Qfc_font_name_encoding); |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
496 if (name) free (name); |
| 3659 | 497 |
| 498 /* nickname, just family and size, but | |
| 499 "family" names usually have style, slant, and weight */ | |
| 500 FcPatternDel (p, FC_FOUNDRY); | |
| 501 FcPatternDel (p, FC_STYLE); | |
| 502 FcPatternDel (p, FC_SLANT); | |
| 503 FcPatternDel (p, FC_WEIGHT); | |
| 504 FcPatternDel (p, FC_PIXEL_SIZE); | |
| 505 FcPatternDel (p, FC_OUTLINE); | |
| 506 FcPatternDel (p, FC_SCALABLE); | |
| 507 FcPatternDel (p, FC_DPI); | |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
508 name = (Extbyte *) FcNameUnparse (p); |
|
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
509 eicpy_ext (eistr_shortname, |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
510 (name ? name : "NOT FOUND"), |
|
4757
a23ac8f90a49
Improve warning and error messages from Xft.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4756
diff
changeset
|
511 Qfc_font_name_encoding); |
|
4758
75975fd0b7fc
Implement more of the fontconfig API.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4757
diff
changeset
|
512 if (name) free (name); |
| 3659 | 513 |
| 514 FcPatternDestroy (p); | |
| 515 } | |
| 516 | |
| 517 /* The language approach may better in the long run, but we can't use | |
| 518 it based on Mule charsets; fontconfig doesn't provide a way to test | |
| 519 for unions of languages, etc. That will require support from the | |
| 520 text module. | |
| 521 | |
| 522 Optimization: cache the generated FcCharSet in the Mule charset. | |
| 523 Don't forget to destroy it if the Mule charset gets deallocated. */ | |
| 524 | |
| 525 { | |
| 526 /* This block possibly should be a function, but it generates | |
| 527 multiple values. I find the "pass an address to return the | |
| 528 value in" idiom opaque, so prefer a block. */ | |
| 529 struct charset_reporter *cr; | |
| 530 for (cr = charset_table; | |
| 531 cr->charset && !EQ (*(cr->charset), charset); | |
| 532 cr++) | |
| 533 ; | |
| 534 | |
| 535 if (cr->rfc3066) | |
| 536 { | |
| 537 DECLARE_DEBUG_FONTNAME (name); | |
| 538 CHECKING_LANG (0, eidata(name), cr->language); | |
| 4932 | 539 lang = cr->rfc3066; |
| 3659 | 540 } |
| 541 else if (cr->charset) | |
| 542 { | |
| 543 /* what the hey, build 'em on the fly */ | |
| 544 /* #### in the case of error this could return NULL! */ | |
| 545 fccs = mule_to_fc_charset (charset); | |
| 4932 | 546 /* #### Bad idea here */ |
| 547 lang = (const Ascbyte *) XSTRING_DATA (XSYMBOL (XCHARSET_NAME | |
| 548 (charset))->name); | |
| 3659 | 549 } |
| 550 else | |
| 551 { | |
| 552 /* OK, we fell off the end of the table */ | |
| 553 warn_when_safe_lispobj (intern ("xft"), intern ("alert"), | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
554 list2 (build_ascstring ("unchecked charset"), |
| 3659 | 555 charset)); |
| 556 /* default to "en" | |
| 557 #### THIS IS WRONG, WRONG, WRONG!! | |
| 558 It is why we never fall through to XLFD-checking. */ | |
| 559 } | |
| 560 | |
| 4932 | 561 ASSERT_ASCTEXT_ASCII (lang); |
| 3659 | 562 |
| 563 if (fccs) | |
| 564 { | |
| 565 /* check for character set coverage */ | |
| 566 int i = 0; | |
| 567 FcCharSet *v; | |
| 568 FcResult r = FcPatternGetCharSet (fontxft, FC_CHARSET, i, &v); | |
| 569 | |
| 570 if (r == FcResultTypeMismatch) | |
| 571 { | |
| 572 DEBUG_XFT0 (0, "Unexpected type return in charset value\n"); | |
| 573 result = Qnil; | |
| 574 } | |
| 575 else if (r == FcResultMatch && FcCharSetIsSubset (fccs, v)) | |
| 576 { | |
| 577 /* The full pattern with the bitmap coverage is massively | |
| 578 unwieldy, but the shorter names are just *wrong*. We | |
| 579 should have the full thing internally as truename, and | |
| 580 filter stuff the client doesn't want to see on output. | |
| 581 Should we just store it into the truename right here? */ | |
| 582 DECLARE_DEBUG_FONTNAME (name); | |
| 583 DEBUG_XFT2 (0, "Xft font %s supports %s\n", | |
| 584 eidata(name), lang); | |
| 585 #ifdef RETURN_LONG_FONTCONFIG_NAMES | |
| 586 result = eimake_string(eistr_fullname); | |
| 587 #else | |
| 588 result = eimake_string(eistr_longname); | |
| 589 #endif | |
| 590 } | |
| 591 else | |
| 592 { | |
| 593 DECLARE_DEBUG_FONTNAME (name); | |
| 594 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", | |
| 595 eidata(name), lang); | |
| 596 result = Qnil; | |
| 597 } | |
| 598 | |
| 599 /* clean up */ | |
| 600 FcCharSetDestroy (fccs); | |
| 601 } | |
| 602 else | |
| 603 { | |
| 604 /* check for language coverage */ | |
| 605 int i = 0; | |
| 606 FcValue v; | |
| 607 /* the main event */ | |
| 608 FcResult r = FcPatternGet (fontxft, FC_LANG, i, &v); | |
| 609 | |
| 610 if (r == FcResultMatch) | |
| 611 { | |
| 612 if (v.type != FcTypeLangSet) /* excessive paranoia */ | |
| 613 { | |
| 614 ASSERT_ASCTEXT_ASCII(FcTypeOfValueToString(v)); | |
| 615 /* Urk! Fall back and punt to core font. */ | |
| 616 DEBUG_XFT1 (0, "Unexpected type of lang value (%s)\n", | |
| 617 FcTypeOfValueToString (v)); | |
| 618 result = Qnil; | |
| 619 } | |
| 4932 | 620 else if (FcLangSetHasLang (v.u.l, (FcChar8 *) lang) |
| 621 != FcLangDifferentLang) | |
| 3659 | 622 { |
| 623 DECLARE_DEBUG_FONTNAME (name); | |
| 624 DEBUG_XFT2 (0, "Xft font %s supports %s\n", | |
| 625 eidata(name), lang); | |
| 626 #ifdef RETURN_LONG_FONTCONFIG_NAMES | |
| 627 result = eimake_string(eistr_fullname); | |
| 628 #else | |
| 629 result = eimake_string(eistr_longname); | |
| 630 #endif | |
| 631 } | |
| 632 else | |
| 633 { | |
| 634 DECLARE_DEBUG_FONTNAME (name); | |
| 635 DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", | |
| 636 eidata(name), lang); | |
| 637 result = Qnil; | |
| 638 } | |
| 639 } | |
| 640 else | |
| 641 { | |
| 642 ASSERT_ASCTEXT_ASCII(FcResultToString(r)); | |
| 643 DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n", | |
| 644 FcResultToString (r)); | |
| 645 result = Qnil; | |
| 646 } | |
| 647 } | |
| 648 | |
| 649 /* clean up and maybe return */ | |
| 650 FcPatternDestroy (fontxft); | |
| 651 if (!UNBOUNDP (result)) | |
| 652 return result; | |
| 653 } | |
| 654 } | |
| 655 return Qnil; | |
| 656 } | |
| 657 #undef DECLARE_DEBUG_FONTNAME | |
| 658 | |
| 659 #endif /* USE_XFT */ | |
| 660 | |
| 661 /* find a font spec that matches font spec FONT and also matches | |
| 662 (the registry of) CHARSET. */ | |
| 663 static Lisp_Object | |
|
4908
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
664 XFUN (find_charset_font) (Lisp_Object device, Lisp_Object font, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
665 Lisp_Object charset, |
|
b3ce27ca7647
various fixes related to gtk, redisplay-xlike-inc.c
Ben Wing <ben@xemacs.org>
parents:
4809
diff
changeset
|
666 enum font_specifier_matchspec_stages stage) |
| 3659 | 667 { |
| 668 Lisp_Object result = Qnil, registries = Qnil; | |
| 669 int j, hyphen_count, registries_len = 0; | |
| 670 Ibyte *hyphening, *new_hyphening; | |
| 671 Bytecount xlfd_length; | |
| 672 | |
| 673 DECLARE_EISTRING(ei_xlfd_without_registry); | |
| 674 DECLARE_EISTRING(ei_xlfd); | |
| 675 | |
| 676 #ifdef USE_XFT | |
| 677 result = xft_find_charset_font(font, charset, stage); | |
| 678 if (!NILP(result)) | |
| 679 { | |
| 680 return result; | |
| 681 } | |
| 682 #endif | |
| 683 | |
| 684 switch (stage) | |
| 685 { | |
| 686 case initial: | |
| 687 { | |
| 688 if (!(NILP(XCHARSET_REGISTRIES(charset))) | |
| 689 && VECTORP(XCHARSET_REGISTRIES(charset))) | |
| 690 { | |
| 691 registries_len = XVECTOR_LENGTH(XCHARSET_REGISTRIES(charset)); | |
| 692 registries = XCHARSET_REGISTRIES(charset); | |
| 693 } | |
| 694 break; | |
| 695 } | |
| 696 case final: | |
| 697 { | |
| 698 registries_len = 1; | |
| 699 registries = Qunicode_registries; | |
| 700 break; | |
| 701 } | |
| 702 default: | |
| 703 { | |
| 704 assert(0); | |
| 705 break; | |
| 706 } | |
| 707 } | |
| 708 | |
| 709 eicpy_lstr(ei_xlfd, font); | |
| 710 hyphening = eidata(ei_xlfd); | |
| 711 xlfd_length = eilen(ei_xlfd); | |
| 712 | |
| 713 /* Count the hyphens in the string, moving new_hyphening to just after the | |
| 714 last one. */ | |
| 715 hyphen_count = count_hyphens(hyphening, xlfd_length, &new_hyphening); | |
| 716 | |
| 717 if (0 == registries_len || (5 > hyphen_count && | |
| 718 !(1 == xlfd_length && '*' == *hyphening))) | |
| 719 { | |
| 720 /* 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 | |
| 722 information on the registry needed. */ | |
| 723 eito_external(ei_xlfd, Qx_font_name_encoding); | |
| 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); | |
| 728 /* No need to loop through the available registries; return | |
| 729 immediately. */ | |
| 730 return result; | |
| 731 } | |
| 732 else if (1 == xlfd_length && '*' == *hyphening) | |
| 733 { | |
| 734 /* It's a single asterisk. We can add the registry directly to the | |
| 735 end. */ | |
| 736 eicpy_ch(ei_xlfd_without_registry, '*'); | |
| 737 } | |
| 738 else | |
| 739 { | |
| 740 /* It's a fully-specified XLFD. Work out where the registry and | |
| 741 encoding are, and initialise ei_xlfd_without_registry to the string | |
| 742 without them. */ | |
| 743 | |
| 744 /* count_hyphens has set new_hyphening to just after the last | |
| 745 hyphen. Move back to just after the hyphen before it. */ | |
| 746 | |
| 747 for (new_hyphening -= 2; new_hyphening > hyphening | |
| 748 && '-' != *new_hyphening; --new_hyphening) | |
| 749 ; | |
| 750 ++new_hyphening; | |
| 751 | |
| 752 eicpy_ei(ei_xlfd_without_registry, ei_xlfd); | |
| 753 | |
| 754 /* Manipulate ei_xlfd_without_registry, using the information about | |
| 755 ei_xlfd, to which it's identical. */ | |
| 756 eidel(ei_xlfd_without_registry, new_hyphening - hyphening, -1, | |
| 757 eilen(ei_xlfd) - (new_hyphening - hyphening), -1); | |
| 758 | |
| 759 } | |
| 760 | |
| 761 /* Now, loop through the registries and encodings defined for this | |
| 762 charset, doing an XListFonts each time with the pattern modified to | |
| 763 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 | |
| 765 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 | |
| 767 data. */ | |
| 768 for (j = 0; j < registries_len && NILP(result); ++j) | |
| 769 { | |
| 770 eireset(ei_xlfd); | |
| 771 eicpy_ei(ei_xlfd, ei_xlfd_without_registry); | |
| 772 | |
| 773 eicat_lstr(ei_xlfd, XVECTOR_DATA(registries)[j]); | |
| 774 | |
| 775 eito_external(ei_xlfd, Qx_font_name_encoding); | |
| 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); | |
| 781 } | |
| 782 | |
| 3676 | 783 /* 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" | |
| 785 to the charset's registry and try again. Not returning a result | |
| 786 for ASCII means our frame geometry calculations are | |
| 787 inconsistent, and that we may crash. */ | |
| 788 | |
| 789 if (1 == xlfd_length && EQ(charset, Vcharset_ascii) && NILP(result) | |
| 790 && ('*' == eigetch(ei_xlfd_without_registry, 0))) | |
| 791 | |
| 792 { | |
| 793 int have_latin1 = 0; | |
| 794 | |
| 795 /* Set this to, for example, is08859-1 if you want to see the | |
| 796 error behaviour. */ | |
| 797 | |
| 798 #define FALLBACK_ASCII_REGISTRY "iso8859-1" | |
| 799 | |
| 800 for (j = 0; j < registries_len; ++j) | |
| 801 { | |
| 802 if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[j]), | |
| 4124 | 803 (Ibyte *) FALLBACK_ASCII_REGISTRY)) |
| 3676 | 804 { |
| 805 have_latin1 = 1; | |
| 806 break; | |
| 807 } | |
| 808 } | |
| 809 | |
| 810 if (!have_latin1) | |
| 811 { | |
| 812 Lisp_Object new_registries = make_vector(registries_len + 1, Qnil); | |
| 813 | |
| 814 XVECTOR_DATA(new_registries)[0] | |
|
4952
19a72041c5ed
Mule-izing, various fixes related to char * arguments
Ben Wing <ben@xemacs.org>
parents:
4932
diff
changeset
|
815 = build_ascstring(FALLBACK_ASCII_REGISTRY); |
| 3676 | 816 |
| 817 memcpy(XVECTOR_DATA(new_registries) + 1, | |
| 818 XVECTOR_DATA(registries), | |
| 819 sizeof XVECTOR_DATA(registries)[0] * | |
| 820 XVECTOR_LENGTH(registries)); | |
| 821 | |
| 822 /* Calling set_charset_registries instead of overwriting the | |
| 823 value directly, to allow the charset font caches to be | |
| 824 invalidated and a change to the default face to be | |
| 825 noted. */ | |
| 826 set_charset_registries(charset, new_registries); | |
| 827 | |
| 3680 | 828 warn_when_safe (Qface, Qwarning, |
| 829 "Your ASCII charset registries contain nothing " | |
| 830 "sensible. Adding `" FALLBACK_ASCII_REGISTRY "'."); | |
| 831 | |
| 3676 | 832 /* And recurse. */ |
| 833 result = | |
| 834 DEVMETH_OR_GIVEN (XDEVICE (device), find_charset_font, | |
| 835 (device, font, charset, stage), | |
| 836 result); | |
| 837 } | |
| 838 else | |
| 839 { | |
| 840 DECLARE_EISTRING (ei_connection_name); | |
| 841 | |
| 842 /* We preserve a copy of the connection name for the error message | |
| 843 after the device is deleted. */ | |
| 844 eicpy_lstr (ei_connection_name, | |
| 845 DEVICE_CONNECTION (XDEVICE(device))); | |
| 846 | |
| 847 stderr_out ("Cannot find a font for ASCII, deleting device on %s\n", | |
| 848 eidata (ei_connection_name)); | |
| 849 | |
| 850 io_error_delete_device (device); | |
| 851 | |
| 852 /* Do a normal warning in the event that we have other, non-X | |
| 853 frames available. (If we don't, io_error_delete_device will | |
| 854 have exited.) */ | |
| 855 warn_when_safe | |
| 856 (Qface, Qerror, | |
| 857 "Cannot find a font for ASCII, deleting device on %s.\n" | |
| 858 "\n" | |
| 859 "Your X server fonts appear to be inconsistent; fix them, or\n" | |
| 860 "the next frame you create on that DISPLAY will crash this\n" | |
| 861 "XEmacs. At a minimum, provide one font with an XLFD ending\n" | |
| 862 "in `" FALLBACK_ASCII_REGISTRY "', so we can work out what size\n" | |
| 863 "a frame should be. ", | |
| 864 eidata (ei_connection_name)); | |
| 865 } | |
| 866 | |
| 867 } | |
| 868 | |
| 3659 | 869 /* This function used to return the font spec, in the case where a font |
| 870 didn't exist on the X server but it did match the charset. We're not | |
| 871 doing that any more, because none of the other platform code does, and | |
| 872 the old behaviour was badly-judged in other respects, so I don't trust | |
| 873 the original author to have had a good reason for it. */ | |
| 874 | |
| 875 return result; | |
| 876 } | |
| 877 | |
| 878 #endif /* MULE */ |
