File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ import matplotlib
3+ from matplotlib import font_manager
4+ import shutil
5+ import glob
6+
7+ # Get the current config directory
8+ config_dir = matplotlib .get_configdir ()
9+
10+ # Append your font directory to the config directory
11+ font_dir = os .path .join (config_dir , "fonts" , "otf" )
12+
13+ # Check if the font directory exists, if not, create it
14+ if not os .path .exists (font_dir ):
15+ os .makedirs (font_dir )
16+
17+ # Path to your font directory
18+ your_font_dir = "C:/Users/ÁlvaroHernández/Documents/GitHub/matplotlib_thePathof/fonts/DINPro"
19+
20+ # Copy all OTF font files to the font directory
21+ for font_file in glob .glob (os .path .join (your_font_dir , "*.otf" )):
22+ shutil .copy (font_file , font_dir )
23+
24+ # Delete the existing font cache
25+ font_cache_path = font_manager .get_cachedir ()
26+ font_list_cache = os .path .join (font_cache_path , 'fontlist-v310.json' )
27+ if os .path .exists (font_list_cache ):
28+ os .remove (font_list_cache )
You can’t perform that action at this time.
0 commit comments