mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-05 14:42:42 -07:00
got harfbuzz working (need to fixup the text size measuring)
This commit is contained in:
@@ -271,7 +271,7 @@ init :: proc "c" ()
|
|||||||
case .DUMMY: fmt.println(">> using dummy backend")
|
case .DUMMY: fmt.println(">> using dummy backend")
|
||||||
}
|
}
|
||||||
|
|
||||||
ve.startup( & demo_ctx.ve_ctx, .STB_TrueType, allocator = context.allocator, snap_shape_position = false )
|
ve.startup( & demo_ctx.ve_ctx, .STB_TrueType, allocator = context.allocator, snap_shape_position = false, use_advanced_text_shaper = true )
|
||||||
ve_sokol.setup_gfx_objects( & demo_ctx.render_ctx, & demo_ctx.ve_ctx, vert_cap = 1024 * 1024, index_cap = 1024 * 1024 )
|
ve_sokol.setup_gfx_objects( & demo_ctx.render_ctx, & demo_ctx.ve_ctx, vert_cap = 1024 * 1024, index_cap = 1024 * 1024 )
|
||||||
|
|
||||||
error : mem.Allocator_Error
|
error : mem.Allocator_Error
|
||||||
@@ -478,10 +478,10 @@ etiam dignissim diam quis enim. Convallis convallis tellus id interdum.`
|
|||||||
draw_text_string_pos_norm("그들의 장비와 기구는 모두 살아 있다.", font_demo_korean, 36, {0.3, current_scroll - (section_start + 0.92)}, COLOR_WHITE)
|
draw_text_string_pos_norm("그들의 장비와 기구는 모두 살아 있다.", font_demo_korean, 36, {0.3, current_scroll - (section_start + 0.92)}, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Arabic", font_print, 19, {0.2, current_scroll - (section_start + 0.96)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Arabic", font_print, 19, {0.2, current_scroll - (section_start + 0.96)}, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("حب السماء لا تمطر غير الأحلام. This one needs HarfBuzz to work!", font_demo_arabic, 24, {0.3, current_scroll - (section_start + 0.96)}, COLOR_WHITE)
|
draw_text_string_pos_norm("حب السماء لا تمطر غير الأحلام. (This one needs HarfBuzz to work!)", font_demo_arabic, 24, {0.3, current_scroll - (section_start + 0.96)}, COLOR_WHITE)
|
||||||
|
|
||||||
draw_text_string_pos_norm("Hebrew", font_print, 19, {0.2, current_scroll - (section_start + 1.0)}, COLOR_WHITE)
|
draw_text_string_pos_norm("Hebrew", font_print, 19, {0.2, current_scroll - (section_start + 1.0)}, COLOR_WHITE)
|
||||||
draw_text_string_pos_norm("אז הגיע הלילה של כוכב השביט הראשון. This one needs HarfBuzz to work!", font_demo_hebrew, 22, {0.3, current_scroll - (section_start + 1.0)}, COLOR_WHITE)
|
draw_text_string_pos_norm("אז הגיע הלילה של כוכב השביט הראשון. (This one needs HarfBuzz to work!)", font_demo_hebrew, 22, {0.3, current_scroll - (section_start + 1.0)}, COLOR_WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zoom Test
|
// Zoom Test
|
||||||
|
@@ -98,7 +98,7 @@ function build-SokolBackendDemo
|
|||||||
# $build_args += $flag_optimize_minimal
|
# $build_args += $flag_optimize_minimal
|
||||||
# $build_args += $flag_optimize_speed
|
# $build_args += $flag_optimize_speed
|
||||||
$build_args += $falg_optimize_aggressive
|
$build_args += $falg_optimize_aggressive
|
||||||
# $build_args += $flag_debug
|
$build_args += $flag_debug
|
||||||
$build_args += $flag_pdb_name + $pdb
|
$build_args += $flag_pdb_name + $pdb
|
||||||
$build_args += $flag_subsystem + 'windows'
|
$build_args += $flag_subsystem + 'windows'
|
||||||
# $build_args += ($flag_extra_linker_flags + $linker_args )
|
# $build_args += ($flag_extra_linker_flags + $linker_args )
|
||||||
|
@@ -91,6 +91,7 @@ shaper_shape_from_text :: proc( ctx : ^ShaperContext, info : ^ShaperInfo, output
|
|||||||
harfbuzz.buffer_set_language( buffer, harfbuzz.language_get_default() )
|
harfbuzz.buffer_set_language( buffer, harfbuzz.language_get_default() )
|
||||||
|
|
||||||
// Perform the actual shaping of this run using HarfBuzz.
|
// Perform the actual shaping of this run using HarfBuzz.
|
||||||
|
harfbuzz.buffer_set_content_type( buffer, harfbuzz.Buffer_Content_Type.UNICODE )
|
||||||
harfbuzz.shape( font, buffer, nil, 0 )
|
harfbuzz.shape( font, buffer, nil, 0 )
|
||||||
|
|
||||||
// Loop over glyphs and append to output buffer.
|
// Loop over glyphs and append to output buffer.
|
||||||
@@ -141,21 +142,23 @@ shaper_shape_from_text :: proc( ctx : ^ShaperContext, info : ^ShaperInfo, output
|
|||||||
|
|
||||||
for codepoint, byte_offset in text_utf8
|
for codepoint, byte_offset in text_utf8
|
||||||
{
|
{
|
||||||
script := harfbuzz.unicode_script( hb_ucfunc, cast(harfbuzz.Codepoint) codepoint )
|
hb_codepoint := cast(harfbuzz.Codepoint) codepoint
|
||||||
|
|
||||||
|
script := harfbuzz.unicode_script( hb_ucfunc, hb_codepoint )
|
||||||
|
|
||||||
// Can we continue the current run?
|
// Can we continue the current run?
|
||||||
ScriptKind :: harfbuzz.Script
|
ScriptKind :: harfbuzz.Script
|
||||||
|
|
||||||
special_script : b32 = script == ScriptKind.UNKNOWN || script == ScriptKind.INHERITED || script == ScriptKind.COMMON
|
special_script : b32 = script == ScriptKind.UNKNOWN || script == ScriptKind.INHERITED || script == ScriptKind.COMMON
|
||||||
if special_script || script == current_script {
|
if special_script || script == current_script || byte_offset == 0 {
|
||||||
harfbuzz.buffer_add( ctx.hb_buffer, cast(harfbuzz.Codepoint) codepoint, codepoint == '\n' ? 1 : 0 )
|
harfbuzz.buffer_add( ctx.hb_buffer, hb_codepoint, codepoint == '\n' ? 1 : 0 )
|
||||||
current_script = special_script ? current_script : script
|
current_script = special_script ? current_script : script
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// End current run since we've encountered a script change.
|
// End current run since we've encountered a script change.
|
||||||
shape_run( ctx.hb_buffer, current_script, info.font, output, & position, & vertical_position, ascent, descent, line_gap, size, size_scale )
|
shape_run( ctx.hb_buffer, current_script, info.font, output, & position, & vertical_position, ascent, descent, line_gap, size, size_scale )
|
||||||
harfbuzz.buffer_add( ctx.hb_buffer, cast(harfbuzz.Codepoint) codepoint, codepoint == '\n' ? 1 : 0 )
|
harfbuzz.buffer_add( ctx.hb_buffer, hb_codepoint, codepoint == '\n' ? 1 : 0 )
|
||||||
current_script = script
|
current_script = script
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -152,6 +152,7 @@ startup :: proc( ctx : ^Context, parser_kind : ParserKind,
|
|||||||
context.allocator = ctx.backing
|
context.allocator = ctx.backing
|
||||||
|
|
||||||
snap_shape_pos = snap_shape_position
|
snap_shape_pos = snap_shape_position
|
||||||
|
text_shape_adv = use_advanced_text_shaper
|
||||||
|
|
||||||
if default_curve_quality == 0 {
|
if default_curve_quality == 0 {
|
||||||
default_curve_quality = 3
|
default_curve_quality = 3
|
||||||
|
Reference in New Issue
Block a user