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.

134 lines
2.9 KiB

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