| 1 | import os |
| 2 | import gg |
| 3 | |
| 4 | println('Usage: `v run examples/gg/draw_unicode_text_with_gg.v [FONT_PATH] [TEXT_PATH]`') |
| 5 | |
| 6 | font_path := os.args[1] or { |
| 7 | os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf')) |
| 8 | } |
| 9 | dump(font_path) |
| 10 | |
| 11 | text_path := os.args[2] or { |
| 12 | os.resource_abs_path(os.join_path('..', 'ttf_font/draw_static_text.txt')) |
| 13 | } |
| 14 | dump(text_path) |
| 15 | |
| 16 | text := os.read_file(text_path)! |
| 17 | dump(text) |
| 18 | |
| 19 | gg.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 | |