static FontResolver() { string fontDir; bool isOSX = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX); if (isOSX) { fontDir = "/Library/Fonts/"; SSupportedFonts = System.IO.Directory.GetFiles(fontDir, "*.ttf", System.IO.SearchOption.AllDirectories); SetupFontsFiles(SSupportedFonts); return; } bool isLinux = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux); if (isLinux) { SSupportedFonts = LinuxSystemFontResolver.Resolve(); SetupFontsFiles(SSupportedFonts); return; } bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows); if (isWindows) { fontDir = System.Environment.ExpandEnvironmentVariables(@"%SystemRoot%\Fonts"); SSupportedFonts = System.IO.Directory.GetFiles(fontDir, "*.ttf", System.IO.SearchOption.AllDirectories); SetupFontsFiles(SSupportedFonts); return; } throw new System.NotImplementedException("FontResolver not implemented for this platform (PdfSharpCore.Utils.FontResolver.cs)."); }
static FontResolver() { string fontDir; bool isOSX = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX); if (isOSX) { fontDir = "/Library/Fonts/"; SSupportedFonts = System.IO.Directory.GetFiles(fontDir, "*.ttf", System.IO.SearchOption.AllDirectories); SetupFontsFiles(SSupportedFonts); return; } bool isLinux = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux); if (isLinux) { SSupportedFonts = LinuxSystemFontResolver.Resolve(); SetupFontsFiles(SSupportedFonts); return; } bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows); if (isWindows) { fontDir = System.Environment.ExpandEnvironmentVariables(@"%SystemRoot%\Fonts"); var fontPaths = new List <string>(); var systemFontPaths = System.IO.Directory.GetFiles(fontDir, "*.ttf", System.IO.SearchOption.AllDirectories); fontPaths.AddRange(systemFontPaths); var appdataFontDir = System.Environment.ExpandEnvironmentVariables(@"%LOCALAPPDATA%\Microsoft\Windows\Fonts"); if (System.IO.Directory.Exists(appdataFontDir)) { var appdataFontPaths = System.IO.Directory.GetFiles(appdataFontDir, "*.ttf", System.IO.SearchOption.AllDirectories); fontPaths.AddRange(appdataFontPaths); } SSupportedFonts = fontPaths.ToArray(); SetupFontsFiles(SSupportedFonts); return; } throw new System.NotImplementedException("FontResolver not implemented for this platform (PdfSharpCore.Utils.FontResolver.cs)."); }