mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-06 06:52:44 -07:00
Reduce shape cache reserve length, possible improvemnet in positioning in draw_text_batch, shape_text_uncached
This commit is contained in:
@@ -1,11 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
A port of (https://github.com/hypernewbie/VEFontCache) to Odin.
|
A port of (https://github.com/hypernewbie/VEFontCache) to Odin.
|
||||||
|
|
||||||
Changes:
|
See: https://github.com/Ed94/VEFontCache-Odin
|
||||||
- Font Parser & Glyph Shaper are abstracted to their own interface
|
|
||||||
- Font Face parser info stored separately from entries
|
|
||||||
- ve_fontcache_loadfile not ported (just use odin's core:os or os2), then call load_font
|
|
||||||
- Macro defines have been made (mostly) into runtime parameters
|
|
||||||
*/
|
*/
|
||||||
package VEFontCache
|
package VEFontCache
|
||||||
|
|
||||||
@@ -130,7 +126,7 @@ InitShapeCacheParams :: struct {
|
|||||||
|
|
||||||
InitShapeCacheParams_Default :: InitShapeCacheParams {
|
InitShapeCacheParams_Default :: InitShapeCacheParams {
|
||||||
capacity = 8 * 1024,
|
capacity = 8 * 1024,
|
||||||
reserve_length = 1 * 1024,
|
reserve_length = 256,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ve_fontcache_init
|
// ve_fontcache_init
|
||||||
|
@@ -29,6 +29,7 @@ DrawList :: struct {
|
|||||||
calls : [dynamic]DrawCall,
|
calls : [dynamic]DrawCall,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(Ed): This was a rough translation of the raw values the orignal was using, need to give better names...
|
||||||
FrameBufferPass :: enum u32 {
|
FrameBufferPass :: enum u32 {
|
||||||
None = 0,
|
None = 0,
|
||||||
Glyph = 1,
|
Glyph = 1,
|
||||||
@@ -489,8 +490,8 @@ draw_text_batch :: proc(ctx: ^Context, entry: ^Entry, shaped: ^ShapedText,
|
|||||||
// Draw cacxhed glyph
|
// Draw cacxhed glyph
|
||||||
slot_position, _ := atlas_bbox( atlas, region_kind, atlas_index )
|
slot_position, _ := atlas_bbox( atlas, region_kind, atlas_index )
|
||||||
glyph_scale := bounds_size * entry.size_scale + glyph_padding
|
glyph_scale := bounds_size * entry.size_scale + glyph_padding
|
||||||
bounds_0_scaled := ceil( vbounds_0 * entry.size_scale )
|
bounds_0_scaled := ceil(vbounds_0 * entry.size_scale)
|
||||||
dst := glyph_translate + (bounds_0_scaled - glyph_padding) * scale
|
dst := glyph_translate + bounds_0_scaled * scale
|
||||||
dst_scale := glyph_scale * scale
|
dst_scale := glyph_scale * scale
|
||||||
textspace_x_form( & slot_position, & glyph_scale, atlas_size )
|
textspace_x_form( & slot_position, & glyph_scale, atlas_size )
|
||||||
|
|
||||||
|
@@ -111,7 +111,7 @@ shape_text_uncached :: proc( ctx : ^Context, font : FontID, text_utf8 : string,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if abs( entry.size ) <= Advance_Snap_Smallfont_Size {
|
if abs( entry.size ) <= Advance_Snap_Smallfont_Size {
|
||||||
position.x = ceil( position.x )
|
position.x = position.x
|
||||||
}
|
}
|
||||||
|
|
||||||
append( & output.glyphs, parser_find_glyph_index( & entry.parser_info, codepoint ))
|
append( & output.glyphs, parser_find_glyph_index( & entry.parser_info, codepoint ))
|
||||||
@@ -122,14 +122,14 @@ shape_text_uncached :: proc( ctx : ^Context, font : FontID, text_utf8 : string,
|
|||||||
position.y
|
position.y
|
||||||
})
|
})
|
||||||
|
|
||||||
position.x += f32(advance) * entry.size_scale
|
position.x += ceil(f32(advance) * entry.size_scale)
|
||||||
prev_codepoint = codepoint
|
prev_codepoint = codepoint
|
||||||
}
|
}
|
||||||
|
|
||||||
output.end_cursor_pos = position
|
output.end_cursor_pos = position
|
||||||
max_line_width = max(max_line_width, position.x)
|
max_line_width = max(max_line_width, position.x)
|
||||||
|
|
||||||
output.size.x = max_line_width
|
output.size.x = ceil(max_line_width)
|
||||||
output.size.y = f32(line_count) * line_height
|
output.size.y = f32(line_count) * line_height
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user