fonts update
This commit is contained in:
parent
3c0afacccb
commit
b6eb555db8
|
@ -26,6 +26,7 @@ __pycache__
|
||||||
|
|
||||||
# 字体
|
# 字体
|
||||||
/fonts
|
/fonts
|
||||||
|
/utils/fonts
|
||||||
*.ttc
|
*.ttc
|
||||||
*.ttf
|
*.ttf
|
||||||
*.otf
|
*.otf
|
||||||
|
|
|
@ -7,11 +7,38 @@ import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
fonts_list = ['SimSun.ttc', 'TimesNewRoman.ttf'] # 字体列表
|
||||||
|
fonts_suffix = ['ttc', 'ttf', 'otf'] # 字体后缀
|
||||||
|
|
||||||
|
|
||||||
# 创建字体库
|
# 创建字体库
|
||||||
def add_fronts(fonts_file):
|
def add_fronts(fonts_file="./fonts.sh"):
|
||||||
os.system(f'bash {fonts_file}')
|
os.system(f'bash {fonts_file}')
|
||||||
print(f'字体文件加载完成!')
|
print(f'字体文件加载完成!')
|
||||||
|
|
||||||
|
|
||||||
# if __name__ == "__main__":
|
# 判断字体文件
|
||||||
# add_fronts("../fonts.sh")
|
def is_fonts(fonts_dir):
|
||||||
|
if (os.path.isdir(fonts_dir)):
|
||||||
|
# 如果字体库存在
|
||||||
|
fonts_flag = 0 # 判别标志
|
||||||
|
f_list = os.listdir(fonts_dir) # 本地字体库
|
||||||
|
for i in fonts_list:
|
||||||
|
if (i not in f_list):
|
||||||
|
# 字体不存在
|
||||||
|
fonts_flag = 1
|
||||||
|
if (fonts_flag == 1):
|
||||||
|
# 字体不存在
|
||||||
|
print(f'字体不存在,正在加载。。。')
|
||||||
|
add_fronts() # 创建字体库
|
||||||
|
else:
|
||||||
|
print(f'{fonts_list}字体已存在!')
|
||||||
|
else:
|
||||||
|
# 字体库不存在,创建字体库
|
||||||
|
print(f'字体库不存在,正在创建。。。')
|
||||||
|
add_fronts() # 创建字体库
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# add_fronts("./fonts.sh")
|
||||||
|
is_fonts("./fonts")
|
||||||
|
|
Loading…
Reference in New Issue