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

Add support to SVG paths with attribute fill-rule "evenodd" and partial support for paths with stroke attribute (only some icons tested) #138

Closed
wants to merge 10 commits into from

Conversation

ramirezcgn
Copy link
Contributor

@ramirezcgn ramirezcgn commented Sep 19, 2021

Fixes #62 and try to fix #60

Proposed changes

Added paperjs to handle fill-rule "evenodd"

Code quality

  • I made some tests for my changes
  • I added my name in the
    contributors
    field of the package.json file

License

To get your contribution merged, you must check the following.

  • I read the project license in the LICENSE file
  • I agree with publishing under this project license

Join

  • I wish to join the core team
  • I agree that with great powers comes responsibilities
  • I'm a nice person

My NPM username: ramirezcgn

@ramirezcgn ramirezcgn changed the title Add support to SVG paths with attribute fill-rule "evenodd" Add support to SVG paths with attribute fill-rule "evenodd" and Partial support for paths with stroke attribute Sep 21, 2021
@ramirezcgn ramirezcgn changed the title Add support to SVG paths with attribute fill-rule "evenodd" and Partial support for paths with stroke attribute Add support to SVG paths with attribute fill-rule "evenodd" and partial support for paths with stroke attribute (only some icons tested) Sep 21, 2021
Copy link
Owner

@nfroidure nfroidure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it should be merged. A question though is, is it the SVG fonts that do not support those SVG details or the svg2ttf converter. If so, maybe that the PR should be done there.

strokeWidth,
hasFillAttr
);
var pngBuffer = await Svg2(svgBuffer).png({ transparent: false }).toBuffer();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting the SVG to a PNG and then to an SVG again seems like a huge process to only suppot stroke regarding the fact that not everyone need it. Indeed most of iconfont designers knows the limitations of iconfonts and then avoir using unsupported SVG features or at least convert the SVGs upstream. I'm not sure it worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, in my case it has happened to me many times, the designers give you the icon and you have to find how to adapt it, in this case it seemed like a good addition to avoid wasting time. Even if it is a partial support.

@@ -831,7 +831,7 @@ describe('Providing bad glyphs', () => {
unicode: ['\uE002'],
};

let firstError = true;
/*let firstError = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the code is not useful anymore, best is to remove it then comment it. Why is it removed btw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because when I change the sax library for saxasync, the latter does not throw the error that the original one does and I don't know why or if that test is really necessary.

@@ -23,10 +23,10 @@
"cz": "env NODE_ENV=${NODE_ENV:-cli} git cz",
"lint": "eslint src/*.js bin/*.js tests/*.mocha.js",
"metapak": "metapak",
"mocha": "mocha tests/*.mocha.js",
"mocha": "mocha tests/*.mocha.js --timeout 10000",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that the need to add a timeout is an indicator of the fact that we should not support fill-rule attributes, at least, not by converting from svg to png and back to svg then.

Copy link
Contributor Author

@ramirezcgn ramirezcgn Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout extend is for the async version of the sax library, it takes more time to process when you have strokes for the conversion.

@ramirezcgn
Copy link
Contributor Author

In this case is this library the problem, but, I can keep the stroke part on my fork...

@ramirezcgn ramirezcgn closed this Oct 4, 2021
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.

It seems that fill-rule="evenodd" does not works correctly Empty glyph when icon is made of strokes
2 participants