vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: 1380c3667211e7147d30210f418a18c8f237a630
Parent: 9259573432ade2a81bafc3a538ca1e0989576866
Author: Randy Palamar
Date:   Mon,  2 Sep 2024 15:42:33 -0600

font.c: fixing FontAtlas glyph size rounding

The scale value is fractional so these need to be properly rounded
otherwise some glyphs will overflow their cells ('g', ',' for
vertical overflow; 'W' for horizontal overflow).

Diffstat:
Mfont.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/font.c b/font.c @@ -187,10 +187,10 @@ update_font_metrics(FontAtlas *fa) { i32 x0, x1, y0, y1; stbtt_GetFontBoundingBox(&fa->fonts[0][FS_NORMAL].font_info, &x0, &y0, &x1, &y1); - f32 scale = fa->fonts[0][FS_NORMAL].stbtt_scale; - fa->size.h = scale * (y1 - y0); - fa->size.w = scale * (x1 - x0); - fa->deltay = -scale * y0; + f32 scale = fa->fonts[0][FS_NORMAL].stbtt_scale; + fa->size.h = scale * (y1 - y0) + 0.5; + fa->size.w = scale * (x1 - x0) + 0.5; + fa->deltay = -scale * y0 + 0.5; } static void