Freigeben über


IDWriteFontFace Interface

Represents an absolute reference to a font face which contains font face type, appropriate file references, face identification data and various font data such as metrics, names and glyph outlines.

Mitglieder

IDWriteFontFaceSchnittstelle erbt von der IUnknown-Schnittstelle. IDWriteFontFace umfasst auch die folgenden Typen von Mitgliedern:

  • Methoden

Methoden

IDWriteFontFaceSchnittstelle umfasst die folgenden Methoden.

Methode Beschreibung
GetDesignGlyphMetrics

Obtains ideal (resolution-independent) glyph metrics in font design units.

GetFiles

Obtains the font files representing a font face.

GetGdiCompatibleGlyphMetrics

Obtains glyph metrics in font design units with the return values compatible with what GDI would produce.

GetGdiCompatibleMetrics

Obtains design units and common metrics for the font face. These metrics are applicable to all the glyphs within a fontface and are used by applications for layout calculations.

GetGlyphCount

Obtains the number of glyphs in the font face.

GetGlyphIndices

Returns the nominal mapping of UCS4 Unicode code points to glyph indices as defined by the font 'CMAP' table.

GetGlyphRunOutline

Computes the outline of a run of glyphs by calling back to the outline sink interface.

GetIndex

Obtains the index of a font face in the context of its font files.

GetMetrics

Obtains design units and common metrics for the font face. These metrics are applicable to all the glyphs within a fontface and are used by applications for layout calculations.

GetRecommendedRenderingMode

Determines the recommended rendering mode for the font, given the specified size and rendering parameters.

GetSimulations

Obtains the algorithmic style simulation flags of a font face.

GetType

Obtains the file format type of a font face.

IsSymbolFont

Determines whether the font is a symbol font.

ReleaseFontTable

Releases the table obtained earlier from TryGetFontTable.

TryGetFontTable

Finds the specified OpenType font table, if it exists, and returns a pointer to it. The function accesses the underlying font data via the IDWriteFontFileStream interface implemented by the font file loader.

 

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