mirror of https://github.com/bjornbytes/lovr.git
parent
717f95f6bd
commit
0d7fed1fa7
|
@ -11,6 +11,17 @@ static int l_lovrRasterizerGetFontSize(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_lovrRasterizerGetBoundingBox(lua_State* L) {
|
||||||
|
Rasterizer* rasterizer = luax_checktype(L, 1, Rasterizer);
|
||||||
|
float box[4];
|
||||||
|
lovrRasterizerGetBoundingBox(rasterizer, box);
|
||||||
|
lua_pushnumber(L, box[0]);
|
||||||
|
lua_pushnumber(L, box[1]);
|
||||||
|
lua_pushnumber(L, box[2]);
|
||||||
|
lua_pushnumber(L, box[3]);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
static int l_lovrRasterizerGetGlyphCount(lua_State* L) {
|
static int l_lovrRasterizerGetGlyphCount(lua_State* L) {
|
||||||
Rasterizer* rasterizer = luax_checktype(L, 1, Rasterizer);
|
Rasterizer* rasterizer = luax_checktype(L, 1, Rasterizer);
|
||||||
uint32_t count = lovrRasterizerGetGlyphCount(rasterizer);
|
uint32_t count = lovrRasterizerGetGlyphCount(rasterizer);
|
||||||
|
@ -187,6 +198,7 @@ static int l_lovrRasterizerGetGlyphCurves(lua_State* L) {
|
||||||
|
|
||||||
const luaL_Reg lovrRasterizer[] = {
|
const luaL_Reg lovrRasterizer[] = {
|
||||||
{ "getFontSize", l_lovrRasterizerGetFontSize },
|
{ "getFontSize", l_lovrRasterizerGetFontSize },
|
||||||
|
{ "getBoundingBox", l_lovrRasterizerGetBoundingBox },
|
||||||
{ "getGlyphCount", l_lovrRasterizerGetGlyphCount },
|
{ "getGlyphCount", l_lovrRasterizerGetGlyphCount },
|
||||||
{ "hasGlyphs", l_lovrRasterizerHasGlyphs },
|
{ "hasGlyphs", l_lovrRasterizerHasGlyphs },
|
||||||
{ "getAscent", l_lovrRasterizerGetAscent },
|
{ "getAscent", l_lovrRasterizerGetAscent },
|
||||||
|
|
|
@ -54,6 +54,15 @@ float lovrRasterizerGetFontSize(Rasterizer* rasterizer) {
|
||||||
return rasterizer->size;
|
return rasterizer->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lovrRasterizerGetBoundingBox(Rasterizer* rasterizer, float box[4]) {
|
||||||
|
int x0, y0, x1, y1;
|
||||||
|
stbtt_GetFontBoundingBox(&rasterizer->font, &x0, &y0, &x1, &y1);
|
||||||
|
box[0] = x0 * rasterizer->scale;
|
||||||
|
box[1] = y0 * rasterizer->scale;
|
||||||
|
box[2] = x1 * rasterizer->scale;
|
||||||
|
box[3] = y1 * rasterizer->scale;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t lovrRasterizerGetGlyphCount(Rasterizer* rasterizer) {
|
uint32_t lovrRasterizerGetGlyphCount(Rasterizer* rasterizer) {
|
||||||
return rasterizer->font.numGlyphs;
|
return rasterizer->font.numGlyphs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ typedef struct Rasterizer Rasterizer;
|
||||||
Rasterizer* lovrRasterizerCreate(struct Blob* blob, float size);
|
Rasterizer* lovrRasterizerCreate(struct Blob* blob, float size);
|
||||||
void lovrRasterizerDestroy(void* ref);
|
void lovrRasterizerDestroy(void* ref);
|
||||||
float lovrRasterizerGetFontSize(Rasterizer* rasterizer);
|
float lovrRasterizerGetFontSize(Rasterizer* rasterizer);
|
||||||
|
void lovrRasterizerGetBoundingBox(Rasterizer* rasterizer, float box[4]);
|
||||||
uint32_t lovrRasterizerGetGlyphCount(Rasterizer* rasterizer);
|
uint32_t lovrRasterizerGetGlyphCount(Rasterizer* rasterizer);
|
||||||
bool lovrRasterizerHasGlyph(Rasterizer* rasterizer, uint32_t codepoint);
|
bool lovrRasterizerHasGlyph(Rasterizer* rasterizer, uint32_t codepoint);
|
||||||
bool lovrRasterizerHasGlyphs(Rasterizer* rasterizer, const char* str, size_t length);
|
bool lovrRasterizerHasGlyphs(Rasterizer* rasterizer, const char* str, size_t length);
|
||||||
|
|
Loading…
Reference in New Issue