setFont改为font模块,字体文件放到parts/fonts内,调整打包ci对应处

This commit is contained in:
MrZ626
2021-08-29 14:17:52 +08:00
parent 66dcfa40b0
commit 16c377427a
11 changed files with 91 additions and 87 deletions

55
Zframework/font.lua Normal file
View File

@@ -0,0 +1,55 @@
local gc=love.graphics
local fontCache={}
local currentFontSize
local FONT={}
function FONT.set(s)
if s~=currentFontSize then
if not fontCache[s]then
fontCache[s]=gc.setNewFont(s,'light',gc.getDPIScale()*SCR.k*2)
end
gc.setFont(fontCache[s])
currentFontSize=s
end
end
function FONT.get(s)print(1)
if not fontCache[s]then
fontCache[s]=gc.setNewFont(s,'light',gc.getDPIScale()*SCR.k*2)
end
return fontCache[s]
end
function FONT.reset()
for s in next,fontCache do
fontCache[s]=gc.setNewFont(s,'light',gc.getDPIScale()*SCR.k*2)
end
end
function FONT.init(mainFont,secFont)
mainFont=love.filesystem.newFile(mainFont)
secFont=love.filesystem.newFile(secFont)
function FONT.set(s)
if s~=currentFontSize then
if not fontCache[s]then
fontCache[s]=gc.setNewFont(mainFont,s,'light',gc.getDPIScale()*SCR.k*2)
fontCache[s]:setFallbacks(gc.setNewFont(secFont,s,'light',gc.getDPIScale()*SCR.k*2))
end
gc.setFont(fontCache[s])
currentFontSize=s
end
end
function FONT.get(s)
if not fontCache[s]then
fontCache[s]=gc.setNewFont(mainFont,s,'light',gc.getDPIScale()*SCR.k*2)
fontCache[s]:setFallbacks(gc.setNewFont(secFont,s,'light',gc.getDPIScale()*SCR.k*2))
end
return fontCache[s]
end
function FONT.reset()
for s in next,fontCache do
fontCache[s]=gc.setNewFont(mainFont,s,'light',gc.getDPIScale()*SCR.k*2)
fontCache[s]:setFallbacks(gc.setNewFont(secFont,s,'light',gc.getDPIScale()*SCR.k*2))
end
end
FONT.reset()
end
return FONT