您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

GdiplusFontCollection.h 3.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. // protected method
  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. #ifndef DCR_USE_NEW_235072
  89. inline Status
  90. InstalledFontCollection::InstallFontFile(IN const WCHAR* filename)
  91. {
  92. return SetStatus(DllExports::GdipInstallFontFile(nativeFontCollection, filename));
  93. }
  94. inline Status
  95. InstalledFontCollection::UninstallFontFile(IN const WCHAR* filename)
  96. {
  97. return SetStatus(DllExports::GdipUninstallFontFile(nativeFontCollection, filename));
  98. }
  99. #endif
  100. inline
  101. PrivateFontCollection::PrivateFontCollection()
  102. {
  103. nativeFontCollection = NULL;
  104. lastResult = DllExports::GdipNewPrivateFontCollection(&nativeFontCollection);
  105. }
  106. inline
  107. PrivateFontCollection::~PrivateFontCollection()
  108. {
  109. DllExports::GdipDeletePrivateFontCollection(&nativeFontCollection);
  110. }
  111. inline Status
  112. PrivateFontCollection::AddFontFile(IN const WCHAR* filename)
  113. {
  114. return SetStatus(DllExports::GdipPrivateAddFontFile(nativeFontCollection, filename));
  115. }
  116. inline Status
  117. PrivateFontCollection::AddMemoryFont(IN const void* memory,
  118. IN INT length)
  119. {
  120. return SetStatus(DllExports::GdipPrivateAddMemoryFont(
  121. nativeFontCollection,
  122. memory,
  123. length));
  124. }
  125. #endif // _GDIPLUSFONTCOLL_H