cyrraz / plothist

Visualize and compare data in a scalable way and a beautiful style.
https://plothist.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
14 stars 1 forks source link

Case of unnecessary font installation #143

Open 0ctagon opened 6 months ago

0ctagon commented 6 months ago

In some cases, the fonts are already installed in the machine, but matplotlib is unaware of the location and doesn't check it. In this case, the user download the fonts even if he doesn't need to. We could add in the __init__ something like:

import matplotlib
from matplotlib import font_manager

# Check if the recommended fonts are installed in the texlive path and the matplotlib path
font_dirs = ["/usr/share/texlive/texmf-dist/fonts", matplotlib.__path__[0]]

for font_dir in font_dirs:
    font_files = font_manager.findSystemFonts()
    for font_file in font_files:
        font_manager.fontManager.addfont(font_file)

but then will the fontManager (ref) still tries the default path if you don't tell where to look? I had problems providing explicitly None as a default parameters, some found fonts crashes the fontManager.addfont, so I'm a bit confused by how it proceeds to get the fonts.

cyrraz commented 3 months ago

Hello @0ctagon, I think you fixed that, didn't you?

0ctagon commented 2 months ago

Not yet. https://github.com/cyrraz/plothist/pull/158 only check if the fonts are already installed in ~/.fonts, it doesn't checks in all the system if they already are installed and then link it to matplotlib.