From 27ef5439837b7107186aef2b278f82a88b9d8a80 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 24 Aug 2024 09:04:13 +0300 Subject: [PATCH] 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 --- examples/gg/draw_unicode_text_with_gg.v | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 examples/gg/draw_unicode_text_with_gg.v diff --git a/examples/gg/draw_unicode_text_with_gg.v b/examples/gg/draw_unicode_text_with_gg.v new file mode 100644 index 000000000..d5f2e80b9 --- /dev/null +++ b/examples/gg/draw_unicode_text_with_gg.v @@ -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() + } +) -- 2.39.5