PrivateFontCollection.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // System.Drawing.Text.PrivateFontCollection.cs
  3. //
  4. // (C) 2002 Ximian, Inc. http://www.ximian.com
  5. // Author: Everaldo Canuto [email protected]
  6. // Sanjay Gupta ([email protected])
  7. //
  8. using System;
  9. using System.IO;
  10. using System.Drawing;
  11. using System.Runtime.InteropServices;
  12. namespace System.Drawing.Text {
  13. [ComVisible(false)]
  14. public sealed class PrivateFontCollection : FontCollection {
  15. // constructors
  16. internal PrivateFontCollection ( IntPtr ptr ): base ( ptr )
  17. {}
  18. public PrivateFontCollection ()
  19. {
  20. Status status = GDIPlus.GdipNewPrivateFontCollection( out nativeFontCollection );
  21. GDIPlus.CheckStatus ( status );
  22. }
  23. // methods
  24. [ComVisible(false)]
  25. public void AddFontFile( string filename )
  26. {
  27. if ( filename == null )
  28. throw new Exception ( "Value cannot be null, Parameter name : filename" );
  29. bool exists = File.Exists( filename );
  30. if ( !exists )
  31. throw new Exception ( "The path is not of a legal form" );
  32. Status status = GDIPlus.GdipPrivateAddFontFile ( nativeFontCollection, filename );
  33. GDIPlus.CheckStatus ( status );
  34. }
  35. [ComVisible(false)]
  36. public void AddMemoryFont ( IntPtr memory, int length )
  37. {
  38. Status status = GDIPlus.GdipPrivateAddMemoryFont ( nativeFontCollection, memory, length );
  39. GDIPlus.CheckStatus ( status );
  40. }
  41. }
  42. }