mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
gg: improve font loading diagnostics with -d debug_font
This commit is contained in:
parent
5f3dcde358
commit
8be64ef80e
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user