63 return (
glFont *)lua_touserdata( L, ind );
76 luaL_typerror( L, ind, FONT_METATABLE );
90 luaL_getmetatable( L, FONT_METATABLE );
91 lua_setmetatable( L, -2 );
105 if ( lua_getmetatable( L, ind ) == 0 )
107 lua_getfield( L, LUA_REGISTRYINDEX, FONT_METATABLE );
110 if ( lua_rawequal( L, -1, -2 ) )
142 lua_pushboolean( L, ( memcmp( f1, f2,
sizeof(
glFont ) ) == 0 ) );
160 const char *fname, *prefix;
162 if ( lua_gettop( L ) == 1 ) {
164 h = luaL_checkint( L, 1 );
166 fname = luaL_optstring( L, 1, NULL );
167 h = luaL_checkint( L, 2 );
170 if ( fname == NULL ) {
171 fname = _( FONT_DEFAULT_PATH );
172 prefix = FONT_PATH_PREFIX;
176 if (
gl_fontInit( &font, fname, h, prefix, FONT_FLAG_DONTREUSE ) )
177 return NLUA_ERROR( L, _(
"failed to load font '%s'" ), fname );
180 lua_pushstring( L, fname );
181 lua_pushstring( L, prefix );
195 lua_pushnumber( L, font->
h );
210 const char *text = luaL_checkstring( L, 2 );
212 lua_pushinteger( L, width );
228 const char *smin = luaL_checkstring( L, 2 );
229 const char *smag = luaL_optstring( L, 3, smin );
235 if ( min == 0 || mag == 0 )
236 NLUA_INVALID_PARAMETER( L, 2 );
254 const char *s = luaL_checkstring( L, 2 );
255 const char *prefix = luaL_optstring( L, 3,
"" );
257 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.
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.
GLenum gl_stringToFilter(const char *s)
Gets the associated min/mag filter from a string.
Represents a font in memory.