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
44
45
46
47
48
49
50
|
#pragma once
#include "cglm/types.h"
#include "freetype/freetype.h"
#include "hash.h"
#include "rendering.h"
#include "utils.h"
typedef u32 codepoint_t;
enum font_context_error_e {
FONT_CONTEXT_ERROR_NONE,
FONT_CONTEXT_ERROR_LIBRARY,
};
struct font_context_s {
FT_Library library;
};
enum font_context_error_e wayc_font_context_init(struct font_context_s* ctx);
void wayc_font_context_deinit(struct font_context_s* ctx);
struct glyph_s {
ivec2 uv0, uv1;
i32 bearing_x, bearing_y;
f32 advance;
};
enum font_error_e {
FONT_ERROR_NONE,
FONT_ERROR_FILE_LOAD,
FONT_ERROR_FONT_LOAD,
FONT_ERROR_NOT_MATCH,
FONT_ERROR_ATLAS_FULL,
};
struct font_s {
u8* data;
FT_Face face;
struct hashmap_s<codepoint_t, struct glyph_s> cache;
};
enum font_error_e wayc_font_init(struct font_s* font,
struct font_context_s* ctx, u32 fsize,
const char* path);
enum font_error_e wayc_font_lookup(struct font_s* font, struct atlas_s* atlas,
struct atlas_packer_s* packer,
codepoint_t codepoint, struct glyph_s* out);
void wayc_font_deinit(struct font_s* font);
|