



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 | MatchInfo |
|---|---|---|
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;
Caching will make it so that when you call those methods and get a font, if you call it again, it won't make a new one unless your mod has not called this method for that specific font yet. Each mod has its own cache.
If you want this, wherever it says [CACHE], replace it with true. Otherwise, replace it with false. Caching is recommended.
(Place this in your MelonMod class)
#region Fontifier
private static Func<bool, TMP_FontAsset> GetFont;
/// <inheritdoc/>
public override void OnInitializeMelon()
{
GetFont = RegisterModWithReferenceCopy(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 = FontFromNameCopy(this.Info.Name, ((dynamic)args).Value, [CACHE]);
}
#endregion
ALSO: When you create the TextMeshPro, make sure to TextMeshProInstance.font = GetFont([CACHE]);
(Place this in your MelonMod class)
#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;
Caching will make it so that when you call those methods and get a font, if you call it again, it won't make a new one unless your mod has not called this method for that specific font yet. Each mod has its own cache.
If you want this, wherever it says [CACHE], replace it with true. Otherwise, replace it with false. Caching is recommended.
(Place this in your MelonMod class)
#region Fontifier
private static Func<bool, TMP_FontAsset> GetFont;
private static Func<string, bool, TMP_FontAsset> FontFromName;
/// <inheritdoc/>
public override void OnInitializeMelon()
{
if (FindMelon("Fontifier", "ninjaguardian")?.GetType() is Type fontifierType && fontifierType != null) (GetFont, FontFromName) = ((Func<TMP_FontAsset>, Func<string, TMP_FontAsset>))fontifierType.GetMethod("RegisterModCopy", 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, [CACHE]);
}
#endregion
ALSO: When you create the TextMeshPro, make sure to TextMeshProInstance.font = GetFont([CACHE]);
(Place this in your MelonMod class)
#region Fontifier
private static Func<TMP_FontAsset> GetFont;
private static Func<string, TMP_FontAsset> FontFromName;
/// <inheritdoc/>
public override void OnInitializeMelon()
{
if (FindMelon("Fontifier", "ninjaguardian")?.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
My code: CC0 1.0 Universal (public domain)
Includes SixLabors.Fonts.dll (© Six Labors, Apache License 2.0)