mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Added font failovers for missing fonts
This commit is contained in:
parent
33286fb804
commit
1010e8ac83
2 changed files with 44 additions and 5 deletions
|
@ -54,6 +54,7 @@ namespace Beefy.gfx
|
||||||
static extern int32 FTFont_GetKerning(FTFont* font, int32 char8CodeA, int32 char8CodeB);
|
static extern int32 FTFont_GetKerning(FTFont* font, int32 char8CodeA, int32 char8CodeB);
|
||||||
|
|
||||||
static Dictionary<String, String> sFontNameMap ~ DeleteDictionaryAndKeysAndItems!(_);
|
static Dictionary<String, String> sFontNameMap ~ DeleteDictionaryAndKeysAndItems!(_);
|
||||||
|
static Dictionary<String, String> sFontFailMap ~ DeleteDictionaryAndKeysAndItems!(_);
|
||||||
static Monitor sMonitor = new .() ~ delete _;
|
static Monitor sMonitor = new .() ~ delete _;
|
||||||
|
|
||||||
struct FTFont
|
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)
|
public void Dispose(bool cacheRetain)
|
||||||
{
|
{
|
||||||
if (mFTFont != null)
|
if (mFTFont != null)
|
||||||
|
@ -336,13 +360,23 @@ namespace Beefy.gfx
|
||||||
String pathStr;
|
String pathStr;
|
||||||
if (sFontNameMap.TryGetValue(lookupStr, out pathStr))
|
if (sFontNameMap.TryGetValue(lookupStr, out pathStr))
|
||||||
{
|
{
|
||||||
char8[256] windowsDir;
|
if (!pathStr.Contains(':'))
|
||||||
Windows.GetWindowsDirectoryA(&windowsDir, 256);
|
{
|
||||||
path.Append(&windowsDir);
|
char8[256] windowsDir;
|
||||||
path.Append(@"\Fonts\");
|
Windows.GetWindowsDirectoryA(&windowsDir, 256);
|
||||||
|
path.Append(&windowsDir);
|
||||||
|
path.Append(@"\Fonts\");
|
||||||
|
}
|
||||||
|
|
||||||
path.Append(pathStr);
|
path.Append(pathStr);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if ((sFontFailMap != null) && (sFontFailMap.TryGetValue(lookupStr, out pathStr)))
|
||||||
|
{
|
||||||
|
path.Append(pathStr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,6 +392,9 @@ namespace Beefy.gfx
|
||||||
float usePointSize = pointSize;
|
float usePointSize = pointSize;
|
||||||
mPath = new String();
|
mPath = new String();
|
||||||
GetFontPath(fontName, mPath);
|
GetFontPath(fontName, mPath);
|
||||||
|
|
||||||
|
Console.WriteLine("Font loading {} from {}", fontName, mPath);
|
||||||
|
|
||||||
if (mPath.IsEmpty)
|
if (mPath.IsEmpty)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ namespace IDE
|
||||||
public class IDEApp : BFApp
|
public class IDEApp : BFApp
|
||||||
{
|
{
|
||||||
public static String sRTVersionStr = "042";
|
public static String sRTVersionStr = "042";
|
||||||
public const String cVersion = "0.42.4";
|
public const String cVersion = "0.42.5";
|
||||||
|
|
||||||
#if BF_PLATFORM_WINDOWS
|
#if BF_PLATFORM_WINDOWS
|
||||||
public static readonly String sPlatform64Name = "Win64";
|
public static readonly String sPlatform64Name = "Win64";
|
||||||
|
@ -10634,6 +10634,8 @@ namespace IDE
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Font.AddFontFailEntry("Segoe UI", scope String()..AppendF("{}fonts/NotoSans-Regular.ttf", mInstallDir));
|
||||||
|
|
||||||
DarkTheme aTheme = new DarkTheme();
|
DarkTheme aTheme = new DarkTheme();
|
||||||
aTheme.Init();
|
aTheme.Init();
|
||||||
ThemeFactory.mDefault = aTheme;
|
ThemeFactory.mDefault = aTheme;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue