diff --git a/src/StudioCore/CFG.cs b/src/StudioCore/CFG.cs index 52e814570..89bb807ba 100644 --- a/src/StudioCore/CFG.cs +++ b/src/StudioCore/CFG.cs @@ -49,6 +49,8 @@ public class CFG public bool FontKorean = false; public bool FontThai = false; public bool FontVietnamese = false; + public string TTFEnglish = ""; + public string TTFOther = ""; public bool AliasBank_EditorMode = false; diff --git a/src/StudioCore/MapStudioNew.cs b/src/StudioCore/MapStudioNew.cs index 113a3cbd6..60cde6f1a 100644 --- a/src/StudioCore/MapStudioNew.cs +++ b/src/StudioCore/MapStudioNew.cs @@ -165,12 +165,19 @@ public unsafe MapStudioNew(IGraphicsContext context, string version) private unsafe void SetupFonts() { + string engFont = @"Assets\Fonts\RobotoMono-Light.ttf"; + string otherFont = @"Assets\Fonts\NotoSansCJKtc-Light.otf"; + if (!string.IsNullOrWhiteSpace(CFG.Current.TTFEnglish) && File.Exists(CFG.Current.TTFEnglish)) + engFont = CFG.Current.TTFEnglish; + if (!string.IsNullOrWhiteSpace(CFG.Current.TTFOther) && File.Exists(CFG.Current.TTFOther)) + otherFont = CFG.Current.TTFOther; + ImFontAtlas* fonts = ImGui.GetIO()->Fonts; - var fileEn = Path.Combine(AppContext.BaseDirectory, @"Assets\Fonts\RobotoMono-Light.ttf"); + var fileEn = Path.Combine(AppContext.BaseDirectory, engFont); var fontEn = File.ReadAllBytes(fileEn); var fontEnNative = new IntPtr(ImGui.MemAlloc(fontEn.Length)); Marshal.Copy(fontEn, 0, fontEnNative, fontEn.Length); - var fileOther = Path.Combine(AppContext.BaseDirectory, @"Assets\Fonts\NotoSansCJKtc-Light.otf"); + var fileOther = Path.Combine(AppContext.BaseDirectory, otherFont); var fontOther = File.ReadAllBytes(fileOther); var fontOtherNative = new IntPtr(ImGui.MemAlloc(fontOther.Length)); Marshal.Copy(fontOther, 0, fontOtherNative, fontOther.Length); diff --git a/src/StudioCore/SettingsMenu.cs b/src/StudioCore/SettingsMenu.cs index 24e5f085e..09f8bbc64 100644 --- a/src/StudioCore/SettingsMenu.cs +++ b/src/StudioCore/SettingsMenu.cs @@ -13,6 +13,8 @@ using System.Reflection; using Veldrid; using StudioCore.Interface; +using StudioCore.Platform; +using System.IO; namespace StudioCore; @@ -86,8 +88,45 @@ private void DisplaySettings_System() } // Additional Language Fonts - if (ImGui.CollapsingHeader("Additional Language Fonts")) + if (ImGui.CollapsingHeader("Fonts and Additional Language Characters")) { + + if (CFG.Current.ShowUITooltips) + { + ShowHelpMarker("Use the following font for English characters. .ttf and .otf expected."); + ImGui.SameLine(); + } + if (ImGui.Button("Set English font")) + { + PlatformUtils.Instance.OpenFileDialog("Select Font", ["*.ttf", "*.otf"], out string path); + if (File.Exists(path)) + { + CFG.Current.TTFEnglish = path; + FontRebuildRequest = true; + } + } + ImGui.SameLine(); + ImGui.Text(CFG.Current.TTFEnglish); + + if (CFG.Current.ShowUITooltips) + { + ShowHelpMarker("Use the following font for Non-English characters. .ttf and .otf expected."); + ImGui.SameLine(); + } + if (ImGui.Button("Set Other Languages font")) + { + PlatformUtils.Instance.OpenFileDialog("Select Font", ["ttf", "otf"], out string path); + if (File.Exists(path)) + { + CFG.Current.TTFOther = path; + FontRebuildRequest = true; + } + } + ImGui.SameLine(); + ImGui.Text(CFG.Current.TTFOther); + + ImGui.Separator(); + if (CFG.Current.ShowUITooltips) { ShowHelpMarker("Include Chinese font.\nAdditional fonts take more VRAM and increase startup time.");