tweet-printer/test2.py

32 lines
933 B
Python
Raw Permalink Normal View History

2018-05-11 08:40:35 +00:00
#!/usr/bin/env python3
from PIL import Image, ImageDraw, ImageFont
def main():
out = Image.new("1", (576, 400), 0)
d = ImageDraw.Draw(out)
font1 = ImageFont.truetype("fonts/DejaVuSansMono.ttf", 18)
font2 = ImageFont.truetype("fonts/NotoMono-Regular.ttf", 18)
font3 = ImageFont.truetype("fonts/VeraMono.ttf", 18)
font = font3
line_height = d.textsize("-", font=font)[1]
line_spacing = 4 + line_height
lines = ["Test",
"1234567890123456789012345678901234567890123456789012",
"---------+---------+---------+---------+---------+--",
"Hallo, das hier ist ein Test mit Sonderzeichen!",
"äöüßÄÖܵ¹²³¼€¬{[]}\\",
"/\\/\\/\\/\\/\\/\\/\\~~~+++---___^^^°°°%%$$§§"]
for i,line in enumerate(lines):
d.text((0, i*line_spacing), line, font=font, fill=1)
out.show()
if __name__ == "__main__":
main()