From 8be64ef80e8039741a210d77e346ad0aae0701db Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 6 Nov 2021 17:15:04 +0200 Subject: [PATCH] gg: improve font loading diagnostics with `-d debug_font` --- vlib/gg/text_rendering.c.v | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/vlib/gg/text_rendering.c.v b/vlib/gg/text_rendering.c.v index 9530dd2ade..4aec569c65 100644 --- a/vlib/gg/text_rendering.c.v +++ b/vlib/gg/text_rendering.c.v @@ -65,6 +65,7 @@ fn new_ft(c FTConfig) ?&FT { } } + mut normal_path := c.font_path mut bytes := []byte{} $if android { // First try any filesystem paths @@ -82,26 +83,33 @@ fn new_ft(c FTConfig) ?&FT { return none } } - bold_path := if c.custom_bold_font_path != '' { + mut bold_path := if c.custom_bold_font_path != '' { c.custom_bold_font_path } else { get_font_path_variant(c.font_path, .bold) } bytes_bold := os.read_bytes(bold_path) or { debug_font_println('failed to load font "$bold_path"') + bold_path = c.font_path bytes } - mono_path := get_font_path_variant(c.font_path, .mono) + mut mono_path := get_font_path_variant(c.font_path, .mono) bytes_mono := os.read_bytes(mono_path) or { debug_font_println('failed to load font "$mono_path"') + mono_path = c.font_path bytes } - italic_path := get_font_path_variant(c.font_path, .italic) + mut italic_path := get_font_path_variant(c.font_path, .italic) bytes_italic := os.read_bytes(italic_path) or { debug_font_println('failed to load font "$italic_path"') + italic_path = c.font_path bytes } fons := sfons.create(512, 512, 1) + debug_font_println('Font used for font_normal : $normal_path') + debug_font_println('Font used for font_bold : $bold_path') + debug_font_println('Font used for font_mono : $mono_path') + debug_font_println('Font used for font_italic : $italic_path') return &FT{ fons: fons font_normal: C.fonsAddFontMem(fons, c'sans', bytes.data, bytes.len, false)