[cairo] [PATCH] Enable links to image files in SVG backend

Alexander Shulgin alex.shulgin at gmail.com
Wed Jan 20 02:18:24 PST 2010

On Wed, Jan 20, 2010 at 10:20, Carl Worth <cworth at cworth.org> wrote:
> Finally, after you've created one, (or more), commits, you can format
> these as mail messages to be submitted with:
>      git format-patch origin/master
> Which will create one file for each commit you've created since the
> origin/master commit.

Oh, thanks, this seems to work better.  I've tried something like
this, but not exactly, and it produced no output at all.

>> To overcome this I've added "text/x-uri-encoded" which will be emitted
>> to SVG stream as is.  So normal users are going to use x-uri and
>> sophisticated servers might need to use x-uri-encoded.
> I'm not sure I follow here. Why wouldn't we want cairo to always emit
> the URL as is, and just require the user of the cairo API to always
> create a valid URL?

I think, because URI encoding is in some way a part of SVG specs, user
can't and shouldn't have to deal with this.

To make things little more explicit we can rename "x-uri" to
"x-filename" (needs %-encoding for SVG) and "x-uri-encoded" to just
"x-uri" (doesn't need that).  If it comes to another backend which
will support "x-filename", it might or _might not_ need to encode
"x-filename" metadata in some way, so percent encoding in the SVG
backend is justified, IMO.

In other words: if you use "x-filename" we take care of the needed
encoding, if you use "x-uri" be sure to provide valid URI.

>> 3. It turned out that most popular software doesn't handle percent
>> encoded URIs as it should according to SVG-1.1 spec.  I've tried
>> Inkscape, librsvg, Chrome and Firefox--only the latter seems to handle
>> them correctly.  Need to file bugs for the rest.
> Thanks for being aware of this. I hope you'll follow up and file those
> bug reports. That's one thing I think the cairo community has been
> pretty good about, (filing upstream bugs when cairo development
> discovers bugs in packages related to cairo).

This is next on my TODO. :)

4. Another thing I forgot to mention, is the use of set_mime_data() in
cairo-png.c.  I believe it's not justified and can lead to confusing

Consider someone loading a PNG image with
cairo_image_surface_create_from_png(), then creating a cairo_t on that
and drawing something, like two crossed lines (X).  Now, if he tries
to create a SVG surface and uses that surface as a source for
painting, the changes made through cairo context (that cross) won't
appear in the resulting file, which is sure confusing.  To overcome
this he'll need to call cairo_surface_set_mime_data(my_png_surface,
CAIRO_MIME_TYPE_PNG, NULL, 0, NULL, NULL), which is nearly not obvious
or expected.


More information about the cairo mailing list