Fixed ui rendering issue with getting vertical metrics unscaled.
This commit is contained in:
parent
cb6053395c
commit
d6e232b3f7
@ -613,17 +613,18 @@ measure_text_size :: #force_inline proc( ctx : ^Context, font : Font_ID, px_size
|
||||
return shaped.size
|
||||
}
|
||||
|
||||
get_font_vertical_metrics :: #force_inline proc ( ctx : ^Context, font : Font_ID ) -> ( ascent, descent, line_gap : f32 )
|
||||
get_font_vertical_metrics :: #force_inline proc ( ctx : ^Context, font : Font_ID, px_szie : f32 ) -> ( ascent, descent, line_gap : f32 )
|
||||
{
|
||||
assert( ctx != nil )
|
||||
assert( font >= 0 && int(font) < len(ctx.entries) )
|
||||
|
||||
entry := & ctx.entries[ font ]
|
||||
// ascent_i32, descent_i32, line_gap_i32 := parser_get_font_vertical_metrics( entry.parser_info )
|
||||
font_scale := parser_scale( entry.parser_info, px_szie )
|
||||
|
||||
ascent = entry.ascent
|
||||
descent = entry.descent
|
||||
line_gap = entry.line_gap
|
||||
ascent = font_scale * entry.ascent
|
||||
descent = font_scale * entry.descent
|
||||
line_gap = font_scale * entry.line_gap
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -937,7 +937,7 @@ draw_text_shape_pos_norm :: #force_inline proc( shape : ShapedText, id : FontID,
|
||||
ve_id, resolved_size := font_provider_resolve_draw_id( id, font_size * config.font_size_screen_scalar )
|
||||
color_norm := normalize_rgba8(color)
|
||||
|
||||
screen_size_norm := Vec2{1 / width, 1 / height}
|
||||
screen_size_norm := Vec2 { 1 / width, 1 / height }
|
||||
|
||||
ve.set_colour( & font_provider_ctx.ve_ctx, color_norm )
|
||||
ve.draw_text_shape( & font_provider_ctx.ve_ctx, ve_id, f32(resolved_size), pos, screen_size_norm * scale * (1 / config.font_size_screen_scalar), shape )
|
||||
@ -977,10 +977,10 @@ draw_text_string_pos_extent_zoomed :: #force_inline proc( text : string, id : Fo
|
||||
text_scale : Vec2 = screen_size_norm
|
||||
// if config.cam_zoom_mode == .Smooth
|
||||
{
|
||||
diff_scalar := 1 + (zoom_adjust_size - f32_resolved_size) / f32_resolved_size
|
||||
text_scale = diff_scalar * screen_size_norm
|
||||
text_scale.x = clamp( text_scale.x, 0, screen_size.x )
|
||||
text_scale.y = clamp( text_scale.y, 0, screen_size.y )
|
||||
diff_scalar := 1 + (zoom_adjust_size - f32_resolved_size) / f32_resolved_size
|
||||
text_scale = diff_scalar * screen_size_norm
|
||||
text_scale.x = clamp( text_scale.x, 0, screen_size.x )
|
||||
text_scale.y = clamp( text_scale.y, 0, screen_size.y )
|
||||
}
|
||||
|
||||
// Down-sample back
|
||||
|
@ -142,7 +142,7 @@ measure_text_size :: #force_inline proc( text : string, font : FontID, font_size
|
||||
get_font_vertical_metrics :: #force_inline proc ( font : FontID, font_size := Font_Use_Default_Size ) -> ( ascent, descent, line_gap : f32 )
|
||||
{
|
||||
ve_id, size := font_provider_resolve_draw_id( font, font_size )
|
||||
ascent, descent, line_gap = ve.get_font_vertical_metrics( & get_state().font_provider_ctx.ve_ctx, ve_id )
|
||||
ascent, descent, line_gap = ve.get_font_vertical_metrics( & get_state().font_provider_ctx.ve_ctx, ve_id, font_size )
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -191,14 +191,14 @@ ui_box_compute_layout :: proc( box : ^UI_Box,
|
||||
{
|
||||
ascent, descent, line_gap := get_font_vertical_metrics(style.font, layout.font_size)
|
||||
|
||||
offset := text_size
|
||||
offset += { 0, -descent }
|
||||
// offset := text_size
|
||||
// offset += { 0, -descent }
|
||||
|
||||
content_size := content_bounds.max - content_bounds.min
|
||||
text_pos : Vec2
|
||||
text_pos = content_bounds.min
|
||||
text_pos += { 0, -descent }
|
||||
text_pos = content_bounds.min
|
||||
text_pos += (content_size - text_size) * layout.text_alignment
|
||||
text_pos += { 0, -descent }
|
||||
|
||||
computed.text_size = text_size
|
||||
computed.text_pos = text_pos
|
||||
|
Loading…
Reference in New Issue
Block a user