Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/StudioCore/CFG.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 9 additions & 2 deletions src/StudioCore/MapStudioNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 40 additions & 1 deletion src/StudioCore/SettingsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using System.Reflection;
using Veldrid;
using StudioCore.Interface;
using StudioCore.Platform;
using System.IO;

namespace StudioCore;

Expand Down Expand Up @@ -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.");
Expand Down