FontManager.Gdi.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // available in FR.OS, FR.NET, FR.WPF
  2. #if !SKIA && !FRCORE && (!MONO || WPF)
  3. using System;
  4. using System.Diagnostics;
  5. using System.Drawing.Text;
  6. using System.IO;
  7. namespace FastReport
  8. {
  9. public static partial class FontManager
  10. {
  11. /// <summary>
  12. /// Adds a font from the specified file to this collection.
  13. /// </summary>
  14. /// <param name="filename">A System.String that contains the file name of the font to add.</param>
  15. /// <returns>true if the font is registered by application.</returns>
  16. public static bool AddFont(string filename)
  17. {
  18. bool success = false;
  19. if (File.Exists(filename))
  20. {
  21. PrivateFontCollection.AddFontFile(filename);
  22. success = true;
  23. }
  24. else
  25. {
  26. Debug.WriteLine($"Font file '{filename}' not found");
  27. }
  28. return success;
  29. }
  30. /// <summary>
  31. /// Adds a font contained in system memory to this collection.
  32. /// </summary>
  33. /// <param name="memory">The memory address of the font to add.</param>
  34. /// <param name="length">The memory length of the font to add.</param>
  35. public static void AddFont(IntPtr memory, int length)
  36. {
  37. PrivateFontCollection.AddMemoryFont(memory, length);
  38. }
  39. }
  40. }
  41. #endif