[cairo] Font rendering options

Bill Spitzak spitzak at d2.com
Fri Jul 8 10:54:37 PDT 2005


 >>>So, what would the API look like? The simplest thing to do would
 >>>be to make cairo_render_options_t a bitfield

I would very much like to see the interface be a const char* pointer to 
a string describing the font. Examples:

"Helvetica"
"Helvetica Bold"
"Helvetica Weight=100"
"Helvetica Bold FreeTypeHack=1 MSFontTwiddle=foo antialias=0"

This has a huge advantage: it is obvious how to store a font description 
in a file. And the API is very simple, with a single parameter, and all 
language bindings handle strings easily. Also since I would say 90% to 
100% of any program is only concerned with communicating "which font" 
from one place to another, with only the font-selecting widget really 
examining it, this makes 90-100% of the code handling fonts easy to 
implement and portable between backends.

This also means the "toy" interface can request any font that the 
backend can deliver. This is vital if Cairo is going to be used for user 
interfaces (please don't delude yourselves into thinking programs wont 
use the "toy" interface). The "preferences" program can be fully aware 
of the backend and provide all the dials and switches to control it. 
After the user selects the font, it would then call the backend to get 
the "name" of the font, and this resulting string would be stored in the 
preferences file.

There is a huge difference between my proposal and a lot of older ones 
(such as XLFDs): there are *NO ERRORS*! An infinite number of different 
strings refer to the same font, and it is designed so that any string 
recognized by one backend will be recognized and produce a similar font 
on another back end. The following strings will all result in the same font:

"Helvetica Bold Italic"
"Helvetica Bold Oblique"
"Helvetica Italic Bold"
"Helvetica Bold Italic UnrecognizedOption=blah"

Getting a list of *all* possible different strings is backend-specific. 
However there should be a "toy font lister" which will return the first 
word ("Helvetica" in the above example) of all possible strings. 
Programs will probably assumme they can tack on "Bold" and "Italic" and 
get other fonts, finding out if these are really different fonts 
backend-specific.



More information about the cairo mailing list