-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfont.hh
39 lines (32 loc) · 1.21 KB
/
font.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include "map-file.hh"
#include <string>
#include <stdexcept>
#include <cstdint> // for std::uint32_t
#include <vector>
#include "image.hh"
namespace tue
{
struct font
{
//XXX: vvvv COPIED FROM stb_truetype ------------------------------
//XXX: vvvv DO NOT TOUCH ------------------------------------------
void * userdata;
unsigned char * data; // pointer to .ttf file
int fontstart; // offset of start of font
int numGlyphs; // number of glyphs, needed for range checking
int loca,head,glyf,hhea,hmtx,kern; // table locations as offset from start of .ttf
int index_map; // a cmap mapping for our chosen character encoding
int indexToLocFormat; // format needed to map from glyph index to glyph
//XXX: ^^^^ COPIED FROM stb_truetype ------------------------------
//XXX: ^^^^ DO NOT TOUCH ------------------------------------------
font(std::string const& path, int index=0);
image render(std::uint32_t codepoint, int height=16);
private:
file_map::uptr file;
};
inline namespace font_exceptions
{
struct parse_failure : std::runtime_error { using runtime_error::runtime_error; };
};
}