vtgl

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

Commit: ba6c29c8d28fe4e5d7dc216915828e71f0e39e58
Parent: 9e22de408da34435d16f3a204e1d63ad8a900e0c
Author: Randy Palamar
Date:   Tue, 22 Oct 2024 16:52:51 -0600

check '_' to make sure reported font width is valid

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

diff --git a/font.c b/font.c @@ -267,6 +267,12 @@ font_atlas_update(FontAtlas *fa, iv2 glyph_bitmap_dim) fa->info.w = (u32)(scale * (x1 - x0)) + 1; fa->info.baseline = (u32)(-scale * y0) + 1; + /* NOTE: sometimes the reported width is wrong; try '_' which is often the widest char */ + i32 glyph_idx = stbtt_FindGlyphIndex(&font->font_info, '_'); + stbtt_GetGlyphBitmapBoxSubpixel(&font->font_info, glyph_idx, scale, scale, 0, 0, + &x0, &y0, &x1, &y1); + if (x1 - x0 > fa->info.w) fa->info.w = x1 - x0; + gc->tiles_in_x = (glyph_bitmap_dim.x - 1) / fa->info.w - 1; gc->tiles_in_y = (glyph_bitmap_dim.y - 1) / fa->info.h - 1;