Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
3.3 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * fontcollection.hpp
  8. *
  9. * Abstract:
  10. *
  11. * Font collection. These objects implement the internal GdiPlus
  12. * installable fonts (system fonts) and private fonts (fonts an
  13. * application can temporarily install).
  14. *
  15. * Revision History:
  16. *
  17. * 03/06/00 DChinn
  18. * Created it.
  19. *
  20. \**************************************************************************/
  21. #ifndef _FONTCOLLECTION_HPP
  22. #define _FONTCOLLECTION_HPP
  23. class GpFontCollection
  24. {
  25. private:
  26. // We now use an ObjectTag to determine if the object is valid
  27. // instead of using a BOOL. This is much more robust and helps
  28. // with debugging. It also enables us to version our objects
  29. // more easily with a version number in the ObjectTag.
  30. ObjectTag Tag; // Keep this as the 1st value in the object!
  31. protected:
  32. VOID SetValid(BOOL valid)
  33. {
  34. Tag = valid ? ObjectTagFontCollection : ObjectTagInvalid;
  35. }
  36. public:
  37. BOOL IsValid() const
  38. {
  39. #ifdef _X86_
  40. // We have to guarantee that the Tag field doesn't move for
  41. // versioning to work between releases of GDI+.
  42. ASSERT(offsetof(GpFontCollection, Tag) == 4);
  43. #endif
  44. ASSERT((Tag == ObjectTagFontCollection) || (Tag == ObjectTagInvalid));
  45. #if DBG
  46. if (Tag == ObjectTagInvalid)
  47. {
  48. WARNING1("Invalid FontCollection");
  49. }
  50. #endif
  51. return (Tag == ObjectTagFontCollection);
  52. }
  53. GpFontCollection()
  54. {
  55. SetValid(TRUE); // default is valid
  56. }
  57. ~GpFontCollection()
  58. {
  59. SetValid(FALSE); // so we don't use a deleted object
  60. }
  61. INT GetFamilyCount (); // number of enumerable families in the collection
  62. GpStatus GetFamilies ( // enumerate the fonts in a collection
  63. INT numSought,
  64. GpFontFamily* gpfamilies[],
  65. INT* numFound
  66. );
  67. virtual BOOL LoadRegistered()=0; // is TRUE if we should load all registered
  68. // fonts every time we try to enumerate
  69. // (e.g., if the object is an installed
  70. // font collection)
  71. GpFontTable *GetFontTable() { return FontTable; }
  72. protected:
  73. GpFontTable *FontTable; // hash table of GpFontFile
  74. };
  75. class GpInstalledFontCollection : public GpFontCollection
  76. {
  77. public:
  78. ~GpInstalledFontCollection();
  79. static GpInstalledFontCollection* GetGpInstalledFontCollection();
  80. GpStatus InstallFontFile (const WCHAR *filename);
  81. GpStatus UninstallFontFile (const WCHAR *filename);
  82. virtual BOOL LoadRegistered() { return TRUE; }
  83. protected:
  84. GpInstalledFontCollection();
  85. private:
  86. static GpInstalledFontCollection* instance;
  87. };
  88. class GpPrivateFontCollection : public GpFontCollection
  89. {
  90. public:
  91. GpPrivateFontCollection();
  92. ~GpPrivateFontCollection();
  93. GpStatus AddFontFile (const WCHAR *filename);
  94. GpStatus AddMemoryFont (const void *memory, INT length);
  95. virtual BOOL LoadRegistered() { return FALSE; }
  96. };
  97. #endif // FONTCOLLECTION_HPP