Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After ‘arcto’ path command(a or A), spaces are no longer removed by default #1353

Merged
merged 1 commit into from
Feb 20, 2021

Conversation

yisibl
Copy link
Contributor

@yisibl yisibl commented Feb 20, 2021

Background

In the svg elliptical arc curve commands, the white space after large-arc-flag and sweep-flag can be removed. Svgo was implemented here(258fecf) before and enabled by default.

The idea of the implementer @GreLI at the time was:

It's a totally standard syntax from a 8-years old specification (and was introduced in a working draft a year before). If some software has a problems with it—those should be addressed to that software.

However, more and more people report that there will be problems. I think that as an svg compressor, security and compatibility are the most important. Although browsers all support omitting the white space after large-arc-flag and sweep-flag, mainstream vector software such as Sketch and Adobe Illustrator do not support it. Even if these software are supported, they are paid software, and the upgrade cost for users is huge. As a designer, I can't understand why the SVG file compressed by svgo will make an error when reopened. We can't think about the problem from the perspective of a developer who can write code. Even for a developer, the rules of path data are obscure.

image

So this PR disables the noSpaceAfterFlags option by default. Although the compressed file size increases slightly, I think it is worth it. If your SVG file is only used in the browser or pursues the ultimate file size, you can enable it through the following options:

{
    "plugins": [
        { "convertPathData": { "noSpaceAfterFlags": true } },
        { "mergePaths": { "noSpaceAfterFlags": true } }
    ]
}

Fixed: #1317 #1138 #1164 #1183 #1189

@yisibl
Copy link
Contributor Author

yisibl commented Feb 20, 2021

@TrySound PTAL

@TrySound TrySound merged commit 8d7cfa0 into svg:master Feb 20, 2021
@TrySound
Copy link
Member

Thanks a lot @yisibl!

@Jupi007
Copy link

Jupi007 commented Feb 20, 2021

Thanks @yisibl 👍

@yisibl
Copy link
Contributor Author

yisibl commented Feb 20, 2021

@TrySound Can you help me change the git email and username of the master branch commit? I used the wrong company email. Or I resubmit a PR. Thanks a lot.

@TrySound
Copy link
Member

Sorry, don't want to rewrite master history especially after release. Looks like both are here. Is it a big problem?
image

@yisibl
Copy link
Contributor Author

yisibl commented Feb 21, 2021

You are so fast! That's it for now.

@GreLI
Copy link
Member

GreLI commented Mar 30, 2021

It's a fame, that software doesn't support SVG well 😒

wmfgerrit pushed a commit to wikimedia/design-codex that referenced this pull request Jan 25, 2022
Adding further options to general SVGO config including
- new `eol: 'lf'` and
- new `finalNewline: true`
both additions of recent minor SVGO versions. With that deleting the
command line `final-newline` flag.

With comment https://gerrit.wikimedia.org/r/c/design/codex/+/755319/comment/35fbaf55_19418aac/
pointing to svg/svgo#1353 the few added bytes
seem acceptable for better usage of the libraries raw icons. Also in a
far-future we might include Codex icon package raw SVGs as the general
WikimediaUI icon library instead of currently OOUI – exposing them to a
much wider audience. With that people opening those icons in Inkscape
or similar will only become more common.

Therefore re-crushing SVGs with new SVGO config and
adding 'minify:svg' script to 'build:svg'.

Bug: T299738
Change-Id: Ib1b97c793a1c41cde26a83932dca9f64bf67a4a9
wmfgerrit pushed a commit to wikimedia/design-codex that referenced this pull request Feb 2, 2022
Changing build step sequence to optimize SVG files according to main
SVGO config before transforming them.
Re-adding micro optimizations removed in latest versions of SVGO
svg/svgo#1353 for the transformed
CommonJS/ES module/JSON formats.

Also
- adding section about SVGO optimization in icons 'README.md'.
- adding section about icons licenses and adding a few links and
  general clarification.
- updating snapshots with differently optimized icons.

Bug: T299738
Change-Id: I6aaec1ab6c3b53918d087a83446a2051135d5fe4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]Path compression lost space
4 participants