Cache and list the font paths known to ``fc-list``.
()
| 252 | |
| 253 | @cache |
| 254 | def _get_fontconfig_fonts(): |
| 255 | """Cache and list the font paths known to ``fc-list``.""" |
| 256 | try: |
| 257 | if b'--format' not in subprocess.check_output(['fc-list', '--help']): |
| 258 | _log.warning( # fontconfig 2.7 implemented --format. |
| 259 | 'Matplotlib needs fontconfig>=2.7 to query system fonts.') |
| 260 | return [] |
| 261 | out = subprocess.check_output(['fc-list', '--format=%{file}\\n']) |
| 262 | except (OSError, subprocess.CalledProcessError): |
| 263 | return [] |
| 264 | return [Path(os.fsdecode(fname)) for fname in out.split(b'\n')] |
| 265 | |
| 266 | |
| 267 | @cache |
searching dependent graphs…