diff --git a/Zframework/init.lua b/Zframework/init.lua index 109a38c5..bb6245be 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -388,6 +388,7 @@ function love.resize(w,h) if BG.resize then BG.resize(w,h)end if SCN.resize then SCN.resize(w,h)end WIDGET.resize(w,h) + resetFont() SHADER.warning:send('w',w*SCR.dpi) end diff --git a/Zframework/setFont.lua b/Zframework/setFont.lua index 3567b035..8f78a61c 100644 --- a/Zframework/setFont.lua +++ b/Zframework/setFont.lua @@ -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 diff --git a/barlowCond.ttf b/barlowCond.ttf new file mode 100644 index 00000000..649d1376 Binary files /dev/null and b/barlowCond.ttf differ diff --git a/font.ttf b/puhui.ttf similarity index 100% rename from font.ttf rename to puhui.ttf