diff --git a/.gitignore b/.gitignore index cb21d42..2ffa42d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ static/images/* -current_games/* \ No newline at end of file +current_games/* + +__pycache__/ \ No newline at end of file diff --git a/font-list.txt b/font-list.txt index e1ddd85..8d3e82a 100644 --- a/font-list.txt +++ b/font-list.txt @@ -24,6 +24,6 @@ Roboto #Roboto Slab #Rockwell #Sabon -Segoe UI +#Segoe UI #Times New Roman #Verdana \ No newline at end of file diff --git a/font_game/__pycache__/images.cpython-310.pyc b/font_game/__pycache__/images.cpython-310.pyc index 1387ca0..26310d5 100644 Binary files a/font_game/__pycache__/images.cpython-310.pyc and b/font_game/__pycache__/images.cpython-310.pyc differ diff --git a/font_game/images.py b/font_game/images.py index 1372d0e..c878eb1 100644 --- a/font_game/images.py +++ b/font_game/images.py @@ -1,13 +1,16 @@ import os +import random from PIL import Image, ImageFont, ImageDraw import lorem from font_game import gen_id, IMAGE_SIZE, IMAGE_BACKGROUND, MARGINS, FONT_COLOR def gen_image(font: ImageFont.ImageFont) -> str: - img = Image.new("RGB", IMAGE_SIZE, IMAGE_BACKGROUND) + image_mult = random.uniform(0.8,1.2) + image_size = (int(IMAGE_SIZE[0]*image_mult), int(IMAGE_SIZE[1]*image_mult)) + img = Image.new("RGB", image_size, IMAGE_BACKGROUND) drawer = ImageDraw.Draw(img) - text_width = IMAGE_SIZE[0] - 2 * MARGINS + text_width = int((IMAGE_SIZE[0] - 2 * MARGINS)*image_mult) text = lorem.sentence() text_list = [] line = "" @@ -21,7 +24,7 @@ def gen_image(font: ImageFont.ImageFont) -> str: text_list.append(line) drawer.text( - (MARGINS, MARGINS), + (int(MARGINS*image_mult), int(MARGINS*image_mult)), '\n'.join(text_list), FONT_COLOR, font, diff --git a/fonts/Bembo.OTF b/fonts/Bembo.OTF new file mode 100644 index 0000000..7d1eb82 Binary files /dev/null and b/fonts/Bembo.OTF differ diff --git a/fonts/Cambria.TTF b/fonts/Cambria.TTF new file mode 100644 index 0000000..ab88fb4 Binary files /dev/null and b/fonts/Cambria.TTF differ