19 lines808 BC
1#ifndef FONT_H
2#define FONT_H
3
4#include <stdint.h>
5
6enum { FONT_REGULAR, FONT_MEDIUM, FONT_BOLD, FONT_COUNT };
7
8int font_init(void); // 0 if the bundled fonts are missing
9// draws UTF-8 text with its top at y; cut with "…" past maxw (0: no limit). Returns the width.
10int font_draw(int font, int px, int x, int y, const char *s, uint32_t argb, int maxw);
11int font_width(int font, int px, const char *s);
12int font_line_height(int font, int px);
13// draws text centred on cx
14int font_draw_center(int font, int px, int cx, int y, const char *s, uint32_t argb, int maxw);
15void font_draw_glyph_centered(int font, int px, int cx, int cy, const char *ch, uint32_t argb);
16int font_draw_right(int font, int px, int rx, int y, const char *s, uint32_t argb);
17void font_flush(void); // forget the cached glyphs
18
19#endif