mfont 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

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/__init__.py CHANGED
@@ -1,11 +1,12 @@
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
-
1
+ """
2
+ 快速加载字体工具
3
+
4
+ - mfont.load_font 加载 宋体 + roman - fonts from [https://github.com/AaaGss/Font_RomanSong]
5
+ - mfont.load_font.load_lxg - 加载 LXGW 字体
6
+ - mfont.load_font.load_heiti() # 加载方正黑体
7
+ - mfont.load_font.reset_font() # 重新加载 LXGW 字体
8
+ - mfont.load_font.switch(xxx) # 加载本地字体
9
+
10
+ """
11
+
11
12
  __version__ = "0.1.0"
Binary file
mfont/load_font.py CHANGED
@@ -1,44 +1,49 @@
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
-
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
+ FONT_NAME = "RomanSong"
14
+
15
+ if debug:
16
+ # 开发模式,打印字体名
17
+ for fpath in font_files:
18
+ fp = font_manager.FontProperties(fname=fpath)
19
+ print(fp.get_name())
20
+ font_manager.fontManager.addfont(fpath)
21
+ FONT_NAME = fp.get_name()
22
+ else:
23
+ # 正式模式,只加载指定字体
24
+ for fpath in font_files:
25
+ font_manager.fontManager.addfont(fpath)
26
+
27
+
28
+ matplotlib.rc('font', family=FONT_NAME)
29
+ matplotlib.rc('axes', unicode_minus=False)
30
+
31
+ def switch(fpath: str|Path):
32
+ fp = font_manager.FontProperties(fname=fpath)
33
+ font_manager.fontManager.addfont(path=fpath)
34
+
35
+ matplotlib.rc('font', family=fp.get_name())
36
+
37
+ def reset_font():
38
+ _auto_configure()
39
+
40
+ def load_lxg():
41
+ FONT_NAME = "LXGW WenKai GB Lite"
42
+ matplotlib.rc('font', family=FONT_NAME)
43
+
44
+ def load_heiti():
45
+ FONT_NAME = "FZHei-B01S"
46
+ matplotlib.rc('font', family=FONT_NAME)
47
+
48
+ _auto_configure()
49
+
@@ -0,0 +1,21 @@
1
+ Metadata-Version: 2.4
2
+ Name: mfont
3
+ Version: 0.1.2
4
+ Summary: Add your description here
5
+ Requires-Python: >=3.12
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: matplotlib
8
+ Requires-Dist: twine>=6.2.0
9
+
10
+
11
+ `pip install mfont`
12
+
13
+ ```python
14
+ import mfont.load_font
15
+
16
+ ...
17
+ ```
18
+
19
+ # v0.1.2
20
+ 🧹 默认字体从 `lgx` 改为 宋体 + `roman`
21
+ 字体来源 [AaaGss/Font_RomanSong](https://github.com/AaaGss/Font_RomanSong) 组合字体
@@ -0,0 +1,9 @@
1
+ mfont/__init__.py,sha256=D-A-dd9G3D9_JUV0p39PbK4KmtosqBtWxxnzJ0L6h1c,376
2
+ mfont/load_font.py,sha256=SIYDbLMxnIP-R2VH0BBcnB1g3IxsVTNqATWfwqPKE6k,1348
3
+ mfont/fonts/FangZhengHeiTiJianTi-1.ttf,sha256=gWf1rYgUA8D2eELsQqzvmEmnYn5YCJeClc-yriMv3tk,2990476
4
+ mfont/fonts/LXGWWenKaiGBLite-Regular.ttf,sha256=r3MYtPcreG5_mJycf1v-rkiNKLJKC8qML2_xD_qzwS0,14125640
5
+ mfont/fonts/RomanSong.ttf,sha256=sVrhHIcDeLdfvAOKYJp8PKLgntQOgLwqBrvh7E_swnw,11522156
6
+ mfont-0.1.2.dist-info/METADATA,sha256=ZBTt-3aE0j-IdOv43MTLhCWaueyG23oTJuuJ30OvjVw,441
7
+ mfont-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
8
+ mfont-0.1.2.dist-info/top_level.txt,sha256=xtGLQA1Ayf4ZjD8uBGxmQxxOq1_8SoHVP94NCM6vISY,6
9
+ mfont-0.1.2.dist-info/RECORD,,
@@ -1,12 +0,0 @@
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
@@ -1,8 +0,0 @@
1
- mfont/__init__.py,sha256=XZdwC-TmCMYKTSM_KBOqCMXcXnp_5LYriA0SygDFUCU,260
2
- mfont/load_font.py,sha256=_LD1qTqJrLpWievEyuhHmi8jFnw4Qj8XzL1MYUHo7Wk,1166
3
- mfont/fonts/FangZhengHeiTiJianTi-1.ttf,sha256=gWf1rYgUA8D2eELsQqzvmEmnYn5YCJeClc-yriMv3tk,2990476
4
- mfont/fonts/LXGWWenKaiGBLite-Regular.ttf,sha256=r3MYtPcreG5_mJycf1v-rkiNKLJKC8qML2_xD_qzwS0,14125640
5
- mfont-0.1.0.dist-info/METADATA,sha256=G8Rcfn-RmaX8A9qjKazwbOYzlJJbjI879bKlk-uB-O8,265
6
- mfont-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- mfont-0.1.0.dist-info/top_level.txt,sha256=xtGLQA1Ayf4ZjD8uBGxmQxxOq1_8SoHVP94NCM6vISY,6
8
- mfont-0.1.0.dist-info/RECORD,,
File without changes