GdiPlusFontCollection.h
上传用户:jinlangri
上传日期:2022-07-17
资源大小:10774k
文件大小:3k
源码类别:

GDI/图象编程

开发平台:

Visual C++

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