phauer / svg-buddy

Command line tool to embed fonts into SVG files
MIT License
45 stars 2 forks source link

No fonts detected in SVG file due to missing trailing semicolon after font-family: #2

Closed GrahamHannington closed 3 years ago

GrahamHannington commented 4 years ago

A snippet from the input SVG file (created by CorelDRAW 2019):

 <defs>
  <style type="text/css">
   <![CDATA[

    /* ... */

    .fnt2 {font-weight:normal;font-size:141.06px;font-family:'IBM Plex Mono'}
    .fnt0 {font-weight:normal;font-size:141.06px;font-family:'IBM Plex Sans'}
    .fnt5 {font-weight:bold;font-size:141.06px;font-family:'IBM Plex Mono'}
    .fnt1 {font-weight:bold;font-size:141.06px;font-family:'IBM Plex Sans'}
    .fnt3 {font-style:italic;font-weight:normal;font-size:141.06px;font-family:'IBM Plex Mono'}
    .fnt4 {font-style:italic;font-weight:normal;font-size:141.06px;font-family:'IBM Plex Sans'}
   ]]>
  </style>
 </defs>

svg-buddy 1.2.2 reports "No fonts detected".

After looking at the relevant regex in SvgFontDetector.kt, I can see why:

val fonts1 = detectusedFontsWithRegex(inputSvgString, Pattern.compile("font-family:(.*?);"))

My input SVG is missing the expected trailing semicolon after font-family:.

Sure enough, after I edited the input SVG file and appended the missing semicolons, svg-buddy detected the fonts.

For some thoughts on those semicolons, see the Stack Overflow question "Leaving out the last semicolon of a CSS block".

phauer commented 3 years ago

Thank you for reporting this issue. I just released version 1.2.3 containing the fix. :-)

GrahamHannington commented 3 years ago

You're welcome. Thank you for svg-buddy!