Text improvements

* Added clear_atlas_region_caches & clear_shape_cache to VEFontCache (Used on hot-reload by the pototype's font provider)
* 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
* Large imporvement to text hinting and general rendering of text
This commit is contained in:
2024-12-29 17:30:00 -05:00
parent 7eab6f9a7f
commit 7488a6828e
10 changed files with 171 additions and 69 deletions

View File

@ -807,7 +807,7 @@ draw_text_string_pos_norm :: proc( content : string, id : FontID, size : f32, po
color_norm := normalize_rgba8(color)
ve.set_colour( & font_provider_ctx.ve_ctx, color_norm )
ve.draw_text( & font_provider_ctx.ve_ctx, ve_id, content, pos, Vec2{1 / width, 1 / height} * scale * (1/config.font_size_screen_scalar) )
ve.draw_text( & font_provider_ctx.ve_ctx, ve_id, content, pos, Vec2{1 / width, 1 / height} * scale * (1 / config.font_size_screen_scalar) )
return
}
@ -853,7 +853,7 @@ draw_text_string_pos_extent_zoomed :: proc( content : string, id : FontID, size
{
f32_resolved_size := f32(resolved_size)
diff_scalar := 1 + (zoom_adjust_size - f32_resolved_size) / f32_resolved_size
text_scale = diff_scalar * screen_scale
text_scale = diff_scalar * screen_scale
text_scale.x = clamp( text_scale.x, 0, screen_size.x )
text_scale.y = clamp( text_scale.y, 0, screen_size.y )
}

View File

@ -325,7 +325,7 @@ update :: proc( delta_time : f64 ) -> b32
flags = frame_style_flags,
anchor = {},
// alignment = { 0.5, 0.5 },
font_size = 12,
font_size = 14,
text_alignment = { 0.0, 0.0 },
// corner_radii = { 0.2, 0.2, 0.2, 0.2 },
pos = { 0, 0 },
@ -334,7 +334,8 @@ update :: proc( delta_time : f64 ) -> b32
}
scope( default_layout )
frame_style_default := UI_Style {
bg_color = Color_BG_TextBox,
// bg_color = Color_BG_TextBox,
bg_color = Color_Transparent,
font = default_font,
text_color = Color_White,
}