Cache fontlist

pull/5286/head
Frans de Jonge 5 years ago
parent 621a84c1d3
commit 418aa1e5d6

@ -2,6 +2,7 @@ local CanvasContext = require("document/canvascontext")
local FontList = { local FontList = {
fontdir = "./fonts", fontdir = "./fonts",
fontlist = {},
} }
--[[ --[[
@ -94,14 +95,14 @@ local function _readList(target, dir)
end end
function FontList:getFontList() function FontList:getFontList()
local fontlist = {} if #self.fontlist > 0 then return self.fontlist end
_readList(fontlist, self.fontdir) _readList(self.fontlist, self.fontdir)
-- multiple paths should be joined with semicolon -- multiple paths should be joined with semicolon
for dir in string.gmatch(getExternalFontDir() or "", "([^;]+)") do for dir in string.gmatch(getExternalFontDir() or "", "([^;]+)") do
_readList(fontlist, dir) _readList(self.fontlist, dir)
end end
table.sort(fontlist) table.sort(self.fontlist)
return fontlist return self.fontlist
end end
return FontList return FontList

Loading…
Cancel
Save