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

"Error: Param not a number: a,l" on SVG path #152

Open
Oreilles opened this issue Apr 22, 2020 · 6 comments
Open

"Error: Param not a number: a,l" on SVG path #152

Oreilles opened this issue Apr 22, 2020 · 6 comments

Comments

@Oreilles
Copy link
Contributor

The path for which the error occurs is quite long. Here's a fiddle to replicate:
https://jsfiddle.net/87fjznso/1/
Error occurs in both 3.1.0 and current 4.2.3. I haven't tested other versions.

@pshihn
Copy link
Collaborator

pshihn commented Apr 22, 2020

I don't know how you generated the path but it's kinda funky looking. The reason why it's failing is because the path has sections like this:

a931 931 0 00-1 138

as opposed to

a931 931 0 0 0 -1 138

Note that when roughjs parses it, it thinks the number is 00 which is just 0. And it thinks that there's a missing value.
Browsers can be more forgiving.

I can change rough to interpret 00 to 0 0 but there are too many cases to consider. I suggest if you change path string so your zeros have a space after them.

@Oreilles
Copy link
Contributor Author

Thanks, the path is initially from wikipedia, but minified with svgo's convertPathData plugin.

@pshihn
Copy link
Collaborator

pshihn commented Apr 22, 2020

yes it must be because of the minification.
I'm not sure I'm inclined to fix this unless you cannot update your path

@Oreilles
Copy link
Contributor Author

I definetly can change the path, it's not an issue at all - I just though you might be interested in this kind of (pretty specific) behaviour.

Maybe the path parser used by Firefox or Chrome could be found in their source code.

@wclr
Copy link

wclr commented Jul 13, 2020

This happend to me too while svg-icons conversion after upgraded from svgo 1.2.2 to the latest 1.3.2, though in browser icons work ok, but rough can not parse some paths. It also happens with convertPathData plugin disabled, but in more rare cases.

I tried to "fix" paths and compare and changes but had no good luck with it. There is not only glued zeros (00) problem. It is really a mess .

Not even sure how to describe this issue in svgo repo. Besides. as I said there seems no issues with optimized icons in browser, only rough can't deal with them.

UPD. There is an example.
Source svg: https://gist.github.com/whitecolor/26a5e750f70444e49ecd3a69c3f107d2

But this example seem to contain only glued zeros issue, other more complex icons had more complex changes that are not so easy to deal with from the first glance.

And paths that are avaiabled in browser for this icon:

v 1.2.2 (this works with rough)

M50.2.075C22.645.075.22 22.497.22 50.05c0 27.55 22.424 49.974 49.979 49.974 27.55 0 49.978-22.42 49.978-49.974C100.178 22.495 77.754.075 50.2.075zm0 4.469c25.098 0 45.51 20.407 45.51 45.506 0 25.098-20.412 45.51-45.51 45.51-25.099 0-45.51-20.412-45.51-45.51C4.69 24.95 25.1 4.544 50.2 4.544z

M50.424 27.387a1.952 1.952 0 0 0-1.947 1.949v19.139H29.334c-1.073 0-1.95.876-1.95 1.949s.877 1.947 1.95 1.947h19.143v19.143c0 1.072.874 1.949 1.947 1.949s1.949-.876 1.949-1.951v-19.14h19.145a1.95 1.95 0 0 0 1.945-1.948c0-1.073-.874-1.95-1.947-1.95H52.373V29.337c0-1.073-.876-1.95-1.95-1.95z

v 1.3.2 (this error with rough)

M50.2.075C22.645.075.22 22.497.22 50.05c0 27.55 22.424 49.974 49.979 49.974 27.55 0 49.978-22.42 49.978-49.974C100.178 22.495 77.754.075 50.2.075zm0 4.469c25.098 0 45.51 20.407 45.51 45.506 0 25.098-20.412 45.51-45.51 45.51-25.099 0-45.51-20.412-45.51-45.51C4.69 24.95 25.1 4.544 50.2 4.544z

M50.424 27.387a1.952 1.952 0 00-1.947 1.949v19.139H29.334c-1.073 0-1.95.876-1.95 1.949s.877 1.947 1.95 1.947h19.143v19.143c0 1.072.874 1.949 1.947 1.949s1.949-.876 1.949-1.951v-19.14h19.145a1.95 1.95 0 001.945-1.948c0-1.073-.874-1.95-1.947-1.95H52.373V29.337c0-1.073-.876-1.95-1.95-1.95z

@wclr
Copy link

wclr commented Jul 13, 2020

There is another more complex example of converted with svgo paths

1.2.2 (this works with rough)

M63.316 8.401l1.091-1.634 1.072-1.612 2.412-3.617A.968.968 0 1066.28.467l-2.584 3.878-1.087 1.63-1.104 1.652c-3.495-1.354-7.392-2.115-11.508-2.115-4.112 0-8.009.76-11.504 2.115l-1.098-1.652-1.087-1.63-2.588-3.88a.97.97 0 00-1.343-.27.968.968 0 00-.267 1.341l2.41 3.617 1.076 1.612L36.688 8.4c-8.21 3.823-13.763 11.066-13.763 19.356H77.08c0-8.288-5.553-15.53-13.763-19.354zM38.398 20.02a2.9 2.9 0 110-5.8 2.9 2.9 0 010 5.8zm23.206 0a2.9 2.9 0 010-5.8 2.9 2.9 0 110 5.8zM23.342 31.625h-.417v42.551a6.13 6.13 0 006.124 6.126h4.42a5.794 5.794 0 00-.23 1.61v12.253a5.803 5.803 0 0011.606 0V81.912c0-.556-.086-1.1-.23-1.61h10.774a5.794 5.794 0 00-.23 1.61v12.253c0 3.202 2.6 5.802 5.803 5.802 3.202 0 5.802-2.6 5.802-5.802V81.912c0-.556-.082-1.1-.23-1.61h4.42a6.132 6.132 0 006.125-6.125V31.625h-.417zM13.253 31.625A5.801 5.801 0 007.45 37.43v24.819a5.803 5.803 0 005.802 5.802c3.202 0 5.802-2.6 5.802-5.802v-24.82a5.8 5.8 0 00-5.802-5.803zM86.751 31.625a5.8 5.8 0 00-5.802 5.804v24.819a5.802 5.802 0 005.802 5.802c3.203 0 5.798-2.6 5.798-5.802v-24.82a5.799 5.799 0 00-5.798-5.803z

v 1.3.2 (this error with rough)

M63.316 8.401l1.091-1.634 1.072-1.612 2.412-3.617A.968.968 0 0 0 66.28.467l-2.584 3.878-1.087 1.63-1.104 1.652c-3.495-1.354-7.392-2.115-11.508-2.115-4.112 0-8.009.76-11.504 2.115l-1.098-1.652-1.087-1.63-2.588-3.88a.97.97 0 0 0-1.343-.27.968.968 0 0 0-.267 1.341l2.41 3.617 1.076 1.612L36.688 8.4c-8.21 3.823-13.763 11.066-13.763 19.356H77.08c0-8.288-5.553-15.53-13.763-19.354zM38.398 20.02a2.9 2.9 0 1 1 0-5.8 2.9 2.9 0 1 1 0 5.8zm23.206 0a2.9 2.9 0 0 1 0-5.8 2.9 2.9 0 0 1 0 5.8zM23.342 31.625h-.417v42.551a6.13 6.13 0 0 0 6.124 6.126h4.42a5.794 5.794 0 0 0-.23 1.61v12.253a5.803 5.803 0 0 0 11.606 0V81.912c0-.556-.086-1.1-.23-1.61h10.774a5.794 5.794 0 0 0-.23 1.61v12.253c0 3.202 2.6 5.802 5.803 5.802 3.202 0 5.802-2.6 5.802-5.802V81.912c0-.556-.082-1.1-.23-1.61h4.42a6.132 6.132 0 0 0 6.125-6.125V31.625h-.417zM13.253 31.625A5.801 5.801 0 0 0 7.45 37.43v24.819a5.803 5.803 0 0 0 5.802 5.802c3.202 0 5.802-2.6 5.802-5.802v-24.82a5.8 5.8 0 0 0-5.802-5.803zM86.751 31.625a5.8 5.8 0 0 0-5.802 5.804v24.819a5.802 5.802 0 0 0 5.802 5.802c3.203 0 5.798-2.6 5.798-5.802v-24.82a5.799 5.799 0 0 0-5.798-5.803z

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

No branches or pull requests

3 participants