fonts update

This commit is contained in:
13339479676 2022-01-27 13:54:24 +08:00
parent 3c0afacccb
commit b6eb555db8
3 changed files with 31 additions and 3 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ __pycache__
# 字体
/fonts
/utils/fonts
*.ttc
*.ttf
*.otf

View File

@ -7,11 +7,38 @@ import os
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}')
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")