forked from kivvi3412/HandWrite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tools.py
42 lines (37 loc) · 1.11 KB
/
tools.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
import os
import fnmatch
class BasicTools(object):
def __init__(self):
# 字体颜色字典
self.font_color_dict = {
"black": (0, 0, 0, 255),
"white": (255, 255, 255, 255),
"red": (255, 0, 0, 255),
"blue": (0, 0, 255, 255)
}
# 背景颜色字典
self.background_color_dict = {
"transparent": (0, 0, 0, 0),
"white": (255, 255, 255, 255)
}
# 默认方法倍率(rate)
self.default_rate_dict = {
"x1": 1,
"x2": 2,
"x4": 4,
"x8": 8,
"x16": 16,
"x32": 32,
"x64": 64
}
@staticmethod
def get_ttf_file_path() -> (list, list):
ttf_library_path = "ttf_library"
ttf_files = []
ttf_files_path = []
for file in os.listdir(ttf_library_path):
if fnmatch.fnmatch(file, '*.ttf'):
ttf_files.append(file[:-4])
ttf_files_path.append(os.path.join(ttf_library_path, file))
return ttf_files, ttf_files_path