General improvements (text and features)

* Added clear_atlas_region_caches & clear_shape_cache to VEFontCache (Usage Example: On hot-reloads to force refresh the caches if tuning the library)
* Made glyph_draw's over_sample a vec2 for initialization (incase user wants to do some float value multiple of 4x4)
* ADVANCE_SNAP_SMALLFONT_SIZE made a runtime option: Shaper_Context.adv_snap_small_font_threshold
* Some improvement to text hinting and general rendering of text
* Better defaults for initialization of the library
This commit is contained in:
2024-12-29 18:27:46 -05:00
parent 55a4c3dee6
commit 90ca01bdaa
8 changed files with 177 additions and 91 deletions

View File

@@ -74,7 +74,7 @@ shape_text_uncached :: proc( ctx : ^Context, font : Font_ID, text_utf8 : string,
line_gap := f32(line_gap_i32)
line_height := (ascent - descent + line_gap) * entry.size_scale
if ctx.text_shape_adv
if ctx.use_advanced_shaper
{
shaper_shape_from_text( & ctx.shaper_ctx, & entry.shaper_info, output, text_utf8, ascent_i32, descent_i32, line_gap_i32, entry.size, entry.size_scale )
return
@@ -106,22 +106,19 @@ shape_text_uncached :: proc( ctx : ^Context, font : Font_ID, text_utf8 : string,
prev_codepoint = rune(0)
continue
}
if abs( entry.size ) <= ADVANCE_SNAP_SMALLFONT_SIZE {
position.x = position.x
if abs( entry.size ) <= ctx.shaper_ctx.adv_snap_small_font_threshold {
position.x = ceil(position.x)
}
append( & output.glyphs, parser_find_glyph_index( & entry.parser_info, codepoint ))
advance, _ := parser_get_codepoint_horizontal_metrics( & entry.parser_info, codepoint )
if ctx.snap_shape_pos do position.x = ceil(position.x)
append( & output.positions, Vec2 {
position.x,
position.y
ceil(position.x),
ceil(position.y)
})
position.x += f32(advance) * entry.size_scale
if ctx.snap_shape_pos do position.x = ceil(position.x)
prev_codepoint = codepoint
}