Source code of Windows XP (NT5)
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.

146 lines
3.1 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 2000, Microsoft Corp. All Rights Reserved.
  4. *
  5. * Abstract:
  6. *
  7. * Font collections (Installed and Private)
  8. *
  9. * Revision History:
  10. *
  11. * 03/07/2000 DChinn
  12. * Created it.
  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. 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. for (INT i = 0; i < *numFound; i++)
  57. {
  58. DllExports::GdipCloneFontFamily(nativeFamilyList[i],
  59. &gpfamilies[i].nativeFamily);
  60. }
  61. delete [] nativeFamilyList;
  62. return status;
  63. }
  64. inline Status FontCollection::GetLastStatus () const
  65. {
  66. return lastResult;
  67. }
  68. // protected method
  69. inline Status
  70. FontCollection::SetStatus(IN Status status) const
  71. {
  72. lastResult = status;
  73. return lastResult;
  74. }
  75. inline
  76. InstalledFontCollection::InstalledFontCollection()
  77. {
  78. nativeFontCollection = NULL;
  79. lastResult = DllExports::GdipNewInstalledFontCollection(&nativeFontCollection);
  80. }
  81. inline
  82. InstalledFontCollection::~InstalledFontCollection()
  83. {
  84. }
  85. inline Status
  86. InstalledFontCollection::InstallFontFile(IN const WCHAR* filename)
  87. {
  88. return SetStatus(DllExports::GdipInstallFontFile(nativeFontCollection, filename));
  89. }
  90. inline Status
  91. InstalledFontCollection::UninstallFontFile(IN const WCHAR* filename)
  92. {
  93. return SetStatus(DllExports::GdipUninstallFontFile(nativeFontCollection, filename));
  94. }
  95. inline
  96. PrivateFontCollection::PrivateFontCollection()
  97. {
  98. nativeFontCollection = NULL;
  99. lastResult = DllExports::GdipNewPrivateFontCollection(&nativeFontCollection);
  100. }
  101. inline
  102. PrivateFontCollection::~PrivateFontCollection()
  103. {
  104. DllExports::GdipDeletePrivateFontCollection(&nativeFontCollection);
  105. }
  106. inline Status
  107. PrivateFontCollection::AddFontFile(IN const WCHAR* filename)
  108. {
  109. return SetStatus(DllExports::GdipPrivateAddFontFile(nativeFontCollection, filename));
  110. }
  111. inline Status
  112. PrivateFontCollection::AddMemoryFont(IN const void* memory,
  113. IN INT length)
  114. {
  115. return SetStatus(DllExports::GdipPrivateAddMemoryFont(
  116. nativeFontCollection,
  117. memory,
  118. length));
  119. }
  120. #endif // _GDIPLUSFONTCOLL_H