GdiPlusFontCollection.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. //Download by http://www.NewXing.com
  2. /**************************************************************************\
  3. *
  4. * Copyright (c) 2000, Microsoft Corp. All Rights Reserved.
  5. *
  6. * Module Name:
  7. *
  8. * GdiplusFontCollection.h
  9. *
  10. * Abstract:
  11. *
  12. * Font collections (Installed and Private)
  13. *
  14. \**************************************************************************/
  15. #ifndef _GDIPLUSFONTCOLL_H
  16. #define _GDIPLUSFONTCOLL_H
  17. inline
  18. FontCollection::FontCollection()
  19. {
  20. nativeFontCollection = NULL;
  21. }
  22. inline
  23. FontCollection::~FontCollection()
  24. {
  25. }
  26. inline INT
  27. FontCollection::GetFamilyCount() const
  28. {
  29. INT numFound = 0;
  30. lastResult = DllExports::GdipGetFontCollectionFamilyCount(
  31. nativeFontCollection, &numFound);
  32. return numFound;
  33. }
  34. inline Status
  35. FontCollection::GetFamilies(
  36. IN INT numSought,
  37. OUT FontFamily * gpfamilies,
  38. OUT INT * numFound
  39. ) const
  40. {
  41. if (numSought <= 0 || gpfamilies == NULL || numFound == NULL)
  42. {
  43. return SetStatus(InvalidParameter);
  44. }
  45. *numFound = 0;
  46. GpFontFamily **nativeFamilyList = new GpFontFamily*[numSought];
  47. if (nativeFamilyList == NULL)
  48. {
  49. return SetStatus(OutOfMemory);
  50. }
  51. Status status = SetStatus(DllExports::GdipGetFontCollectionFamilyList(
  52. nativeFontCollection,
  53. numSought,
  54. nativeFamilyList,
  55. numFound
  56. ));
  57. if (status == Ok)
  58. {
  59. for (INT i = 0; i < *numFound; i++)
  60. {
  61. DllExports::GdipCloneFontFamily(nativeFamilyList[i],
  62. &gpfamilies[i].nativeFamily);
  63. }
  64. }
  65. delete [] nativeFamilyList;
  66. return status;
  67. }
  68. inline Status FontCollection::GetLastStatus () const
  69. {
  70. return lastResult;
  71. }
  72. inline Status
  73. FontCollection::SetStatus(IN Status status) const
  74. {
  75. lastResult = status;
  76. return lastResult;
  77. }
  78. inline
  79. InstalledFontCollection::InstalledFontCollection()
  80. {
  81. nativeFontCollection = NULL;
  82. lastResult = DllExports::GdipNewInstalledFontCollection(&nativeFontCollection);
  83. }
  84. inline
  85. InstalledFontCollection::~InstalledFontCollection()
  86. {
  87. }
  88. inline
  89. PrivateFontCollection::PrivateFontCollection()
  90. {
  91. nativeFontCollection = NULL;
  92. lastResult = DllExports::GdipNewPrivateFontCollection(&nativeFontCollection);
  93. }
  94. inline
  95. PrivateFontCollection::~PrivateFontCollection()
  96. {
  97. DllExports::GdipDeletePrivateFontCollection(&nativeFontCollection);
  98. }
  99. inline Status
  100. PrivateFontCollection::AddFontFile(IN const WCHAR* filename)
  101. {
  102. return SetStatus(DllExports::GdipPrivateAddFontFile(nativeFontCollection, filename));
  103. }
  104. inline Status
  105. PrivateFontCollection::AddMemoryFont(IN const void* memory,
  106. IN INT length)
  107. {
  108. return SetStatus(DllExports::GdipPrivateAddMemoryFont(
  109. nativeFontCollection,
  110. memory,
  111. length));
  112. }
  113. #endif // _GDIPLUSFONTCOLL_H