[cairo] CAIRO_DEBUG, take 2

Adrian Johnson ajohnson at redneon.com
Thu May 8 06:15:20 PDT 2008

Chris Wilson wrote:
> So far, through CAIRO_DEBUG, you can generate uncompressed pdf output,
> force the use of fallback images and fonts in the pdf/ps/svg backends
> and trigger a backtrace on a cairo_error(). (The backtrace now tries to
> use the better backtrace_symbols() from utils/backtrace-symbols.c.)
> Thanks.

The ability to control PDF compression and enable/disable font 
subsetters from an environment variable is something I've been wanting 
to do for a long time. It is great to see the infrastructure coming 
together so that it will be easy to these add options.

Quoting from README.debug:
 > To enable the debugging output, one simply sets the CAIRO_DEBUG
 > environment
 > variable to the list of facilities desired.
 > $ CAIRO_DEBUG=option1[,option2[,...]]; export CAIRO_DEBUG
 > e.g.
 > $ CAIRO_DEBUG=backtrace,abort; export CAIRO_DEBUG
 > Alternatively, you can use any of " ,;:|" as the separator between
 > options.

I think that allowing all these separators may create problems if in 
future we want to have options that use various types of separators 
within an option. For example "option=value1,value2", 
"option_range=low:high" or "option_flags=foo|bar". I would prefer that 
we choose only one separator. We can print a help message describing the 
option syntax if there was an error parsing the options.

Carl mentioned on IRC is it would be useful to have "CAIRO_DEBUG=help" 
print out a list of all the options so this would make it easy to find 
out the correct use of the options.

For boolean options I prefer "option=true|false" (we could also accept 
"0|1" and "t|f") instead of "disable-option", "enable-option", and 
"force-option". It is less typing and allows an option in a script to be 
toggled without needing the remove the option then remember what it is 
called to put it back in again.

 > force-fallbacks       - Force the use of all fallbacks.
 > force-fallbacks=image - Force the use of image fallbacks
 > force-fallbacks=font  - Force the use of font fallbacks
 > force-fallbacks=image+font - Force the use of image and font fallbacks
 > uncompressed          - Prevent the pdf backend from compressing their
 > output.

I would like to see more finer-grained control over the font subsetting 
than this. For example a user may have a printer (or version of 
ghostscript [1]) that has issues with TrueType fonts. It would be useful 
to only disable the truetype subsetter for the PS backend without 
affecting PDF fonts or PS Type 1 fonts. eg


Similarly with the compression it would be useful to set it per backend. 
This would also be a good place to control the compression level as 
originally proposed in [2]. eg


to set the maximum zlib compression level on the PDF output. And

CAIRO_DEBUG=pdf.compression=0 or CAIRO_DEBUG=pdf.compression=false to 
disable compression.

We could have "backend.option=value" to set an option on a backend and 
"option=value" to set the same option on all backends. eg

"CAIRO_DEBUG=compression=0" to disable compression on all backends that 
use compression.

The option "force-fallbacks=image+font" isn't useful. If full page image 
fallbacks are in use there will be no fonts to embed.

 >    [configure.in] Check release status (major.minor.micro)
 >   Define a CAIRO_RELEASE_STATUS in terms of micro/minor version and
 > use it
 >    to set an enable debugging flag.

Not sure why this is useful. Isn't the point of the debug variable to 
allow users using a release version to control options like the font 

[1] https://bugs.freedesktop.org/show_bug.cgi?id=8180


More information about the cairo mailing list