: asapien/signet

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
/* Minimal TrueType reader: just enough to embed a font and measure text. */
#ifndef SIGNET_TTF_H
#define SIGNET_TTF_H

#include <stddef.h>
#include <stdint.h>

struct ttf {
	uint8_t *data;
	size_t len;
	int units;		/* unitsPerEm */
	int ascent, descent;	/* hhea, font units; descent is negative */
	int bbox[4];
	int nglyphs, nhmetrics;
	uint32_t hmtx, cmap;	/* table / subtable offsets */
	int cmap_fmt;		/* 4 or 12 */
};

int ttf_load(struct ttf *, const char *path);
void ttf_free(struct ttf *);
uint16_t ttf_gid(const struct ttf *, uint32_t codepoint);
int ttf_advance(const struct ttf *, uint16_t gid);

#endif