Skip to content

Commit d0c09d8

Browse files
committed
Fix default font asset screwing with bold font
1 parent e3170fa commit d0c09d8

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

BeatSaberMarkupLanguage/Harmony Patches/FontAssetDefaultValueSetters.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Linq;
1+
using System.Collections.Generic;
2+
using System.Linq;
3+
using System.Reflection;
24
using HarmonyLib;
35
using TMPro;
46
using UnityEngine;
@@ -21,14 +23,20 @@ public static bool Prefix(ref Shader __result)
2123
}
2224
}
2325

24-
[HarmonyPatch(typeof(TMP_Settings), nameof(TMP_Settings.instance), MethodType.Getter)]
25-
internal static class TMP_Settings_GetFontAsset
26+
[HarmonyPatch]
27+
internal static class TextMeshPro_LoadFontAsset
2628
{
27-
public static void Postfix()
29+
public static IEnumerable<MethodBase> TargetMethods()
2830
{
29-
if (TMP_Settings.s_Instance.m_defaultFontAsset == null)
31+
yield return AccessTools.DeclaredMethod(typeof(TextMeshPro), "LoadFontAsset");
32+
yield return AccessTools.DeclaredMethod(typeof(TextMeshProUGUI), "LoadFontAsset");
33+
}
34+
35+
public static void Prefix(TMP_Text __instance)
36+
{
37+
if (__instance.font == null)
3038
{
31-
TMP_Settings.s_Instance.m_defaultFontAsset = Resources.FindObjectsOfTypeAll<TMP_FontAsset>().FirstOrDefault(f => f.name == "Teko-Medium SDF");
39+
__instance.font = BeatSaberUI.MainTextFont;
3240
}
3341
}
3442
}

0 commit comments

Comments
 (0)