Not correct generalized SPLIT_N_X_N due to imageWithoutPrnuNpArrayTile

This commit is contained in:
Benjamin_Loison committed 2024-03-29 13:11:24 +01:00
1 parent 96bbd50a3b
commit 2d96bdc225
2 files changed
+11 -7

No files matched your search

+5 -3
View File
@@ -23,9 +23,11 @@ def getPrnuShownAsSuch(size):
image = Image.new('L', size)
draw = ImageDraw.Draw(image)
# I guess that the maximal character height is higher than the maximal character width. Hence, the `TEXT` may not be spanned on the full width.
fontSize = min(HEIGHT, WIDTH // len(TEXT))
font = ImageFont.truetype(os.path.expanduser('~/.local/share/fonts/impact.ttf'), fontSize)
fontPath = os.path.expanduser('~/.local/share/fonts/impact.ttf')
for fontSize in range(1, HEIGHT + 1):
font = ImageFont.truetype(fontPath, fontSize)
if font.getlength(TEXT) > WIDTH:
break
# Center vertically, especially in the case `HEIGHT` > `WIDTH`.
draw.text((0, HEIGHT // 2 - fontSize // 2), TEXT, 255, font = font)
return np.array(image)