Skip to content

Commit 50be4b7

Browse files
Create loadDINProFonts.py
1 parent ac2226f commit 50be4b7

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

data/loadDINProFonts.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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)

0 commit comments

Comments
 (0)