Add custom fonts directly to Matplotlib#129
Conversation
This removes the need to manually install them system- or user-wide.
|
|
||
|
|
||
| ROOT_DIR = pathlib.Path(__file__).parent.parent | ||
| sys.path.append(str(ROOT_DIR / "fonts")) |
There was a problem hiding this comment.
Why do we have to put the fonts directory on the path?
There was a problem hiding this comment.
So that it may be imported, regardless of where you run the script from.
dstansby
left a comment
There was a problem hiding this comment.
Looks good in theory to me - needs a rebase, and I left a couple of comments.
There was a problem hiding this comment.
To convey that this file does something on import, could it be renamed to setup_fonts.py?
There was a problem hiding this comment.
Or, put the code in a function and then in all the files below have something like
import custom_fonts
custom_fonts.setup_fonts()It's a bit more verbose, but more obvious that code is being run to setup the fonts. I'm not too bothered either way, just a suggestion.
|
|
||
| HERE = Path(__file__).parent.resolve() | ||
| for font in HERE.glob('*/*.[ot]tf'): | ||
| fontManager.addfont(font) |
There was a problem hiding this comment.
If these are being directly added to the font manager, does that mean the following part of the README no longer applies?
The fonts can be made discoverable by matplotlib (through fontconfig) by creating the following in $HOME/.config/fontconfig/fonts.conf (see here):
This removes the need to manually install them system- or user-wide.
This depends on my other PRs, so will be in draft until they're merged.