|
|
@@ -52,6 +52,7 @@ def eink_quote_qr(args):
|
|
|
text = groups[1]
|
|
|
author = groups[2]
|
|
|
|
|
|
+ text = re.sub(r"[^a-zA-Z0-9, ]","", text).strip()
|
|
|
if author:
|
|
|
author = re.sub(r"[^a-zA-Z0-9 ]","", author).strip()
|
|
|
from urllib.parse import urlencode
|
|
|
@@ -93,12 +94,22 @@ def eink_text_qr(text, qrdata, smalltext=None):
|
|
|
|
|
|
text, font = simpilib.fitText(text_image, fontpath, text)
|
|
|
|
|
|
- draw.text((0,0), text, align="center", font = font, fill = 255, spacing=2)
|
|
|
+ w, h = draw.textsize(text, font=font)
|
|
|
+ center = [
|
|
|
+ int((text_image[0] - w)/2),
|
|
|
+ int((text_image[1]-h)/2) - 3,
|
|
|
+ ]
|
|
|
+ draw.text(center, text, align="center", font = font, fill = 255, spacing=2)
|
|
|
|
|
|
if smalltext != None and len(smalltext) > 2:
|
|
|
smalltext, smallfont = simpilib.fitText(small_image, fontpath, smalltext)
|
|
|
|
|
|
- draw.text((base_image.width-pic.width, pic.height), smalltext, align="center", font = font, fill = 255, spacing=2)
|
|
|
+ w, h = draw.textsize(smalltext, font=font)
|
|
|
+ center = [
|
|
|
+ base_image.width-pic.width+int((small_image[0] - w)/2),
|
|
|
+ pic.height + int((small_image[1] - h)/2),
|
|
|
+ ]
|
|
|
+ draw.text(center, smalltext, align="center", font = font, fill = 255, spacing=2)
|
|
|
|
|
|
epd.displayPartial(epd.getbuffer(base_image))
|
|
|
epd.sleep()
|