Skip to content

Commit

Permalink
examples,gg: modify all remaining calls to fons.add_font_mem/3 to use…
Browse files Browse the repository at this point in the history
… an array.clone()
  • Loading branch information
spytheman committed Feb 7, 2025
1 parent 16a6e45 commit 10f2fe1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/sokol/fonts.v
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn init(mut state AppState) {
'RobotoMono-Regular.ttf')))
{
println('loaded font: ${bytes.len}')
state.font_normal = state.font_context.add_font_mem('sans', bytes, false)
state.font_normal = state.font_context.add_font_mem('sans', bytes.clone(), true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/sokol/freetype_raven.v
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fn init(mut state AppState) {
'RobotoMono-Regular.ttf')))
{
println('loaded font: ${bytes.len}')
state.font_normal = state.fons.add_font_mem('sans', bytes, false)
state.font_normal = state.fons.add_font_mem('sans', bytes.clone(), true)
}
}

Expand Down
18 changes: 9 additions & 9 deletions vlib/gg/text_rendering.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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.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)
font_normal: fons.add_font_mem('sans', bytes_normal.clone(), true)
font_bold: fons.add_font_mem('sans', bytes_bold.clone(), true)
font_mono: fons.add_font_mem('sans', bytes_mono.clone(), true)
font_italic: fons.add_font_mem('sans', bytes_italic.clone(), true)
scale: c.scale
}
} else {
Expand Down Expand Up @@ -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.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)
font_normal: fons.add_font_mem('sans', bytes.clone(), true)
font_bold: fons.add_font_mem('sans', bytes_bold.clone(), true)
font_mono: fons.add_font_mem('sans', bytes_mono.clone(), true)
font_italic: fons.add_font_mem('sans', bytes_italic.clone(), true)
scale: c.scale
}
}
Expand All @@ -144,7 +144,7 @@ pub fn (ctx &Context) set_text_cfg(cfg gx.TextCfg) {
debug_font_println('failed to load font "${cfg.family}"')
return
}
f = ctx.ft.fons.add_font_mem(cfg.family, bytes, false)
f = ctx.ft.fons.add_font_mem(cfg.family, bytes.clone(), true)
unsafe {
ctx.ft.fonts_map[cfg.family] = f
}
Expand Down

0 comments on commit 10f2fe1

Please sign in to comment.