diff --git a/examples/sokol_demo/sokol_demo.odin b/examples/sokol_demo/sokol_demo.odin index 4ca47a9..dedbdba 100644 --- a/examples/sokol_demo/sokol_demo.odin +++ b/examples/sokol_demo/sokol_demo.odin @@ -705,8 +705,8 @@ etiam dignissim diam quis enim. Convallis convallis tellus id interdum.` cleanup :: proc "c" () { context = runtime.default_context() - // ve.shutdown( & demo_ctx.ve_ctx ) - // gfx.shutdown() + ve.shutdown( & demo_ctx.ve_ctx ) + gfx.shutdown() } main :: proc() diff --git a/vefontcache/draw.odin b/vefontcache/draw.odin index fd21aa4..776fda5 100644 --- a/vefontcache/draw.odin +++ b/vefontcache/draw.odin @@ -476,7 +476,7 @@ draw_text_batch :: proc(ctx: ^Context, entry: ^Entry, shaped: ^ShapedText, bounds_size := Vec2 { vbounds_1.x - vbounds_0.x, vbounds_1.y - vbounds_0.y } shaped_position := shaped.positions[index] - glyph_translate := position + shaped_position * scale + glyph_translate := position + (shaped_position) * scale if region_kind == .E { diff --git a/vefontcache/shaped_text.odin b/vefontcache/shaped_text.odin index 5accedd..bbc9c26 100644 --- a/vefontcache/shaped_text.odin +++ b/vefontcache/shaped_text.odin @@ -106,7 +106,7 @@ shape_text_uncached :: proc( ctx : ^Context, font : FontID, text_utf8 : string, max_line_width = max(max_line_width, position.x) position.x = 0.0 position.y -= line_height - position.y = ceil(position.y) + position.y = position.y prev_codepoint = rune(0) continue } @@ -117,19 +117,22 @@ shape_text_uncached :: proc( ctx : ^Context, font : FontID, text_utf8 : string, append( & output.glyphs, parser_find_glyph_index( & entry.parser_info, codepoint )) advance, _ := parser_get_codepoint_horizontal_metrics( & entry.parser_info, codepoint ) + if ctx.snap_shape_pos do position.x = ceil(position.x) + append( & output.positions, Vec2 { - ceil(position.x), + position.x, position.y }) - position.x += ceil(f32(advance) * entry.size_scale) + position.x += f32(advance) * entry.size_scale + if ctx.snap_shape_pos do position.x = ceil(position.x) prev_codepoint = codepoint } output.end_cursor_pos = position max_line_width = max(max_line_width, position.x) - output.size.x = ceil(max_line_width) + output.size.x = max_line_width output.size.y = f32(line_count) * line_height } } diff --git a/vefontcache/vefontcache.odin b/vefontcache/vefontcache.odin index 970d93e..df76e5f 100644 --- a/vefontcache/vefontcache.odin +++ b/vefontcache/vefontcache.odin @@ -45,6 +45,7 @@ Context :: struct { snap_width : f32, snap_height : f32, + colour : Colour, cursor_pos : Vec2, @@ -61,6 +62,7 @@ Context :: struct { default_curve_quality : i32, text_shape_adv : b32, + snap_shape_pos : b32, debug_print : b32, debug_print_verbose : b32, @@ -135,6 +137,8 @@ startup :: proc( ctx : ^Context, parser_kind : ParserKind, atlas_params := InitAtlasParams_Default, glyph_draw_params := InitGlyphDrawParams_Default, shape_cache_params := InitShapeCacheParams_Default, + use_advanced_text_shaper : b32 = true, + snap_shape_position : b32 = true, default_curve_quality : u32 = 3, entires_reserve : u32 = 512, temp_path_reserve : u32 = 1024, @@ -147,6 +151,8 @@ startup :: proc( ctx : ^Context, parser_kind : ParserKind, ctx.backing = allocator context.allocator = ctx.backing + snap_shape_pos = snap_shape_position + if default_curve_quality == 0 { default_curve_quality = 3 }