[cairo] Inline SVG images and the need to prefix identifiers
Bryce Harrington
bryce at osg.samsung.com
Fri Oct 23 01:09:32 PDT 2015
On Tue, Oct 20, 2015 at 04:42:02PM +0200, Christian von Schultz wrote:
> Hello!
>
> Background: SVG can be used inline in XHTML. My use case involves
> using MathML with SVG fallback using <annotation-xml>, to express
> mathematics in an XHTML document. I generate my SVG images using
> LaTeX, Poppler and Cairo.
>
> The problem when inserting several SVG documents into the same XHTML
> document is that some id's are clashing. The first SVG image has
> <symbol overflow="visible" id="glyph0-0">
> and so has the second SVG image, and the third, and so on.
> Then the <use> element with xlink:href="#glyph0-0" doesn't know which
> symbol it refers to, and things aren't rendered properly. This problem
> arises with every id and every reference. Changing the identifiers and
> references when patching it all together is possible, but I worry a
> bit about missing something. There are several ways references can be
> made...
>
> Would it make sense to have Cairo support inserting a prefix (or
> appending a suffix) to the element identifiers as they are generated?
> A "char *prefix" in the cairo_svg_document struct, for instance,
> enabling code such as
> _cairo_output_stream_printf (document->xml_node_glyphs,
> "<symbol overflow=\"visible\" id=\"%sglyph%d-%d\">\n",
> document->prefix,
> font_id,
> subset_glyph_index);
> in _cairo_svg_document_emit_glyph(), and similarly in the other
> emitters (alpha, image, pattern, clip, surface, linear, radial, mask)?
>
> It would make life easier (and less error prone) for anyone trying to
> combine SVG files on the XML level.
>
> Comments are welcome.
Sounds reasonable, I'd definitely entertain a patch to add this to cairo
if you'd like to submit one.
Bryce
More information about the cairo
mailing list