Danny Wyatt Posted November 19, 2022 Posted November 19, 2022 I exported some text as SVG, I used both options: 1 - Converted to curves and then exported 2 - Left it as text and used the "Export text as curves..." option inside the Export window On both scenarios I ended up with files that add extra empty space after the text, like this (see the space after the G?) Is there a reason for that? Is this a bug? Is it normal and if so, how can I fix it to look like this (besides opening the file and changing the document size manually, of course, because for 1 file that's "ok", but with multiple files, that's extra useless work): Quote
Danny Wyatt Posted November 19, 2022 Author Posted November 19, 2022 I figured it out. For some reason I'm not aware of, SVG doesn't accept decimals so if my text is 24.7px wide, when I open it with AD it will adjust the document size to 25px and that's where the empty space comes from. Is there a reason behind this behavior of not accepting decimals? I understand that 1px of empty space is not significant, especially at the end of the text (unless you live in a country that reads right to left and in that case, it's an extra space that may have some impact on how things can become a bit blurry?), but I still would like to know if there's a reason for this and if there's a work around to make the document open with the size of the content? Quote
GarryP Posted November 19, 2022 Posted November 19, 2022 2 hours ago, Danny Wyatt said: SVG doesn't accept decimals The SVG format does accept decimals for most values including positions and sizes. 2 hours ago, Danny Wyatt said: text is 24.7px wide, when I open it with AD it will adjust the document size to 25px The Affinity applications, when creating a document with Units of Pixels, need to use integers for the dimensions as there’s no such thing as a fraction of a pixel, so they round the value up if needed. Quote
Danny Wyatt Posted November 19, 2022 Author Posted November 19, 2022 1 hour ago, GarryP said: The SVG format does accept decimals for most values including positions and sizes. What I mean is that, yes you can use elements with decimals, but the document itself seems to always round it up, so for example a text that's 24.7px wide inside AD, when I export it as SVG and open it again with AD, it will open a document that's 25px, not 24.7px. And this is not just for AD, because as you said, the Affinity applications round it up, but when I import the SVG to Photoshop, for example, I can see that it also adds the space at the end, meaning the SVG itself is not accepting the 24.7px as the width of the image, but 25px instead. Look at this example: Opening it with AD, look how the right hand side and the bottom adds some empty space: Same SVG file inside Photoshop (you can see that the empty space is there, right and bottom - the S and the G) Again, this is probably not a relevant issue most of the time, but it's definitely adding space that was not supposed to be there. Here's an example of a green square that was snapped to the pixel (whole value) and then opened in Photoshop and aligned to a guide. And the same thing for a red square, but this one had decimals so the SVG added that extra white space at the bottom. Now when I align it, Photoshop will align the edge, which is the empty space, not the red area: Quote
Danny Wyatt Posted November 19, 2022 Author Posted November 19, 2022 1 hour ago, GarryP said: The SVG format does accept decimals for most values including positions and sizes. When opening the red square file with VSCode, you can see that the file itself is saying that the viewBox doesn't have the decimals, so I believe that's what's causing this extra space: Quote
Danny Wyatt Posted November 19, 2022 Author Posted November 19, 2022 1 hour ago, GarryP said: The Affinity applications, when creating a document with Units of Pixels, need to use integers for the dimensions as there’s no such thing as a fraction of a pixel, so they round the value up if needed. I guess this proves it otherwise: I created a new document with decimals and it didn't round it up. So why is it round the SVG up, but not its own documents? Quote
GarryP Posted November 20, 2022 Posted November 20, 2022 You bring up some good points that I hadn’t considered. Rather than me just ‘arguing the toss’ over small details I think I’ll step aside and hope that an expert will come along and explain things better. (You might want to remove the “[SOLVED]” from the thread title.) Quote
Recommended Posts
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.