User: stephent
Date: 05/09/24 15:04:24
Branch: xemacs/src sjt-xft
Modified: xemacs/src ChangeLog objects-x.c
Log:
Comments, bug fix, and debug output reduction
<87u0gaejex.fsf(a)tleepslib.sk.tsukuba.ac.jp>
<87psqyeiu0.fsf(a)tleepslib.sk.tsukuba.ac.jp>
<87ll1mei3w.fsf(a)tleepslib.sk.tsukuba.ac.jp>
Revision Changes Path
1.758.2.29 +17 -0 XEmacs/xemacs/src/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.758.2.28
retrieving revision 1.758.2.29
diff -u -p -r1.758.2.28 -r1.758.2.29
--- ChangeLog 2005/09/23 18:20:37 1.758.2.28
+++ ChangeLog 2005/09/24 13:04:16 1.758.2.29
@@ -1,3 +1,20 @@
+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.
+
+2005-09-24 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * objects-x.c (x_find_charset_font): Work around buggy return
+ value in FcInit().
+
+2005-09-24 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * objects-x.c: Improve various header comments.
+ (x_font_instance_truename): Remove obsolete #ifdef 0 code.
+
2005-09-12 Mike Alexander <mta(a)arbortext.com>
* intl-win32.c (mswindows_current_locale): Define in non-MULE
1.26.2.19 +146 -101 XEmacs/xemacs/src/objects-x.c
Index: objects-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/objects-x.c,v
retrieving revision 1.26.2.18
retrieving revision 1.26.2.19
diff -u -p -r1.26.2.18 -r1.26.2.19
--- objects-x.c 2005/04/18 03:51:18 1.26.2.18
+++ objects-x.c 2005/09/24 13:04:20 1.26.2.19
@@ -243,7 +243,7 @@ x_color_list (void)
going to #ifdef the return values defaulting to short. -- sjt
*/
-/* #### Do we need to properly implement Qxft_font_name_encoding? */
+/* Standard for fontconfig. Use a macro to show we're not guessing. */
#define Qxft_font_name_encoding Qutf_8
/* DEBUGGING STUFF */
@@ -518,7 +518,8 @@ x_finalize_font_instance (Lisp_Font_Inst
/* Determining the truename of a font is hard. (Big surprise.)
- This is almost not true for fontconfig. At least in theory, it is
+ This is not true for fontconfig. Each font has a (nearly) canonical
+ representation up to permutation of the order of properties. It is
possible to construct a name which exactly identifies the properties of
the current font. However, it is theoretically possible that there exists
another font with a super set of those properties that would happen to get
@@ -824,7 +825,6 @@ x_font_instance_truename (Lisp_Font_Inst
/* First, try an Xft font. */
if (NILP (FONT_INSTANCE_TRUENAME (f)) && FONT_INSTANCE_X_XFTFONT (f))
{
-#ifndef DO_FORMER_BIZARRE_GYMNASTICS
/* The font is already open, we just unparse. */
FcChar8 *res = FcNameUnparse (FONT_INSTANCE_X_XFTFONT (f)->pattern);
if (res)
@@ -840,65 +840,6 @@ x_font_instance_truename (Lisp_Font_Inst
Qnil, Qfont, errb);
/* used to return Qnil here */
}
-#else
- /* FORMER BIZARRE GYMNASTICS */
- int core;
- FcChar8* fcfont;
- FcPattern *pat = FONT_INSTANCE_X_XFTFONT (f)->pattern;
- FcResult res_xlfd = FcPatternGetString (pat, XFT_XLFD, 0, &fcfont);
- FcResult res_core = FcPatternGetBool (pat, XFT_CORE, 0, &core);
-
- /* #### boy this is broken!! FIXME!!
- Probably only makes sense in Xft v1. */
- if (res_xlfd == FcResultNoMatch || res_core == FcResultNoMatch || !core)
- /* #### should we test fcfont for something here? if so, what? */
- {
- /* we've got an Xft font! */
- FcChar8 *res = FcNameUnparse (pat);
- Lisp_Object name = (res ? make_string (res, strlen (res)) : Qnil);
- /* #### huh? device? Fc don' need no steekin' device! */
- Lisp_Object real_pat = Ffc_font_real_pattern (name, f->device);
- free (res);
-
- res = FcNameUnparse (XFCPATTERN_PTR(real_pat));
- if (res)
- {
- FONT_INSTANCE_TRUENAME (f) = make_string (res, strlen (res));
- free (res);
- return FONT_INSTANCE_TRUENAME (f);
- }
- else
- {
- maybe_signal_error (Qgui_error,
- "Couldn't unparse Xft font to truename",
- Qnil, Qfont, errb);
- /* used to return Qnil here */
- }
- }
- else if (res_xlfd == FcResultMatch && res_core == FcResultMatch)
- {
- FONT_INSTANCE_TRUENAME (f) =
- build_ext_string (truename_via_XListFonts (dpy,
- (Extbyte *) &fcfont[0]),
- Qx_font_name_encoding);
- return FONT_INSTANCE_TRUENAME (f);
- }
- else if (res_xlfd == FcResultTypeMismatch || res_core == FcResultTypeMismatch)
- { /* Now we're f.... */
- maybe_signal_error (Qgui_error,
- "Xft TypeMismatch while determining font truename",
- Qnil, Qfont, errb);
- /* used to return Qnil here */
- }
- /* we shouldn't have to worry about FcResultNoId */
- else
- { /* Now we're f.... */
- maybe_signal_error (Qgui_error,
- "Xft bogus status while determining font truename",
- Qnil, Qfont, errb);
- /* used to return Qnil here */
- }
-#endif /* DO_FORMER_BIZARRE_GYMNASTICS */
}
#endif /* USE_XFT */
@@ -1194,9 +1135,10 @@ mule_to_fc_charset (Lisp_Object cs)
struct charset_reporter {
Lisp_Object *charset;
- /* #### Mule-ize these strings? */
- Extbyte *language;
- FcChar8 *rfc3066;
+ /* #### Mule-ize these strings?
+ No hurry, this is a debug facility. */
+ Extbyte *language; /* ASCII, please */
+ FcChar8 *rfc3066; /* ASCII, please */
};
static struct charset_reporter charset_table[] =
@@ -1243,9 +1185,6 @@ x_find_charset_font (Lisp_Object device,
int count = 0;
const Extbyte *patternext;
Lisp_Object result = Qunbound;
-#ifdef USE_XFT
- FcBool waste;
-#endif
int i;
/* #### with Xft need to handle second stage here -- sjt
@@ -1269,22 +1208,27 @@ x_find_charset_font (Lisp_Object device,
gives language or repertoire coverage.
*/
- waste = FcInit ();
- if (!waste) /* I don't think this can fail */
- /* #### should we init in xft_fonts_init()
- and FcInitBringUpToDate() here? */
+ FcInit (); /* No-op if already initialized.
+ In fontconfig 2.3.2, this cannot return
+ failure, but that looks like a bug. We
+ check for it with FcGetCurrentConfig(),
+ which *can* fail. */
+ if (!FcConfigGetCurrent()) /* #### should we init in xft_fonts_init()
+ and FcInitBringUpToDate() here?
+ I think not. We should expose FcInit*
+ interfaces to LISP and decide when to
+ reinitialize intelligently. */
stderr_out ("Failed fontconfig initialization\n");
- else if (waste)
+ else
{
FcPattern *fontxft; /* long-lived, freed at end of this block */
FcResult fcresult;
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 @@ x_find_charset_font (Lisp_Object device,
{
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 @@ x_find_charset_font (Lisp_Object device,
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 @@ x_find_charset_font (Lisp_Object device,
[[ 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 @@ x_find_charset_font (Lisp_Object device,
}
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;
}
}