examples: clean file path usage in the examples, move all the fonts in the common assets folder (#12736)
parent
6f5d952d8f
commit
89eb5425cd
|
@ -910,7 +910,7 @@ fn (mut app App) showfps() {
|
|||
fn main() {
|
||||
mut app := &App{}
|
||||
app.new_game()
|
||||
mut font_path := os.resource_abs_path(os.join_path('../assets/fonts/', 'RobotoMono-Regular.ttf'))
|
||||
mut font_path := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
|
||||
$if android {
|
||||
font_path = 'fonts/RobotoMono-Regular.ttf'
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
@ -152,7 +152,7 @@ fn on_init(mut app App) {
|
|||
[console]
|
||||
fn main() {
|
||||
println("Press 'q' to quit.")
|
||||
mut font_path := os.resource_abs_path(os.join_path('../assets/fonts/', 'RobotoMono-Regular.ttf'))
|
||||
mut font_path := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
|
||||
$if android {
|
||||
font_path = 'fonts/RobotoMono-Regular.ttf'
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ fn (mut app App) resize() {
|
|||
// is needed for easier diagnostics on windows
|
||||
[console]
|
||||
fn main() {
|
||||
mut font_path := os.resource_abs_path(os.join_path('../assets/fonts/', 'RobotoMono-Regular.ttf'))
|
||||
mut font_path := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
|
||||
$if android {
|
||||
font_path = 'fonts/RobotoMono-Regular.ttf'
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ fn main() {
|
|||
mut app := &App{
|
||||
gg: 0
|
||||
}
|
||||
mut font_path := os.resource_abs_path(os.join_path('../assets/fonts/', 'RobotoMono-Regular.ttf'))
|
||||
mut font_path := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
|
||||
$if android {
|
||||
font_path = 'fonts/RobotoMono-Regular.ttf'
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ mut:
|
|||
}
|
||||
|
||||
fn main() {
|
||||
mut font_path := os.resource_abs_path(os.join_path('../assets/fonts/', 'RobotoMono-Regular.ttf'))
|
||||
mut font_path := os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'RobotoMono-Regular.ttf'))
|
||||
mut app := &App{
|
||||
gg: 0
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ fn main() {
|
|||
user_data: app
|
||||
init_fn: init_images
|
||||
)
|
||||
app.image = app.gg.create_image(os.resource_abs_path('logo.png'))
|
||||
mut logo_path := os.resource_abs_path(os.join_path('..', 'assets', 'logo.png'))
|
||||
app.image = app.gg.create_image(logo_path)
|
||||
app.gg.run()
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,8 @@ fn main() {
|
|||
}
|
||||
|
||||
fn init_images(mut app App) {
|
||||
app.image = app.gg.create_image(os.resource_abs_path('logo.png'))
|
||||
mut logo_path := os.resource_abs_path(os.join_path('..', 'assets', 'logo.png'))
|
||||
app.image = app.gg.create_image(logo_path)
|
||||
}
|
||||
|
||||
fn frame(mut app App) {
|
||||
|
|
|
@ -12,6 +12,7 @@ mut:
|
|||
font_normal int
|
||||
}
|
||||
|
||||
[console]
|
||||
fn main() {
|
||||
mut color_action := C.sg_color_attachment_action{
|
||||
action: gfx.Action(C.SG_ACTION_CLEAR)
|
||||
|
@ -46,7 +47,9 @@ fn init(mut state AppState) {
|
|||
C.sgl_setup(s)
|
||||
state.fons = sfons.create(512, 512, 1)
|
||||
// or use DroidSerif-Regular.ttf
|
||||
if bytes := os.read_bytes(os.resource_abs_path('../assets/fonts/RobotoMono-Regular.ttf')) {
|
||||
if bytes := os.read_bytes(os.resource_abs_path(os.join_path('..', 'assets', 'fonts',
|
||||
'RobotoMono-Regular.ttf')))
|
||||
{
|
||||
println('loaded font: $bytes.len')
|
||||
state.font_normal = C.fonsAddFontMem(state.fons, c'sans', bytes.data, bytes.len,
|
||||
false)
|
||||
|
|
|
@ -61,6 +61,7 @@ mut:
|
|||
inited bool
|
||||
}
|
||||
|
||||
[console]
|
||||
fn main() {
|
||||
mut color_action := C.sg_color_attachment_action{
|
||||
action: gfx.Action(C.SG_ACTION_CLEAR)
|
||||
|
@ -99,7 +100,9 @@ fn init(user_data voidptr) {
|
|||
C.sgl_setup(s)
|
||||
state.fons = sfons.create(512, 512, 1)
|
||||
// or use DroidSerif-Regular.ttf
|
||||
if bytes := os.read_bytes(os.resource_abs_path('../assets/fonts/RobotoMono-Regular.ttf')) {
|
||||
if bytes := os.read_bytes(os.resource_abs_path(os.join_path('..', 'assets', 'fonts',
|
||||
'RobotoMono-Regular.ttf')))
|
||||
{
|
||||
println('loaded font: $bytes.len')
|
||||
state.font_normal = C.fonsAddFontMem(state.fons, c'sans', bytes.data, bytes.len,
|
||||
false)
|
||||
|
|
|
@ -11,8 +11,8 @@ const (
|
|||
win_height = 700
|
||||
bg_color = gx.white
|
||||
font_paths = [
|
||||
os.resource_abs_path('Imprima-Regular.ttf'),
|
||||
os.resource_abs_path('Graduate-Regular.ttf'),
|
||||
os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'Imprima-Regular.ttf')),
|
||||
os.resource_abs_path(os.join_path('..', 'assets', 'fonts', 'Graduate-Regular.ttf')),
|
||||
]
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue