Caching with Uniscribe (Windows Embedded CE 6.0)

1/6/2010

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 for information in the script cache first, 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 its font and shaper caches, frees font data only when all sizes of the font are free, and frees shaper data only when all fonts that the shaper supports are free. 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. Because required tables will already be cached, the call will usually succeed.

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.

See Also

Other Resources

Uniscribe Application Development