EasyPlotLib 0.0.7__tar.gz → 0.0.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,33 @@
1
1
  import os
2
+
3
+ import matplotlib as mpl
2
4
  import matplotlib.font_manager as fm
3
5
  import matplotlib.pyplot as plt
4
6
 
7
+ import EasyPlotLib
8
+
5
9
  from .cartopy_helper import cartopy_plot_tickmarks
6
10
  from .figsizes_set import figsizes, subplot_labels
7
- import EasyPlotLib
8
11
 
9
12
  # register the bundled stylesheets in the matplotlib style library
10
13
  EasyPlotLib_path = EasyPlotLib.__path__[0]
11
14
  font_dir = os.path.join(EasyPlotLib_path, "fonts")
12
15
  styles_path = os.path.join(EasyPlotLib_path, "styles")
13
16
 
14
- # add fonts
15
17
  font_files = fm.findSystemFonts(fontpaths=[font_dir])
16
- for font_file in font_files:
17
- fm.fontManager.addfont(font_file)
18
+ font_files_set = set(font_files)
19
+
20
+ # 检查是否需要更新缓存
21
+ existing_fonts = {font.fname for font in fm.fontManager.ttflist}
22
+ if not existing_fonts >= font_files_set:
23
+ for font_file in font_files:
24
+ fm.fontManager.addfont(font_file)
25
+
26
+ # 仅当添加了新字体时更新缓存
27
+ cache = os.path.join(
28
+ mpl.get_cachedir(), f"fontlist-v{fm.FontManager.__version__}.json"
29
+ )
30
+ fm.json_dump(fm.fontManager, cache)
18
31
 
19
32
  # Reads styles in /styles folder and all subfolders
20
33
  stylesheets = {} # plt.style.library is a dictionary
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: EasyPlotLib
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: A simple plotting library
5
5
  Home-page: https://github.com/yourusername/EasyPlotLib
6
6
  Author: HanYuyang
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: EasyPlotLib
3
- Version: 0.0.7
3
+ Version: 0.0.9
4
4
  Summary: A simple plotting library
5
5
  Home-page: https://github.com/yourusername/EasyPlotLib
6
6
  Author: HanYuyang
File without changes
File without changes
File without changes