diff --git a/BeefLibs/Beefy2D/src/gfx/Font.bf b/BeefLibs/Beefy2D/src/gfx/Font.bf index 6828fcad..4363fe6c 100644 --- a/BeefLibs/Beefy2D/src/gfx/Font.bf +++ b/BeefLibs/Beefy2D/src/gfx/Font.bf @@ -54,6 +54,7 @@ namespace Beefy.gfx static extern int32 FTFont_GetKerning(FTFont* font, int32 char8CodeA, int32 char8CodeB); static Dictionary sFontNameMap ~ DeleteDictionaryAndKeysAndItems!(_); + static Dictionary sFontFailMap ~ DeleteDictionaryAndKeysAndItems!(_); static Monitor sMonitor = new .() ~ delete _; struct FTFont @@ -205,6 +206,29 @@ namespace Beefy.gfx } } + public static void AddFontFailEntry(StringView mapFrom, StringView mapTo) + { + using (sMonitor.Enter()) + { + if (sFontFailMap == null) + sFontFailMap = new .(); + + String str = new String(mapFrom); + str.ToUpper(); + bool added = sFontFailMap.TryAdd(str, var keyPtr, var valuePtr); + if (added) + { + *keyPtr = str; + *valuePtr = new String(mapTo); + } + else + { + delete str; + (*valuePtr).Set(mapTo); + } + } + } + public void Dispose(bool cacheRetain) { if (mFTFont != null) @@ -336,13 +360,23 @@ namespace Beefy.gfx String pathStr; if (sFontNameMap.TryGetValue(lookupStr, out pathStr)) { - char8[256] windowsDir; - Windows.GetWindowsDirectoryA(&windowsDir, 256); - path.Append(&windowsDir); - path.Append(@"\Fonts\"); + if (!pathStr.Contains(':')) + { + char8[256] windowsDir; + Windows.GetWindowsDirectoryA(&windowsDir, 256); + path.Append(&windowsDir); + path.Append(@"\Fonts\"); + } + path.Append(pathStr); + return; } #endif + if ((sFontFailMap != null) && (sFontFailMap.TryGetValue(lookupStr, out pathStr))) + { + path.Append(pathStr); + return; + } } } } @@ -358,6 +392,9 @@ namespace Beefy.gfx float usePointSize = pointSize; mPath = new String(); GetFontPath(fontName, mPath); + + Console.WriteLine("Font loading {} from {}", fontName, mPath); + if (mPath.IsEmpty) return false; diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 55b96ccd..9775ed35 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -119,7 +119,7 @@ namespace IDE public class IDEApp : BFApp { public static String sRTVersionStr = "042"; - public const String cVersion = "0.42.4"; + public const String cVersion = "0.42.5"; #if BF_PLATFORM_WINDOWS public static readonly String sPlatform64Name = "Win64"; @@ -10634,6 +10634,8 @@ namespace IDE #endif } + Font.AddFontFailEntry("Segoe UI", scope String()..AppendF("{}fonts/NotoSans-Regular.ttf", mInstallDir)); + DarkTheme aTheme = new DarkTheme(); aTheme.Init(); ThemeFactory.mDefault = aTheme;