Mercurial > hg > xemacs-beta
diff 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 |
line wrap: on
line diff
--- a/src/fontcolor-xlike-inc.c Mon Mar 29 23:23:33 2010 -0500 +++ b/src/fontcolor-xlike-inc.c Sun Apr 04 23:46:50 2010 -0500 @@ -34,27 +34,53 @@ #include "console-xlike-inc.h" -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) +#define DEBUG_FONTS1(format, arg) \ +do { \ + if (debug_x_fonts) \ + debug_out (format, arg); \ +} while (0) + +#define DEBUG_FONTS2(format, arg1, arg2) \ +do { \ + if (debug_x_fonts) \ + debug_out (format, arg1, arg2); \ +} while (0) -#ifdef DEBUG_XEMACS -# define DEBUG_OBJECTS(FORMAT, ...) \ - do { if (debug_x_objects) stderr_out(FORMAT, __VA_ARGS__); } while (0) -#else /* DEBUG_XEMACS */ -# define DEBUG_OBJECTS(format, ...) -#endif /* DEBUG_XEMACS */ +#define DEBUG_FONTS3(format, arg1, arg2, arg3) \ +do { \ + if (debug_x_fonts) \ + debug_out (format, arg1, arg2, arg3); \ +} while (0) -#elif defined(__GNUC__) +#define DEBUG_FONTS4(format, arg1, arg2, arg3, arg4) \ +do { \ + if (debug_x_fonts) \ + debug_out (format, arg1, arg2, arg3, arg4); \ +} while (0) -#ifdef DEBUG_XEMACS -# define DEBUG_OBJECTS(format, args...) \ - do { if (debug_x_objects) stderr_out(format, args ); } while (0) -#else /* DEBUG_XEMACS */ -# define DEBUG_OBJECTS(format, args...) -#endif /* DEBUG_XEMACS */ +#define DEBUG_FONTS_LISP1(format, arg) \ +do { \ + if (debug_x_fonts) \ + debug_out_lisp (format, 1, arg); \ +} while (0) + +#define DEBUG_FONTS_LISP2(format, arg1, arg2) \ +do { \ + if (debug_x_fonts) \ + debug_out_lisp (format, 2, arg1, arg2); \ +} while (0) -#else /* defined(__STDC_VERSION__) [...] */ -# define DEBUG_OBJECTS (void) -#endif +#define DEBUG_FONTS_LISP3(format, arg1, arg2, arg3) \ +do { \ + if (debug_x_fonts) \ + debug_out_lisp (format, 3, arg1, arg2, arg3); \ +} while (0) + +#define DEBUG_FONTS_LISP4(format, arg1, arg2, arg3, arg4) \ +do { \ + if (debug_x_fonts) \ + debug_out_lisp (format, 4, arg1, arg2, arg3, arg4); \ +} while (0) #ifdef MULE @@ -62,14 +88,14 @@ at run-time. For other code it isn't. */ static int -count_hyphens(const Ibyte *str, Bytecount length, Ibyte **last_hyphen) +count_hyphens (const Ibyte *str, Bytecount length, Ibyte **last_hyphen) { int hyphen_count = 0; const Ibyte *hyphening = str; const Ibyte *new_hyphening; for (hyphen_count = 0; - NULL != (new_hyphening = (Ibyte *) memchr((const void *)hyphening, '-', length)); + NULL != (new_hyphening = (Ibyte *) memchr ((const void *)hyphening, '-', length)); hyphen_count++) { ++new_hyphening; @@ -111,9 +137,8 @@ Display *dpy = DEVICE_X_DISPLAY (d); Extbyte *extname; XftFont *rf; - const Ibyte *the_nonreloc; - if (!NILP(reloc)) + if (!NILP (reloc)) { the_nonreloc = XSTRING_DATA (reloc); extname = LISP_STRING_TO_EXTERNAL (reloc, Qx_font_name_encoding); @@ -141,7 +166,7 @@ */ if (EQ (charset, Vcharset_ascii) && (!memchr (the_nonreloc, '*', the_length)) - && (5 > (count_hyphens(the_nonreloc, the_length, NULL)))) + && (5 > (count_hyphens (the_nonreloc, the_length, NULL)))) { return 1; } @@ -153,20 +178,20 @@ else if (STAGE_INITIAL == stage) { registries = XCHARSET_REGISTRIES (charset); - if (NILP(registries)) + if (NILP (registries)) { return 0; } } - else assert(0); + else assert (0); CHECK_VECTOR (registries); - registries_len = XVECTOR_LENGTH(registries); + registries_len = XVECTOR_LENGTH (registries); for (i = 0; i < registries_len; ++i) { - if (!(STRINGP(XVECTOR_DATA(registries)[i])) - || (XSTRING_LENGTH(XVECTOR_DATA(registries)[i]) > the_length)) + if (!(STRINGP (XVECTOR_DATA (registries)[i])) + || (XSTRING_LENGTH (XVECTOR_DATA (registries)[i]) > the_length)) { continue; } @@ -177,10 +202,10 @@ "Alphabetic case distinctions are allowed but are for human readability concerns only. Conforming X servers will perform matching on font name query or open requests independent of case." */ - if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[i]), + if (0 == qxestrcasecmp (XSTRING_DATA (XVECTOR_DATA (registries)[i]), the_nonreloc + (the_length - XSTRING_LENGTH - (XVECTOR_DATA(registries)[i])))) + (XVECTOR_DATA (registries)[i])))) { return 1; } @@ -189,31 +214,34 @@ } static Lisp_Object -xlistfonts_checking_charset (Lisp_Object device, const Extbyte *xlfd, +xlistfonts_checking_charset (Lisp_Object device, const Ibyte *xlfd, Lisp_Object charset, enum font_specifier_matchspec_stages stage) { Extbyte **names; Lisp_Object result = Qnil; int count = 0, i; - DECLARE_EISTRING(ei_single_result); + DECLARE_EISTRING (ei_single_result); + Extbyte *fontext; + DEBUG_FONTS2 ("xlistfonts_checking_charset called, XLFD %s stage %s", + xlfd, stage == STAGE_INITIAL ? "initial" : "final"); + DEBUG_FONTS_LISP1 (" charset %s\n", charset); + fontext = ITEXT_TO_EXTERNAL (xlfd, Qx_font_name_encoding); names = XListFonts (GET_XLIKE_DISPLAY (XDEVICE (device)), - xlfd, MAX_FONT_COUNT, &count); + fontext, MAX_FONT_COUNT, &count); for (i = 0; i < count; ++i) { - eireset(ei_single_result); - eicpy_ext(ei_single_result, names[i], Qx_font_name_encoding); + eireset (ei_single_result); + eicpy_ext (ei_single_result, names[i], Qx_font_name_encoding); - if (DEVMETH_OR_GIVEN(XDEVICE (device), font_spec_matches_charset, + if (DEVMETH_OR_GIVEN (XDEVICE (device), font_spec_matches_charset, (XDEVICE (device), charset, - eidata(ei_single_result), Qnil, 0, + eidata (ei_single_result), Qnil, 0, -1, stage), 0)) { - result = eimake_string(ei_single_result); - DEBUG_OBJECTS ("in xlistfonts_checking_charset, returning %s\n", - eidata(ei_single_result)); + result = eimake_string (ei_single_result); break; } } @@ -223,6 +251,7 @@ XFreeFontNames (names); } + DEBUG_FONTS_LISP1 ("xlistfonts_checking_charset returns %s\n", result); return result; } @@ -397,7 +426,7 @@ I don't believe this is documented. */ DEBUG_XFT1 (1, "confirming charset for font instance %s\n", - XSTRING_DATA(font)); + XSTRING_DATA (font)); /* #### this looks like a fair amount of work, but the basic design has never been rethought, and it should be @@ -535,7 +564,7 @@ if (cr->rfc3066) { DECLARE_DEBUG_FONTNAME (name); - CHECKING_LANG (0, eidata(name), cr->language); + CHECKING_LANG (0, eidata (name), cr->language); lang = cr->rfc3066; } else if (cr->charset) @@ -581,18 +610,18 @@ Should we just store it into the truename right here? */ DECLARE_DEBUG_FONTNAME (name); DEBUG_XFT2 (0, "Xft font %s supports %s\n", - eidata(name), lang); + eidata (name), lang); #ifdef RETURN_LONG_FONTCONFIG_NAMES - result = eimake_string(eistr_fullname); + result = eimake_string (eistr_fullname); #else - result = eimake_string(eistr_longname); + result = eimake_string (eistr_longname); #endif } else { DECLARE_DEBUG_FONTNAME (name); DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", - eidata(name), lang); + eidata (name), lang); result = Qnil; } @@ -611,7 +640,7 @@ { if (v.type != FcTypeLangSet) /* excessive paranoia */ { - ASSERT_ASCTEXT_ASCII(FcTypeOfValueToString(v)); + ASSERT_ASCTEXT_ASCII (FcTypeOfValueToString (v)); /* Urk! Fall back and punt to core font. */ DEBUG_XFT1 (0, "Unexpected type of lang value (%s)\n", FcTypeOfValueToString (v)); @@ -622,24 +651,24 @@ { DECLARE_DEBUG_FONTNAME (name); DEBUG_XFT2 (0, "Xft font %s supports %s\n", - eidata(name), lang); + eidata (name), lang); #ifdef RETURN_LONG_FONTCONFIG_NAMES - result = eimake_string(eistr_fullname); + result = eimake_string (eistr_fullname); #else - result = eimake_string(eistr_longname); + result = eimake_string (eistr_longname); #endif } else { DECLARE_DEBUG_FONTNAME (name); DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n", - eidata(name), lang); + eidata (name), lang); result = Qnil; } } else { - ASSERT_ASCTEXT_ASCII(FcResultToString(r)); + ASSERT_ASCTEXT_ASCII (FcResultToString (r)); DEBUG_XFT1 (0, "Getting lang: unexpected result=%s\n", FcResultToString (r)); result = Qnil; @@ -670,12 +699,12 @@ Ibyte *hyphening, *new_hyphening; Bytecount xlfd_length; - DECLARE_EISTRING(ei_xlfd_without_registry); - DECLARE_EISTRING(ei_xlfd); + DECLARE_EISTRING (ei_xlfd_without_registry); + DECLARE_EISTRING (ei_xlfd); #ifdef USE_XFT - result = xft_find_charset_font(font, charset, stage); - if (!NILP(result)) + result = xft_find_charset_font (font, charset, stage); + if (!NILP (result)) { return result; } @@ -685,11 +714,11 @@ { case STAGE_INITIAL: { - if (!(NILP(XCHARSET_REGISTRIES(charset))) - && VECTORP(XCHARSET_REGISTRIES(charset))) + if (!(NILP (XCHARSET_REGISTRIES (charset))) + && VECTORP (XCHARSET_REGISTRIES (charset))) { - registries_len = XVECTOR_LENGTH(XCHARSET_REGISTRIES(charset)); - registries = XCHARSET_REGISTRIES(charset); + registries_len = XVECTOR_LENGTH (XCHARSET_REGISTRIES (charset)); + registries = XCHARSET_REGISTRIES (charset); } break; } @@ -701,18 +730,18 @@ } default: { - assert(0); + assert (0); break; } } - eicpy_lstr(ei_xlfd, font); - hyphening = eidata(ei_xlfd); - xlfd_length = eilen(ei_xlfd); + eicpy_lstr (ei_xlfd, font); + hyphening = eidata (ei_xlfd); + xlfd_length = eilen (ei_xlfd); /* Count the hyphens in the string, moving new_hyphening to just after the last one. */ - hyphen_count = count_hyphens(hyphening, xlfd_length, &new_hyphening); + hyphen_count = count_hyphens (hyphening, xlfd_length, &new_hyphening); if (0 == registries_len || (5 > hyphen_count && !(1 == xlfd_length && '*' == *hyphening))) @@ -720,10 +749,7 @@ /* No proper XLFD specified, or we can't modify the pattern to change the registry and encoding to match what we want, or we have no information on the registry needed. */ - eito_external(ei_xlfd, Qx_font_name_encoding); - DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n", - eidata(ei_xlfd)); - result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd), + result = xlistfonts_checking_charset (device, eidata (ei_xlfd), charset, stage); /* No need to loop through the available registries; return immediately. */ @@ -733,7 +759,7 @@ { /* It's a single asterisk. We can add the registry directly to the end. */ - eicpy_ch(ei_xlfd_without_registry, '*'); + eicpy_ch (ei_xlfd_without_registry, '*'); } else { @@ -749,12 +775,12 @@ ; ++new_hyphening; - eicpy_ei(ei_xlfd_without_registry, ei_xlfd); + eicpy_ei (ei_xlfd_without_registry, ei_xlfd); /* Manipulate ei_xlfd_without_registry, using the information about ei_xlfd, to which it's identical. */ - eidel(ei_xlfd_without_registry, new_hyphening - hyphening, -1, - eilen(ei_xlfd) - (new_hyphening - hyphening), -1); + eidel (ei_xlfd_without_registry, new_hyphening - hyphening, -1, + eilen (ei_xlfd) - (new_hyphening - hyphening), -1); } @@ -765,18 +791,14 @@ anyway, where before the X server did its search, transferred huge amounts of data, and then we proceeded to do a regexp search on that data. */ - for (j = 0; j < registries_len && NILP(result); ++j) + for (j = 0; j < registries_len && NILP (result); ++j) { - eireset(ei_xlfd); - eicpy_ei(ei_xlfd, ei_xlfd_without_registry); + eireset (ei_xlfd); + eicpy_ei (ei_xlfd, ei_xlfd_without_registry); - eicat_lstr(ei_xlfd, XVECTOR_DATA(registries)[j]); - - eito_external(ei_xlfd, Qx_font_name_encoding); + eicat_lstr (ei_xlfd, XVECTOR_DATA (registries)[j]); - DEBUG_OBJECTS ("about to xlistfonts_checking_charset, XLFD %s\n", - eidata(ei_xlfd)); - result = xlistfonts_checking_charset (device, eiextdata(ei_xlfd), + result = xlistfonts_checking_charset (device, eidata (ei_xlfd), charset, stage); } @@ -786,8 +808,8 @@ for ASCII means our frame geometry calculations are inconsistent, and that we may crash. */ - if (1 == xlfd_length && EQ(charset, Vcharset_ascii) && NILP(result) - && ('*' == eigetch(ei_xlfd_without_registry, 0))) + if (1 == xlfd_length && EQ (charset, Vcharset_ascii) && NILP (result) + && ('*' == eigetch (ei_xlfd_without_registry, 0))) { int have_latin1 = 0; @@ -799,7 +821,7 @@ for (j = 0; j < registries_len; ++j) { - if (0 == qxestrcasecmp(XSTRING_DATA(XVECTOR_DATA(registries)[j]), + if (0 == qxestrcasecmp (XSTRING_DATA (XVECTOR_DATA (registries)[j]), (Ibyte *) FALLBACK_ASCII_REGISTRY)) { have_latin1 = 1; @@ -809,21 +831,21 @@ if (!have_latin1) { - Lisp_Object new_registries = make_vector(registries_len + 1, Qnil); + Lisp_Object new_registries = make_vector (registries_len + 1, Qnil); - XVECTOR_DATA(new_registries)[0] - = build_ascstring(FALLBACK_ASCII_REGISTRY); + XVECTOR_DATA (new_registries)[0] + = build_ascstring (FALLBACK_ASCII_REGISTRY); - memcpy(XVECTOR_DATA(new_registries) + 1, - XVECTOR_DATA(registries), - sizeof XVECTOR_DATA(registries)[0] * - XVECTOR_LENGTH(registries)); + memcpy (XVECTOR_DATA (new_registries) + 1, + XVECTOR_DATA (registries), + sizeof XVECTOR_DATA (registries)[0] * + XVECTOR_LENGTH (registries)); /* Calling set_charset_registries instead of overwriting the value directly, to allow the charset font caches to be invalidated and a change to the default face to be noted. */ - set_charset_registries(charset, new_registries); + set_charset_registries (charset, new_registries); warn_when_safe (Qface, Qwarning, "Your ASCII charset registries contain nothing " @@ -842,7 +864,7 @@ /* We preserve a copy of the connection name for the error message after the device is deleted. */ eicpy_lstr (ei_connection_name, - DEVICE_CONNECTION (XDEVICE(device))); + DEVICE_CONNECTION (XDEVICE (device))); stderr_out ("Cannot find a font for ASCII, deleting device on %s\n", eidata (ei_connection_name));