Changed love.graphics.newFont() to mimic regular love's params
Updated docs/api.md
This commit is contained in:
@@ -141,7 +141,7 @@ dimensions as the screen.
|
|||||||
##### love.graphics.newQuad(x, y, width, height)
|
##### love.graphics.newQuad(x, y, width, height)
|
||||||
Creates and returns a new quad.
|
Creates and returns a new quad.
|
||||||
|
|
||||||
##### love.graphics.newFont([filename [, ptsize]])
|
##### love.graphics.newFont([filename ,] ptsize)
|
||||||
Creates and returns a new font. `filename` should be the name of a ttf file and
|
Creates and returns a new font. `filename` should be the name of a ttf file and
|
||||||
`ptsize` its size. If no `filename` is provided the built in font is used.
|
`ptsize` its size. If no `filename` is provided the built in font is used.
|
||||||
|
|
||||||
|
|||||||
11
src/font.c
11
src/font.c
@@ -152,8 +152,15 @@ void font_blit(font_t *self, pixel_t *buf, int bufw, int bufh,
|
|||||||
|
|
||||||
|
|
||||||
int l_font_new(lua_State *L) {
|
int l_font_new(lua_State *L) {
|
||||||
const char *filename = lua_isnoneornil(L, 1) ? NULL : luaL_checkstring(L, 1);
|
const char *filename;
|
||||||
int ptsize = luaL_optnumber(L, 2, 12);
|
int ptsize = 12;
|
||||||
|
if ( lua_isnoneornil(L, 2) ) {
|
||||||
|
filename = NULL;
|
||||||
|
ptsize = luaL_optnumber(L, 1, ptsize);
|
||||||
|
} else {
|
||||||
|
filename = luaL_checkstring(L, 1);
|
||||||
|
ptsize = luaL_optnumber(L, 2, ptsize);
|
||||||
|
}
|
||||||
font_t *self = luaobj_newudata(L, sizeof(*self));
|
font_t *self = luaobj_newudata(L, sizeof(*self));
|
||||||
luaobj_setclass(L, CLASS_TYPE, CLASS_NAME);
|
luaobj_setclass(L, CLASS_TYPE, CLASS_NAME);
|
||||||
if (filename) {
|
if (filename) {
|
||||||
|
|||||||
Reference in New Issue
Block a user