gg: custom bold font path
parent
d3deaa1f59
commit
0ddf0a4b92
52
vlib/gg/gg.v
52
vlib/gg/gg.v
|
@ -25,39 +25,40 @@ pub type FNChar = fn (c u32, x voidptr)
|
||||||
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub:
|
pub:
|
||||||
width int
|
width int
|
||||||
height int
|
height int
|
||||||
use_ortho bool
|
use_ortho bool
|
||||||
retina bool
|
retina bool
|
||||||
resizable bool
|
resizable bool
|
||||||
user_data voidptr
|
user_data voidptr
|
||||||
font_size int
|
font_size int
|
||||||
create_window bool
|
create_window bool
|
||||||
// window_user_ptr voidptr
|
// window_user_ptr voidptr
|
||||||
window_title string
|
window_title string
|
||||||
borderless_window bool
|
borderless_window bool
|
||||||
always_on_top bool
|
always_on_top bool
|
||||||
bg_color gx.Color
|
bg_color gx.Color
|
||||||
init_fn FNCb = voidptr(0)
|
init_fn FNCb = voidptr(0)
|
||||||
frame_fn FNCb = voidptr(0)
|
frame_fn FNCb = voidptr(0)
|
||||||
cleanup_fn FNCb = voidptr(0)
|
cleanup_fn FNCb = voidptr(0)
|
||||||
fail_fn FNFail = voidptr(0)
|
fail_fn FNFail = voidptr(0)
|
||||||
event_fn FNEvent = voidptr(0)
|
event_fn FNEvent = voidptr(0)
|
||||||
keydown_fn FNKeyDown = voidptr(0)
|
keydown_fn FNKeyDown = voidptr(0)
|
||||||
// special case of event_fn
|
// special case of event_fn
|
||||||
char_fn FNChar = voidptr(0)
|
char_fn FNChar = voidptr(0)
|
||||||
// special case of event_fn
|
// special case of event_fn
|
||||||
move_fn FNMove = voidptr(0)
|
move_fn FNMove = voidptr(0)
|
||||||
// special case of event_fn
|
// special case of event_fn
|
||||||
click_fn FNMove = voidptr(0)
|
click_fn FNMove = voidptr(0)
|
||||||
// special case of event_fn
|
// special case of event_fn
|
||||||
// wait_events bool // set this to true for UIs, to save power
|
// wait_events bool // set this to true for UIs, to save power
|
||||||
fullscreen bool
|
fullscreen bool
|
||||||
scale f32 = 1.0
|
scale f32 = 1.0
|
||||||
// vid needs this
|
// vid needs this
|
||||||
// init_text bool
|
// init_text bool
|
||||||
font_path string
|
font_path string
|
||||||
ui_mode bool
|
custom_bold_font_path string
|
||||||
|
ui_mode bool // refreshes only on events to save CPU usage
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Context {
|
pub struct Context {
|
||||||
|
@ -122,6 +123,7 @@ fn gg_init_sokol_window(user_data voidptr) {
|
||||||
// t := time.ticks()
|
// t := time.ticks()
|
||||||
g.ft = new_ft({
|
g.ft = new_ft({
|
||||||
font_path: g.config.font_path
|
font_path: g.config.font_path
|
||||||
|
custom_bold_font_path: g.config.custom_bold_font_path
|
||||||
scale: sapp.dpi_scale()
|
scale: sapp.dpi_scale()
|
||||||
}) or {
|
}) or {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -26,6 +26,7 @@ pub:
|
||||||
|
|
||||||
struct FTConfig {
|
struct FTConfig {
|
||||||
font_path string
|
font_path string
|
||||||
|
custom_bold_font_path string
|
||||||
scale f32 = 1.0
|
scale f32 = 1.0
|
||||||
font_size int
|
font_size int
|
||||||
}
|
}
|
||||||
|
@ -52,7 +53,7 @@ fn new_ft(c FTConfig) ?&FT {
|
||||||
return none
|
return none
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bold_path := get_font_path_variant(c.font_path, .bold)
|
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 {
|
bytes_bold := os.read_bytes(bold_path) or {
|
||||||
debug_font_println('failed to load font "$bold_path"')
|
debug_font_println('failed to load font "$bold_path"')
|
||||||
bytes
|
bytes
|
||||||
|
|
|
@ -1265,7 +1265,7 @@ pub fn (mut f Fmt) fn_decl(node ast.FnDecl) {
|
||||||
f.stmts(node.stmts)
|
f.stmts(node.stmts)
|
||||||
f.write('}')
|
f.write('}')
|
||||||
}
|
}
|
||||||
if !node.is_anon {
|
if !node.is_anon && !node.no_body {
|
||||||
f.writeln('\n')
|
f.writeln('\n')
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue