IDWriteFontFile Interface
Represents a font file. Applications such as font managers or font viewers can call IDWriteFontFile::Analyze to find out if a particular file is a font file, and whether it is a font type that is supported by the font system.
Mitglieder
IDWriteFontFileSchnittstelle erbt von der IUnknown-Schnittstelle. IDWriteFontFile umfasst auch die folgenden Typen von Mitgliedern:
- Methoden
Methoden
IDWriteFontFileSchnittstelle umfasst die folgenden Methoden.
Methode | Beschreibung |
---|---|
Analyze | Analyzes a file and returns whether it represents a font, and whether the font type is supported by the font system. |
GetLoader | Obtains the file loader associated with a font file object. |
GetReferenceKey | Obtains the pointer to the reference key of a font file. The returned pointer is valid until the font file object is released. |
Beispiele
The following code example demonstrates creating a font face from a font file's file name.
HRESULT CreateFontFaceFromFontFile(wchar_t* filename, IDWriteFontFace **ppFontFace)
{
HRESULT hr = S_OK;
IDWriteFactory* pDWriteFactory = NULL;
IDWriteFontFace* pFontFace = NULL;
IDWriteFontFile* pFontFiles = NULL;
// Create the DirectWrite factory.
hr = DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED,
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(&pDWriteFactory)
);
//Gets a filename from a application directory
WCHAR fontFolderPath[MAX_PATH];
UINT curDirLength = GetCurrentDirectory(
sizeof(fontFolderPath),
fontFolderPath
);
if (curDirLength == 0)
{
return E_UNEXPECTED;
}
if (SUCCEEDED(hr))
{
hr = StringCchCatW(
fontFolderPath,
sizeof(fontFolderPath),
L"\\"
);
}
if (SUCCEEDED(hr))
{
hr = StringCchCatW(
fontFolderPath,
sizeof(fontFolderPath),
(STRSAFE_LPCWSTR)filename
);
}
if (SUCCEEDED(hr))
{
hr = pDWriteFactory->CreateFontFileReference(
fontFolderPath,
NULL,
&pFontFiles);
}
IDWriteFontFile* fontFileArray[] = {pFontFiles};
if (SUCCEEDED(hr))
{
hr = pDWriteFactory->CreateFontFace(
DWRITE_FONT_FACE_TYPE_TRUETYPE,
1, // file count
fontFileArray,
0,
DWRITE_FONT_SIMULATIONS_NONE,
&pFontFace
);
}
//Return the pointer to the caller
*ppFontFace = pFontFace;
SafeRelease(&pDWriteFactory);
SafeRelease(&pFontFiles);
return hr;
}
Anforderungen
Mindestens unterstützter Client |
Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista |
Mindestens unterstützter Server |
Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 |
Header |
Dwrite.h |
Bibliothek |
Dwrite.lib |
DLL |
Dwrite.dll |