mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-06 06:52:44 -07:00
fix parser handling of glyph shape freeing
This commit is contained in:
@@ -611,7 +611,7 @@ batch_generate_glyphs_draw_list :: proc ( draw_list : ^Draw_List,
|
|||||||
error : Allocator_Error
|
error : Allocator_Error
|
||||||
glyph.shape, error = parser_get_glyph_shape(entry.parser_info, shape.glyph[id])
|
glyph.shape, error = parser_get_glyph_shape(entry.parser_info, shape.glyph[id])
|
||||||
assert(error == .None)
|
assert(error == .None)
|
||||||
assert(glyph.shape != nil)
|
assert(len(glyph.shape) > 0)
|
||||||
|
|
||||||
generate_glyph_pass_draw_list( draw_list, & glyph_buffer.shape_gen_scratch,
|
generate_glyph_pass_draw_list( draw_list, & glyph_buffer.shape_gen_scratch,
|
||||||
glyph_pack[id].shape,
|
glyph_pack[id].shape,
|
||||||
@@ -621,7 +621,7 @@ batch_generate_glyphs_draw_list :: proc ( draw_list : ^Draw_List,
|
|||||||
glyph_pack[id].draw_transform.scale
|
glyph_pack[id].draw_transform.scale
|
||||||
)
|
)
|
||||||
|
|
||||||
assert(glyph.shape != nil)
|
assert(len(glyph.shape) > 0)
|
||||||
parser_free_shape(entry.parser_info, glyph.shape)
|
parser_free_shape(entry.parser_info, glyph.shape)
|
||||||
|
|
||||||
target_quad := & glyph_pack[id].draw_quad
|
target_quad := & glyph_pack[id].draw_quad
|
||||||
@@ -736,7 +736,7 @@ batch_generate_glyphs_draw_list :: proc ( draw_list : ^Draw_List,
|
|||||||
error : Allocator_Error
|
error : Allocator_Error
|
||||||
glyph.shape, error = parser_get_glyph_shape(entry.parser_info, shape.glyph[id])
|
glyph.shape, error = parser_get_glyph_shape(entry.parser_info, shape.glyph[id])
|
||||||
assert(error == .None)
|
assert(error == .None)
|
||||||
assert(glyph.shape != nil)
|
assert(len(glyph.shape) > 0)
|
||||||
|
|
||||||
// Render glyph to glyph render target (FBO)
|
// Render glyph to glyph render target (FBO)
|
||||||
generate_glyph_pass_draw_list( draw_list, & glyph_buffer.shape_gen_scratch,
|
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
|
glyph.draw_transform.scale
|
||||||
)
|
)
|
||||||
|
|
||||||
assert(glyph.shape != nil)
|
assert(len(glyph.shape) > 0)
|
||||||
parser_free_shape(entry.parser_info, glyph.shape)
|
parser_free_shape(entry.parser_info, glyph.shape)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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 )
|
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 )
|
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
|
stb_shape : [^]stbtt.vertex
|
||||||
nverts := stbtt.GetGlyphShape( font.stbtt_info, cast(i32) glyph_index, & stb_shape )
|
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.data = stb_shape
|
||||||
shape_raw.len = int(nverts)
|
shape_raw.len = int(nverts)
|
||||||
shape_raw.cap = int(nverts)
|
shape_raw.cap = int(nverts)
|
||||||
shape_raw.allocator = runtime.nil_allocator()
|
shape_raw.allocator = nil_allocator()
|
||||||
error = Allocator_Error.None
|
error = Allocator_Error.None
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user