Jump to content

Pasting SVG into document gives a different result than placing


Recommended Posts

I have some simple SVG code (Note: ignore the viewBox attribute, it’s wrong):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" version="1.1" viewBox="-0.5mm -0.5mm 11.0mm 11.0mm">
 <rect x="0mm" y="0mm" width="10mm" height="10mm" stroke="black" stroke-width="1mm" fill="none" />
</svg>

When I paste it into Designer, for example, from the clipboard, the rectangle has a width and height of 2.4mm and a stroke width of 0.24mm, which are the original values divided by 4.166666...
However, when I place the same SVG document into my Affinity document it is shown correctly, width and height of 10mm and a stroke width of 1mm.

See the attached image where the small black rectangle is the one that was pasted and the larger black rectangle is the placed embedded SVG document.

Is there something I am doing wrong or is this expected behaviour?

Screenshot 2021-01-06 142613.png

Link to post
Share on other sites

First there appears to be no style information associated with that shown SVG file code, you may want to add that!

Further ...

45 minutes ago, GarryP said:

When I paste it into Designer, for example, from the clipboard

... copied from where before pasting via the clipboard into Designer? - Behaves Ok for me via copy/paste ...

 

☛ Affinity Designer 1.9.3 ◆ Affinity Photo 1.9.3 ◆ OSX El Capitan

Link to post
Share on other sites

In my opinion, you are doing nothing wrong and there is a bug.

4.1667 is 300/72 and there is an explanation for that ratio.

Affinity apps use pixel as the internal unit of measurement, regardless of units you see in the UI. Non-pixel quantities seen in the UI are derived according to the document pixel density (misnamed as DPI instead of PPI).

Your pasted SVG is specified with mm, so the resulting pixels size of the pasted Rectangle should be based on the receiving document's PPI, but the app is wrongly assuming 72 PPI regardless of the actual PPI.

When you paste the SVG and the app assumes it has a pixel density of 72 PPI, 10 x 10 mm is translated to 28.346 x 28.346 pixels for the specification of the Affinity Rectangle regardless of the PPI of the receiving document.
If the receiving document has 72 PPI then 28.346 pixels will be presented in the app UI as 10 mm.
If the receiving document has 300 PPI then 28.346 pixels will be presented in the app UI as 2.4 mm.

 

Link to post
Share on other sites
4 minutes ago, anon2 said:

Affinity apps use pixel as the internal unit of measurement, regardless of units you see in the UI. Non-pixel quantities seen in the UI are derived according to the document pixel density (misnamed as DPI instead of PPI).

That's right, it always coverts all other units (mm, cm, inch ... etc.) internally into pixels, which is finally what it deals with. This can also be often seen when performing doc or object position or size transformations via input boxes etc. - From GarryP's screenshot it's not visable which pixel density his document was setup in this case, but I think what @anon2 suggests is exacly the reason here for that evil behavior. - In the screenrecording above I used equal setup documents with a pixel density of 72 PPI, thus the behavior looks correct there.

 

☛ Affinity Designer 1.9.3 ◆ Affinity Photo 1.9.3 ◆ OSX El Capitan

Link to post
Share on other sites

This is starting to make sense now, even if it’s not what I would expect.
I’ve done some more experiments and all I’ve managed to do is confuse myself even more.
I’ll need to look at this more closely when I get time as I’m sure I must be missing some vital understanding.

Link to post
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

Please note there is currently a delay in replying to some post. See pinned thread in the Questions forum. These are the Terms of Use you will be asked to agree to if you join the forum. | 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.