Skip to content

Commit

Permalink
Fix Font Loader Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
marcussacana committed Dec 27, 2020
1 parent 809040e commit 289db82
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion StringReloads/Engine/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public string[] IniLines {
public bool LogFile => ((bool?)(_LogFile ??= GetValue("LogFile").ToBoolean())).Value;

bool? _LoadLocalFont = null;
public bool LoadLocalFont => ((bool?)(_LoadLocalFont ??= GetValue("LoadLocalFont").ToBoolean())).Value;
public bool LoadLocalFont => ((bool?)(_LoadLocalFont ??= GetValue("LoadLocalFonts").ToBoolean())).Value;

Log.LogLevel? _LogLevel = null;
public Log.LogLevel LogLevel => ((Log.LogLevel?)(_LogLevel ??= GetValue("LogLevel").ToLogLevel())).Value;
Expand Down
10 changes: 7 additions & 3 deletions StringReloads/Engine/Unmanaged/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,20 @@ internal static void LoadLocalFonts()
from Font in Directory.GetFiles(RootDir, Ext)
select Font);

Log.Trace("Font Search Root: " + RootDir);

foreach (var Font in Fonts)
{
int Loaded = AddFontResourceExW(Font, FR_PRIVATE, null);

if (Loaded > 0)
Log.Information("{0} Fonts Loaded From {1}", Loaded.ToString(), Path.GetFileName(Font));
Log.Debug($"{Loaded} Fonts Loaded From: {Path.GetFileName(Font)}");
else
Log.Trace($"Failed to Load Font: {Path.GetFileName(Font)}");
}
}

[DllImport("gdi32.dll")]
[DllImport("gdi32.dll", CharSet = CharSet.Unicode)]
static extern int AddFontResourceExW(string lpszFilename, uint fl, void* reserved);

const uint FR_PRIVATE = 0x10;
Expand Down

0 comments on commit 289db82

Please sign in to comment.