-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFontFixer.cs
More file actions
47 lines (42 loc) · 1.34 KB
/
FontFixer.cs
File metadata and controls
47 lines (42 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using BepInEx;
using HarmonyLib;
using System.IO;
using TMPro;
using UnityEngine;
namespace FontFixerNS
{
[BepInPlugin("FontFixer", "FontFixer", "1.0.0")]
class FontFixer : BaseUnityPlugin
{
public static BepInEx.Logging.ManualLogSource L;
public static AssetBundle FontBundle;
public static string BundlePath;
private void Awake()
{
L = Logger;
BundlePath = Path.Combine(Directory.GetParent(this.Info.Location).ToString(), "mod.bundle");
var harmony = new Harmony("FontFixer");
harmony.PatchAll(typeof(Patches));
}
}
class Patches
{
[HarmonyPatch(typeof(FontManager), "Awake")]
[HarmonyPostfix]
public static void FMAwake()
{
FontFixer.L.LogInfo("loading fonts..");
if (FontFixer.FontBundle == null)
FontFixer.FontBundle = AssetBundle.LoadFromFile(FontFixer.BundlePath);
if (FontFixer.FontBundle == null)
{
FontFixer.L.LogError("Failed to load Font AssetBundle!");
return;
}
FontManager.instance.ChineseTraditionalFontAsset = FontFixer.FontBundle.LoadAsset<TMP_FontAsset>("DYNTCB");
FontManager.instance.ChineseSimplifiedFontAsset = FontFixer.FontBundle.LoadAsset<TMP_FontAsset>("DYNSCB");
FontManager.instance.JapaneseFontAsset = FontFixer.FontBundle.LoadAsset<TMP_FontAsset>("DYNJPB");
FontManager.instance.KoreanFontAsset = FontFixer.FontBundle.LoadAsset<TMP_FontAsset>("DYNKRB");
}
}
}