IDWriteFontFace4::GetGlyphImageData method (dwrite_3.h)

Gets a pointer to the glyph data based on the desired image format.

Syntax

HRESULT GetGlyphImageData(
  [in]  UINT16                     glyphId,
        UINT32                     pixelsPerEm,
        DWRITE_GLYPH_IMAGE_FORMATS glyphImageFormat,
  [out] DWRITE_GLYPH_IMAGE_DATA    *glyphData,
  [out] void                       **glyphDataContext
);

Parameters

[in] glyphId

Type: UINT16

The ID of the glyph to retrieve image data for.

pixelsPerEm

Type: UINT32

Requested pixels per em.

glyphImageFormat

Type: DWRITE_GLYPH_IMAGE_FORMATS

Specifies which formats are supported in the font.

[out] glyphData

Type: DWRITE_GLYPH_IMAGE_DATA*

On return contains data for a glyph.

[out] glyphDataContext

Type: void**

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

The glyphDataContext must be released via ReleaseGlyphImageData when done if the data is not empty, similar to IDWriteFontFileStream::ReadFileFragment and IDWriteFontFileStream::ReleaseFileFragment. The data pointer is valid so long as the IDWriteFontFace exists and ReleaseGlyphImageData has not been called.

The DWRITE_GLYPH_IMAGE_DATA::uniqueDataId is valuable for caching purposes so that if the same resource is returned more than once, an existing resource can be quickly retrieved rather than needing to reparse or decompress the data.

The function only returns SVG or raster data - requesting TrueType/CFF/COLR data returns DWRITE_E_INVALIDARG. Those must be drawn via DrawGlyphRun or queried using GetGlyphOutline instead. Exactly one format may be requested or else the function returns DWRITE_E_INVALIDARG. If the glyph does not have that format, the call is not an error, but the function returns empty data.

Requirements

Requirement Value
Target Platform Windows
Header dwrite_3.h
Library Dwrite.lib

See also

IDWriteFontFace4