summaryrefslogtreecommitdiff
path: root/src/text.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/text.cc')
-rw-r--r--src/text.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/text.cc b/src/text.cc
index e6ce175..b703ad1 100644
--- a/src/text.cc
+++ b/src/text.cc
@@ -5,6 +5,7 @@
#include "atlas.h"
#include "freetype/freetype.h"
+#include "hash.h"
#include "shaders.h"
#include "utils.h"
@@ -134,14 +135,32 @@ enum font_error_e wayc_font_init(struct font_s* font,
font->face = face;
font->font_size = font_size;
font->atlas = atlas;
+ wayc_hashmap_init(&font->cached);
success = true;
return FONT_ERROR_NONE;
}
+enum font_error_e wayc_font_render(struct font_s* font, codepoint_t codepoint,
+ struct glyph_s* glyph) {
+ wayc_notnull(font);
+ wayc_notnull(glyph);
+
+ struct glyph_s cached;
+ if (wayc_hashmap_get(&font->cached, &codepoint, &cached)) {
+ *glyph = cached;
+ return FONT_ERROR_NONE;
+ }
+
+
+
+ return FONT_ERROR_NONE;
+}
+
void wayc_font_deinit(struct font_s* font) {
wayc_notnull(font);
+ wayc_hashmap_deinit(&font->cached);
wayc_atlas_deinit(&font->atlas);
FT_Done_Face(font->face);
}