# HG changeset patch # User Kenichi Handa # Date 1211852607 0 # Node ID fe15ab9a9bc773c1956a793cf6972aa8a927fc0c # Parent 3bf215f97a31fb841eb83186e59523b5b771677d (xfont_open): Fix calculation of font->average_width. diff -r 3bf215f97a31 -r fe15ab9a9bc7 src/xfont.c --- 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;