]> git.eshelyaron.com Git - emacs.git/commitdiff
(xfont_open): Fix calculation of font->average_width.
authorKenichi Handa <handa@m17n.org>
Tue, 27 May 2008 01:45:00 +0000 (01:45 +0000)
committerKenichi Handa <handa@m17n.org>
Tue, 27 May 2008 01:45:00 +0000 (01:45 +0000)
src/ChangeLog
src/xfont.c

index e899db277bf58bd10874db3258add8e3ab7b9005..d72f1b54057ef014ba83e60df150b32e99b6fd3e 100644 (file)
@@ -1,3 +1,7 @@
+2008-05-27  Kenichi Handa  <handa@m17n.org>
+
+       * xfont.c (xfont_open): Fix calculation of font->average_width.
+
 2008-05-27  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * casefiddle.c (casify_object): Try to guess better whether the
index f84312413ca48c53b0cc9d5fff33ae94e3b8b4b9..e6f0bde5114b83d1c1e69e4ae9b7a7dc2e93573f 100644 (file)
@@ -613,8 +613,14 @@ xfont_open (f, entity, pixel_size)
          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;