BTBurke / svg-embed-font

A tool to embed font files in SVG so they will render properly across all devices
MIT License
83 stars 10 forks source link

No fonts found #3

Open tauinger-de opened 5 years ago

tauinger-de commented 5 years ago

Hi,

thanks for providing this promising tool, however I can't get any benefit when running it with the following dummy SVG ("Found 0 fonts to be embedded."):

<svg width="800" height="450" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <text x="400" y="200" font-size="66" text-anchor="middle"
          font-family="Roboto-Light">
        Blahblahblah 00' 12'
    </text>
</svg>

Am I missing something? Typo?

BTBurke commented 5 years ago

It's likely because it's a contrived example. I believe most tools like Inkscape and Adobe Illustrator use a more CSS-style font-family declaration in a style tag like:

<svg viewBox="0 0 240 80" xmlns="http://www.w3.org/2000/svg">
  <style>
    .small { font: italic 13px sans-serif; font-family: Roboto-Light}
  </style>
  <text x="20" y="35" class="small">My</text>
</svg>

It's looking for that font-family: declaration. It won't find font-family=. That could be updated, but I'm not sure any software packages use that notation in the wild.

jsettlem commented 4 years ago

I can confirm that PowerPoint makes svgs with "font-family=". It also uses capital ".SVG" for the extension which this script dislikes.

skylarmt commented 3 years ago

Inkscape does this too when exporting optimized SVGs.