v2 / examples / gg / draw_unicode_text_with_gg.v
33 lines · 28 sloc · 736 bytes · 27ef5439837b7107186aef2b278f82a88b9d8a80
Raw
1import os
2import gg
3
4println('Usage: `v run examples/gg/draw_unicode_text_with_gg.v [FONT_PATH] [TEXT_PATH]`')
5
6font_path := os.args[1] or {
7 os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
8}
9dump(font_path)
10
11text_path := os.args[2] or {
12 os.resource_abs_path(os.join_path('..', 'ttf_font/draw_static_text.txt'))
13}
14dump(text_path)
15
16text := os.read_file(text_path)!
17dump(text)
18
19gg.start(
20 window_title: 'Draw unicode text with gg'
21 bg_color: gg.Color{155, 155, 128, 255}
22 width: 1024
23 height: 140
24 font_path: font_path
25 frame_fn: fn [text] (ctx &gg.Context) {
26 ctx.begin()
27 ctx.draw_text(30, 50, text,
28 size: 24
29 color: gg.Color{50, 50, 255, 255}
30 )
31 ctx.end()
32 }
33)
34