Strip the font bundle to 59 KB and replace the polling sweep with a hook

The bundle was built by rewriting the Korean translation mod's asset bundle, so
it still carried everything that mod needed and we did not: three unused font
assets, their materials and textures, and a .resS stream holding two 2048x2048
atlases. Deleted those, dropped the stream, and rewrote m_Container and
m_PreloadTable to reference only the four surviving objects. 862 KB -> 59 KB,
verified by reloading: the embedded font still round-trips as Cabin with full
Slovak coverage and the Gill Sans MT metrics.

The 2s sweep existed to catch labels whose font the game reassigns without any
text change, which happens on a language switch. A postfix on the Text.font
setter catches exactly that, at the moment it happens rather than up to two
seconds later, and costs nothing when idle. Re-entry is safe: our own assignment
fires the hook once, which finds the state already correct and returns.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jaroslav Beneš
2026-07-21 21:46:47 +02:00
parent 575a819c73
commit bea593732d
3 changed files with 7 additions and 10 deletions
+7
View File
@@ -144,6 +144,7 @@ namespace SlovakTranslation
var bestLength = 0;
foreach (var candidate in _gameDynamicFonts)
{
if (candidate == null) continue;
var baseName = candidate.name.EndsWith("_Dynamic")
? candidate.name.Substring(0, candidate.name.Length - "_Dynamic".Length)
: candidate.name;
@@ -283,6 +284,12 @@ namespace SlovakTranslation
[HarmonyPostfix, HarmonyPatch(typeof(Text), "text", MethodType.Setter)]
public static void TextChanged(Text __instance) => SlovakFont.Apply(__instance);
// The game reassigns fonts wholesale when the language changes. Re-deciding here
// is safe: our own assignment re-enters once, finds the state already correct,
// and stops.
[HarmonyPostfix, HarmonyPatch(typeof(Text), "font", MethodType.Setter)]
public static void FontAssigned(Text __instance) => SlovakFont.Apply(__instance);
[HarmonyPostfix, HarmonyPatch(typeof(TextTranslation), nameof(TextTranslation.SetLanguage))]
public static void LanguageChanged() => SlovakFont.ApplyToAll();
}