添加barlow-condense字体作为首选英文字体(免费商用)

This commit is contained in:
MrZ626
2021-08-29 04:10:10 +08:00
parent 6b93675ec1
commit 557cdf6cfb
4 changed files with 24 additions and 6 deletions

View File

@@ -2,12 +2,17 @@ local gc=love.graphics
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')
if
love.filesystem.getInfo('barlowCond.ttf')and
love.filesystem.getInfo('puhui.ttf')
then
local fontData=love.filesystem.newFile('barlowCond.ttf')
local fallback=love.filesystem.newFile('puhui.ttf')
function setFont(s)
if s~=currentFontSize then
if not fontCache[s]then
fontCache[s]=newFont(fontData,s)
fontCache[s]=newFont(fontData,s,'light',gc.getDPIScale()*SCR.k*2)
fontCache[s]:setFallbacks(newFont(fallback,s,'light',gc.getDPIScale()*SCR.k*2))
end
setNewFont(fontCache[s])
currentFontSize=s
@@ -15,15 +20,22 @@ if love.filesystem.getInfo('font.ttf')then
end
function getFont(s)
if not fontCache[s]then
fontCache[s]=newFont(fontData,s)
fontCache[s]=newFont(fontData,s,'light',gc.getDPIScale()*SCR.k*2)
fontCache[s]:setFallbacks(newFont(fallback,s,'light',gc.getDPIScale()*SCR.k*2))
end
return fontCache[s]
end
function resetFont()
for s in next,fontCache do
fontCache[s]=newFont(fontData,s,'light',gc.getDPIScale()*SCR.k*2)
fontCache[s]:setFallbacks(newFont(fallback,s,'light',gc.getDPIScale()*SCR.k*2))
end
end
else
function setFont(s)
if s~=currentFontSize then
if not fontCache[s]then
fontCache[s]=newFont(s)
fontCache[s]=newFont(s,'light',gc.getDPIScale()*SCR.k*2)
end
setNewFont(fontCache[s])
currentFontSize=s
@@ -31,8 +43,13 @@ else
end
function getFont(s)
if not fontCache[s]then
fontCache[s]=newFont(s)
fontCache[s]=newFont(s,'light',gc.getDPIScale()*SCR.k*2)
end
return fontCache[s]
end
function resetFont()
for s in next,fontCache do
fontCache[s]=newFont(s,'light',gc.getDPIScale()*SCR.k*2)
end
end
end