DirectWrite API Reference
This section provides detailed API documentation for DirectWrite, a Microsoft API for high-quality text rendering, font management, and text layout in Windows.
Core Interfaces
Explore the primary interfaces that form the core of DirectWrite functionality.
| Interface | Description |
|---|---|
| IDWriteFactory | The factory interface used to create other DirectWrite objects. |
| IDWriteTextFormat | Represents text formatting properties, such as font family, size, weight, and style. |
| IDWriteTextLayout | Represents a block of text that is laid out and formatted. |
| IDWriteFontFile | Represents a font file. |
| IDWriteFontFace | Represents a single font face within a font family. |
Key Concepts
Understand the fundamental concepts behind DirectWrite's text rendering pipeline.
Font Enumeration and Properties
Learn how to discover available fonts on the system and access their properties.
Example: Enumerating Font Families
__in IDWriteFontCollection* pFontCollection,
__out_ecount_opt(count) DWRITE_FONT_FAMILY_INFO* fontFamilies,
__in UINT32 size,
__out UINT32* actualSize
);
Text Rendering and Styling
Discover how to apply various text styles, including bold, italics, and paragraph alignment.
Common Tasks
Find guidance on performing frequent operations with DirectWrite.
- Creating an IDWriteFactory Object
- Creating an IDWriteTextFormat Object
- Creating an IDWriteTextLayout Object
- Drawing Text to a Render Target
- Getting Text Metrics
IDWriteFactory Interface
The primary interface for creating DirectWrite objects. You typically create one instance of IDWriteFactory for your application.
Methods
| Method | Description |
|---|---|
| CreateTextFormat | Creates a text format object, which encapsulates font face information and paragraph properties. |
| CreateTextLayout | Creates a text layout object, which is used to represent a block of text that is laid out and formatted. |
| GetGdiNaturalFontCacheClasses | Retrieves the GDI natural font cache classes. |
IDWriteTextFormat Interface
Represents text formatting properties, including font family, font weight, font style, font stretch, font size, locale name, and paragraph properties.
Properties
| Property | Type | Description |
|---|---|---|
| Font Family Name | const WCHAR* |
The name of the font family. |
| Font Weight | DWRITE_FONT_WEIGHT |
The weight of the font (e.g., normal, bold). |
| Font Style | DWRITE_FONT_STYLE |
The style of the font (e.g., normal, italic). |
| Font Stretch | DWRITE_FONT_STRETCH |
The stretch of the font (e.g., condensed, expanded). |
| Font Size | FLOAT |
The size of the font in DIPs (Device Independent Pixels). |