[cairo] MIME data docs per surface

Simon Sapin simon.sapin at exyr.org
Sat Jan 5 08:24:24 PST 2013


Hi,

Docs for cairo_surface_set_mime_data() say:
> See corresponding backend surface docs for details about which MIME
> types it can handle.

Indeed, the docs for the SVG backend does a great job at explaining what 
MIME types are supported and how. But it’s the only one AFAICT.

Here is what I added to cairocffi’s documentation of the PDF backend, 
based on my reading of cairo’s source code and of the PDF spec:

     The PDF surface backend recognizes the following MIME types
     for the data attached to a surface
     (see :meth:`~Surface.set_mime_data`)
     when it is used as a source pattern for drawing on this surface:
     ``image/jpeg`` and
     ``image/jp2``.
     If any of them is specified, the PDF backend emits an image
     with the content of MIME data
     (with the ``/DCTDecode`` or ``/JPXDecode`` filter, respectively)
     instead of a surface snapshot
     (with the ``/FlateDecode`` filter),
     which typically produces PDF with a smaller file size.

And for the PostScript backend:

     The PostScript surface backend recognizes the ``image/jpeg``
     MIME type for the data attached to a surface
     (see :meth:`~Surface.set_mime_data`)
     when it is used as a source pattern for drawing on this surface.
     If it is specified, the PostScript backend emits an image
     with the content of MIME data (with the ``/DCTDecode`` filter)
     instead of a surface snapshot (with the ``/FlateDecode`` filter),
     which typically produces PostScript with a smaller file size.

The syntax is for Sphinx, but can easily be converted for GTK-Doc.

Something should also be said about the Win32 backend (which apparently 
supports image/png and image/jpeg) but I don’t have it in cairocffi.

And maybe mention for the other backends that no MIME type is supported, 
so any MIME data is ignored.

-- 
Simon Sapin


More information about the cairo mailing list