Adding custom fonts
Is there a way to add a font file so that we can configure schemdraw with a custom font ? If not, what are the supported fonts ? Thank you!
Comments (6)
-
repo owner -
This is great. However, is there a way to specify font using a .ttf file ? Basically point schemdraw to a .ttf file and then use it in the above mentioned manner ? Thank you
-
repo owner Here’s what I just figured out.. Matplotlib’s font_manager needs to cache the font first:
from matplotlib import font_manager fpath = '/path/to/Peralta-Regular.ttf' font_manager.fontManager.addfont(fpath)
Then, it will be found by font name just as if it was installed in the system fonts path:
with schemdraw.Drawing() as d: d.config(font='Peralta')
It would be neat if Schemdraw could do this for you when the font parameter is a ttf and not in the cache already.
-
This is great. Thank you!
-
repo owner 7945134
will make this automatic, just set font=”path/to/font.ttf”. Works with Matplotlib backend, and SVG backend when Ziamath is installed. -
repo owner - changed status to resolved
- Log in to comment
You can set the font on a single label:
or as the default for an entire drawing:
The font can be a named font installed on the system, or a family like “serif” or “sans-serif”. The font parameter is a pass-through to Matplotlib’s fontfamily, so check there for more on what fonts are available.
I’ll keep this issue here since this needs to be better defined in the documentation.