master uint/maus / include / maus_font.h
 1#ifndef MAUS_FONT_H
 2#define MAUS_FONT_H
 3
 4#include <stdint.h>
 5#include <stdbool.h>
 6
 7#include "maus.h"
 8
 9#define MAUS_BDF_GLYPHS_MAX 256
10
11typedef struct {
12    uint8_t*    bmp;
13    uint16_t    w;
14    uint16_t    h;
15    int16_t     xoff;
16    int16_t     yoff;
17    uint16_t    adv;
18    bool        valid;
19} MausGlyph;
20
21typedef struct {
22    MausGlyph glyphs[MAUS_BDF_GLYPHS_MAX];
23    int32_t     asc;
24    int32_t     dsc;
25    int32_t     cellh;
26    int32_t     cellw;
27} MausFont;
28
29/* Loops through text passing parameters to glyph drawer */
30void maus_draw_text(Maus* mw, MausFont* font, int32_t x, int32_t y,
31                    const char* text, MausColor col);
32
33/* load a bdf font into MausFont. returns NULL on fail */
34MausFont* maus_font_load(const char* path);
35
36/* release all allocations made with a MausFont */
37void maus_font_free(MausFont* font);
38
39#endif /* MAUS_FONT_H */
40