changeset 95330:fe15ab9a9bc7

(xfont_open): Fix calculation of font->average_width.
author Kenichi Handa <handa@m17n.org>
date Tue, 27 May 2008 01:43:27 +0000
parents 3bf215f97a31
children 40d6367d8bf8
files src/xfont.c
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/xfont.c	Tue May 27 01:13:25 2008 +0000
+++ b/src/xfont.c	Tue May 27 01:43:27 2008 +0000
@@ -613,8 +613,14 @@
 	  for (char2b.byte2 = 33; char2b.byte2 <= 126; char2b.byte2++)
 	    if ((pcm = xfont_get_pcm (xfont, &char2b)) != NULL)
 	      width += pcm->width, n++;
-	  font->average_width = width / n;
+	  if (n > 0)
+	    font->average_width = width / n;
 	}
+      if (font->average_width == 0)
+	/* No easy way other than this to get a reasonable
+	   average_width.  */
+	font->average_width
+	  = (xfont->min_bounds.width + xfont->max_bounds.width) / 2;
     }
 
   BLOCK_INPUT;