Microsoft Learn

Documentation for Windows Development

DirectWrite API Reference

DirectWrite is a text rendering and formatting API that provides high-performance, high-quality text rendering suitable for user interfaces, documents, and other display scenarios. It offers advanced typography features and integrates seamlessly with other Windows graphics technologies.

Core Interfaces

Explore the fundamental interfaces that form the backbone of DirectWrite functionality.

IDWriteFactory

interface IDWriteFactory

The factory object is the primary entry point for creating other DirectWrite objects, such as text formats, text layout objects, and more.

Methods:
  • CreateTextFormat
  • CreateTypography
  • CreateRenderingParams

IDWriteTextFormat

interface IDWriteTextFormat

Represents the formatting of a block of text, including font properties, paragraph alignment, and text wrapping.

Properties:
  • GetFontFamilyName
  • GetFontWeight
  • GetFontSize
  • GetParagraphAlignment
  • GetTextAlignment

IDWriteTextLayout

interface IDWriteTextLayout : IDWriteTextAnalysisSink

An object that represents a paragraph of text with layout properties applied. It can be used to draw text and query layout information.

Methods:
  • Draw
  • DetermineTextBounds
  • HitTestTextPosition

IDWriteGlyphRun

struct DWRITE_GLYPH_RUN

Represents a run of glyphs that share the same font, orientation, and other properties. This is a fundamental unit for rendering.

Members:
  • fontFace
  • fontEmSize
  • glyphCount
  • glyphIndices
  • glyphAdvances

Typography and Advanced Features

Leverage DirectWrite's powerful typography features for sophisticated text rendering.

IDWriteTypography

interface IDWriteTypography

Represents a set of OpenType typography features that can be applied to text.

Methods:
  • AddFontFeature
  • AddFontVariation

OpenType Features

DirectWrite supports a wide range of OpenType features, including:

  • Ligatures (DWRITE_FONT_FEATURE_TAG_LIGATURES)
  • Stylistic sets (DWRITE_FONT_FEATURE_TAG_STYLISTIC_SET)
  • Swashes (DWRITE_FONT_FEATURE_TAG_SWASH)
  • Contextual alternates (DWRITE_FONT_FEATURE_TAG_CONTEXTUAL_ALTERNATES)

Rendering and Measurement

Understand how to render text and obtain accurate layout metrics.

IDWriteTextRenderer

interface IDWriteTextRenderer

An abstract interface that you implement to draw text using DirectWrite. You typically implement this in conjunction with Direct2D.

Methods:
  • DrawGlyphRun
  • DrawUnderline
  • DrawStrikethrough