User: stephent
Date: 05/02/20 15:46:52
Modified: xemacs/src Tag: sjt-xft ChangeLog objects-x.c
Log:
sane character width estimate <87is4n8f4q.fsf(a)tleepslib.sk.tsukuba.ac.jp>
Revision Changes Path
No revision
No revision
1.758.2.9 +6 -0 XEmacs/xemacs/src/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.758.2.8
retrieving revision 1.758.2.9
diff -u -r1.758.2.8 -r1.758.2.9
--- ChangeLog 2005/02/11 15:50:40 1.758.2.8
+++ ChangeLog 2005/02/20 14:46:46 1.758.2.9
@@ -1,3 +1,9 @@
+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.
+
2005-02-11 Eric Knauel <eric(a)xemacs.org>
* xft-fonts.c: throw away old code that was wrapped inside
1.26.2.7 +26 -16 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.6
retrieving revision 1.26.2.7
diff -u -r1.26.2.6 -r1.26.2.7
--- objects-x.c 2005/02/01 15:46:56 1.26.2.6
+++ objects-x.c 2005/02/20 14:46:49 1.26.2.7
@@ -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
Show replies by date