[cairo-commit] 2 commits - src/cairo-svg-surface.c test/svg2png.c
Emmanuel Pacaud
emmanuel at kemper.freedesktop.org
Tue May 2 14:38:50 PDT 2006
src/cairo-svg-surface.c | 25 +++++++++++++++++++++++--
test/svg2png.c | 3 +--
2 files changed, 24 insertions(+), 4 deletions(-)
New commits:
diff-tree e7459428dc87f7372dd7d5bd903341d619ee726f (from 1264ae9af4f4aa3bc9f6495e84a7888cd16809da)
Author: Emmanuel Pacaud <emmanuel.pacaud at free.fr>
Date: Tue May 2 23:37:23 2006 +0200
SVG: Convert SVG file with a resolution of 72 dpi.
That means 1 point = 1 pixel
diff --git a/test/svg2png.c b/test/svg2png.c
index b3b094a..bdfbc8b 100644
--- a/test/svg2png.c
+++ b/test/svg2png.c
@@ -34,8 +34,6 @@
#define FAIL(msg) \
do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0)
-#define PIXELS_PER_POINT 1
-
int main (int argc, char *argv[])
{
GError *error = NULL;
@@ -50,6 +48,7 @@ int main (int argc, char *argv[])
error = NULL;
+ rsvg_set_default_dpi (72.0);
pixbuf = rsvg_pixbuf_from_file (filename, &error);
if (error != NULL)
FAIL (error->message);
diff-tree 1264ae9af4f4aa3bc9f6495e84a7888cd16809da (from 773692b7df9f0ccf250f259c1bc430c343765651)
Author: Emmanuel Pacaud <emmanuel.pacaud at free.fr>
Date: Tue May 2 23:35:06 2006 +0200
SVG: Really use width and height in point unit.
I guess it makes more sense to use a unit for
specifying image size that doesn't depend on context.
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index b713fc9..e06afb7 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1625,6 +1625,7 @@ _cairo_svg_document_create (cairo_output
cairo_svg_document_t *document;
xmlDocPtr doc;
xmlNodePtr node;
+ xmlBufferPtr xml_buffer;
char buffer[CAIRO_SVG_DTOSTR_BUFFER_LEN];
document = malloc (sizeof (cairo_svg_document_t));
@@ -1657,10 +1658,30 @@ _cairo_svg_document_create (cairo_output
document->xml_node_main = node;
document->xml_node_defs = xmlNewChild (node, NULL, CC2XML ("defs"), NULL);
+ xml_buffer = xmlBufferCreate ();
+
_cairo_dtostr (buffer, sizeof buffer, width);
- xmlSetProp (node, CC2XML ("width"), CC2XML (buffer));
+ xmlBufferCat (xml_buffer, C2XML (buffer));
+ xmlBufferCat (xml_buffer, CC2XML ("pt"));
+ xmlSetProp (node, CC2XML ("width"), C2XML (xmlBufferContent (xml_buffer)));
+ xmlBufferEmpty (xml_buffer);
+
_cairo_dtostr (buffer, sizeof buffer, height);
- xmlSetProp (node, CC2XML ("height"), CC2XML (buffer));
+ xmlBufferCat (xml_buffer, C2XML (buffer));
+ xmlBufferCat (xml_buffer, CC2XML ("pt"));
+ xmlSetProp (node, CC2XML ("height"), C2XML (xmlBufferContent (xml_buffer)));
+ xmlBufferEmpty (xml_buffer);
+
+ xmlBufferCat (xml_buffer, CC2XML ("0 0 "));
+ _cairo_dtostr (buffer, sizeof buffer, width);
+ xmlBufferCat (xml_buffer, C2XML (buffer));
+ xmlBufferCat (xml_buffer, CC2XML (" "));
+ _cairo_dtostr (buffer, sizeof buffer, height);
+ xmlBufferCat (xml_buffer, C2XML (buffer));
+ xmlSetProp (node, CC2XML ("viewBox"), C2XML (xmlBufferContent (xml_buffer)));
+
+ xmlBufferFree (xml_buffer);
+
xmlSetProp (node, CC2XML ("xmlns"), CC2XML ("http://www.w3.org/2000/svg"));
xmlSetProp (node, CC2XML ("xmlns:xlink"), CC2XML ("http://www.w3.org/1999/xlink"));
xmlSetProp (node, CC2XML ("version"), CC2XML ("1.2"));
More information about the cairo-commit
mailing list