IDWriteFactory::CreateGlyphRunAnalysis method (dwrite.h)
Creates a glyph run analysis object, which encapsulates information used to render a glyph run.
Syntax
HRESULT CreateGlyphRunAnalysis(
[in] DWRITE_GLYPH_RUN const *glyphRun,
FLOAT pixelsPerDip,
[in, optional] DWRITE_MATRIX const *transform,
DWRITE_RENDERING_MODE renderingMode,
DWRITE_MEASURING_MODE measuringMode,
FLOAT baselineOriginX,
FLOAT baselineOriginY,
[out] IDWriteGlyphRunAnalysis **glyphRunAnalysis
);
Parameters
[in] glyphRun
Type: const DWRITE_GLYPH_RUN*
A structure that contains the properties of the glyph run (font face, advances, and so on).
pixelsPerDip
Type: FLOAT
Number of physical pixels per DIP (device independent pixel). For example, if rendering onto a 96 DPI bitmap then pixelsPerDip is 1. If rendering onto a 120 DPI bitmap then pixelsPerDip is 1.25.
[in, optional] transform
Type: const DWRITE_MATRIX*
Optional transform applied to the glyphs and their positions. This transform is applied after the scaling specified the emSize and pixelsPerDip.
renderingMode
Type: DWRITE_RENDERING_MODE
A value that specifies the rendering mode, which must be one of the raster rendering modes (that is, not default and not outline).
measuringMode
Type: DWRITE_MEASURING_MODE
Specifies the measuring mode to use with glyphs.
baselineOriginX
Type: FLOAT
The horizontal position (X-coordinate) of the baseline origin, in DIPs.
baselineOriginY
Type: FLOAT
Vertical position (Y-coordinate) of the baseline origin, in DIPs.
[out] glyphRunAnalysis
Type: IDWriteGlyphRunAnalysis**
When this method returns, contains an address of a pointer to the newly created glyph run analysis object.
Return value
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
The glyph run analysis object contains the results of analyzing the glyph run, including the positions of all the glyphs and references to all of the rasterized glyphs in the font cache.
Examples
The following code example shows how to create a glyph run analysis object. In this example, an empty glyph run is being used.
HRESULT CreateGlyphRunAnalysis(IDWriteFontFace *pFontFace, IDWriteGlyphRunAnalysis **ppGlyphRunAnalysis)
{
HRESULT hr = S_OK;
IDWriteFactory* pDWriteFactory = NULL;
// Create the DirectWrite factory.
hr = DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED,
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(&pDWriteFactory)
);
DWRITE_GLYPH_RUN emptyGlyphRun = { 0 };
UINT16 glyphIndex = 0;
emptyGlyphRun.fontFace = pFontFace;
emptyGlyphRun.glyphIndices = &glyphIndex;
emptyGlyphRun.glyphCount = 0;
emptyGlyphRun.fontEmSize = 12;
IDWriteGlyphRunAnalysis* pGlyphRunAnalysis = NULL;
if (SUCCEEDED(hr))
{
hr = pDWriteFactory->CreateGlyphRunAnalysis(
&emptyGlyphRun,
1.0f, // pixelsPerDip,
NULL, // transform,
DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC,
DWRITE_MEASURING_MODE_GDI_CLASSIC,
0.0f, // baselineOriginX,
0.0f, // baselineOriginY,
&pGlyphRunAnalysis);
}
*ppGlyphRunAnalysis = pGlyphRunAnalysis;
SafeRelease(&pDWriteFactory);
return S_OK;
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | dwrite.h |
Library | Dwrite.lib |
DLL | Dwrite.dll |