Compare commits

..

1 Commits

Author SHA1 Message Date
6ebdcd1cde Fix text size? Not sure 2024-08-15 10:21:57 +02:00

View File

@ -11,14 +11,14 @@ import PIL.ImageFont
import qrcode import qrcode
HERE = os.path.dirname(__file__) HERE = os.path.dirname(__file__)
font = PIL.ImageFont.truetype(os.path.join(HERE, 'inconsolata.ttf'), 20) font = PIL.ImageFont.truetype(os.path.join(HERE, 'inconsolata.ttf'), 25)
DEFAULT_SOCKET = '/tmp/catprint.s' DEFAULT_SOCKET = '/tmp/catprint.s'
def text2img(text): def text2img(text):
maxwidth=384 maxwidth=384
height=21 height=26
img = PIL.Image.new('1', (maxwidth, height)) img = PIL.Image.new('1', (maxwidth, height))
d = PIL.ImageDraw.Draw(img) d = PIL.ImageDraw.Draw(img)
tw, th = d.textsize(text, font=font) tw, th = d.textsize(text, font=font)
@ -47,7 +47,7 @@ def get_template0(qr_payload, line0, line1, line2=''):
height = qrh height = qrh
textheight = 21 textheight = 21
texttop = (height - 3 * textheight) / 3 texttop = (height - 3 * textheight) / 3
textleft = qrw + 20 textleft = qrw + 10
img = PIL.Image.new('1', (width, height)) img = PIL.Image.new('1', (width, height))
img.paste(qr) img.paste(qr)
d = PIL.ImageDraw.Draw(img) d = PIL.ImageDraw.Draw(img)