-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Collections.Generic; | ||
using HarmonyLib; | ||
using MelonLoader; | ||
using TMPro; | ||
using UnityEngine; | ||
using UnityEngine.TextCore.LowLevel; | ||
|
||
namespace AquaMai.Fix; | ||
|
||
public class FontFix | ||
{ | ||
private static TMP_FontAsset fontAsset; | ||
private static List<TMP_FontAsset> fixedFonts = []; | ||
|
||
public static void DoCustomPatch(HarmonyLib.Harmony h) | ||
{ | ||
var font = new Font(@"C:\Windows\Fonts\msyhbd.ttc"); | ||
fontAsset = TMP_FontAsset.CreateFontAsset(font, 90, 9, GlyphRenderMode.SDFAA, 8192, 8192); | ||
} | ||
|
||
[HarmonyPatch(typeof(TextMeshProUGUI), "Awake")] | ||
[HarmonyPostfix] | ||
public static void PostFix(TextMeshProUGUI __instance) | ||
{ | ||
if (fixedFonts.Contains(__instance.font)) return; | ||
# if DEBUG | ||
MelonLogger.Msg($"[FontFix] Fixing font: {__instance.font.name}"); | ||
# endif | ||
__instance.font.fallbackFontAssetTable.Add(fontAsset); | ||
fixedFonts.Add(__instance.font); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.IO; | ||
using HarmonyLib; | ||
using MelonLoader; | ||
using TMPro; | ||
using UnityEngine; | ||
using UnityEngine.TextCore.LowLevel; | ||
|
||
namespace AquaMai.UX; | ||
|
||
public class CustomFont | ||
{ | ||
private static TMP_FontAsset fontAsset; | ||
|
||
public static void DoCustomPatch(HarmonyLib.Harmony h) | ||
{ | ||
var fontPath = Path.Combine(Environment.CurrentDirectory, "LocalAssets", "font.ttf"); | ||
if (!File.Exists(fontPath)) return; | ||
|
||
var font = new Font(fontPath); | ||
|
||
// 不设置成 8192 的话,贴图会用完,剩下的字显示不出来 | ||
fontAsset = TMP_FontAsset.CreateFontAsset(font, 90, 9, GlyphRenderMode.SDFAA, 8192, 8192); | ||
} | ||
|
||
[HarmonyPatch(typeof(TextMeshProUGUI), "Awake")] | ||
[HarmonyPostfix] | ||
public static void PostFix(TextMeshProUGUI __instance) | ||
{ | ||
if (fontAsset is null) return; | ||
# if DEBUG | ||
MelonLogger.Msg($"{__instance.font.name} {__instance.text}"); | ||
# endif | ||
__instance.font = fontAsset; | ||
} | ||
} |