[BZ#760112] rsvg_handle_get_(position|dimensions)_sub() returns wrong value
Submitted by Jehan
Assigned to Federico Mena Quintero
Link to original bug (#760112)
Description
For GIMP, we are moving towards SVG icons, and I am writing a script which extracts objects from a single SVG file by their id into a separate SVG file, and update the viewBox.
I use librsvg to extract the position and dimension of the objects. It works mostly well, but for some icons, I get very weird result and I am forced to recreate the icon from scratch.
Steps:
- download art-libre.svg from: https://raw.githubusercontent.com/gnome-design-team/gnome-icons/master/art-libre-symbolic/src/art-libre.svg
- load it with librsvg's rsvg_handle_new_from_file().
- We will interest ourselves for instance in the Wilber icon (id #g39819). If you open the file art-libre.svg in Inkscape, you can check that object #g39819 has size 16x16.
- get the position for this object with rsvg_handle_get_position_sub()
- get the dimension with rsvg_handle_get_dimensions_sub()
Result: I should get dimensions 16x16, as Inkscape shows me. Instead I get very weird 278x211 dimensions. The returned position is very weird as well: (-363, 226), and it cannot be used to create a proper viewBox in any way.
There is a clear discrepancy between what Inkscape shows me and what librsvg returns. librsvg returns right values for most of the objects but there are still a bunch of them where it doesn't (for instance all the "stock-channel-*" icons as well in the same file).