VEFontCache: Adjustments to positioning & text size shape values

This commit is contained in:
Edward R. Gonzalez 2024-06-30 13:36:54 -04:00
parent 2698670890
commit 8ecfd7407e
4 changed files with 29 additions and 4 deletions

View File

@ -489,7 +489,7 @@ draw_text_batch :: proc(ctx: ^Context, entry: ^Entry, shaped: ^ShapedText,
// Draw cacxhed glyph
slot_position, _ := atlas_bbox( atlas, region_kind, atlas_index )
glyph_scale := bounds_size * entry.size_scale + glyph_padding
bounds_0_scaled := ceil( vbounds_0 * entry.size_scale )
bounds_0_scaled := ceil(vbounds_0 * entry.size_scale)
dst := glyph_translate + bounds_0_scaled * scale
dst_scale := glyph_scale * scale
textspace_x_form( & slot_position, & glyph_scale, atlas_size )

View File

@ -12,6 +12,16 @@ import "core:math"
ceil_f64 :: math.ceil_f64
ceil_f64le :: math.ceil_f64le
ceil_f64be :: math.ceil_f64be
floor_f16 :: math.floor_f16
floor_f16le :: math.floor_f16le
floor_f16be :: math.floor_f16be
floor_f32 :: math.floor_f32
floor_f32le :: math.floor_f32le
floor_f32be :: math.floor_f32be
floor_f64 :: math.floor_f64
floor_f64le :: math.floor_f64le
floor_f64be :: math.floor_f64be
import "core:math/linalg"
import "core:mem"
Kilobyte :: mem.Kilobyte
@ -54,6 +64,20 @@ clear :: proc {
clear_dynamic_array,
}
floor :: proc {
math.floor_f16,
math.floor_f16le,
math.floor_f16be,
math.floor_f32,
math.floor_f32le,
math.floor_f32be,
math.floor_f64,
math.floor_f64le,
math.floor_f64be,
floor_vec2,
}
make :: proc {
make_dynamic_array,
make_dynamic_array_len,

View File

@ -16,7 +16,8 @@ vec2_64_from_vec2 :: #force_inline proc "contextless" ( v2 : Vec2 ) -> Vec2
vec2_from_vec2i :: #force_inline proc "contextless" ( v2i : Vec2i ) -> Vec2 { return { f32(v2i.x), f32(v2i.y) }}
vec2i_from_vec2 :: #force_inline proc "contextless" ( v2 : Vec2 ) -> Vec2i { return { i32(v2.x), i32(v2.y) }}
@(require_results) ceil_vec2 :: proc "contextless" ( v : Vec2 ) -> Vec2 { return { ceil_f32(v.x), ceil_f32(v.y) } }
@(require_results) ceil_vec2 :: proc "contextless" ( v : Vec2 ) -> Vec2 { return { ceil_f32(v.x), ceil_f32(v.y) } }
@(require_results) floor_vec2 :: proc "contextless" ( v : Vec2 ) -> Vec2 { return { floor_f32(v.x), floor_f32(v.y) } }
// This buffer is used below excluisvely to prevent any allocator recusion when verbose logging from allocators.
// This means a single line is limited to 32k buffer (increase naturally if this SOMEHOW becomes a bottleneck...)

View File

@ -111,7 +111,7 @@ shape_text_uncached :: proc( ctx : ^Context, font : FontID, text_utf8 : string,
continue
}
if abs( entry.size ) <= Advance_Snap_Smallfont_Size {
position.x = ceil( position.x )
position.x = position.x
}
append( & output.glyphs, parser_find_glyph_index( & entry.parser_info, codepoint ))
@ -129,7 +129,7 @@ shape_text_uncached :: proc( ctx : ^Context, font : FontID, text_utf8 : string,
output.end_cursor_pos = position
max_line_width = max(max_line_width, position.x)
output.size.x = max_line_width
output.size.x = ceil(max_line_width)
output.size.y = f32(line_count) * line_height
}
}