update requirements.

This commit is contained in:
Zhang Muyu
2023-09-18 00:27:01 +08:00
parent 186beac8b6
commit fc439203ae
3 changed files with 3 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
svgwrite
cairosvg
lxml
pillow
pillow==9.5.0

View File

@@ -50,7 +50,7 @@ content_width = min_width
content_height = min_height + exit_height + 2 * safe_area_size
parser = argparse.ArgumentParser()
parser.add_argument('-d', '--data', dest='Data', type=str, default='./example/demo.json', help='Path of json data file.')
parser.add_argument('-d', '--data', dest='Data', type=str, default='./example/example.json', help='Path of json data file.')
args = parser.parse_args()
data_file_path = args.Data
@@ -186,7 +186,7 @@ with open(svg_file_path, 'wb') as f:
# save as png
cairosvg.svg2png(url=svg_file_path, write_to=png_file_path)
os.remove(svg_file_path)
# os.remove(svg_file_path)
# additional element
# open the image

View File

@@ -3,13 +3,3 @@ from PIL import ImageFont
class FontSize:
def get_font_width(text, font, size):
return sum([ImageFont.truetype(font, int(size), 0).getsize(char)[0] for char in text])
def font_size_width_dict(font, size):
dict = {}
for char in range(ord('0'), ord('9') + 1):
dict[chr(char)] = ImageFont.truetype(font, size, 0).getsize(chr(char))[0] / size
for char in range(ord('A'), ord('Z') + 1):
dict[chr(char)] = ImageFont.truetype(font, size, 0).getsize(chr(char))[0] / size
for char in range(ord('a'), ord('z') + 1):
dict[chr(char)] = ImageFont.truetype(font, size, 0).getsize(chr(char))[0] / size
return dict