matplotlib / matplotlib/matplotlib
Rely on OS-level tools for building the font cache
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 23.2k
- Fork
- 8.5k
- Merge medio
- 1g 6h
- PR unite (30g)
- 66
Descrizione
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?
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da font_manager.py e analizza l’attuale rilevamento codificato dei percorsi dei font. Confronta gli approcci Linux fc-list e macOS system_profiler descritti qui, inclusa l’analisi con plistlib e l’uso opzionale di fc-list su macOS. Il lavoro è completo quando il rilevamento a livello di sistema operativo copre le piattaforme indicate e la gestione del registro di Windows rimane intatta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Refactoring
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100