APPROVE COMMIT sjt-xft
This patch gives the user more control over verbosity of fontconfig
font names in debugging output via the variable xft-debug. It also
reduces the verbosity of both font names and frequency of output for
xft-debug=1.
More controversially, it reduces the verbosity of Xft font truenames
by removing more of the rarely user-specified properties from the
fontconfig name. I'm open to discussion on this.
Index: src/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.758.2.28
diff -u -U0 -r1.758.2.28 ChangeLog
--- src/ChangeLog 23 Sep 2005 18:20:37 -0000 1.758.2.28
+++ src/ChangeLog 24 Sep 2005 12:50:27 -0000
@@ -0,0 +1,7 @@
+2005-09-24 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * objects-x.c (x_find_charset_font): Give user more control of
+ debug verbosity. Reduce verbosity at debug_xft=1. Reduce
+ verbosity of truename by removing properties that are rarely
+ specified from fontconfig font name.
+
Index: src/objects-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/objects-x.c,v
retrieving revision 1.26.2.18
diff -u -r1.26.2.18 objects-x.c
--- src/objects-x.c 18 Apr 2005 03:51:18 -0000 1.26.2.18
+++ src/objects-x.c 24 Sep 2005 12:50:36 -0000
@@ -1281,10 +1226,9 @@
FcConfig *fcc;
FcChar8 *lang = "en"; /* #### probably a bad idea */
FcCharSet *fccs = NULL;
- DECLARE_EISTRING (eistr_shortname);
-#ifdef RETURN_LONG_FONTCONFIG_NAMES
- DECLARE_EISTRING (eistr_longname);
-#endif
+ DECLARE_EISTRING (eistr_shortname); /* user-friendly nickname */
+ DECLARE_EISTRING (eistr_longname); /* omit FC_LANG and FC_CHARSET */
+ DECLARE_EISTRING (eistr_fullname); /* everything */
LISP_STRING_TO_EXTERNAL (font, patternext, Qxft_font_name_encoding);
fcc = FcConfigGetCurrent ();
@@ -1293,36 +1237,66 @@
{
FcPattern *p = FcNameParse (patternext);
- PRINT_XFT_PATTERN (1, "FcNameParse'ed name is %s\n", p);
+ PRINT_XFT_PATTERN (3, "FcNameParse'ed name is %s\n", p);
/* #### Next two return FcBool, but what does the return mean? */
/* The order is correct according the fontconfig docs. */
FcConfigSubstitute (fcc, p, FcMatchPattern);
- PRINT_XFT_PATTERN (0, "FcConfigSubstitute'ed name is %s\n", p);
+ PRINT_XFT_PATTERN (2, "FcConfigSubstitute'ed name is %s\n", p);
FcDefaultSubstitute (p);
- PRINT_XFT_PATTERN (1, "FcDefaultSubstitute'ed name is %s\n", p);
+ PRINT_XFT_PATTERN (3, "FcDefaultSubstitute'ed name is %s\n", p);
/* #### check fcresult of following match? */
fontxft = FcFontMatch (fcc, p, &fcresult);
/* this prints the long fontconfig name */
- PRINT_XFT_PATTERN (0, "FcFontMatch'ed name is %s\n", fontxft);
+ PRINT_XFT_PATTERN (1, "FcFontMatch'ed name is %s\n", fontxft);
FcPatternDestroy (p);
}
- /* heuristic to give reasonable-length names for debug reports */
+ /* heuristic to give reasonable-length names for debug reports
+
+ I considered #ifdef SUPPORT_FULL_FONTCONFIG_NAME etc but that's
+ pointless. We're just going to remove this code once the font/
+ face refactoring is done, but until then it could be very useful.
+ */
{
FcPattern *p = FcFontRenderPrepare (fcc, fontxft, fontxft);
FcChar8 *name;
-#ifdef RETURN_LONG_FONTCONFIG_NAMES
+
/* full name, including language coverage and repertoire */
name = FcNameUnparse (p);
- eicpy_ext (eistr_longname, name, Qxft_font_name_encoding);
+ eicpy_ext (eistr_fullname, name, Qxft_font_name_encoding);
free (name);
-#endif
- /* short name, omitting coverage and repertoire */
+
+ /* long name, omitting coverage and repertoire, plus a number
+ of rarely useful properties */
FcPatternDel (p, FC_CHARSET);
FcPatternDel (p, FC_LANG);
+ FcPatternDel (p, FC_WIDTH);
+ FcPatternDel (p, FC_SPACING);
+ FcPatternDel (p, FC_HINTING);
+ FcPatternDel (p, FC_VERTICAL_LAYOUT);
+ FcPatternDel (p, FC_AUTOHINT);
+ FcPatternDel (p, FC_GLOBAL_ADVANCE);
+ FcPatternDel (p, FC_INDEX);
+ FcPatternDel (p, FC_SCALE);
+ FcPatternDel (p, FC_FONTVERSION);
+ name = FcNameUnparse (p);
+ eicpy_ext (eistr_longname, name, Qxft_font_name_encoding);
+ free (name);
+
+ /* nickname, just family and size, but
+ "family" names usually have style, slant, and weight */
+ FcPatternDel (p, FC_FOUNDRY);
+ FcPatternDel (p, FC_STYLE);
+ FcPatternDel (p, FC_SLANT);
+ FcPatternDel (p, FC_WEIGHT);
+ FcPatternDel (p, FC_PIXEL_SIZE);
+ FcPatternDel (p, FC_OUTLINE);
+ FcPatternDel (p, FC_SCALABLE);
+ FcPatternDel (p, FC_DPI);
name = FcNameUnparse (p);
eicpy_ext (eistr_shortname, name, Qxft_font_name_encoding);
free (name);
+
FcPatternDestroy (p);
}
@@ -1342,7 +1316,19 @@
if (cr->rfc3066)
{
- CHECKING_LANG (0, eidata(eistr_shortname), cr->language);
+ /* #### is it worth incorporating this logic in a macro? */
+ if (debug_xft > 2)
+ {
+ CHECKING_LANG (0, eidata(eistr_fullname), cr->language);
+ }
+ else if (debug_xft > 1)
+ {
+ CHECKING_LANG (0, eidata(eistr_longname), cr->language);
+ }
+ else if (debug_xft > 0)
+ {
+ CHECKING_LANG (0, eidata(eistr_shortname), cr->language);
+ }
lang = cr->rfc3066;
}
else if (cr->charset)
@@ -1384,20 +1370,51 @@
[[ Aidan says yes. The full pattern with the bitmap
coverage is massively unwieldy. ]]
- It would be nice if we could just store it into the truename
- right here, though. */
- DEBUG_XFT2 (0, "Xft font %s supports %s\n",
- eidata(eistr_shortname), lang);
+ Yah, but that's just *wrong*. We should have the full
+ thing internally, and filter stuff the client doesn't want
+ to see on output.
+ And it would be nice if we could just store it into the
+ truename right here, though. */
+ /* #### is it worth incorporating this logic in a macro? */
+ if (debug_xft > 2)
+ {
+ DEBUG_XFT2 (0, "Xft font %s supports %s\n",
+ eidata(eistr_fullname), lang);
+ }
+ else if (debug_xft > 1)
+ {
+ DEBUG_XFT2 (0, "Xft font %s supports %s\n",
+ eidata(eistr_longname), lang);
+ }
+ else if (debug_xft > 0)
+ {
+ DEBUG_XFT2 (0, "Xft font %s supports %s\n",
+ eidata(eistr_shortname), lang);
+ }
#ifdef RETURN_LONG_FONTCONFIG_NAMES
- result = eimake_string(eistr_longname);
+ result = eimake_string(eistr_fullname);
#else
- result = eimake_string(eistr_shortname);
+ result = eimake_string(eistr_longname);
#endif
}
else
{
- DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
- eidata(eistr_shortname), lang);
+ /* #### is it worth incorporating this logic in a macro? */
+ if (debug_xft > 2)
+ {
+ DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
+ eidata(eistr_fullname), lang);
+ }
+ else if (debug_xft > 1)
+ {
+ DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
+ eidata(eistr_longname), lang);
+ }
+ else if (debug_xft > 0)
+ {
+ DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
+ eidata(eistr_shortname), lang);
+ }
result = Qnil;
}
@@ -1424,18 +1441,46 @@
}
else if (FcLangSetHasLang (v.u.l, lang) != FcLangDifferentLang)
{
- DEBUG_XFT2 (0, "Xft font %s supports %s\n",
- eidata(eistr_shortname), lang);
+ /* #### is it worth incorporating this logic in a macro? */
+ if (debug_xft > 2)
+ {
+ DEBUG_XFT2 (0, "Xft font %s supports %s\n",
+ eidata(eistr_fullname), lang);
+ }
+ else if (debug_xft > 1)
+ {
+ DEBUG_XFT2 (0, "Xft font %s supports %s\n",
+ eidata(eistr_longname), lang);
+ }
+ else if (debug_xft > 0)
+ {
+ DEBUG_XFT2 (0, "Xft font %s supports %s\n",
+ eidata(eistr_shortname), lang);
+ }
#ifdef RETURN_LONG_FONTCONFIG_NAMES
- result = eimake_string(eistr_longname);
+ result = eimake_string(eistr_fullname);
#else
- result = eimake_string(eistr_shortname);
+ result = eimake_string(eistr_longname);
#endif
}
else
{
- DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
- eidata(eistr_shortname), lang);
+ /* #### is it worth incorporating this logic in a macro? */
+ if (debug_xft > 2)
+ {
+ DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
+ eidata(eistr_fullname), lang);
+ }
+ else if (debug_xft > 1)
+ {
+ DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
+ eidata(eistr_longname), lang);
+ }
+ else if (debug_xft > 0)
+ {
+ DEBUG_XFT2 (0, "Xft font %s doesn't support %s\n",
+ eidata(eistr_shortname), lang);
+ }
result = Qnil;
}
}
--
Graduate School of Systems and Information Engineering University of Tsukuba
http://turnbull.sk.tsukuba.ac.jp/ Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Economics of Information Communication and Computation Systems
Experimental Economics, Microeconomic Theory, Game Theory