Skip to content

Commit 59ab359

Browse files
committed
#2268: fixed font() api arguments count
1 parent 116113d commit 59ab359

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

src/api.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ enum
290290
0, \
291291
void, \
292292
tic_mem*, s32 index, s32 x, s32 y, s32 w, s32 h, \
293-
u8* trans_colors, u8 trans_count, s32 scale, tic_flip flip, tic_rotate rotate) \
293+
u8* trans_colors, u8 trans_count, s32 scale, tic_flip flip, tic_rotate rotate) \
294294
\
295295
\
296296
macro(btn, \
@@ -363,7 +363,7 @@ enum
363363
"The map can be up to 240 cells wide by 136 deep.\n" \
364364
"This function will draw the desired area of the map to a specified screen position.\n" \
365365
"For example, map(5,5,12,10,0,0) will draw a 12x10 section of the map, " \
366-
"starting from map coordinates (5,5) to screen position (0,0).\n" \
366+
"starting from map coordinates (5,5) to screen position (0,0).\n" \
367367
"The map function's last parameter is a powerful callback function " \
368368
"for changing how map cells (sprites) are drawn when map is called.\n" \
369369
"It can be used to rotate, flip and replace sprites while the game is running.\n" \
@@ -379,7 +379,7 @@ enum
379379
1, \
380380
void, \
381381
tic_mem*, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, \
382-
u8* trans_colors, u8 trans_count, s32 scale, RemapFunc remap, void* data) \
382+
u8* trans_colors, u8 trans_count, s32 scale, RemapFunc remap, void* data) \
383383
\
384384
\
385385
macro(mget, \
@@ -606,17 +606,17 @@ enum
606606
\
607607
\
608608
macro(font, \
609-
"font(text x y chromakey char_width char_height fixed=false scale=1) -> width", \
609+
"font(text x y chromakey char_width char_height fixed=false scale=1 alt=false) -> width", \
610610
\
611611
"Print string with font defined in foreground sprites.\n" \
612612
"To simply print to the screen, check out `print()`.\n" \
613613
"To print to the console, check out `trace()`.", \
614-
8, \
614+
9, \
615615
6, \
616616
0, \
617617
s32, \
618618
tic_mem*, const char* text, s32 x, s32 y, \
619-
u8* trans_colors, u8 trans_count, s32 w, s32 h, bool fixed, s32 scale, bool alt) \
619+
u8* trans_colors, u8 trans_count, s32 w, s32 h, bool fixed, s32 scale, bool alt) \
620620
\
621621
\
622622
macro(mouse, \
@@ -700,8 +700,8 @@ enum
700700
tic_mem*, float x1, float y1, float x2, float y2, float x3, float y3, u8 color) \
701701
\
702702
\
703-
macro(ttri, \
704-
"ttri(x1 y1 x2 y2 x3 y3 u1 v1 u2 v2 u3 v3 texsrc=0 chromakey=-1 z1=0 z2=0 z3=0)", \
703+
macro(ttri, \
704+
"ttri(x1 y1 x2 y2 x3 y3 u1 v1 u2 v2 u3 v3 texsrc=0 chromakey=-1 z1=0 z2=0 z3=0)", \
705705
\
706706
"It renders a triangle filled with texture from image ram, map ram or vbank.\n" \
707707
"Use in 3D graphics.\n" \

src/api/js.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -675,18 +675,13 @@ static JSValue js_font(JSContext *ctx, JSValueConst this_val, s32 argc, JSValueC
675675
s32 x = getInteger(ctx, argv[1]);
676676
s32 y = getInteger(ctx, argv[2]);
677677
u8 chromakey = getInteger(ctx, argv[3]);
678-
s32 width = getInteger2(ctx, argv[4], TIC_SPRITESIZE);
679-
s32 height = getInteger2(ctx, argv[5], TIC_SPRITESIZE);
678+
s32 width = getInteger2(ctx, argv[4], TIC_SPRITESIZE);
679+
s32 height = getInteger2(ctx, argv[5], TIC_SPRITESIZE);
680680
bool fixed = JS_ToBool(ctx, argv[6]);
681-
s32 scale = getInteger2(ctx, argv[7], 1);
681+
s32 scale = getInteger2(ctx, argv[7], 1);
682682
bool alt = JS_ToBool(ctx, argv[8]);
683683

684-
if(scale == 0)
685-
{
686-
return JS_NewInt32(ctx, 0);
687-
}
688-
689-
s32 size = tic_api_font(tic, text, x, y, &chromakey, 1, width, height, fixed, scale, alt);
684+
s32 size = scale ? tic_api_font(tic, text, x, y, &chromakey, 1, width, height, fixed, scale, alt) : 0;
690685

691686
JS_FreeCString(ctx, text);
692687
return JS_NewInt32(ctx, size);

0 commit comments

Comments
 (0)