Overview

DirectWrite is independent of any particular graphics technology.

Microsoft provides integrations with GDI, Direct2D, and Direct3D.

<aside> 💡 DirectWrite can also be used with a custom rendering backend.

</aside>

DirectWrite uses the OpenType Font technology to enable high quality typography and support for international text.

DirectWrite is designed as three layers of functionality.

Text Layout

The layout can either position the glyphs ideally based on their widths (as WPF does), or it can snap the glyphs to the nearest pixel positions.

Glyph Rendering

Text in DirectWrite is rendered using Microsoft ClearType (enhances the clarity and readability of text).

DirectWrite also enables you to use a custom renderer for glyphs by implementing the IDWriteTextRenderer interface which contains the DrawGlyphRun method.

void DrawGlyphRun(
    void* clientDrawingContext,
    FLOAT baselineOriginX,
    FLOAT baselineOriginY,
    DWRITE_MEASURING_MODE measuringMode,
    DWRITE_GLYPH_RUN const* glyphRun,
    DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription,
    IUnknown* clientDrawingEffect
) = 0;

Integration with Direct2D

The DirectWrite objects are used directly by Direct2D.