Bug 5314

Summary: svg-print backend
Product: cairo Reporter: Dom Lachowicz <domlachowicz>
Component: svg backendAssignee: Emmanuel Pacaud <emmanuel.pacaud>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: enhancement    
Priority: high Keywords: patch
Version: 1.1.1   
Hardware: x86 (IA32)   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: patch to implement a svg-print backend
Updated patch
Only emits <pageSet> if there is more than one page
New patch - should fix compositing
An new patch

Description Dom Lachowicz 2005-12-11 07:41:43 UTC
The SVG backend is starting to look good. It would be neat if it also supported
the SVGPrint standard (http://www.w3.org/TR/SVGPrint/). It maps cleanly onto
cairo's show_page API and for single-page outputs, tools like librsvg can still
load the documents.

Patch on the way.
Comment 1 Dom Lachowicz 2005-12-11 07:42:56 UTC
Created attachment 4068 [details] [review]
patch to implement a svg-print backend
Comment 2 Dom Lachowicz 2005-12-11 07:44:59 UTC
FYI - this patch also corrects a small buglet - s/cairo_format_t/cairo_content_t
Comment 3 Dom Lachowicz 2006-01-08 06:53:19 UTC
Created attachment 4289 [details] [review]
Updated patch
Comment 4 Dom Lachowicz 2006-01-08 06:53:53 UTC
Reassign to Emmanuel
Comment 5 Emmanuel Pacaud 2006-01-20 07:56:49 UTC
Hi Dom,

I would be happy to add multi-page capability to SVG backend, but unfortunately,
it seems inkscape currently doesn't support SVG-Print, and I really want to be
able to open SVG files produced by cairo with it.

An idea would be to stick to current output, and switch to SVG-Print as soon as
document has more than one page.

Comment 6 Dom Lachowicz 2006-01-20 08:00:56 UTC
Hi Emmanuel,

That sounds reasonable. I'll modify my patch to do this.
Comment 7 Dom Lachowicz 2006-01-29 08:45:23 UTC
Created attachment 4501 [details] [review]
Only emits <pageSet> if there is more than one page

This should hopefully be more to your liking.
Comment 8 Emmanuel Pacaud 2006-01-30 04:09:19 UTC
Hi Dom,

Your patch breaks compositing of svg surfaces.

+    surface->xml_node = xmlNewChild (surface->document->xml_node_main,
+				     NULL, CC2XML ("g"), NULL);

When you had before:

-    surface->xml_node = xmlNewChild (surface->id == 0 ? 
-				     document->xml_node_main : 
-				     document->xml_node_defs, 
-				     NULL, CC2XML ("g"), NULL);

And in one page svg, there's a useless <g> </g> around main surface.

Otherwise, it's ok to commit.
Comment 9 Dom Lachowicz 2006-01-30 05:15:57 UTC
Created attachment 4504 [details] [review]
New patch - should fix compositing

The extra "g" around the content is a harmless artifact. I needed a node to put
the whole page's content into before adding it to the <page> or <svg>, as
appropriate.

This patch should fix compositing of SVG surfaces. The new ID scheme for
surfaces is "surface" + surface->id + "-" + number_of_pages. This way, we keep
the surface0 == primary surface distinction, plus generate unique ids for each
individual page.
Comment 10 Emmanuel Pacaud 2006-01-30 06:02:55 UTC
If you change naming convention here:

+    snprintf (buffer, sizeof buffer, "surface%d-%d", surface->id, 
+	      _cairo_array_num_elements (&surface->document->pages));

You also need to adapt this code:

    child = xmlNewChild (node, NULL, CC2XML("use"), NULL);
    snprintf (buffer, sizeof buffer, "#surface%d", surface->id);
    xmlSetProp (child, CC2XML ("xlink:href"), C2XML (buffer));

in emit_composite_svg_pattern()

Not that creating a similar svg surface with cairo_surface_create_similar during
drawing of one page, and painting it on an another page may happen, so you need
to store the second id.
Comment 11 Emmanuel Pacaud 2006-11-12 12:03:38 UTC
Created attachment 7761 [details] [review]
An new patch
Comment 12 Emmanuel Pacaud 2006-11-18 04:22:11 UTC
Pushed to master.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.