Win32 Text API Comparison
For those developers that are migrating their Win32 application code, the following table lists the Win32 Text APIs and the approximate equivalent in DirectWrite.
GDI Text calls | Description | DirectWrite Equivalent |
---|---|---|
AddFontMemResourceEx | Adds an embedded font to the system font table. | CreateCustomFontFileReference + CreateCustomFontCollection |
AddFontResource | Adds a font resource to the system font table. | There is no equivalent. AddFontResource adds to the system font collection as part of the GDI font installation step. DirectWrite populates the system font collection upfront and automatically monitors updates to it, so no installation is ever needed. |
AddFontResourceEx | Adds a private or non-enumerable font to the system font table. | Same as above |
CreateFont | Creates a logical font. | Instead of logical font, applications can specify a set of font properties (for example family name, weight, style, stretch, and size) to create a IDWriteTextFormat. Only apps requiring enumeration of the font will access a IDWriteFont through the IDWriteFontCollection. |
CreateFontIndirect | Creates a logical font from a structure. | Same as above |
CreateFontIndirectEx | Creates a logical font from a structure. | Same as above |
DrawText | Draws formatted text in a rectangle. | IDWriteTextLayout::Draw |
DrawTextEx | Draws formatted text in a rectangle. | IDWriteTextLayout::Draw |
EnumFontFamExProc | An application-defined callback function used with EnumFontFamiliesEx to process fonts. | IDWriteFontCollection interface, through IDWriteFactory::GetSystemFontCollection |
EnumFontFamiliesEx | Enumerates all fonts in the system with certain characteristics. | IDWriteFontCollection interface, through IDWriteFactory::GetSystemFontCollection |
ExtTextOut | Draws a character string. | IDWriteTextLayout::Draw or IDWriteRenderBitmapTarget::DrawGlyphRun |
GetAspectRatioFilterEx | Gets the setting for the aspect-ratio filter. | N/A |
GetCharABCWidths | Gets the widths of consecutive characters from the TrueType font. | IDWriteFontFace::GetDesignGlyphMetrics |
GetCharABCWidthsFloat | Gets the widths of consecutive characters from the current font. | IDWriteFontFace::GetDesignGlyphMetrics |
GetCharABCWidthsI | Gets the widths of consecutive glyph indices or an array of glyph indices from the TrueType font. | IDWriteFontFace::GetDesignGlyphMetrics |
GetCharacterPlacement | Gets information about a character string. | IDWriteTextAnalyzer |
GetCharWidth32 | Gets the widths of consecutive characters from the current font. | IDWriteFontFace::GetDesignGlyphMetrics or IDWriteTextLayout::GetMetrics |
GetCharWidthFloat | Gets the fractional widths of consecutive characters from the current font. | IDWriteFontFace::GetDesignGlyphMetrics or IDWriteTextLayout::GetMetrics |
GetCharWidthI | Gets the widths of consecutive glyph indices or an array of glyph indices from the current font. | IDWriteFontFace::GetDesignGlyphMetrics or IDWriteTextLayout::GetMetrics |
GetFontData | Gets metric data for a TrueType font. | IDWriteFontFace::TryGetFontTable |
GetFontLanguageInfo | Returns information about the selected font for a display context. | N/A |
GetFontUnicodeRanges | Tells which Unicode characters are supported by a font. | loop of IDWriteFont::HasCharacter |
GetGlyphIndices | Translates a string into an array of glyph indices. | IDWriteFontFace::GetGlyphIndices |
GetGlyphOutline | Gets the outline or bitmap for a character in the TrueType font. | glyph metrics -- IDWriteFontFace::GetDesignGlyphMetrics, actual outline information --IDwriteFontFace::GetGlyphRunOutline, if you want glyph bitmaps, IDWriteRenderBitmapRenderTarget::DrawGlyphRun |
GetKerningPairs | Gets the character-kerning pairs for a font. | Kerning allowed via typographic properties of the layout (DirectWrite does kerning itself, so there is no method to return this information). |
GetOutlineTextMetrics | Gets text metrics for TrueType fonts. | IDWriteFontFace::GetMetrics |
GetRasterizerCaps | Tells whether TrueType fonts are installed. | (TrueType fonts are installed on Windows Vista and Windows 7 by default.) |
GetTabbedTextExtent | Computes the width and height of a character string, including tabs. | IDWriteTextLayout::GetMetrics |
GetTextAlign | Gets the text-alignment setting for a device context. | IDWriteTextFormat::GetTextAlignment |
GetTextCharacterExtra | Gets the current inter character spacing for a device context. | N/A |
GetTextColor | Gets the text color for a device context. | N/A. (DirectWrite is independent of rendering and hence does not know the color. Applications need to keep track of it themselves.) |
GetTextExtentExPoint | Gets the number of characters in a string that will fit within a space. | IDWriteTextLayout::GetMetrics |
GetTextExtentExPointI | Gets the number of glyph indices that will fit within a space. | IDWriteTextLayout::GetMetrics |
GetTextExtentPoint32 | Computes the width and height of a string of text. | IDWriteTextLayout::GetMetrics |
GetTextExtentPointI | Computes the width and height of an array of glyph indices. | IDWriteTextLayout::GetMetrics |
GetTextFace | Gets the name of the font that is selected into a device context. | IDWriteFont::GetFaceNames (Returns all of the names) |
GetTextMetrics | Fills a buffer with the metrics for a font. | IDWriteFontFace::GetMetrics |
PolyTextOut | Draws several strings using the font and text colors in a device context. | N/A; create several layout objects |
RemoveFontMemResourceEx | Removes a font whose source was embedded in a document from the system font table. | IUnknown::Release on the associated object |
RemoveFontResource | Removes the fonts in a file from the system font table | N/A |
RemoveFontResourceEx | Removes a private or non-enumerable font from the system font table. | N/A |
SetMapperFlags | Alters the algorithm used to map logical fonts to physical fonts. | N/A |
SetTextAlign | Sets the text-alignment flags for a device context. | IDWriteTextFormat::SetTextAlignment |
SetTextCharacterExtra | Sets the inter-character spacing. | N/A |
SetTextColor | Sets the text color for a device context. | An application has to take care of specifying the color in one of the Draw calls. |
SetTextJustification | Specifies the amount of space the system should add to the break characters in a string. | N/A. Justification and character spacing are not supported in this release. |
TabbedTextOut | Writes a character string at a location, expanding tabs to specified values. | IDWriteTextLayout::Draw |
TextOut | Writes a character string at a location | IDWriteTextLayout::Draw |