fontello / svg2ttf

SVG -> TTF font convertor
MIT License
518 stars 79 forks source link

Math.floor instead of parseInt #81

Closed rhalff closed 5 years ago

rhalff commented 5 years ago

Hi, I'm trying to port this code to dart and I'm not sure about the usage of parseInt() in several places. e.g https://github.com/fontello/svg2ttf/blob/master/lib/sfnt.js#L89

parseInt in these places is not used to convert from a string to integer, but it does result in the float value to be floored.

Are these values meant to be floored at all? If so perhaps using Math.floor() is faster (and more clear).

https://jsperf.com/test-parseint-and-math-floor

puzrin commented 5 years ago

Probably, this was attempt to cast type if source was string (not int). But i don't remember why. May be, code was just copy-pasted between similar places.

You are right, it looks strange.

rhalff commented 5 years ago

Thanks for the answer, at least I know why it could be there.