From 2050c0e0576f05156f192aa4caf48834d2f28b14 Mon Sep 17 00:00:00 2001 From: fschildt Date: Fri, 22 Aug 2025 15:23:11 +0200 Subject: first commit --- src/client/font.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/client/font.h (limited to 'src/client/font.h') diff --git a/src/client/font.h b/src/client/font.h new file mode 100644 index 0000000..19ad31e --- /dev/null +++ b/src/client/font.h @@ -0,0 +1,41 @@ +#ifndef FONT_H +#define FONT_H + +#include +#include + +#include + +typedef struct { + i32 width; + i32 height; + union { + u32 *rgba; + u8 *grayscale; + } data; +} Bitmap; + +typedef struct { + f32 xoff; + f32 yoff; + f32 advance_width; + Bitmap bitmap; +} Glyph; + +typedef struct { + Arena arena; + stbtt_fontinfo info; + f32 scale; + i32 baseline; + i32 y_advance; + Glyph glyphs[96]; +} Font; + + +b32 font_init(Font *font, char *path, int font_size); +Glyph* font_get_glyph(Font *font, u32 codepoint); +f32 font_get_string32_width(Font *font, String32 *str); +f32 font_get_string32_cursor_xoff(Font *font, String32 *str, u32 cursor); +f32 font_get_height(Font *font); + +#endif // FONT_H -- cgit v1.2.3