diff options
Diffstat (limited to 'src/text.cc')
| -rw-r--r-- | src/text.cc | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/src/text.cc b/src/text.cc index cac4a42..b52e9fe 100644 --- a/src/text.cc +++ b/src/text.cc @@ -7,8 +7,8 @@ #include "cglm/types.h" #include "freetype/freetype.h" +#include "geometry.h" #include "hash.h" -#include "rendering.h" #include "utils.h" static bool wayc_font_cache_lookup(struct font_s* font, codepoint_t codepoint, @@ -18,12 +18,12 @@ static bool wayc_font_cache_lookup(struct font_s* font, codepoint_t codepoint, if (ok) *out = glyph; return ok; } - +/* static void wayc_font_cache_insert(struct font_s* font, codepoint_t codepoint, struct glyph_s glyph) { wayc_notnull(font); wayc_hashmap_insert(&font->cache, &codepoint, &glyph); -} +} */ enum font_context_error_e wayc_font_context_init(struct font_context_s* ctx) { wayc_notnull(ctx); @@ -76,13 +76,10 @@ enum font_error_e wayc_font_init(struct font_s* font, return FONT_ERROR_NONE; } -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) { +enum font_error_e wayc_font_lookup(struct font_s* font, codepoint_t codepoint, + struct glyph_s* out) { wayc_notnull(font); - wayc_notnull(atlas); wayc_notnull(out); - FT_Face face = font->face; bool found = wayc_font_cache_lookup(font, codepoint, out); @@ -98,29 +95,32 @@ enum font_error_e wayc_font_lookup(struct font_s* font, struct atlas_s* atlas, FT_Bitmap bitmap = slot->bitmap; if (bitmap.pitch != (i32)bitmap.width) wayc_panic("unsupported pitch"); + /* ivec2 size = {(i32)bitmap.width, (i32)bitmap.rows}; - ivec2 uv0; + ivec2 uv0; - bool ok = wayc_atlas_packer_allocate(packer, WAYC_X(size), WAYC_Y(size), uv0); - if (!ok) return FONT_ERROR_ATLAS_FULL; + bool ok = wayc_atlas_packer_allocate(packer, WAYC_X(size), WAYC_Y(size), + uv0); if (!ok) return FONT_ERROR_ATLAS_FULL; - ok = wayc_atlas_set(atlas, IMAGE_DATA_TYPE_UNSIGNED_BYTE, uv0, WAYC_X(size), - WAYC_Y(size), IMAGE_FORMAT_RED_ALIGNMENT, bitmap.buffer); - if (!ok) return FONT_ERROR_ATLAS_FULL; + ok = wayc_atlas_set(atlas, IMAGE_DATA_TYPE_UNSIGNED_BYTE, uv0, WAYC_X(size), + WAYC_Y(size), IMAGE_FORMAT_RED_ALIGNMENT, + bitmap.buffer); if (!ok) return FONT_ERROR_ATLAS_FULL; - struct glyph_s glyph = {}; - glyph.bearing_x = slot->bitmap_left; - glyph.bearing_y = slot->bitmap_top; - glyph.advance = (f32)slot->advance.x / WAYC_SCALE; + struct glyph_s glyph = {}; + glyph.bearing_x = slot->bitmap_left; + glyph.bearing_y = slot->bitmap_top; + glyph.advance = (f32)slot->advance.x / WAYC_SCALE; - glyph.uv0[0] = uv0[0]; - glyph.uv0[1] = uv0[1]; - glyph.uv1[0] = uv0[0] + size[0]; - glyph.uv1[1] = uv0[1] + size[1]; + glyph.uv0[0] = uv0[0]; + glyph.uv0[1] = uv0[1]; + glyph.uv1[0] = uv0[0] + size[0]; + glyph.uv1[1] = uv0[1] + size[1]; - wayc_font_cache_insert(font, codepoint, glyph); + wayc_font_cache_insert(font, codepoint, glyph); + *out = glyph; - *out = glyph; + */ + wayc_panic("Atlas packing not implemented yet"); return FONT_ERROR_NONE; } @@ -131,7 +131,7 @@ void wayc_font_deinit(struct font_s* font) { FT_Done_Face(font->face); mi_free(font->data); } - +/* static void wayc_text_assemble_one(const struct glyph_s* glyph, vec2* pen, f32 atlas_width, f32 atlas_height, struct text_vertex_s* out_verts, @@ -167,7 +167,7 @@ static void wayc_text_assemble_one(const struct glyph_s* glyph, vec2* pen, #pragma GCC unroll 6 for (usize i = 0; i < WAYC_QUAD_NINDICES; ++i) out_indices[i] = base + (text_index_t)quad.indices[i]; -} +} */ enum text_error_e wayc_text_assemble(struct text_s* text, usize* out_size, text_index_t** out_indices, @@ -177,8 +177,8 @@ enum text_error_e wayc_text_assemble(struct text_s* text, usize* out_size, wayc_notnull(out_indices); wayc_notnull(out_verts); + /* bool success = false; - usize glyph_count = wayc_string_length(&text->string); usize vertex_count = glyph_count * WAYC_QUAD_NVERTS; @@ -225,5 +225,7 @@ enum text_error_e wayc_text_assemble(struct text_s* text, usize* out_size, *out_verts = vertices; success = true; + */ + wayc_panic("Text assembly not implemented yet"); return TEXT_ERROR_NONE; }
\ No newline at end of file |
