examples: add examples/gg/draw_unicode_text_with_gg.v, for easy comparison of how different fonts and unicode texts will look, when rendered by gg

This commit is contained in:
Delyan Angelov 2024-08-24 09:04:13 +03:00
parent 4b799fd81d
commit 27ef543983
No known key found for this signature in database
GPG key ID: 66886C0F12D595ED

View file

@ -0,0 +1,33 @@
import os
import gg
println('Usage: `v run examples/gg/draw_unicode_text_with_gg.v [FONT_PATH] [TEXT_PATH]`')
font_path := os.args[1] or {
os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
}
dump(font_path)
text_path := os.args[2] or {
os.resource_abs_path(os.join_path('..', 'ttf_font/draw_static_text.txt'))
}
dump(text_path)
text := os.read_file(text_path)!
dump(text)
gg.start(
window_title: 'Draw unicode text with gg'
bg_color: gg.Color{155, 155, 128, 255}
width: 1024
height: 140
font_path: font_path
frame_fn: fn [text] (ctx &gg.Context) {
ctx.begin()
ctx.draw_text(30, 50, text,
size: 24
color: gg.Color{50, 50, 255, 255}
)
ctx.end()
}
)