缺失字体时使用引擎自带字体
This commit is contained in:
@@ -2,11 +2,13 @@ local gc=love.graphics
|
|||||||
local int=math.floor
|
local int=math.floor
|
||||||
local format=string.format
|
local format=string.format
|
||||||
|
|
||||||
local fontData=love.filesystem.newFile("font.ttf")
|
do
|
||||||
local newFont=gc.setNewFont
|
local newFont=gc.setNewFont
|
||||||
local setNewFont=gc.setFont
|
local setNewFont=gc.setFont
|
||||||
local fontCache,currentFontSize={}
|
local fontCache,currentFontSize={}
|
||||||
function setFont(s)
|
if love.filesystem.getInfo("font.ttf")then
|
||||||
|
local fontData=love.filesystem.newFile("font.ttf")
|
||||||
|
function setFont(s)
|
||||||
local f=fontCache[s]
|
local f=fontCache[s]
|
||||||
if s~=currentFontSize then
|
if s~=currentFontSize then
|
||||||
if f then
|
if f then
|
||||||
@@ -19,6 +21,23 @@ function setFont(s)
|
|||||||
currentFontSize=s
|
currentFontSize=s
|
||||||
end
|
end
|
||||||
return f
|
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
|
end
|
||||||
|
|
||||||
function toTime(s)
|
function toTime(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user