Closed
Description
Bug report
Bug summary
FontProperties has a __str__
that appears to be intended to allow roundtripping (see use of get_fontconfig_pattern
/parse_fontconfig_pattern
), but after fp = FontProperties()
; one has FontProperties(str(fp)) != fp
.
Code for reproduction
from matplotlib.font_manager import FontProperties, findfont
from matplotlib import style; style.use("seaborn")
fp = FontProperties()
print(fp)
print(findfont(fp))
fp_str_roundtrip = FontProperties(str(fp))
print(fp_str_roundtrip)
print(findfont(fp_str_roundtrip))
(setting the style to (matplotlib's version of) seaborn has the side-effect of changing the default sans-serif font from dejavusans to arial, which leads to the difference in the result of findfont -- otherwise, the default sans-serif font is also dejavusans and both calls to findfont return it).
Actual outcome
:family=sans-serif:style=normal:variant=normal:weight=normal:stretch=normal:size=10.0
/usr/share/fonts/TTF/arial.ttf
:family=:style=normal:variant=normal:weight=normal:stretch=normal:size=10.0
findfont: Font family [''] not found. Falling back to DejaVu Sans.
/home/antony/src/extern/matplotlib/lib/matplotlib/mpl-data/fonts/ttf/DejaVuSans.ttf
Expected outcome
Proper roundtripping.
Matplotlib version
- Operating system: linux
- Matplotlib version: master
- Matplotlib backend (
print(matplotlib.get_backend())
): any - Python version: 37
- Jupyter version (if applicable):
- Other libraries: