From 82fb9789b1f1d0d93c2d8d33d5b030d9292a6cd2 Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sat, 16 May 2015 20:07:47 +0200 Subject: [PATCH] bigger name in printed labels --- data/triggers-available/print_label.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/data/triggers-available/print_label.py b/data/triggers-available/print_label.py index d4b2856..699a408 100755 --- a/data/triggers-available/print_label.py +++ b/data/triggers-available/print_label.py @@ -14,12 +14,12 @@ import cups import tempfile from PIL import Image, ImageFont, ImageDraw -KEEP_IMG = False +KEEP_IMG = True LABEL_WIDTH = 13488 LABEL_HEIGHT = 3744 FONT_TEXT = 'Ubuntu-C.ttf' -#FONT_TEXT = 'CONCIBB_.TTF' +FONT_TEXT = 'CONCIBB_.TTF' FONT_TEXT_ENCODING = 'latin-1' FONT_BARCODE = 'free3of9.ttf' @@ -36,14 +36,15 @@ def build_label(w, h, barcode_text, line1, line2, font_text=FONT_TEXT, font_barc line1 = unicode(line1, 'utf-8').encode(FONT_TEXT_ENCODING, 'ignore') line2 = unicode(line2, 'utf-8').encode(FONT_TEXT_ENCODING, 'ignore') fontbar = ImageFont.truetype(_get_resource(font_barcode), 2000) - fontnorm = ImageFont.truetype(_get_resource(font_text), 840) + fontname = ImageFont.truetype(_get_resource(font_text), 1100) + fontjob = ImageFont.truetype(_get_resource(font_text), 780) image = Image.new('RGB', (w, h), (255, 255, 255)) draw = ImageDraw.Draw(image) wbar, hbar = draw.textsize(barcode_text, font=fontbar) - wnorm1, hnorm1 = draw.textsize(line1, font=fontnorm) - wnorm2, hnorm2 = draw.textsize(line2, font=fontnorm) - draw.text(((w-wnorm1)/2, -1200+(h-hnorm1)/2), line1, (0, 0, 0), font=fontnorm) - draw.text(((w-wnorm2)/2, -450+(h-hnorm2)/2), line2, (0, 0, 0), font=fontnorm) + wnorm1, hnorm1 = draw.textsize(line1, font=fontname) + wnorm2, hnorm2 = draw.textsize(line2, font=fontjob) + draw.text(((w-wnorm1)/2, -1300+(h-hnorm1)/2), line1, (0, 0, 0), font=fontname) + draw.text(((w-wnorm2)/2, -480+(h-hnorm2)/2), line2, (0, 0, 0), font=fontjob) draw.text(((w-wbar)/2, 850+(h-hbar)/2), barcode_text, (0, 0, 0), font=fontbar) if not KEEP_IMG: tmpfile = tempfile.NamedTemporaryFile(prefix='eventman_print_label_', suffix='.png')