[librsvg] (#365): rsvg-convert: Specify pixel dimensiosn for SVG output
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] (#365): rsvg-convert: Specify pixel dimensiosn for SVG output
- Date: Wed, 24 Oct 2018 00:20:45 +0000 (UTC)
commit ff36118bc875fa0548783c085b03c68526c4907b
Author: Antonio Ospite <ao2 ao2 it>
Date: Tue Oct 23 10:47:49 2018 +0200
(#365): rsvg-convert: Specify pixel dimensiosn for SVG output
The RsvgDimensionData structure uses pixels as unit for drawing
dimensions (see librsvg/rsvg.h), but the default unit for SVG documents
in cairo is pt; thus, when exporting to SVG with rsvg-convert, the
output drawing results scaled up compared to the original one.
Since rsvg already converted input units to pixels, it's safe to assume
the SVG output is always in pixels, so set the SVG surface units to
pixels to keep the original dimensions.
Bump cairo dependency to 1.5.12 as cairo_svg_surface_set_document_unit()
was not available before that version.
Fixes https://gitlab.gnome.org/GNOME/librsvg/issues/365
configure.ac | 2 +-
rsvg-convert.c | 4 +++-
2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1979819d..4ead3b2b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,7 +39,7 @@ AC_SUBST([LIBRSVG_MICRO_VERSION],[rsvg_micro_version])
dnl ===========================================================================
dnl Please update COMPILING.md with version numbers if these change
-CAIRO_REQUIRED=1.15.4
+CAIRO_REQUIRED=1.15.12
CROCO_REQUIRED=0.6.1
dnl This corresponds to Freetype2 2.8
FREETYPE2_REQUIRED=20.0.14
diff --git a/rsvg-convert.c b/rsvg-convert.c
index c0873622..fa2b9341 100644
--- a/rsvg-convert.c
+++ b/rsvg-convert.c
@@ -409,9 +409,11 @@ main (int argc, char **argv)
}
#endif
#ifdef CAIRO_HAS_SVG_SURFACE
- else if (!strcmp (format, "svg"))
+ else if (!strcmp (format, "svg")) {
surface = cairo_svg_surface_create_for_stream (rsvg_cairo_write_func, output_file,
scaled_width, scaled_height);
+ cairo_svg_surface_set_document_unit(surface, CAIRO_SVG_UNIT_PX);
+ }
#endif
#ifdef CAIRO_HAS_XML_SURFACE
else if (!strcmp (format, "xml")) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]