@ -78,7 +78,10 @@ function Font:getFace(font, size)
end
end
function Font : _readList ( target , dir )
function Font : _readList ( target , dir )
for f in lfs.dir ( dir ) do
-- lfs.dir non-exsitent directory will give error, weird!
local ok , iter , dir_obj = pcall ( lfs.dir , dir )
if not ok then return end
for f in iter , dir_obj do
if lfs.attributes ( dir .. " / " .. f , " mode " ) == " directory " and f ~= " . " and f ~= " .. " then
if lfs.attributes ( dir .. " / " .. f , " mode " ) == " directory " and f ~= " . " and f ~= " .. " then
self : _readList ( target , dir .. " / " .. f )
self : _readList ( target , dir .. " / " .. f )
else
else
@ -95,7 +98,7 @@ function Font:getFontList()
local fontlist = { }
local fontlist = { }
self : _readList ( fontlist , self.fontdir )
self : _readList ( fontlist , self.fontdir )
-- multiple path should be joined with semicolon in FONTDIR env variable
-- multiple path should be joined with semicolon in FONTDIR env variable
for dir in string.gmatch ( os.getenv ( " FONTDIR" ) or " " , " ([^;]+) " ) do
for dir in string.gmatch ( os.getenv ( " EXT_ FONT_ DIR" ) or " " , " ([^;]+) " ) do
self : _readList ( fontlist , dir )
self : _readList ( fontlist , dir )
end
end
table.sort ( fontlist )
table.sort ( fontlist )