APPROVE COMMIT sjt-xft
Index: src/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.758.2.8
diff -u -U0 -r1.758.2.8 ChangeLog
--- src/ChangeLog 11 Feb 2005 15:50:40 -0000 1.758.2.8
+++ src/ChangeLog 20 Feb 2005 14:41:59 -0000
@@ -0,0 +1,6 @@
+2005-02-20 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * objects-x.c (x_initialize_font_instance): Estimate average cell
+ width based on dimensions of "representative" string. Suppress
+ some excessive debug output. Get rid of spurious tests.
+
Index: src/objects-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/objects-x.c,v
retrieving revision 1.26.2.6
diff -u -r1.26.2.6 objects-x.c
--- src/objects-x.c 1 Feb 2005 15:46:56 -0000 1.26.2.6
+++ src/objects-x.c 20 Feb 2005 14:42:07 -0000
@@ -261,22 +261,29 @@
/* #### This shit is just plain wrong unless we have a character cell
font. It really hoses us on large repertoire Unicode fonts with
"double-width" characters. */
- /* #### We just init'ed the memory; these are all zero to start. */
- if (f->ascent < rf->ascent)
- f->ascent = rf->ascent;
- if (f->descent < rf->descent)
- f->descent = rf->descent;
- if (f->width < rf->max_advance_width)
- f->width = rf->max_advance_width;
- if (f->height < rf->height)
- f->height = rf->height;
+ f->ascent = rf->ascent;
+ f->descent = rf->descent;
+ {
+ /* This is an approximation that AFAIK only gets used to compute
+ cell size for estimating window dimensions. The test_string8
+ is an ASCII string whose characters should approximate the
+ distribution of widths expected in real text. */
+ static const char test_string8[] = "Mmneei";
+ static const int len = sizeof (test_string8) - 1;
+ XGlyphInfo glyphinfo;
+
+ XftTextExtents8 (dpy, rf, test_string8, len, &glyphinfo);
+ /* #### maybe should be glyphinfo.xOff - glyphinfo.x? */
+ f->width = glyphinfo.width/len + 1;
+ }
+ f->height = rf->height;
/* #### Is this right? See comment on proportional_p below. */
f->proportional_p = 1; /* we can't recognize monospaced fonts! */
- if (debug_xft > 1)
- stderr_out ("initialized ascent %d descent %d width %d height %d\n",
- f->ascent, f->descent, f->width, f->height);
if (debug_xft > 0)
+ stderr_out ("initialized metrics ascent %d descent %d width %d height %d\n",
+ f->ascent, f->descent, f->width, f->height);
+ if (debug_xft > 2) /* we also output on initialization of any font below */
stderr_out ("initialized Xft font %s\n", extname);
}
else
@@ -355,10 +362,13 @@
{
int n = 3, d = 5;
/* #### check for weirdness */
- if (n*f->height < d*f->width)
- stderr_out ("width of %s is %d, larger than %d/%d its height %d\n",
- extname, f->width, n, d, f->height);
- stderr_out ("initialized Xft font %s\n", extname);
+ if (n * f->height < d * f->width)
+ stderr_out ("font %s: width:height is %d:%d, larger than %d:%d\n",
+ extname, f->width, f->height, n, d);
+ if (f->height <= 0 || f->width <= 0)
+ stderr_out ("bogus dimensions of font %s: width = %d, height = %d\n",
+ extname, f->width, f->height);
+ stderr_out ("initialized font %s\n", extname);
}
#else
#undef rf
--
Institute of Policy and Planning Sciences
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Ask not how you can "do" free software business;
ask what your business can "do for" free software.