gg: fix ./v -gc none -autofree run examples/tetris/ (avoid return s1 + s2 + s3, clone the arrays, passed to the fontstash wrapper)

This commit is contained in:
Delyan Angelov 2025-02-07 14:22:18 +02:00
parent 331178b23b
commit 16a6e45274
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
4 changed files with 23 additions and 16 deletions

View File

@ -51,9 +51,11 @@ fn (mut f Flag) free() {
// str returns a string representation of the given Flag
pub fn (f Flag) str() string {
return '' + ' flag:\n' + ' name: ${f.name}\n' +
' abbr: `${f.abbr.ascii_str()}`\n' + ' usage: ${f.usage}\n' +
' desc: ${f.val_desc}'
return ' flag:
name: ${f.name}
abbr: `${f.abbr.ascii_str()}`
usage: ${f.usage}
desc: ${f.val_desc}'
}
// str returns a string representation of the given array of Flags

View File

@ -56,10 +56,10 @@ fn new_ft(c FTConfig) ?&FT {
fons.set_error_callback(clear_atlas_callback, fons)
return &FT{
fons: fons
font_normal: fons.add_font_mem('sans', bytes_normal, false)
font_bold: fons.add_font_mem('sans', bytes_bold, false)
font_mono: fons.add_font_mem('sans', bytes_mono, false)
font_italic: fons.add_font_mem('sans', bytes_italic, false)
font_normal: fons.add_font_mem('sans', bytes_normal.clone(), false)
font_bold: fons.add_font_mem('sans', bytes_bold.clone(), false)
font_mono: fons.add_font_mem('sans', bytes_mono.clone(), false)
font_italic: fons.add_font_mem('sans', bytes_italic.clone(), false)
scale: c.scale
}
} else {
@ -122,10 +122,10 @@ fn new_ft(c FTConfig) ?&FT {
fons.set_error_callback(clear_atlas_callback, fons)
return &FT{
fons: fons
font_normal: fons.add_font_mem('sans', bytes, false)
font_bold: fons.add_font_mem('sans', bytes_bold, false)
font_mono: fons.add_font_mem('sans', bytes_mono, false)
font_italic: fons.add_font_mem('sans', bytes_italic, false)
font_normal: fons.add_font_mem('sans', bytes.clone(), false)
font_bold: fons.add_font_mem('sans', bytes_bold.clone(), false)
font_mono: fons.add_font_mem('sans', bytes_mono.clone(), false)
font_italic: fons.add_font_mem('sans', bytes_italic.clone(), false)
scale: c.scale
}
}

View File

@ -135,5 +135,5 @@ pub fn get_path_variant(font_path string, variant Variant) string {
}
}
}
return fpath + file + '.ttf'
return '${fpath}${file}.ttf'
}

View File

@ -554,11 +554,16 @@ pub fn home_dir() string {
// See also `home_dir()`.
pub fn expand_tilde_to_home(path string) string {
if path == '~' {
return home_dir().trim_right(path_separator)
hdir := home_dir()
return hdir.trim_right(path_separator)
}
if path.starts_with('~' + path_separator) {
return path.replace_once('~' + path_separator, home_dir().trim_right(path_separator) +
path_separator)
source := '~' + path_separator
if path.starts_with(source) {
hdir := home_dir()
trimmed := hdir.trim_right(path_separator)
final := trimmed + path_separator
result := path.replace_once(source, final)
return result
}
return path
}