Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

allow font cleaning and remapping for SVG output #79

Open
wants to merge 2 commits into
base: gh-pages
Choose a base branch
from

Conversation

nsonnad
Copy link
Contributor

@nsonnad nsonnad commented Mar 18, 2016

Hello. We are using saveSvgAsPng to make charts and export them as SVG, so that they can be hand-edited in Illustrator. There is a terrible issue with some versions of Illustrator where it gives a cryptic error if you have a font declaration with either 1) more than one font or 2) a font that is not on your system or named incorrectly.

This change adds two options to the library:

  1. cleanFontDefs, a boolean that if true will extract only the first font-family definition
  2. fontFamilyRemap, an optional hash that remaps the font-family name of the extracted first definition.

I have added an example to index.html that downloads an SVG declared as Georgia, but when you open in illustrator, it is set to Arial. The use case for this is when CSS fonts are declared using CSS conventions like Khula-Light while local fonts may show up as Khula Light, or when you can't assume people will have a custom font installed locally so you may want to remap it to Arial or something.

Let me know what you think, if you're good with this I can add docs on these options. Thanks

@exupero
Copy link
Owner

exupero commented Mar 24, 2016

This is a very specific need. To accomplish the fix you need, I would rather provide a general hook that allows modifying the CSS that gets added for each rule, somewhat like selectorRemap but for the entire rule. Then you could apply this rule transformation within your own application and this library could support other specific needs along the same lines.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants