After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 739916 - Re: dimensions and positions of objects not reading correctly
Re: dimensions and positions of objects not reading correctly
Status: RESOLVED DUPLICATE of bug 760112
Product: librsvg
Classification: Core
Component: general
2.36.x
Other Linux
: Normal normal
: ---
Assigned To: librsvg maintainers
librsvg maintainers
Depends on:
Blocks:
 
 
Reported: 2014-11-10 19:05 UTC by dl
Modified: 2017-08-29 22:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
svgsize.c inkscape.svg karbon1.svg (2.36 KB, application/zip)
2014-11-10 19:05 UTC, dl
Details

Description dl 2014-11-10 19:05:24 UTC
Created attachment 290375 [details]
svgsize.c inkscape.svg karbon1.svg

Hi,

I am using inkscape to create a SVG files containing multiple objects
and rsvg to then render these via cairo.

I am using rsvg_handle_get_dimensions_sub and position_sub() to read the
(x,y) and (w,h) for the objects which are then used to translate and
scale cairo before using rsvg_handle_render_cairo_sub() to render the
object.

I am running into anomalies when reading this attributes. I have
attached a stripped down source for a simple utility which 'walks' the
XML of the file and calls the two functions to dump out all the objects
in the file.

I have also attached a sample SVG file created with inkscape with a
single rectangle of 45x20px on a canvas of 100x100px

Running svgsize on this produces:

$ ./svgsize /tmp/inkscape.svg
svg : svg2 100x 100 ( 0, 0)
defs : defs4 0x 0 ( 0, 0)
namedview : base 0x 0 ( 0, 0)
grid : grid4469 0x 0 ( 0, 0)
metadata : metadata7 0x 0 ( 0, 0)
g : layer1 50x1047 ( 0,-1022)
rect : rect4471 50x1047 ( 0,-1022)

with scrambled sizes and positions for the rect.

If I load the file into karbon (the KDE editor) and save it (with no
other modifications), svgsize produces the correct numbers:

$ ./svgsize /tmp/karbon1.svg
g : layer1 45x 20 ( 5, 5)
rect : rect4471 45x 20 ( 5, 5)

Loading this back into Inkscape and saving it out again, and the
original values are shown.

I have tried this on inkscape stable 0.48 and the development 0.91

I am using rsvg 2.36.1-0ubuntu1 from precise. I get the same problem
with trusty.

Thanks,
Comment 1 dl 2014-11-11 00:57:35 UTC
Two further discoveries

  * If the 'x' and 'y' attributes are moved into an equivalent transform="translate(x,y)" the correct position and sizes are returned.

  * If the stroke-width="0" attribute is removed, better (but not correct) values are returned.
Comment 2 Massimo 2016-02-17 09:34:00 UTC
The problem is here:

https://git.gnome.org/browse/librsvg/tree/rsvg-cairo-draw.c#n515

The 'sb' RsvgBbox should be inserted into 'bbox' only
when sb.width && sb.height are != 0.0 otherwise the
origin is added to bbox, because cairo_stroke_extents
returns x1 = x2 = y1 = y2 = 0 when the stroke extent 
is empty.
Comment 3 Federico Mena Quintero 2017-08-29 22:43:53 UTC

*** This bug has been marked as a duplicate of bug 760112 ***