Skip to content
Snippets Groups Projects
Commit 9235fa53 authored by Alex Ksandra's avatar Alex Ksandra
Browse files

Baseline Quality-Of-Life.

parent 4a36e73d
No related branches found
No related tags found
1 merge request!108Font.draw convert
......@@ -27,6 +27,7 @@ module(..., package.seeall, class.make)
local gfx_prefix = "/data/gfx/"
local cache = {}
local tcache = {}
local fcache = {}
-- Default font
_M.font = core.display.newFont("/data/font/DroidSans.ttf", 12)
......@@ -93,6 +94,7 @@ end
function _M:clearCache()
cache = {}
tcache = {}
fcache = {}
end
function _M:getImage(file, noerror)
......@@ -117,6 +119,19 @@ function _M:getUITexture(file)
return r
end
function _M:drawFontLine(font, text, width) -- always draw with white, outputting texture can have it changed
local cached = table.getTable(fcache, font, font:getStyle())
if cached[text] then return cached[text] end
local tex = font:draw(text, width, 255, 255, 255, true)[1]
local r = {t = tex._tex, w=tex.w, h=tex.h, tw=tex._tex_w, th=tex._tex_h}
cached[text] = r
return r
end
function _M:textureToScreen(tex, x, y, r, g, b, a)
return tex.t:toScreenFull(x, y, tex.w, tex.h, tex.tw, tex.th, r, g, b, a)
end
function _M:makeFrame(base, w, h)
local f = {}
if base then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment