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:
@ -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 )
|
||||
}
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ font_provider_startup :: proc( ctx : ^FontProviderContext )
|
||||
font_cache, error = make( HMapChained(FontDef), hmap_closest_prime(1 * Kilo), persistent_allocator(), dbg_name = "font_cache" )
|
||||
verify( error == AllocatorError.None, "Failed to allocate font_cache" )
|
||||
|
||||
ve.startup( & ve_ctx, .STB_TrueType, allocator = persistent_slab_allocator(), use_advanced_text_shaper = true )
|
||||
ve.startup( & ve_ctx, .STB_TrueType, allocator = persistent_slab_allocator() )
|
||||
ve_ctx.glyph_buffer.over_sample = { 4,4 }
|
||||
log("VEFontCached initialized")
|
||||
// provider_data.ve_ctx.debug_print = true
|
||||
// provider_data.ve_ctx.debug_print_verbose = true
|
||||
@ -52,8 +53,11 @@ font_provider_startup :: proc( ctx : ^FontProviderContext )
|
||||
|
||||
font_provider_reload :: proc( ctx : ^FontProviderContext )
|
||||
{
|
||||
ctx.ve_ctx.glyph_buffer.over_sample = { 4,4 } * 1.0
|
||||
hmap_chained_reload( ctx.font_cache, persistent_allocator())
|
||||
ve.hot_reload( & ctx.ve_ctx, persistent_slab_allocator() )
|
||||
ve.clear_atlas_region_caches(& ctx.ve_ctx)
|
||||
ve.clear_shape_cache(& ctx.ve_ctx)
|
||||
}
|
||||
|
||||
font_provider_shutdown :: proc( ctx : ^FontProviderContext )
|
||||
|
@ -163,8 +163,9 @@ test_whitespace_ast :: proc( default_layout : ^UI_Layout, frame_style_default :
|
||||
text_layout.flags = {
|
||||
// .Origin_At_Anchor_Center,
|
||||
.Fixed_Position_X, .Fixed_Position_Y,
|
||||
.Fixed_Width, .Fixed_Height,
|
||||
// .Fixed_Width, .Fixed_Height,
|
||||
}
|
||||
// text_layout.font_size = 16
|
||||
text_layout.text_alignment = { 0.0, 0.5 }
|
||||
text_layout.alignment = { 0.0, 1.0 }
|
||||
text_layout.size.min = { 1600, 14 }
|
||||
|
Reference in New Issue
Block a user