Initial commit

This commit is contained in:
2026-04-02 17:52:02 -04:00
commit cc510967bc
17 changed files with 1498 additions and 0 deletions

110
Source/FontLoader.cs Normal file
View File

@@ -0,0 +1,110 @@
using System;
using System.Linq;
using TMPro;
using UnityEngine;
using Verse;
namespace raptureparty.RimWorldFontReplacer
{
[StaticConstructorOnStartup]
class FontLoader
{
public static string TargetTinyFontName;
public static string TargetSmallFontName;
public static string TargetMediumFontName;
public static string TargetPlanetFontName;
public static int FontTinySize = 11;
public static int FontSmallSize = 14;
public static int FontMediumSize = 18;
static private Font s_fontTiny;
static private string s_fontTinySearchedName;
static public bool FontTinyFound
{
get; private set;
}
static private Font s_fontSmall;
static private string s_fontSmallSearchedName;
static public bool FontSmallFound
{
get; private set;
}
static private Font s_fontMedium;
static private string s_fontMediumSearchedName;
static public bool FontMediumFound
{
get; private set;
}
static private Font s_fontPlanet;
static private string s_fontPlanetSearchedName;
static public bool FontPlanetFound
{
get; private set;
}
static public Font FontTiny
{
get
{
if (s_fontTinySearchedName != TargetTinyFontName)
{
s_fontTiny = Font.CreateDynamicFontFromOSFont(TargetTinyFontName, FontTinySize);
s_fontTinySearchedName = TargetTinyFontName;
FontTinyFound = Font.GetOSInstalledFontNames().Contains(TargetTinyFontName);
}
return FontTinyFound ? s_fontTiny : Text.fontStyles[0].font;
}
}
static public Font FontSmall
{
get
{
if (s_fontSmallSearchedName != TargetSmallFontName)
{
s_fontSmall = Font.CreateDynamicFontFromOSFont(TargetSmallFontName, FontSmallSize);
s_fontSmallSearchedName = TargetSmallFontName;
FontSmallFound = Font.GetOSInstalledFontNames().Contains(TargetSmallFontName);
}
return FontSmallFound ? s_fontSmall : Text.fontStyles[1].font;
}
}
static public Font FontMedium
{
get
{
if (s_fontMediumSearchedName != TargetMediumFontName)
{
s_fontMedium = Font.CreateDynamicFontFromOSFont(TargetMediumFontName, FontMediumSize);
s_fontMediumSearchedName = TargetMediumFontName;
FontMediumFound = Font.GetOSInstalledFontNames().Contains(TargetMediumFontName); ;
}
return FontMediumFound ? s_fontMedium : Text.fontStyles[2].font;
}
}
static public Font FontPlanet
{
get
{
if (s_fontPlanetSearchedName != TargetPlanetFontName)
{
s_fontPlanet = Font.CreateDynamicFontFromOSFont(TargetPlanetFontName, Text.fontStyles[2].font.fontSize); // TODO: find correct size
s_fontPlanetSearchedName = TargetPlanetFontName;
FontPlanetFound = Font.GetOSInstalledFontNames().Contains(TargetPlanetFontName); ;
}
return FontPlanetFound ? s_fontPlanet : Text.fontStyles[2].font; // TODO: find correct size
}
}
}
}