GdiPlusFontCollection.h
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:3k
源码类别:

模拟服务器

开发平台:

C/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. inline Status
  71. FontCollection::SetStatus(IN Status status) const
  72. {
  73.     lastResult = status;
  74.     return lastResult;
  75. }
  76. inline
  77. InstalledFontCollection::InstalledFontCollection()
  78. {
  79.     nativeFontCollection = NULL;
  80.     lastResult = DllExports::GdipNewInstalledFontCollection(&nativeFontCollection);
  81. }
  82. inline
  83. InstalledFontCollection::~InstalledFontCollection()
  84. {
  85. }
  86. inline
  87. PrivateFontCollection::PrivateFontCollection()
  88. {
  89.     nativeFontCollection = NULL;
  90.     lastResult = DllExports::GdipNewPrivateFontCollection(&nativeFontCollection);
  91. }
  92. inline
  93. PrivateFontCollection::~PrivateFontCollection()
  94. {
  95.     DllExports::GdipDeletePrivateFontCollection(&nativeFontCollection);
  96. }
  97. inline Status
  98. PrivateFontCollection::AddFontFile(IN const WCHAR* filename)
  99. {
  100.     return SetStatus(DllExports::GdipPrivateAddFontFile(nativeFontCollection, filename));
  101. }
  102. inline Status
  103. PrivateFontCollection::AddMemoryFont(IN const void* memory,
  104.                                      IN INT length)
  105. {
  106.     return SetStatus(DllExports::GdipPrivateAddMemoryFont(
  107.         nativeFontCollection,
  108.         memory,
  109.         length));
  110. }
  111. #endif // _GDIPLUSFONTCOLL_H