From 29537db4393cf6d86b7fa42ee57aed938dd3d1d3 Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Wed, 29 Jul 2020 14:40:14 +0200 Subject: [PATCH] :art: fixes text size --- funcs/games/blackjackDraw.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/funcs/games/blackjackDraw.py b/funcs/games/blackjackDraw.py index 639e97a..028cedd 100644 --- a/funcs/games/blackjackDraw.py +++ b/funcs/games/blackjackDraw.py @@ -7,6 +7,7 @@ def drawImage(channel): data = json.load(f) fnt = ImageFont.truetype('resources/futura-bold.ttf', 50) + fntSmol = ImageFont.truetype('resources/futura-bold.ttf', 40) table = Image.open("resources/games/blackjackTable.png") placement = [2,1,3,0,4] @@ -35,11 +36,19 @@ def drawImage(channel): table.paste(userHand,(32+(384*placement[x]),680),userHand) textWidth = fnt.getsize(key)[0] - textImage.text((32+(384*placement[x])+117-int(textWidth/2)-3,1010-3),key,fill=(0,0,0), font=fnt) - textImage.text((32+(384*placement[x])+117-int(textWidth/2)+3,1010-3),key,fill=(0,0,0), font=fnt) - textImage.text((32+(384*placement[x])+117-int(textWidth/2)-3,1010+3),key,fill=(0,0,0), font=fnt) - textImage.text((32+(384*placement[x])+117-int(textWidth/2)+3,1010+3),key,fill=(0,0,0), font=fnt) - textImage.text((32+(384*placement[x])+117-int(textWidth/2),1005),key,fill=(255,255,255), font=fnt) + if textWidth < 360: + textImage.text((32+(384*placement[x])+117-int(textWidth/2)-3,1010-3),key,fill=(0,0,0), font=fnt) + textImage.text((32+(384*placement[x])+117-int(textWidth/2)+3,1010-3),key,fill=(0,0,0), font=fnt) + textImage.text((32+(384*placement[x])+117-int(textWidth/2)-3,1010+3),key,fill=(0,0,0), font=fnt) + textImage.text((32+(384*placement[x])+117-int(textWidth/2)+3,1010+3),key,fill=(0,0,0), font=fnt) + textImage.text((32+(384*placement[x])+117-int(textWidth/2),1005),key,fill=(255,255,255), font=fnt) + else: + textWidth = fntSmol.getsize(key)[0] + textImage.text((32+(384*placement[x])+117-int(textWidth/2)-3,1010-3),key,fill=(0,0,0), font=fntSmol) + textImage.text((32+(384*placement[x])+117-int(textWidth/2)+3,1010-3),key,fill=(0,0,0), font=fntSmol) + textImage.text((32+(384*placement[x])+117-int(textWidth/2)-3,1010+3),key,fill=(0,0,0), font=fntSmol) + textImage.text((32+(384*placement[x])+117-int(textWidth/2)+3,1010+3),key,fill=(0,0,0), font=fntSmol) + textImage.text((32+(384*placement[x])+117-int(textWidth/2),1005),key,fill=(255,255,255), font=fntSmol) table.save("resources/games/blackjackTables/blackjackTable"+channel+".png")