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

Export path to SVG #76

Closed
pwichmann opened this issue Mar 26, 2017 · 7 comments
Closed

Export path to SVG #76

pwichmann opened this issue Mar 26, 2017 · 7 comments

Comments

@pwichmann
Copy link

First of all, thank you very much for the library. This looks super helpful.

I was trying to get an SVG for a string or letter, so that I can further process it in paper.js.

Now, what I receive from this method var svg = run.glyphs[0].path.toSVG(); is not what I expected. I received a complex series like this:

M219 1233L211 722Q247 712 319 712L397 712L397 755Q397 849 383 1037.5Q369 1226 369 1320Q369 1343 386.5 1358.5Q404 1374 417.5 1374Q431 1374 441 [...]

However, I would have expected a well-formatted XML/SVG string.

I am a total noob as should be obvious by now. But how would I be able to obtain an SVG string from the series above?

@pwichmann
Copy link
Author

I am indeed stupid. For all other stupid people out there:

What you get is the d-part of the SVG string:

<svg height="210" width="400">
  <path d="M150 0 L75 200 L225 200 Z" />
</svg>

@pwichmann
Copy link
Author

Interestingly, the resulting SVG object is horizontally mirrored.

This is a 'G'.

g

@Harbs
Copy link

Harbs commented Mar 26, 2017

That's because the coordinate space for fonts is different than SVG. The original path data is not modified.
See: http://stackoverflow.com/questions/14203365/why-svg-font-is-mirrored

@Pomax
Copy link
Contributor

Pomax commented Mar 26, 2017

There was some brief discussion around simplifying this task back in #24 but that issue may have fallen off the radar since.

@pwichmann
Copy link
Author

Don't worry about it, guys!

I just added a horizontal flip to the SVG tags. As simple as that. No headache.

<svg transform="scale(1,-1)"> <path d="' + svg_data_part + '" /> </svg>

@Enelar
Copy link

Enelar commented May 30, 2018

There still bug, svg path doesn't transformed to center of axis, and actually different for each glyph

@Pomax
Copy link
Contributor

Pomax commented Jun 3, 2018

@Enelar please file that as a separate issue.

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

4 participants