Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Accept url in fontManager.addfont #15936

Closed
@MaxGhenis

Description

@MaxGhenis

Bug report

Bug summary

In 3.2.0rc1, fontManager.addfont only accepts local paths. It'd be great to also accept urls, as to avoid requiring downloading a font file.

Code for reproduction

!pip install -U --pre matplotlib
import matplotlib as mpl
mpl.__version__  # 3.2.0rc1
mpl.font_manager.fontManager.addfont('https://github.com/MaxGhenis/random/raw/master/Roboto-Regular.ttf')
mpl.rc('font', family='Roboto')
mpl.pyplot.plot([1, 2])

Actual outcome

findfont: Font family ['Roboto'] not found. Falling back to DejaVu Sans.
chart with dejavu sans instead of roboto

Expected outcome
No warning. Chart with Roboto labels.

This occurs when I instead download the file:

!wget https://github.com/MaxGhenis/random/raw/master/Roboto-Regular.ttf
mpl.font_manager.fontManager.addfont('Roboto-Regular.ttf')

Matplotlib version

  • Operating system: Linux (Google Colab)
  • Matplotlib version: 3.2.0rc1
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.6
  • Jupyter version (if applicable): jupyter core : 4.5.0 jupyter-notebook : 5.2.2
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions