mirror of https://github.com/bjornbytes/lovr.git
Font:hasGlyphs;
This commit is contained in:
parent
20ddad4a9e
commit
112d775635
|
@ -59,6 +59,21 @@ int l_lovrFontSetPixelDensity(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int l_lovrFontHasGlyphs(lua_State* L) {
|
||||
Font* font = luax_checktype(L, 1, Font);
|
||||
Rasterizer* rasterizer = lovrFontGetRasterizer(font);
|
||||
bool hasGlyphs = true;
|
||||
for (int i = 2; i <= lua_gettop(L); i++) {
|
||||
if (lua_type(L, i) == LUA_TSTRING) {
|
||||
hasGlyphs &= lovrRasterizerHasGlyphs(rasterizer, lua_tostring(L, i));
|
||||
} else {
|
||||
hasGlyphs &= lovrRasterizerHasGlyph(rasterizer, luaL_checkinteger(L, i));
|
||||
}
|
||||
}
|
||||
lua_pushboolean(L, hasGlyphs);
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg lovrFont[] = {
|
||||
{ "getWidth", l_lovrFontGetWidth },
|
||||
{ "getHeight", l_lovrFontGetHeight },
|
||||
|
@ -69,5 +84,6 @@ const luaL_Reg lovrFont[] = {
|
|||
{ "setLineHeight", l_lovrFontSetLineHeight },
|
||||
{ "getPixelDensity", l_lovrFontGetPixelDensity },
|
||||
{ "setPixelDensity", l_lovrFontSetPixelDensity },
|
||||
{ "hasGlyphs", l_lovrFontHasGlyphs },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
|
|
@ -68,6 +68,10 @@ void lovrFontDestroy(void* ref) {
|
|||
free(font);
|
||||
}
|
||||
|
||||
Rasterizer* lovrFontGetRasterizer(Font* font) {
|
||||
return font->rasterizer;
|
||||
}
|
||||
|
||||
void lovrFontRender(Font* font, const char* str, float wrap, HorizontalAlign halign, VerticalAlign valign, VertexPointer vertices, float* offsety, uint32_t* vertexCount) {
|
||||
FontAtlas* atlas = &font->atlas;
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ typedef struct {
|
|||
|
||||
Font* lovrFontCreate(Rasterizer* rasterizer);
|
||||
void lovrFontDestroy(void* ref);
|
||||
Rasterizer* lovrFontGetRasterizer(Font* font);
|
||||
void lovrFontRender(Font* font, const char* str, float wrap, HorizontalAlign halign, VerticalAlign valign, VertexPointer vertices, float* offsety, uint32_t* vertexCount);
|
||||
float lovrFontGetWidth(Font* font, const char* string, float wrap);
|
||||
float lovrFontGetHeight(Font* font);
|
||||
|
|
Loading…
Reference in New Issue