photopea / Typr.js

Typr.js - process fonts in Javascript
MIT License
914 stars 73 forks source link

pathToSVG fails with data returned from glyphToPath: TypeError: c.toFixed is not a function #20

Closed mpkelly closed 6 years ago

mpkelly commented 6 years ago

Hello,

I am trying to parse a font that I created with opentype.js using the code here. However, this fails because the coordinates are strings instead of numbers.

I am using the following library functions:

var path = glyphToPath(..) var svgPath = pathToSVG(path)

but this fails because, for CFF fonts, glyphToPath returns string coordinates which are not supported by pathToSVG.

The full error is

bundle.js:119888 Uncaught (in promise) TypeError: c.toFixed is not a function
    at Function.pathToSVG (bundle.js:119888)[

A bit more info:

The font I am working with is this one: https://github.com/amitjakhu/dripicons/blob/master/webfont/fonts/dripicons-v2.ttf and when I parse it initially then Typr works fine. However, I am converting each glyph to an SVG file and then later converting these SVG files back to a glyphs which I write to an OTF file using opentype.js. It is when I try and parse this with Typr that it fails.

FYI My Mac can parse the OTF ok and so can your demo site. I have of course reviewed the code for that site but I can't see how it differs from mine other than you output to canvas whereas I just want the SVG path.

Can you please advise?

Thanks Mike

mpkelly commented 6 years ago

Ignore this issue - I can see that you have added support to pathToSVG for CFF but I am using https://www.npmjs.com/package/typr-ts which isn't up-to-date.

Closed.

photopea commented 6 years ago

ok :)