This commit is contained in:
2026-05-21 23:33:23 -05:00
parent 85781f4510
commit f932a7704b
3 changed files with 76 additions and 7 deletions
+32 -3
View File
@@ -102,23 +102,52 @@ public sealed unsafe class SDL3Window : IDisposable
if (!File.Exists(b.FullPath)) return;
if (Path.GetExtension(b.FullPath) != ".ttf") return;
ImGui.GetIO().AddFont(b.FullPath);
};
_watcher.Deleted += (_, b) =>
{
if (Path.GetExtension(b.FullPath) != ".ttf") return;
ImGui.GetIO().RemoveFont(b.Name);
};
_watcher.Renamed += (_, b) =>
{
if (Path.GetExtension(b.OldFullPath) != ".ttf") return;
ImGui.GetIO().RemoveFont(b.OldName);
if (!File.Exists(b.FullPath)) return;
if (Path.GetExtension(b.FullPath) != ".ttf") return;
ImGui.GetIO().AddFont(b.FullPath);
};
_watcher.IncludeSubdirectories = false;
_watcher.EnableRaisingEvents = true;
string[] fonts = Directory.GetFiles(fontsPath, "*.ttf", SearchOption.AllDirectories);
List<string> fonts = Directory.GetFiles(fontsPath, "*.ttf", SearchOption.AllDirectories).ToList();
fonts.Sort();
List<string> mergeFonts = new List<string>();
for (int i = fonts.Count - 1; i >= 0; i--)
{
if (Path.GetFileName(fonts[i]).StartsWith("merge_", StringComparison.OrdinalIgnoreCase))
{
mergeFonts.Add(fonts[i]);
fonts.RemoveAt(i);
}
}
mergeFonts.Reverse();
foreach (string merge in mergeFonts)
{
io.AddFont(merge, true);
}
foreach (string font in fonts)
{
io.AddFont(font);
foreach (string merge in mergeFonts)
{
io.AddFont(merge, true);
}
}
}
catch (Exception e)