Jump to content
You must now use your email address to sign in [click for more info] ×

Bug in SVG imports


twise

Recommended Posts

Hi,

There appears to be a bug in the SVG import process, specifically when using clones and applying scaling & translations. I noticed this following a change in how Matplotlib in Python exports SVGs - since this change, text characters end up on top of one another rather than being spaced apart when imported into AD. There are no problems importing into Inkscape, Chrome, etc.

Here is a minimal example, with a lowercase L followed by a dash (the SVG file to recreate this is attached). This is how it (correctly) appears when imported into Inkscape.

svg_correct.png.c875e9a531ae4a820b5e78b742a73188.png

And this is how it appears imported into AD.

svg_incorrect.png.cff088cec3c53d5ba9136e92dd73a657.png

The problem seems to lie in the application of x/y positioning to clones when importing into AD. When the paths themselves are scaled (in this example by 0.015625), the X offset is applied before the scaling rather than after, meaning the X offset of the characters is 0.015625 times what it should be. Everything is fine if the "x" value is replaced by an equivalent translation.

# This doesn't work
<use x="27.783203" xlink:href="#DejaVuSans-45"/>

# This works, replacing the "x" argument with a translation
<use transform="translate(27.783203 0)" xlink:href="#DejaVuSans-45"/>

 

More discussion related to this issue can be found in this thread.

 Thanks!

Link to comment
Share on other sites

  • 9 months later...

Are there any updates on this issue?

I have run into the same problem with figures created in current Matplotlib versions.  SVGs are displayed fine in all other software I tested (Mac Finder Preview, Firefox, Safari. Ubuntu Inkscape, ImageViewer), but are mangled in Affinity Designer 1.10.5 (and in Affinity Publisher too).

Edit: I didn't realize the original post was in a Windows-bug section. I should have looked for the MacOS bug section instead before posting. Anyways, this problem seems to be OS-independent.

svg_import_issue.thumb.png.97eece921e03c58ee677cd316a4bbbc3.png

 

Edited by amphioxus
Added note that this in not just Windows bug
Link to comment
Share on other sites

  • 1 year later...
Posted (edited)

Is there any update on the topic? I have the same issue with AD2 on a M2 MacBook Air, 2022 (Sonoma 14.4.1).
The same file is opened correctly in Inkscape. 
Here are more Details, the attached svg was created with Matplotlib: https://github.com/matplotlib/matplotlib/issues/20910#issuecomment-907043109

Quote

 

Thanks for looking at this - having done a bit more investigation it seems that the problem is that AD doesn't parse the text direction offsets in the <use> tag correctly. It looks like instead of applying the offset after scaling everything 1/64, it applies it before transforming, resulting in the offset being 1/64 what it should be.

As this seems to be a bug in AD, I'll report it to them and see what happens!

 


 

Bildschirmfoto 2024-05-28 um 17.03.00.png

Bildschirmfoto 2024-05-28 um 17.03.14.png

example.svg

Edited by Juliaaa
More details
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.