mfont 0.1.0__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.
mfont-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: mfont
3
+ Version: 0.1.0
4
+ Summary: 简洁的 matplotlib 中文字体加载工具
5
+ Author: zsiven
6
+ Author-email:
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: matplotlib
9
+ Dynamic: author
10
+ Dynamic: requires-dist
11
+ Dynamic: requires-python
12
+ Dynamic: summary
mfont-0.1.0/README.md ADDED
@@ -0,0 +1,18 @@
1
+ matplotlib 字体快速导入工具
2
+
3
+ ## 特征
4
+
5
+ - 🚀 导入即用:`import mfont.load_font` 自动设置中文字体
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ pip install mfont
11
+ ```
12
+
13
+
14
+
15
+
16
+
17
+
18
+
@@ -0,0 +1,11 @@
1
+ """
2
+ 快速加载字体工具
3
+
4
+ - mfont.load_font - 加载 LXGW 字体
5
+ - mfont.load_font.load_heiti() # 加载方正黑体
6
+ - mfont.load_font.reset_font() # 重新加载 LXGW 字体
7
+ - mfont.load_font.switch(xxx) # 加载本地字体
8
+
9
+ """
10
+
11
+ __version__ = "0.1.0"
@@ -0,0 +1,44 @@
1
+ from pathlib import Path
2
+
3
+ import matplotlib
4
+ from matplotlib import font_manager
5
+
6
+
7
+ FONT_DIR = Path(__file__).parent / "fonts"
8
+
9
+ def _auto_configure(debug: bool=False):
10
+ # font_dir_path = get_font_ttf_path()
11
+ font_files = font_manager.findSystemFonts(fontpaths=str(FONT_DIR))
12
+ FONT_NAME = "LXGW WenKai GB Lite"
13
+
14
+ if debug:
15
+ # 开发模式,打印字体名
16
+ for fpath in font_files:
17
+ fp = font_manager.FontProperties(fname=fpath)
18
+ print(fp.get_name())
19
+ font_manager.fontManager.addfont(fpath)
20
+ FONT_NAME = fp.get_name()
21
+ else:
22
+ # 正式模式,只加载指定字体
23
+ for fpath in font_files:
24
+ font_manager.fontManager.addfont(fpath)
25
+
26
+
27
+ matplotlib.rc('font', family=FONT_NAME)
28
+ matplotlib.rc('axes', unicode_minus=False)
29
+
30
+ def switch(fpath: str|Path):
31
+ fp = font_manager.FontProperties(fname=fpath)
32
+ font_manager.fontManager.addfont(path=fpath)
33
+
34
+ matplotlib.rc('font', family=fp.get_name())
35
+
36
+ def reset_font():
37
+ _auto_configure()
38
+
39
+ def load_heiti():
40
+ FONT_NAME = "FZHei-B01S"
41
+ matplotlib.rc('font', family=FONT_NAME)
42
+
43
+ _auto_configure()
44
+
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: mfont
3
+ Version: 0.1.0
4
+ Summary: 简洁的 matplotlib 中文字体加载工具
5
+ Author: zsiven
6
+ Author-email:
7
+ Requires-Python: >=3.11
8
+ Requires-Dist: matplotlib
9
+ Dynamic: author
10
+ Dynamic: requires-dist
11
+ Dynamic: requires-python
12
+ Dynamic: summary
@@ -0,0 +1,11 @@
1
+ README.md
2
+ setup.py
3
+ mfont/__init__.py
4
+ mfont/load_font.py
5
+ mfont.egg-info/PKG-INFO
6
+ mfont.egg-info/SOURCES.txt
7
+ mfont.egg-info/dependency_links.txt
8
+ mfont.egg-info/requires.txt
9
+ mfont.egg-info/top_level.txt
10
+ mfont/fonts/FangZhengHeiTiJianTi-1.ttf
11
+ mfont/fonts/LXGWWenKaiGBLite-Regular.ttf
@@ -0,0 +1 @@
1
+ matplotlib
@@ -0,0 +1 @@
1
+ mfont
mfont-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
mfont-0.1.0/setup.py ADDED
@@ -0,0 +1,18 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="mfont",
5
+ version="0.1.0",
6
+ author="zsiven",
7
+ author_email="",
8
+ description="简洁的 matplotlib 中文字体加载工具",
9
+ packages=find_packages(),
10
+ install_requires=[
11
+ "matplotlib",
12
+ ],
13
+ package_data={
14
+ "mfont": ["fonts/*.ttf"],
15
+ },
16
+ include_package_data=True,
17
+ python_requires=">=3.11",
18
+ )