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