What's new in DirectWrite
Here are some of the new additions to DirectWrite.
The following features and APIs were added or updated for Windows 10 Anniversary Update.
Starting in Windows 10 Anniversary Update, DirectWrite provides built-in support for a wider variety of color font formats, allowing developers to use more types of fonts in their DirectWrite-powered apps than ever before. This includes support for:
- The ‘COLR’ OpenType table, which enables compact vector content in fonts. (Supported since Windows 8.1.)
- The ‘SVG ’ OpenType table, which enables SVG content in fonts.
- The ‘CBDT’ OpenType table, which enables color bitmap content in fonts.
- The ‘sbix’ OpenType table, which enables color bitmap content in fonts.
Direct2D, which uses DirectWrite for text rendering, supports these color font formats automatically when the D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT flag is enabled. For more information, see the following topics:
Some font services, such as Adobe Typekit, have client-side utilities that allow a user to load fonts from the service and use them in different applications on their Windows machine. These utilities typically work by making run-time calls to GDI to load additional fonts, rather than permanently installing fonts on the system. Because of that design, on earlier Windows versions, the fonts would be usable in GDI-based applications, but not in DirectWrite applications. Starting in the Windows 10 Anniversary Update, fonts that are loaded by such utilities will also be available in DirectWrite as well as in GDI.
Fonts loaded by a font-service utility are visible in the system font collection obtained by calling the IDWriteFactory::GetSystemFontCollection method. Because font services typically follow a per-user licensing model, fonts loaded by these utilities are managed on a per-user basis. As a result, existing DirectWrite applications can utilize fonts that end-users have obtained using such services, without any code changes required in the application, providing a more seamless experience for users.
The OpenType and TrueType font formats have long supported the ability for multiple fonts to be packaged together in a single font file, known as a “font collection”. The OpenType specification has always allowed fonts to use either TrueType or CFF formats for glyph outline data. Until recently, however, the specification has only allowed for collections in which glyph outlines use the TrueType format. OpenType version 1.7 now allows for collections to use either TrueType or CFF formats for glyph outline data. Starting in the Windows 10 Anniversary Update, DirectWrite will support OpenType collections using CFF outline data.
Starting in Windows 10, fonts that are included with Windows are available in an online service and are accessible via DirectWrite on any Windows 10 device. This applies to all Windows 10 editions, including Mobile, Xbox and Hololens as well as the desktop client. This allows applications to display content using any Windows font even if the font is not currently installed on the device.
Support for the DirectWrite font-service mechanisms has been implemented in the XAML framework, which means that any applications that use XAML require no code changes in order to take advantage of the font service. The Downloadable fonts (XAML) code sample demonstrates this. Applications that call DirectWrite APIs directly will need to use new APIs to make use of the font-service mechanisms. For more information, see the following topics:
- IDWriteFactory3::GetSystemFontCollection method
- IDWriteTextLayout3 interface
- IDWriteFontDownloadQueue interface
- IDWriteFontDownloadListener interface
The Downloadable fonts (DirectWrite) code sample illustrates the use of several of the new APIs.
DirectWrite's font collection interfaces provide a view to a collection of fonts that is organized by font families, using weight, stretch and style as sub-family attributes. Internally, DirectWrite implements the font collection interface using a flat list of fonts with various attributes. This approach is more flexible in that in can support enumeration of weight/stretch/style families, but can also support querying and filtering using other font attributes as well.
In Windows 10, this more flexible font-handling mechanism is made available to applications via the IDWriteFontSet and related APIs. The font set APIs can be used, for example, to create a customized font-picker user interface leveraging application-customized font properties in a custom font set.
For more information, see the following topics:
- IDWriteFontSet interface
- IDWriteFontSetBuilder interface
- DWRITE_FONT_PROPERTY_ID enumeration
- IDWriteFontFactory3::GetSystemFontSet method
DirectWrite’s text format and text layout interfaces support new line-spacing modes. In earlier versions, DirectWrite’s text layout implementation allowed for line spacing in which the height of each line was set automatically based on the tallest item within a line (the “default” mode), or line spacing with all lines set to a uniform height determined by the application (the “uniform” mode). In Windows 10, an additional “proportional” line-spacing mode is supported that gives applications more options for line-spacing behavior. For more information, see the following topics:
- IDWriteTextLayout3 interface
- IDWriteTextLayout3::SetLineSpacing method
- DWRITE_LINE_SPACING structure
- DWRITE_LINE_SPACING_METHOD enumeration
- DWRITE_FONT_LINE_GAP_USAGE enumeration
- IDWriteTextLayout3::GetLineMetrics method
- DWRITE_LINE_METRICS1 structure
The Line spacing (DirectWrite) code sample illustrates use of several of the new APIs, and also provides a visualization of all of the different line-spacing modes that makes it much easier to understand the various line-spacing options that are available.
Since its introduction in Windows 7, DirectWrite has provided a migration path for applications that were originally implemented using GDI’s font model, text layout and rendering. This was provided via the [[IDWriteGdiInterop]] interface. In Windows 10, additional APIs provide additional GDI-interop capabilities. For additional information, see the following topic:
- IDWriteGdiInterop1 interface
Starting in Windows Windows 8.1, DirectWrite provides support for color fonts. Direct2D, which uses DirectWrite for text rendering, has added the enum value D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT to enable this feature when drawing text. For more information, see the following topics:
A new factory interface, IDWriteFactory1, for creating additional interfaces that are available.
Additional font properties, such as: super/subscript, caret slope, PANOSE, and Unicode ranges.
Spacing improvements, such as: control character spacing, legacy kerning pairs, and justification. See the Justification, Kerning, and Spacing topic for more info.
Improved render targets and parameters.
Text complexity analysis improvements.
New script properties, new script support (Unicode 6), font fallback additions, paired parentheses, and bidi augmentation.
Font cache performance enhancements. Starting with Windows 8 the font cache is global and starts when your computer boots.
New rendering modes.
Starting with Windows 8, DirectWrite supports a number of features that help you make apps for the world market.
Here are several areas that help you implement rich text apps that can be tailored to customers across the globe.
Every few years, the Unicode Consortium releases a standardized list of additions to Chinese, Japanese, and Korean Unified Ideograph block. With the Unicode 6.0 revision, they have released extension blocks C and D. These blocks of ideographs can be found on the Unicode website Extension C and Extension D.
Starting with Windows 8, DirectWrite supports the Unicode codepoints for these new blocks of standardized CJK Ideographs, so you can use them in DirectWrite apps.
In March of 2005, the Indian government announced a competition to choose a symbol for the Indian rupee currency. After much competition, on the 15th of July, 2010, the Indian government chose the design created by D. Udaya Kumar, and DirectWrite includes support for the Unicode codepoint tied to the symbol. So, DirectWrite apps now support this currency symbol.
DirectWrite now supports the use of emoji in apps. Previous versions of DirectWrite, presented with a missing glyph box if you tried to render an emoji ideograph. Starting with Windows 8, DirectWrite supports the Unicode codeblock associated with emoji, so if your app uses the Unicode standard codepoints for emoji it displays the appropriate glyphs.
Starting in Windows 8, DirectWrite supports the block of Unicode codepoints that correspond to the glyphs in the Myanmar, Tiffinagh, and Old Hangul languages, so you can create apps that include text from these three languages. In addition to supporting these characters, DirectWrite supports the unique way that Old Hangul handles line breaking.
- Egyptian hieroglyphics
- Imperial Aramaic
- Inscriptional Pahlavi
- Inscriptional Parthian
- Lisu (Fraser)
- Meetei Mayek
- Old South Arabian
- Old Turkish (Orkhon)
- Tai Tham (Lanna)
- Tai Viet