
You are viewing a potentially older version of this package. View Latest Version


This mod lets you change the font of other mods' text. It also allows people to use this in their own mods (see 'For Devs').
| HealthDisplayWithFont | TournamentScoringMod |
|---|---|
If you have UnityExplorer, hit F7 first. If not, ask the discord.
Make sure to press enter and then hit save. If you are, ask the discord.
If you create a TextMeshPro (or similar) in your mod and want to use Fontifier with it, here's how to do it.
First, choose if you want Fontifier to be a required dependency or optional dependency.
using Il2CppTMPro;
using MelonLoader;
using static Fontifier.Fontifier;
// The following two are needed if ImplicitUsings are disabled
using System;
#region Fontifier
private static Func<TMP_FontAsset> GetFont;
/// <inheritdoc/>
public override void OnInitializeMelon()
{
GetFont = RegisterModWithReference(this.Info.Name, new EventHandler<EventArgs>(FontChanged));
}
private static void FontChanged(object sender, EventArgs args)
{
// Change your TextMeshPro.font to the new font.
TextMeshProInstance.font = FontFromName(((dynamic)args).Value);
}
#endregion
ALSO: When you create the TextMeshPro, make sure to TextMeshProInstance.font = GetFont();
using Il2CppTMPro;
using MelonLoader;
using System.Reflection;
// The following two are needed if ImplicitUsings is disabled
using System;
using System.Linq;
#region Fontifier
private static Func<TMP_FontAsset> GetFont;
private static Func<string, TMP_FontAsset> FontFromName;
/// <inheritdoc/>
public override void OnInitializeMelon()
{
if (RegisteredMelons.FirstOrDefault(m => m.Info.Name == "Fontifier")?.GetType() is Type fontifierType && fontifierType != null) (GetFont, FontFromName) = ((Func<TMP_FontAsset>, Func<string, TMP_FontAsset>))fontifierType.GetMethod("RegisterMod", BindingFlags.Public | BindingFlags.Static)?.Invoke(null, new object[] { this.Info.Name, new EventHandler<EventArgs>(FontChanged) });
}
private static void FontChanged(object sender, EventArgs args)
{
// Change your TextMeshPro.font to the new font.
TextMeshProInstance.font = FontFromName(((dynamic)args).Value);
}
#endregion
ALSO: When you create the TextMeshPro, make sure to TextMeshProInstance.font = GetFont();
Get help and find other resources in the Modding Discord