Config.BaseExt.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using FastReport.Fonts;
  2. using System;
  3. using System.Drawing;
  4. using System.Globalization;
  5. using System.IO;
  6. using System.Reflection;
  7. namespace FastReport.Utils
  8. {
  9. public static partial class Config
  10. {
  11. private static Export.Email.EmailSettings FEmailSettings = new Export.Email.EmailSettings();
  12. private static readonly TrueTypeCollection FFontCollection = new TrueTypeCollection();
  13. /// <summary>
  14. /// Gets or sets the settings for the "Send Email" window.
  15. /// </summary>
  16. public static Export.Email.EmailSettings EmailSettings
  17. {
  18. get { return FEmailSettings; }
  19. set { FEmailSettings = value; }
  20. }
  21. /// <summary>
  22. /// Get access to font collection
  23. /// </summary>
  24. public static TrueTypeCollection FontCollection
  25. {
  26. get { return FFontCollection; }
  27. }
  28. #if SKIA
  29. private static CharacterMatcher characterMatcher = new CharacterMatcher();
  30. private class CharacterMatcher : Topten.RichTextKit.ICharacterMatcher
  31. {
  32. public CharacterMatcher()
  33. {
  34. }
  35. SkiaSharp.SKFontManager _fontManager = SkiaSharp.SKFontManager.Default;
  36. /// <inheritdoc />
  37. public SkiaSharp.SKTypeface MatchCharacter(string familyName, int weight, int width, SkiaSharp.SKFontStyleSlant slant, string[] bcp47, int character)
  38. {
  39. // check private fonts
  40. foreach (FontFamily f in PrivateFontCollection.Families)
  41. {
  42. SkiaSharp.SKTypeface t = f.GetTypeface(FontStyle.Regular);
  43. if (t.ContainsGlyph(character))
  44. return t;
  45. }
  46. return _fontManager.MatchCharacter(familyName, weight, width, slant, bcp47, character);
  47. }
  48. }
  49. #endif
  50. private static void ProcessMainAssembly()
  51. {
  52. new AssemblyInitializer();
  53. #if !FRCORE
  54. new AssemblyInitializerDesignExt();
  55. #endif
  56. new AssemblyInitializerBaseExt();
  57. }
  58. }
  59. }