|
@@ -16,15 +16,17 @@ namespace QuestPDF.Drawing
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
public static class FontManager
|
|
public static class FontManager
|
|
|
{
|
|
{
|
|
|
- internal static SkTypefaceProvider TypefaceProvider { get; } = new();
|
|
|
|
|
|
|
+ private static SkTypefaceProvider TypefaceProvider { get; } = new();
|
|
|
|
|
|
|
|
- internal static SkFontCollection LocalFontCollection { get; } = SkFontCollection.Create(TypefaceProvider, SkFontManager.Empty);
|
|
|
|
|
- internal static SkFontCollection GlobalFontCollection { get; } = SkFontCollection.Create(TypefaceProvider, SkFontManager.Global);
|
|
|
|
|
|
|
+ private static SkFontCollection LocalFontCollection { get; } = SkFontCollection.Create(TypefaceProvider, SkFontManager.Local);
|
|
|
|
|
+ private static SkFontCollection GlobalFontCollection { get; } = SkFontCollection.Create(TypefaceProvider, SkFontManager.Global);
|
|
|
|
|
+
|
|
|
|
|
+ internal static SkFontCollection CurrentFontCollection => Settings.UseEnvironmentFonts ? GlobalFontCollection : LocalFontCollection;
|
|
|
|
|
+ internal static SkFontManager CurrentFontManager => Settings.UseEnvironmentFonts ? SkFontManager.Global : SkFontManager.Local;
|
|
|
|
|
|
|
|
static FontManager()
|
|
static FontManager()
|
|
|
{
|
|
{
|
|
|
NativeDependencyCompatibilityChecker.Test();
|
|
NativeDependencyCompatibilityChecker.Test();
|
|
|
- RegisterLibraryDefaultFonts();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
[Obsolete("Since version 2022.8 this method has been renamed. Please use the RegisterFontWithCustomName method.")]
|
|
[Obsolete("Since version 2022.8 this method has been renamed. Please use the RegisterFontWithCustomName method.")]
|
|
@@ -69,28 +71,5 @@ namespace QuestPDF.Drawing
|
|
|
|
|
|
|
|
RegisterFont(stream);
|
|
RegisterFont(stream);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- private static void RegisterLibraryDefaultFonts()
|
|
|
|
|
- {
|
|
|
|
|
- var supportedFontExtensions = new[] { "*.ttf", "*.otf", "*.ttc", "*.pfb" };
|
|
|
|
|
-
|
|
|
|
|
- var executionPath = AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory;
|
|
|
|
|
-
|
|
|
|
|
- var fontFilePaths = supportedFontExtensions
|
|
|
|
|
- .SelectMany(extension => Directory.GetFiles(executionPath, extension, SearchOption.AllDirectories));
|
|
|
|
|
-
|
|
|
|
|
- foreach (var fileName in fontFilePaths)
|
|
|
|
|
- {
|
|
|
|
|
- try
|
|
|
|
|
- {
|
|
|
|
|
- using var fontFileStream = File.OpenRead(fileName);
|
|
|
|
|
- RegisterFont(fontFileStream);
|
|
|
|
|
- }
|
|
|
|
|
- catch
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|