TTFState.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using FastReport.Fonts;
  2. using System;
  3. using System.Drawing;
  4. public class TTFState : IDisposable
  5. {
  6. private bool disposedValue;
  7. public TTFState(Font source_font)
  8. {
  9. string fast_font =
  10. source_font.FontFamily.Name +
  11. (source_font.Bold ? "-B" : string.Empty) +
  12. (source_font.Italic ? "-I" : string.Empty);
  13. FastFontName = fast_font;
  14. SourceFont = source_font;
  15. Value = FastReport.Fonts.FontStreamPool.GetTTF(fast_font, source_font);
  16. }
  17. public TrueTypeFont Value { get; }
  18. public string FastFontName { get; }
  19. public Font SourceFont { get; }
  20. protected virtual void Dispose(bool disposing)
  21. {
  22. if (!disposedValue)
  23. {
  24. if (disposing)
  25. {
  26. FastReport.Fonts.FontStreamPool.ReleaseFontStream(Value);
  27. }
  28. // TODO: set large fields to null
  29. disposedValue = true;
  30. }
  31. }
  32. // // TODO: override finalizer only if 'Dispose(bool disposing)' has code to free unmanaged resources
  33. // ~TTFState()
  34. // {
  35. // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
  36. // Dispose(disposing: false);
  37. // }
  38. public void Dispose()
  39. {
  40. // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
  41. Dispose(disposing: true);
  42. GC.SuppressFinalize(this);
  43. }
  44. }