From e8a7b21eba415489d67d2e0323bfd1b3d6392833 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 11 Jan 2025 17:31:21 -0500 Subject: [PATCH] fix parser handling of glyph shape freeing --- vefontcache/draw.odin | 8 ++++---- vefontcache/parser.odin | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/vefontcache/draw.odin b/vefontcache/draw.odin index a85f1b6..8191304 100644 --- a/vefontcache/draw.odin +++ b/vefontcache/draw.odin @@ -611,7 +611,7 @@ batch_generate_glyphs_draw_list :: proc ( draw_list : ^Draw_List, error : Allocator_Error glyph.shape, error = parser_get_glyph_shape(entry.parser_info, shape.glyph[id]) assert(error == .None) - assert(glyph.shape != nil) + assert(len(glyph.shape) > 0) generate_glyph_pass_draw_list( draw_list, & glyph_buffer.shape_gen_scratch, glyph_pack[id].shape, @@ -621,7 +621,7 @@ batch_generate_glyphs_draw_list :: proc ( draw_list : ^Draw_List, glyph_pack[id].draw_transform.scale ) - assert(glyph.shape != nil) + assert(len(glyph.shape) > 0) parser_free_shape(entry.parser_info, glyph.shape) target_quad := & glyph_pack[id].draw_quad @@ -736,7 +736,7 @@ batch_generate_glyphs_draw_list :: proc ( draw_list : ^Draw_List, error : Allocator_Error glyph.shape, error = parser_get_glyph_shape(entry.parser_info, shape.glyph[id]) assert(error == .None) - assert(glyph.shape != nil) + assert(len(glyph.shape) > 0) // Render glyph to glyph render target (FBO) generate_glyph_pass_draw_list( draw_list, & glyph_buffer.shape_gen_scratch, @@ -747,7 +747,7 @@ batch_generate_glyphs_draw_list :: proc ( draw_list : ^Draw_List, glyph.draw_transform.scale ) - assert(glyph.shape != nil) + assert(len(glyph.shape) > 0) parser_free_shape(entry.parser_info, glyph.shape) } diff --git a/vefontcache/parser.odin b/vefontcache/parser.odin index 666f058..0d1eca8 100644 --- a/vefontcache/parser.odin +++ b/vefontcache/parser.odin @@ -126,7 +126,9 @@ parser_find_glyph_index :: #force_inline proc "contextless" ( font : Parser_Font parser_free_shape :: #force_inline proc( font : Parser_Font_Info, shape : Parser_Glyph_Shape ) { - stbtt.FreeShape( font.stbtt_info, transmute( [^]stbtt.vertex) raw_data(shape) ) + shape := shape + shape_raw := transmute( ^Raw_Dynamic_Array) & shape + stbtt.FreeShape( font.stbtt_info, transmute( [^]stbtt.vertex) shape_raw.data ) } parser_get_codepoint_horizontal_metrics :: #force_inline proc "contextless" ( font : Parser_Font_Info, codepoint : rune ) -> ( advance, to_left_side_glyph : i32 ) @@ -166,11 +168,11 @@ parser_get_glyph_shape :: #force_inline proc ( font : Parser_Font_Info, glyph_in stb_shape : [^]stbtt.vertex nverts := stbtt.GetGlyphShape( font.stbtt_info, cast(i32) glyph_index, & stb_shape ) - shape_raw := transmute( ^runtime.Raw_Dynamic_Array) & shape + shape_raw := transmute( ^Raw_Dynamic_Array) & shape shape_raw.data = stb_shape shape_raw.len = int(nverts) shape_raw.cap = int(nverts) - shape_raw.allocator = runtime.nil_allocator() + shape_raw.allocator = nil_allocator() error = Allocator_Error.None return }