blob: a594add86e154b5068ef6eb597b1ef4efb9427f3 (
plain)
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
39
40
41
42
43
|
#pragma once
#include <filesystem>
#include <stb_truetype.h>
struct MonoBitmap {
int32_t width;
int32_t height;
std::unique_ptr<uint8_t> pixels;
};
struct Glyph {
int32_t xoff;
int32_t yoff;
int32_t xadvance;
MonoBitmap bitmap;
};
class Font {
public:
~Font();
bool Init(const char* path, int font_size);
void Deinit();
void LoadGlyph(Glyph& glyph, uint32_t codepoint);
private:
const char* m_file_content = nullptr;
float m_font_scale;
int m_font_baseline;
int m_font_yadvance;
stbtt_fontinfo m_font_info;
Glyph m_glyphs['~' - ' ' + 1];
};
|