matplotlib / matplotlib/matplotlib

Rely on OS-level tools for building the font cache

Ouverte
#10,932 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

keep topic: text/fonts
Langage dominant
Python
Étoiles
23.2k
Forks
8.5k
Merge moyen
1 j 6 h
PR mergées (30 j)
66

Description

The root issue of #10201 appears to be that in some OSX systems, /FontCollections is included in the font paths searched by the system, but not listed in the hardcoded paths in font_manager.py. While this could be fixed in a piecemeal fashion, I would like to propose instead to strictly rely on OS-level tools to list fonts instead.

This means:
- on Linux, `fc-list --format='%{file}\n'`
- on OSX, `system_profiler SPFontsDataType` (whose output can trivially be parsed by the stdlib plistlib module) (and fc-list too, if it is present).

On Linux, Xorg relies on fontconfig for font selection since at least X11R6.9 (2005; https://www.x.org/archive/X11R6.9.0/doc/html/fonts2.html#3 -- oldest doc on x.org). On OSX, system_profiler appears to be available since at least OSX 10.0 (2001; https://en.wikipedia.org/wiki/System_Information_(Mac)).

On Windows, we are already reading the fonts and font paths from the registry, which appears to be the "correct" place where the info is stored (https://msdn.microsoft.com/en-us/library/windows/desktop/dd144833(v=vs.85).aspx).

This means that on (rare) systems where fontconfig is not present, we'll only find the fonts shipped with Matplotlib (dejavu, etc.). To work around this, we can allow the user to run `python -mmatplotlib.font_manager recache --add-font-path foo --add-font-path bar`, with the expected effect (in fact there's already the (undocumented) `TTFPATH` and `AFMPATH` environment variables which have the same effect).

Thoughts?

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par font_manager.py et examinez la découverte actuelle des chemins de polices codée en dur. Comparez les approches Linux fc-list et macOS system_profiler décrites ici, notamment l’analyse avec plistlib et l’utilisation facultative de fc-list sur macOS. Le travail est considéré comme terminé lorsque la découverte au niveau du système d’exploitation couvre les plateformes indiquées et que la gestion du registre Windows reste intacte.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
tooling
Type d'issue
Refactorisation
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.