deeplook / svglib

Read SVG files and convert them to other formats.
GNU Lesser General Public License v3.0
307 stars 79 forks source link

Error when svg file contains references to font with space in its name #374

Open nyq opened 1 year ago

nyq commented 1 year ago

When input SVG file refers to a font with a space in its name (e.g. "Cascadia Code"), calling svg2rlg results in Unable to find a suitable font for 'font-family:Cascadia Code', weight:normal, style:normal warning messages and the default font is used instead.

Specifically, what happens is that when the font name has a space in its name, convertFontFamily method of Svg2RlgAttributeConverter class located in svglib.py splits the input font name into multiple strings using space character as a delimiter (line 406), and then feeds these split strings into find_font method of FontMap class located in fonts.py, resulting in all calls to find_font failing (because it gets "Cascadia" and "Code" as separate inputs during two separate calls).

There are plenty of fonts with a space character in their name, even in standard Windows distribution, so using space character as a separator is not warranted and breaks the functionality.

github-actions[bot] commented 1 year ago

Thank you for raising your first issue! Your help to improve svglib is much appreciated!