ist: Fix off-by-one error when calculating character width. - st - Simple Terminal Err gopher.r-36.net 70 i Err gopher.r-36.net 70 1Log /scm/st//log.gph gopher.r-36.net 70 1Files /scm/st//files.gph gopher.r-36.net 70 1Refs /scm/st//refs.gph gopher.r-36.net 70 1README /scm/st//file/README.gph gopher.r-36.net 70 1LICENSE /scm/st//file/LICENSE.gph gopher.r-36.net 70 i--- Err gopher.r-36.net 70 1commit 39964614b742c4ec98a326762d98470cb987a45b /scm/st//commit/39964614b742c4ec98a326762d98470cb987a45b.gph gopher.r-36.net 70 1parent 0e48a1995eee1c2babc58523ef0be296e4b1c3e8 /scm/st//commit/0e48a1995eee1c2babc58523ef0be296e4b1c3e8.gph gopher.r-36.net 70 hAuthor: Tor Andersson URL:mailto:tor@ccxvii.net gopher.r-36.net 70 iDate: Wed, 9 Mar 2016 17:11:57 +0100 Err gopher.r-36.net 70 i Err gopher.r-36.net 70 ist: Fix off-by-one error when calculating character width. Err gopher.r-36.net 70 i Err gopher.r-36.net 70 iLEN(str) is one larger than strlen(str) because it also counts the zero Err gopher.r-36.net 70 iterminator. The original code would include the .notdef glyph (since it'll Err gopher.r-36.net 70 itry to encode character 0, which gets encoded to the .notdef glyph) when Err gopher.r-36.net 70 imeasuring the average dimensions of printable ascii characters. Err gopher.r-36.net 70 i Err gopher.r-36.net 70 iThis causes problems with fonts like GNU Unifont where the .notdef glyph is Err gopher.r-36.net 70 inot the same width as the usual half-width characters. Err gopher.r-36.net 70 i Err gopher.r-36.net 70 iSigned-off-by: Christoph Lohmann <20h@r-36.net> Err gopher.r-36.net 70 i Err gopher.r-36.net 70 iDiffstat: Err gopher.r-36.net 70 i st.c | 4 ++-- Err gopher.r-36.net 70 i Err gopher.r-36.net 70 i1 file changed, 2 insertions(+), 2 deletions(-) Err gopher.r-36.net 70 i--- Err gopher.r-36.net 70 1diff --git a/st.c b/st.c /scm/st//file/st.c.gph gopher.r-36.net 70 i@@ -3291,7 +3291,7 @@ xloadfont(Font *f, FcPattern *pattern) Err gopher.r-36.net 70 i Err gopher.r-36.net 70 i XftTextExtentsUtf8(xw.dpy, f->match, Err gopher.r-36.net 70 i (const FcChar8 *) ascii_printable, Err gopher.r-36.net 70 i- LEN(ascii_printable), &extents); Err gopher.r-36.net 70 i+ strlen(ascii_printable), &extents); Err gopher.r-36.net 70 i Err gopher.r-36.net 70 i f->set = NULL; Err gopher.r-36.net 70 i f->pattern = FcPatternDuplicate(pattern); Err gopher.r-36.net 70 i@@ -3302,7 +3302,7 @@ xloadfont(Font *f, FcPattern *pattern) Err gopher.r-36.net 70 i f->rbearing = f->match->max_advance_width; Err gopher.r-36.net 70 i Err gopher.r-36.net 70 i f->height = f->ascent + f->descent; Err gopher.r-36.net 70 i- f->width = DIVCEIL(extents.xOff, LEN(ascii_printable)); Err gopher.r-36.net 70 i+ f->width = DIVCEIL(extents.xOff, strlen(ascii_printable)); Err gopher.r-36.net 70 i Err gopher.r-36.net 70 i return 0; Err gopher.r-36.net 70 i } Err gopher.r-36.net 70 .