Tobias Simetsreiter 4 жил өмнө
parent
commit
b0e91de343
1 өөрчлөгдсөн 9 нэмэгдсэн , 3 устгасан
  1. 9 3
      simpilib/cli.py

+ 9 - 3
simpilib/cli.py

@@ -1,14 +1,16 @@
+#!/usr/bin/env python3
+#
 
 def main():
     import logging
     from waveshare_epd import epd2in13_V2
     import time
     from PIL import Image,ImageDraw
+    import simpilib
 
     import os
     fontpath = os.path.realpath(os.path.join(__file__,"..","..","wavesharelib","pic", 'Font.ttc'))
 
-    import simpilib
 
     text = simpilib.getQuote()
 
@@ -23,10 +25,14 @@ def main():
     font = simpilib.loadFontSize(text, draw, image, fontpath)
 
     w, h = draw.textsize(text, font=font)
-    center = (
+
+    # epd parameters are rotated 90°
+    center = [
         int((epd.height-w)/2),
         int((epd.width-h)/2)
-    )
+    ]
+    # leave some space for low characters
+    center[1] = center[1] - 5
 
     print("Drawing:", (w, h), (epd.height, epd.width))
     draw.text(center, text, align="center", font = font, fill = 0)