display: center text

This commit is contained in:
Romain Bazile 2020-11-30 12:05:35 +01:00
parent 9a0fef4411
commit 054244f32c

View file

@ -51,18 +51,17 @@ bottom = height - padding
x = 0 x = 0
# Load default font. # Load default font.
# font = PIL.ImageFont.truetype(font="truetype/dejavu/DejaVuSansMono.ttf", size=13) font = PIL.ImageFont.truetype(font="truetype/dejavu/DejaVuSansMono.ttf", size=15)
# Draw a black filled box to clear the image. # Draw a black filled box to clear the image.
draw.rectangle((0, 0, width, height), outline=0, fill=0) draw.rectangle((0, 0, width, height), outline=0, fill=0)
draw.text(
(0, 0), text_size = font.getsize_multiline(machineName.replace(" ", "\n"))
machineName.replace(" ", "\n"), x = width / 2 - text_size[0] / 2
font=PIL.ImageFont.truetype(font="truetype/dejavu/DejaVuSansMono.ttf", size=15),
fill=255, draw.text((x, 0), machineName.replace(" ", "\n"), font=font, fill=255, align="center")
align="center",
)
# draw.text((0, top + 15), "READY", font=font, fill=255) # draw.text((0, top + 15), "READY", font=font, fill=255)
# now = datetime.datetime.isoformat(datetime.datetime.now())[:-16] # now = datetime.datetime.isoformat(datetime.datetime.now())[:-16]
# draw.text( # draw.text(