Not correct generalized SPLIT_N_X_N
due to imageWithoutPrnuNpArrayTile
This commit is contained in:
@@ -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)
|
Reference in New Issue
Block a user