Skip to content

Commit 2828a90

Browse files
authored
Merge pull request ststeiger#267 from MichelMichels/localappdata-font-support
Support for Windows fonts inside %LOCALAPPDATA%
2 parents 62eeca8 + a783607 commit 2828a90

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

PdfSharpCore/Utils/FontResolver.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,19 @@ static FontResolver()
5353
if (isWindows)
5454
{
5555
fontDir = System.Environment.ExpandEnvironmentVariables(@"%SystemRoot%\Fonts");
56-
SSupportedFonts = System.IO.Directory.GetFiles(fontDir, "*.ttf", System.IO.SearchOption.AllDirectories);
56+
var fontPaths = new List<string>();
57+
58+
var systemFontPaths = System.IO.Directory.GetFiles(fontDir, "*.ttf", System.IO.SearchOption.AllDirectories);
59+
fontPaths.AddRange(systemFontPaths);
60+
61+
var appdataFontDir = System.Environment.ExpandEnvironmentVariables(@"%LOCALAPPDATA%\Microsoft\Windows\Fonts");
62+
if(System.IO.Directory.Exists(appdataFontDir))
63+
{
64+
var appdataFontPaths = System.IO.Directory.GetFiles(appdataFontDir, "*.ttf", System.IO.SearchOption.AllDirectories);
65+
fontPaths.AddRange(appdataFontPaths);
66+
}
67+
68+
SSupportedFonts = fontPaths.ToArray();
5769
SetupFontsFiles(SSupportedFonts);
5870
return;
5971
}

0 commit comments

Comments
 (0)