Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug summary
Starting with 3.5.0, figures exported as SVG without font embedded in the file (i.e. “svg.fonttype” set to “none”) use thefont
CSS shorthand property.
The problem is that the font-family generic name is quoted and some viewers don’t like it (chrome for exemple). My understanding (readinghttps://developer.mozilla.org/en-US/docs/Web/CSS/font-family) is that only the family name should be quoted if it contains spaces.
Code for reproduction
importmatplotlibimportmatplotlib.pyplotmatplotlib.rcParams["svg.fonttype"]="none"matplotlib.rcParams["font.family"]="sans-serif"matplotlib.use("SVG")fig=matplotlib.pyplot.figure()axes=fig.add_subplot()axes.plot([1,2], [3,4],label="test")axes.legend()fig.savefig(f"test.svg")
Actual outcome
In the text elements, the generic name of the font-family is quoted (here 'sans-serif')<text x="94.6" y="57.629812" transform="rotate(-0, 94.6, 57.629812)">test</text>
Expected outcome
The generic name of the font-family should not be quoted<text x="94.6" y="57.629812" transform="rotate(-0, 94.6, 57.629812)">test</text>
Additional information
No response
Operating system
No response
Matplotlib Version
3.5.1
Matplotlib Backend
SVG
Python version
3.9.10
Jupyter version
No response
Installation
conda