diff options
author | fschildt <florian.schildt@protonmail.com> | 2025-08-22 15:23:11 +0200 |
---|---|---|
committer | fschildt <florian.schildt@protonmail.com> | 2025-08-22 15:23:11 +0200 |
commit | 2050c0e0576f05156f192aa4caf48834d2f28b14 (patch) | |
tree | ee58bd35b0df0a1bacfbc9700ed99ce80c99294e /src/client/font.h |
Diffstat (limited to 'src/client/font.h')
-rw-r--r-- | src/client/font.h | 41 |
1 files changed, 41 insertions, 0 deletions
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 <basic/basic.h> +#include <basic/string32.h> + +#include <stb/stb_truetype.h> + +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 |