diff --git a/mac/label.py b/mac/label.py index e58799d..c54562a 100644 --- a/mac/label.py +++ b/mac/label.py @@ -50,7 +50,7 @@ PROFILES = { # nearly two labels per feed and looked exactly like a chip that would not stop at the # antenna. gap=0 on purpose: the inlay fills most of the label and blinds the optical gap # sensor, so the printer positions by pitch. Proven with a real print-test on this roll. - 'rfid65': dict(web_mm=65, pitch_mm=35, art_mm=(64, 34), gap_mm=0, margin_mm=1.5), + 'rfid65': dict(web_mm=65, pitch_mm=35, art_mm=(64, 34), gap_mm=0, margin_mm=1.5, rotate=False), } DEFAULT_PROFILE = 'large' @@ -184,7 +184,7 @@ def render_art(fields, prof): return img -def render(fields, prof=None, rotate=True): +def render(fields, prof=None, rotate=None): """Full media-sized bitmap, design centred and oriented for the print head. rotate=True (Urovo) the 24 mm web feeds narrow-edge-first, so the landscape @@ -195,12 +195,24 @@ def render(fields, prof=None, rotate=True): prof = prof or profile() dpmm = prof.get('dpmm', DPMM) art = render_art(fields, prof) + # A profile may say it feeds landscape already. The 65 x 35 UHF roll does: 65 is the WEB, + # so the 64 x 34 design sits across it unrotated. Rotating it (the default, right for the + # 24 mm narrow stock) ran the design ALONG a 35 mm label -- printed sideways and clipped + # after ~35 mm. Seen on the bench. Only an explicit rotate=... argument overrides it. + if rotate is None: + rotate = prof.get('rotate', True) if rotate: # ROTATE_270 == 90 degrees clockwise, matching TSPL's rotation sense and the # orientation confirmed on the bench. art = art.transpose(Image.ROTATE_270) cw, ch = mm(prof['web_mm'], dpmm), mm(prof['pitch_mm'], dpmm) + elif 'rotate' in prof: + # Unrotated ON A LABEL PRINTER: the canvas is still the media, web x pitch, so the + # printer gets a full-label bitmap with the design centred -- not an art-sized one. + cw, ch = mm(prof['web_mm'], dpmm), mm(prof['pitch_mm'], dpmm) else: + # Unrotated for the Dymo path (rotate=False passed explicitly): the head is wider than + # the label, so the canvas is the design itself. Unchanged. cw, ch = mm(prof['art_mm'][0], dpmm), mm(prof['art_mm'][1], dpmm) canvas = Image.new('1', (cw + (-cw % 8), ch), 1) canvas.paste(art, (max(0, (canvas.width - art.width) // 2),