66 return (
glFont*) lua_touserdata(L,ind);
79 luaL_typerror(L, ind, FONT_METATABLE);
93 luaL_getmetatable(L, FONT_METATABLE);
94 lua_setmetatable(L, -2);
108 if (lua_getmetatable(L,ind)==0)
110 lua_getfield(L, LUA_REGISTRYINDEX, FONT_METATABLE);
113 if (lua_rawequal(L, -1, -2))
145 lua_pushboolean( L, (memcmp( f1, f2,
sizeof(
glFont) )==0) );
163 const char *fname, *prefix;
165 if (lua_gettop(L)==1) {
167 h = luaL_checkint(L,1);
170 fname = luaL_optstring(L,1,NULL);
171 h = luaL_checkint(L,2);
175 fname = _(FONT_DEFAULT_PATH);
176 prefix = FONT_PATH_PREFIX;
181 if (
gl_fontInit( &font, fname, h, prefix, FONT_FLAG_DONTREUSE ))
182 return NLUA_ERROR(L, _(
"failed to load font '%s'"), fname);
185 lua_pushstring( L, fname );
186 lua_pushstring( L, prefix );
200 lua_pushnumber(L, font->
h);
215 const char *text = luaL_checkstring(L,2);
217 lua_pushinteger(L, width);
232 const char *smin = luaL_checkstring(L,2);
233 const char *smag = luaL_optstring(L,3,smin);
239 if (min==0 || mag==0)
240 NLUA_INVALID_PARAMETER(L,2);
258 const char *s = luaL_checkstring(L,2);
259 const char *prefix = luaL_optstring(L,3,
"");
261 lua_pushboolean(L, !ret);
int gl_printWidthRaw(const glFont *ft_font, const char *text)
Gets the width that it would take to print some text.
int gl_fontAddFallback(glFont *font, const char *fname, const char *prefix)
Adds a fallback font to a font.
void gl_freeFont(glFont *font)
Frees a loaded font. Caution: its glFontStash still has a slot in avail_fonts. At the time of writing...
int gl_fontInit(glFont *font, const char *fname, const unsigned int h, const char *prefix, unsigned int flags)
Initializes a font.
void gl_fontSetFilter(const glFont *ft_font, GLint min, GLint mag)
Sets the minification and magnification filters for a font.
Header file with generic functions and naev-specifics.
glFont * lua_pushfont(lua_State *L, glFont font)
Pushes a font on the stack.
static int fontL_height(lua_State *L)
Gets the height of a font.
static int fontL_width(lua_State *L)
Gets the width of some text for a font.
static int fontL_addFallback(lua_State *L)
Adds a fallback to a font.
int nlua_loadFont(nlua_env env)
Loads the font library.
static int fontL_eq(lua_State *L)
Compares two fonts to see if they are the same.
glFont * luaL_checkfont(lua_State *L, int ind)
Gets font at index or raises error if there is no font at index.
static int fontL_setFilter(lua_State *L)
Sets the font minification and magnification filters.
static int fontL_new(lua_State *L)
Gets a font.
int lua_isfont(lua_State *L, int ind)
Checks to see if ind is a font.
glFont * lua_tofont(lua_State *L, int ind)
Lua bindings to interact with fonts.
static const luaL_Reg fontL_methods[]
static int fontL_gc(lua_State *L)
Frees a font.
GLint gl_stringToFilter(const char *s)
Gets the associated min/mag filter from a string.
Represents a font in memory.