diff options
| author | fschildt <florian.schildt@protonmail.com> | 2025-08-22 15:23:11 +0200 | 
|---|---|---|
| committer | fschildt <florian.schildt@protonmail.com> | 2025-10-15 11:33:23 +0200 | 
| commit | 04e4627e6c11254ee6f49edf5feb1b8d711da41a (patch) | |
| tree | e28f2e62d3e1b83f9686cdeb102e3f47379e6793 /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  | 
