vtgl

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

Commit: d5c18740ce9988bee7af4361631a1bc663864372
Parent: 7799e7695bfe6f863c15a872c4549f7c73741d94
Author: Randy Palamar
Date:   Sun,  8 Dec 2024 16:37:54 -0700

glyph searching clean up

Diffstat:
Mfont.c | 34+++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/font.c b/font.c @@ -207,33 +207,29 @@ render_glyph(Arena *a, FontAtlas *fa, u32 cp, u32 font_id, enum face_style style i32 glyph_idx = 0; i32 font_idx = 0; - /* NOTE: first try the requested font id */ if (font_id < fa->nfonts && fa->fonts[font_id][style].buf) { glyph_idx = stbtt_FindGlyphIndex(fa->fonts[font_id][style].font_info, cp); - if (glyph_idx) - font_idx = font_id; + if (glyph_idx) font_idx = font_id; } - if (!glyph_idx) { - for (u32 i = 0; i < fa->nfonts; i++) { - u32 test_style = style; - if (!fa->fonts[i][test_style].buf) - test_style = FS_NORMAL; - glyph_idx = stbtt_FindGlyphIndex(fa->fonts[i][test_style].font_info, cp); - if (!glyph_idx) { - test_style = FS_NORMAL; - glyph_idx = stbtt_FindGlyphIndex(fa->fonts[i][test_style].font_info, cp); - } - if (glyph_idx) { - font_idx = i; - style = test_style; - break; - } + for (u32 i = 0; !glyph_idx && i < fa->nfonts; i++) { + u32 test_style = style; + if (!fa->fonts[i][test_style].buf) + test_style = FS_NORMAL; + glyph_idx = stbtt_FindGlyphIndex(fa->fonts[i][test_style].font_info, cp); + if (!glyph_idx) { + test_style = FS_NORMAL; + glyph_idx = stbtt_FindGlyphIndex(fa->fonts[i][test_style].font_info, cp); + } + if (glyph_idx) { + font_idx = i; + style = test_style; + break; } } - Font *f = &fa->fonts[font_idx][style]; + Font *f = &fa->fonts[font_idx][style]; f32 scale = f->stbtt_scale; i32 x0, y0, x1, y1, advance, left_bearing; stbtt_GetGlyphBitmapBoxSubpixel(f->font_info, glyph_idx, scale, scale, 0, 0,