fonts opt update

This commit is contained in:
13339479676 2022-01-27 16:25:22 +08:00
parent b6eb555db8
commit 3929e81b2a
4 changed files with 46 additions and 37 deletions

View File

@ -1,4 +1,4 @@
# 引用https://github.com/Haixing-Hu/latex-chinese-fonts
# 字体文件引用https://github.com/Haixing-Hu/latex-chinese-fonts
if [ ! -d "./fonts" ]; then
mkdir ./fonts

44
utils/fonts_opt.py Normal file
View File

@ -0,0 +1,44 @@
# 字体管理
# 创建人:曾逸夫
# 创建时间2022-01-27
import os
import sys
fonts_list = ['SimSun.ttc', 'TimesNewRoman.ttf'] # 字体列表
fonts_suffix = ['ttc', 'ttf', 'otf'] # 字体后缀
# 创建字体库
def add_fronts(fonts_file="./fonts.sh"):
os.system(f'bash {fonts_file}')
print(f'字体文件加载完成!')
# 判断字体文件
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")

View File

@ -6,39 +6,3 @@
import os
import sys
fonts_list = ['SimSun.ttc', 'TimesNewRoman.ttf'] # 字体列表
fonts_suffix = ['ttc', 'ttf', 'otf'] # 字体后缀
# 创建字体库
def add_fronts(fonts_file="./fonts.sh"):
os.system(f'bash {fonts_file}')
print(f'字体文件加载完成!')
# 判断字体文件
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")

1
v05.md
View File

@ -10,6 +10,7 @@
- 加入opencv-webcam-script PyPi版 详细教程文件
- 加入opencv-webcam-script PyPi版 详细教程文件
- 加入bash安装脚本
- 加入字体管理模块