Platform SDK: International Features |
Uniscribe saves Unicode to glyph mappings (CMAP), glyph widths, and OpenType script shaping tables. A handle to the tables for a particular font of a particular size is called a script cache. Many Uniscribe functions call for both an HDC and a SCRIPT_CACHE parameter. These functions look first for information through the script cache, using the device context only when required tables are not already cached. When calling the ScriptShape, ScriptPlace, or ScriptTextOut function, you must provide a pointer to a SCRIPT_CACHE structure, which you must initially set to NULL.
An application may free a script cache at any time. Uniscribe maintains reference counts in it's font and shaper caches, and frees font data only when all sizes of the font are free, and Uniscribe frees shaper data only when all fonts the shaper supports are freed. When you are done with a style -- that is, a certain set of attributes that typically includes font, size, and color -- call the ScriptFreeCache function to free the script cache for the file.
For ScriptShape and ScriptPlace, it is valid to pass a NULL device context. Most often the call will be successful as required tables will already be cached. If the shaping or placement requires access to a device context, ScriptShape or ScriptPlace will return immediately with the E_PENDING error code. Then the application must select the font into the device context. This eliminates most calls to the SelectObject function.