Uniscribe saves Unicode-to-glyph (cmap) mappings, 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 a device context handle parameter and a pointer to a SCRIPT_CACHE structure. 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, the application must pass a pointer to a SCRIPT_CACHE structure. The handle should be initialized to NULL before the first time the application passes it to a Uniscribe function. The application should never pass the same handle for different fonts or different sizes.

An application can free a script cache at any time. Uniscribe maintains reference counts in its font and shaper caches, frees font data only when all sizes of the font are freed, and frees shaper data only when all fonts that the shaper supports are freed. When the application is done with a style, it should call the ScriptFreeCache function to free the script cache for the style.

For ScriptShape and ScriptPlace, it is valid for the application to pass a null device context. Most often the call will succeed, as required tables are already cached. If the shaping or placement requires access to a device context, ScriptShape or ScriptPlace returns immediately with the E_PENDING error code. Then the application must select the font in the device context. For most applications, this helps performance by avoiding repeated preparation of a device context handle with calls to SelectObject.

Related topics

Using Uniscribe