Use Triangle Cache to Improve TrueType Font Vectorization Performance

Sergey Zaitsev

September 10, 2020

For drawings that contain a lot of text, rendering TrueType fonts significantly impacts the performance of rendering the whole drawing.

The next picture illustrates a drawing that contains about 1,800 text entities that use TrueType fonts.
 

triangle cache example

 

The picture above shows the rendering result without using triangle cache. The next picture illustrates the rendering result with triangle cache turned on for the same drawing.

 

result

 

If the same TrueType characters are used inside a drawing multiple times, the tessellation of these characters can take a long time depending on character complexity. Initially characters are stored inside a font cache as shell primitives (contours and holes). For optimization purposes, the shell primitives can store triangles. So the final character vectorization doesn't need to execute tessellation.

The virtual bool useTtfTriangleCache() const; method of the OdGiContext class controls usage of this cache. For Drawings SDK, to prevent the useTtfTriangleCache() method from becoming overloaded, the setUseTtfTriangleCache () method was added to control the corresponding flag in the OdGiContextForDbDatabase class. So the setUseTtfTriangleCache() call is enough to control usage of this cache.

The OdaMfcApp sample application contains an example of using this functionality. The picture below demonstrates how to enable or disable triangle caching.

 

The OdaMfcApp sample application contains an example

 

This functionality is available starting with ODA SDKs version 21.0.