Skip to content

Commit

Permalink
gg: improve font loading diagnostics with -d debug_font
Browse files Browse the repository at this point in the history
  • Loading branch information
spytheman committed Nov 6, 2021
1 parent 5f3dcde commit 8be64ef
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions vlib/gg/text_rendering.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 8be64ef

Please sign in to comment.