From 9ae657988b06b94b607e3418427dd371563b5b6d Mon Sep 17 00:00:00 2001 From: ikinz Date: Wed, 29 Nov 2017 22:43:46 +1000 Subject: [PATCH 1/2] Fix the invisible font bug. On some systems, including mine, font sizes 17 and 23 rendered invisible after Spring.Reload. Due to the cache threshold this included most of the text used in chobby. Invalidating the chili font cache on chobby init fixes the issue. --- LuaMenu/widgets/chobby/core.lua | 3 +++ libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/LuaMenu/widgets/chobby/core.lua b/LuaMenu/widgets/chobby/core.lua index 8a8dac830..cddd7a650 100644 --- a/LuaMenu/widgets/chobby/core.lua +++ b/LuaMenu/widgets/chobby/core.lua @@ -47,6 +47,9 @@ for _, file in ipairs(includes) do end function Chobby:_Initialize() + -- Invalidate the chili font cache. Without this certain font sizes + -- will be invisible after Spring.Reload on many systems. + Chili.FontHandler.InvalidateFontCache() self:WrapCall(function() WG.Delay(function() lobby:AddListener("OnJoinBattle", diff --git a/libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua b/libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua index 195d31b30..51605d221 100644 --- a/libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua +++ b/libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua @@ -81,4 +81,8 @@ function FontHandler.LoadFont(fontname,size,outwidth,outweight) loadedFonts[idx] = font refCounts[idx] = 1 return font -end \ No newline at end of file +end + +function FontHandler.InvalidateFontCache() + loadedFonts = {} +end From d694197207e2f82a5d9194aebf20f0e96378428f Mon Sep 17 00:00:00 2001 From: ikinz Date: Wed, 29 Nov 2017 22:56:51 +1000 Subject: [PATCH 2/2] Set font cache size threshold to 0. --- libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua b/libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua index 51605d221..7667f18c1 100644 --- a/libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua +++ b/libs/chiliui/luamenu/chili/chili/handlers/fonthandler.lua @@ -13,7 +13,7 @@ local refCounts = {} --// maximum fontsize difference --// when we don't find the wanted font rendered with the wanted fontsize --// (in respect to this threshold) then recreate a new one -local fontsize_threshold = 2 +local fontsize_threshold = 0 -- who thought this was ever a good idea? --//============================================================================= --// Destroy