缺失字体时使用引擎自带字体

This commit is contained in:
MrZ626
2020-09-06 21:35:32 +08:00
parent e47e0e1c78
commit 68c4a9fceb

View File

@@ -2,10 +2,12 @@ local gc=love.graphics
local int=math.floor
local format=string.format
local fontData=love.filesystem.newFile("font.ttf")
do
local newFont=gc.setNewFont
local setNewFont=gc.setFont
local fontCache,currentFontSize={}
if love.filesystem.getInfo("font.ttf")then
local fontData=love.filesystem.newFile("font.ttf")
function setFont(s)
local f=fontCache[s]
if s~=currentFontSize then
@@ -20,6 +22,23 @@ function setFont(s)
end
return f
end
else
function setFont(s)
local f=fontCache[s]
if s~=currentFontSize then
if f then
setNewFont(f)
else
f=newFont(s)
fontCache[s]=f
setNewFont(f)
end
currentFontSize=s
end
return f
end
end
end
function toTime(s)
if s<60 then