int register_graphics::drawFont(lua_State *L) { font* f = checkFont(L, 1); shader* s = checkShader(L, 2); if(!s->getLinked() && s != NULL) LOG("WARNING: shader:bind must be called before drawFont!"); const char* message = ""; if(lua_isstring(L, 3)) message = lua_tostring(L, 3); float x; float y; if(lua_isnumber(L,4)) x = lua_tonumber(L, 4); if(lua_isnumber(L,5)) y = lua_tonumber(L, 5); float sx = 1; float sy = 1; if(lua_isnumber(L,6)) sx = lua_tonumber(L, 6); if(lua_isnumber(L,7)) sy = lua_tonumber(L, 7); float r = 255; float g = 255; float b = 255; if(lua_isnumber(L, 8)) r = lua_tonumber(L, 8); if(lua_isnumber(L, 9)) g = lua_tonumber(L, 9); if(lua_isnumber(L, 10)) b = lua_tonumber(L, 10); float a = 255; if(lua_isnumber(L, 11)) a = lua_tonumber(L, 11); f->draw(message, s, x, y, sx, sy, r, g, b, a); return 1; }
static int lua_font_gc(lua_State *L) { struct Font *pFont = checkFont(L, 1); if (pFont) { ui_unload_font(pFont->data); } return 0; }
int register_graphics::deleteFont(lua_State *L) { font* f = checkFont(L, 1); if (f != NULL){ SAFE_DELETE(f); }else{ LOG("can not delete font because it is null!"); return 0; } return 1; }
void CSSSegmentedFontFace::loadFont(const FontDescription& fontDescription, PassRefPtr<LoadFontCallback> callback) { fontRanges(fontDescription); // Kick off the load. if (callback) { if (isLoading()) m_callbacks.append(callback); else if (checkFont()) callback->notifyLoaded(); else callback->notifyError(); } }
void CSSSegmentedFontFace::fontLoaded(CSSFontFace*) { pruneTable(); if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) { Vector<RefPtr<LoadFontCallback> > callbacks; m_callbacks.swap(callbacks); for (size_t index = 0; index < callbacks.size(); ++index) { if (checkFont()) callbacks[index]->notifyLoaded(this); else callbacks[index]->notifyError(this); } } }
void CSSSegmentedFontFace::fontLoaded(CSSFontFace*) { pruneTable(); #if ENABLE(FONT_LOAD_EVENTS) if (RuntimeEnabledFeatures::sharedFeatures().fontLoadEventsEnabled() && !isLoading()) { Vector<RefPtr<LoadFontCallback>> callbacks; m_callbacks.swap(callbacks); for (size_t index = 0; index < callbacks.size(); ++index) { if (checkFont()) callbacks[index]->notifyLoaded(); else callbacks[index]->notifyError(); } } #endif }
int register_graphics::createFont(lua_State *L) { font* f = checkFont(L, 1); shader* s = checkShader(L, 2); luaL_checkstring(L, 3); const char* path = lua_tostring(L, 3); FT_Library freetype; if(FT_Init_FreeType(&freetype)){ LOG("Error: Could not init freetype lib!"); return 0; } float size = 16; if(lua_isnumber(L, 4)) size = lua_tonumber(L, 4); f->load(freetype, s, path, size); return 1; }
int register_graphics::endFont(lua_State *L) { font* f = checkFont(L, 1); f->end(); return 1; }
int register_graphics::beginFont(lua_State *L) { font* f = checkFont(L, 1); f->begin(); return 1; }
static int lua_ui_set_font(lua_State *L) { struct Font *pFont = checkFont(L, 2); if (pFont) ui_set_font(pFont->data); return 0; }