[cairo] font thrashing

Bill Spitzak spitzak at d2.com
Mon May 3 11:51:00 PDT 2004


On Saturday 01 May 2004 08:47 am, David Reveman wrote:
> We can of course include this type of font caching in cairo but I think
> it's better that we leave it to the application.

I disagree. Any application that figures out the name of a font must now do 
it's own font caching, and find out if they have asked for the font before. 
It also has to worry about throwing away the fonts in the cache.

I find it hard to believe there is any concievable implementation where a 
cache inside cairo would not be faster. Cairo would also be able to throw 
away a font any time it wants to, allowing it to be programmed to know that 
there will never be more than a certain number of fonts. It can also store 
"partial results" in the cache, such as small pointers to FreeType info 
needed to reconstruct the font more quickly, this is impossible for an 
appliation which either must cache the entire font or nothing.

A window manager may only think about a few fonts (ie the one used for the 
window title, the one used for the menus) so you may think it acceptable that 
you are forced to remember a structure for each of them. But real 
applications, such as that SVG renderer, have to be prepared to handle an 
unbounded and arbitrary set of fonts, which are always identified by a string 
name.

Cairo's purpose is to provide a programmer-friendly wrapper around XRender 
and other low-level details. I consider asking for the same font by name many 
times a much more programmer-friendly interface than having to allocate a 
structure the first time I ask for the name and remember that I did that next 
time. Therefore I think such a cache is absolutley vital for Cairo.

As I am trying to write a toolkit that uses Cairo for drawing. I know if 
Cairo does not do this, I will be forced to write my own font cache. I can 
guarantee that the results will be worse performing than anything that is 
built into cairo.

-- 
                   ,~,~,~,~ ~ ~ ~ ~
     /\_       _|_========___         Bill Spitzak
 ~~~/\/\\~~~~~~\____________/~~~~~~~~ spitzak at d2.com




More information about the cairo mailing list