Using Font Fallback
Your application must use font fallback during text display if some characters in a string are not supported in the font, or if the application uses a complex script not supported by the font. The requirement for font fallback is detected during the layout process for text, when the application calls the ScriptShape function. For information about text display, see Displaying Text with Uniscribe.
If some of the characters in a string are not supported in a requested font, an application call to ScriptShape succeeds. However, the application must scan the glyph output buffer for the presence of missing glyphs. The glyph index of the missing glyph can be determined for a specific font by calling ScriptGetFontProperties. If a particular glyph is unavailable, the application must either fall back to a different font for a glyph or render a graphic symbol that indicates that no glyph is available.
The font that an application prefers for display might not support a complex script that is required by the text. In this case, the application call to ScriptShape fails with the error code E_SCRIPT_NOT_IN_FONT.
Once it has determined that font fallback is required, the application must assign a fallback font. The application can try the following techniques:
- Call ScriptShape for each font in a font list until one call has an acceptable return.
- Call ScriptShape with each font in a list until it can be determined that no font will succeed. If the error code is always E_SCRIPT_NOT_IN_FONT, a complex script is not supported by the fonts. Either render a graphic symbol that indicates that no glyph is available, or re-specify the script as undefined (no script processing) and start again. To set the script as undefined, set the eScript member of the SCRIPT_ANALYSIS structure to SCRIPT_UNDEFINED.
- Call ScriptShape with each font in a list until it can be determined that no font will succeed. If the error code indicates that some of the characters are mapping to missing glyphs, break up the string into smaller ranges. Different fonts can be assigned to subranges so that more of the characters can be rendered.
Once the application has assigned a font that succeeds in calls to ScriptShape, it can make calls to ScriptPlace to generate glyph advance width and two-dimensional offset information from the output of ScriptShape. The font should succeed in these calls. A font failure in a call to ScriptPlace after success in a ScriptShape call indicates a broken font.
Build date: 11/16/2013