mirror of
https://github.com/LukeSmithxyz/st.git
synced 2024-11-25 16:35:46 +01:00
st: Fix off-by-one error when calculating character width.
LEN(str) is one larger than strlen(str) because it also counts the zero terminator. The original code would include the .notdef glyph (since it'll try to encode character 0, which gets encoded to the .notdef glyph) when measuring the average dimensions of printable ascii characters. This causes problems with fonts like GNU Unifont where the .notdef glyph is not the same width as the usual half-width characters. Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
parent
0e48a1995e
commit
39964614b7
1 changed files with 2 additions and 2 deletions
4
st.c
4
st.c
|
@ -3291,7 +3291,7 @@ xloadfont(Font *f, FcPattern *pattern)
|
||||||
|
|
||||||
XftTextExtentsUtf8(xw.dpy, f->match,
|
XftTextExtentsUtf8(xw.dpy, f->match,
|
||||||
(const FcChar8 *) ascii_printable,
|
(const FcChar8 *) ascii_printable,
|
||||||
LEN(ascii_printable), &extents);
|
strlen(ascii_printable), &extents);
|
||||||
|
|
||||||
f->set = NULL;
|
f->set = NULL;
|
||||||
f->pattern = FcPatternDuplicate(pattern);
|
f->pattern = FcPatternDuplicate(pattern);
|
||||||
|
@ -3302,7 +3302,7 @@ xloadfont(Font *f, FcPattern *pattern)
|
||||||
f->rbearing = f->match->max_advance_width;
|
f->rbearing = f->match->max_advance_width;
|
||||||
|
|
||||||
f->height = f->ascent + f->descent;
|
f->height = f->ascent + f->descent;
|
||||||
f->width = DIVCEIL(extents.xOff, LEN(ascii_printable));
|
f->width = DIVCEIL(extents.xOff, strlen(ascii_printable));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue