From 072b545998b50a48c5065c09591b61cd21891d6c Mon Sep 17 00:00:00 2001 From: psyGamer Date: Tue, 3 Sep 2024 09:22:47 +0200 Subject: [PATCH] Change built-in font on macOS to "Monaco" --- Studio/CelesteStudio/FontManager.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Studio/CelesteStudio/FontManager.cs b/Studio/CelesteStudio/FontManager.cs index 80c6c3de..766e564c 100644 --- a/Studio/CelesteStudio/FontManager.cs +++ b/Studio/CelesteStudio/FontManager.cs @@ -1,3 +1,4 @@ +using Eto; using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -20,6 +21,11 @@ public static class FontManager { private static FontFamily? builtinFontFamily; public static Font CreateFont(string fontFamily, float size, FontStyle style = FontStyle.None) { + if (Platform.Instance.IsMac && fontFamily == FontFamilyBuiltin) { + // The built-in font is broken on macOS for some reason, so fallback to a system font + fontFamily = "Monaco"; + } + if (fontFamily == FontFamilyBuiltin) { var asm = Assembly.GetExecutingAssembly(); builtinFontFamily ??= FontFamily.FromStreams(asm.GetManifestResourceNames() @@ -34,8 +40,9 @@ public static Font CreateFont(string fontFamily, float size, FontStyle style = F private static readonly Dictionary charWidthCache = new(); public static float CharWidth(this Font font) { - if (charWidthCache.TryGetValue(font, out float width)) + if (charWidthCache.TryGetValue(font, out float width)) { return width; + } width = font.MeasureString("X").Width; charWidthCache.Add(font, width);