mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-05 14:42:42 -07:00
Added get_font_entry, resolve_px_scalar_size, snap_normalized_position_to_view
This commit is contained in:
@@ -1196,6 +1196,10 @@ get_font_vertical_metrics :: #force_inline proc ( ctx : Context, font : Font_ID,
|
||||
|
||||
//#region("miscellaneous")
|
||||
|
||||
get_font_entry :: #force_inline proc "contextless" ( ctx : ^Context, font : Font_ID ) -> Entry {
|
||||
return ctx.entries[font]
|
||||
}
|
||||
|
||||
get_cursor_pos :: #force_inline proc "contextless" ( ctx : Context ) -> Vec2 { return ctx.cursor_pos }
|
||||
|
||||
// Will normalize the value of the position and scale based on the provided view.
|
||||
@@ -1237,6 +1241,25 @@ resolve_zoom_size_scale :: #force_inline proc "contextless" (
|
||||
return
|
||||
}
|
||||
|
||||
resolve_px_scalar_size :: #force_inline proc "contextless" ( parser_info : Parser_Font_Info, px_size, px_scalar : f32, norm_scale : Vec2
|
||||
) -> (target_px_size, target_font_scale : f32, target_scale : Vec2 )
|
||||
{
|
||||
target_px_size = px_size * px_scalar
|
||||
target_scale = norm_scale * (1 / px_scalar)
|
||||
target_font_scale = parser_scale( parser_info, target_px_size )
|
||||
return
|
||||
}
|
||||
|
||||
snap_normalized_position_to_view :: #force_inline proc "contextless" ( position, view : Vec2 ) -> (position_snapped : Vec2)
|
||||
{
|
||||
should_snap := cast(f32) i32(view.x > 0 && view.y > 0)
|
||||
view_quotient := 1 / Vec2 { max(view.x, 1), max(view.y, 1) }
|
||||
|
||||
position_snapped = ceil(position * view) * view_quotient * should_snap
|
||||
position_snapped = max(position, position_snapped)
|
||||
return
|
||||
}
|
||||
|
||||
set_alpha_scalar :: #force_inline proc( ctx : ^Context, scalar : f32 ) { assert(ctx != nil); ctx.alpha_sharpen = scalar }
|
||||
set_px_scalar :: #force_inline proc( ctx : ^Context, scalar : f32 ) { assert(ctx != nil); ctx.px_scalar = scalar }
|
||||
set_zoom_px_interval :: #force_inline proc( ctx : ^Context, interval : i32 ) { assert(ctx != nil); ctx.zoom_px_interval = f32(interval) }
|
||||
|
Reference in New Issue
Block a user