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 15#ifndef _GDIPLUSFONTCOLL_H 16#define _GDIPLUSFONTCOLL_H 17 18inline 19FontCollection::FontCollection() 20{ 21 nativeFontCollection = NULL; 22} 23 24inline 25FontCollection::~FontCollection() 26{ 27} 28 29inline INT 30FontCollection::GetFamilyCount() const 31{ 32 INT numFound = 0; 33 34 lastResult = DllExports::GdipGetFontCollectionFamilyCount( 35 nativeFontCollection, &numFound); 36 37 38 39 return numFound; 40} 41 42inline Status 43FontCollection::GetFamilies( 44 IN INT numSought, 45 OUT FontFamily * gpfamilies, 46 OUT INT * numFound 47) const 48{ 49 if (numSought <= 0 || gpfamilies == NULL || numFound == NULL) 50 { 51 return SetStatus(InvalidParameter); 52 } 53 *numFound = 0; 54 GpFontFamily **nativeFamilyList = new GpFontFamily*[numSought]; 55 56 if (nativeFamilyList == NULL) 57 { 58 return SetStatus(OutOfMemory); 59 } 60 61 Status status = SetStatus(DllExports::GdipGetFontCollectionFamilyList( 62 nativeFontCollection, 63 numSought, 64 nativeFamilyList, 65 numFound 66 )); 67 if (status == Ok) 68 { 69 for (INT i = 0; i < *numFound; i++) 70 { 71 DllExports::GdipCloneFontFamily(nativeFamilyList[i], 72 &gpfamilies[i].nativeFamily); 73 } 74 } 75 76 delete [] nativeFamilyList; 77 78 return status; 79} 80 81inline Status FontCollection::GetLastStatus () const 82{ 83 return lastResult; 84} 85 86// protected method 87inline Status 88FontCollection::SetStatus(IN Status status) const 89{ 90 lastResult = status; 91 return lastResult; 92} 93 94inline 95InstalledFontCollection::InstalledFontCollection() 96{ 97 nativeFontCollection = NULL; 98 lastResult = DllExports::GdipNewInstalledFontCollection(&nativeFontCollection); 99} 100 101inline 102InstalledFontCollection::~InstalledFontCollection() 103{ 104} 105 106#ifndef DCR_USE_NEW_235072 107inline Status 108InstalledFontCollection::InstallFontFile(IN const WCHAR* filename) 109{ 110 return SetStatus(DllExports::GdipInstallFontFile(nativeFontCollection, filename)); 111} 112 113inline Status 114InstalledFontCollection::UninstallFontFile(IN const WCHAR* filename) 115{ 116 return SetStatus(DllExports::GdipUninstallFontFile(nativeFontCollection, filename)); 117} 118#endif 119 120inline 121PrivateFontCollection::PrivateFontCollection() 122{ 123 nativeFontCollection = NULL; 124 lastResult = DllExports::GdipNewPrivateFontCollection(&nativeFontCollection); 125} 126 127inline 128PrivateFontCollection::~PrivateFontCollection() 129{ 130 DllExports::GdipDeletePrivateFontCollection(&nativeFontCollection); 131} 132 133inline Status 134PrivateFontCollection::AddFontFile(IN const WCHAR* filename) 135{ 136 return SetStatus(DllExports::GdipPrivateAddFontFile(nativeFontCollection, filename)); 137} 138 139inline Status 140PrivateFontCollection::AddMemoryFont(IN const void* memory, 141 IN INT length) 142{ 143 return SetStatus(DllExports::GdipPrivateAddMemoryFont( 144 nativeFontCollection, 145 memory, 146 length)); 147} 148 149#endif // _GDIPLUSFONTCOLL_H 150