From e40037fd7a922132015340a758468cb5dec71096 Mon Sep 17 00:00:00 2001 From: Fabrice Date: Fri, 13 Feb 2026 07:09:38 +0100 Subject: rasterizing and caching --- src/text.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/text.h') diff --git a/src/text.h b/src/text.h index 4dd495b..c93f968 100644 --- a/src/text.h +++ b/src/text.h @@ -33,15 +33,27 @@ enum font_context_error_e wayc_font_context_init( void wayc_font_context_deinit(struct font_context_s* context); struct glyph_s { + vec2 uv0, uv1; vec2 bearing; - vec2 size; - vec2 uv; + f32 advance; }; +static inline void glyph_print(struct glyph_s* glyph) { + u32 uv0x = WAYC_X(glyph->uv0); + u32 uv0y = WAYC_Y(glyph->uv0); + u32 uv1x = WAYC_X(glyph->uv1); + u32 uv1y = WAYC_Y(glyph->uv1); + fprintf(stderr, + "uv0: (%u, %u), uv1: (%u, %u), bearing: (%f, %f), advance: %f\n", + uv0x, uv0y, uv1x, uv1y, WAYC_X(glyph->bearing), + WAYC_Y(glyph->bearing), glyph->advance); +} + enum font_error_e : u8 { FONT_ERROR_NONE = 0, FONT_ERROR_LOAD_FACE, FONT_ERROR_ATLAS_FAILED, + FONT_ERROR_LOAD_GLYPH, }; struct font_s { @@ -58,4 +70,9 @@ enum font_error_e wayc_font_init(struct font_s* font, u32 atlas_width, u32 atlas_height); enum font_error_e wayc_font_render(struct font_s* font, codepoint_t codepoint, struct glyph_s* glyph); +static inline enum font_error_e wayc_font_flush(struct font_s* font) { + enum atlas_error_e atlas_err = wayc_atlas_flush(&font->atlas); + return atlas_err == ATLAS_ERROR_NONE ? FONT_ERROR_NONE + : FONT_ERROR_ATLAS_FAILED; +} void wayc_font_deinit(struct font_s* font); -- cgit v1.2.3