From b5f68f6895236207355efe6bc92c5b1197948dc2 Mon Sep 17 00:00:00 2001 From: Stephan Sokolow Date: Thu, 22 May 2014 00:45:57 -0400 Subject: [PATCH] Actually use the barcode height and width parameters (And reverse their order in the method signature so corrections to the range checks don't break existing code) --- escpos/constants.py | 4 ++-- escpos/escpos.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/escpos/constants.py b/escpos/constants.py index 11dd3a4..487befa 100644 --- a/escpos/constants.py +++ b/escpos/constants.py @@ -65,8 +65,8 @@ _SET_HRI_FONT = lambda n: GS + 'f' + n BARCODE_FONT_A = _SET_HRI_FONT('\x00') # Font type A for HRI barcode chars BARCODE_FONT_B = _SET_HRI_FONT('\x01') # Font type B for HRI barcode chars -BARCODE_HEIGHT = GS + 'h' + '\x64' # Barcode Height [1-255] -BARCODE_WIDTH = GS + 'w' + '\x03' # Barcode Width [2-6] +BARCODE_HEIGHT = GS + 'h' # Barcode Height [1-255] +BARCODE_WIDTH = GS + 'w' # Barcode Width [2-6] #NOTE: This isn't actually an ESC/POS command. It's the common prefix to the # two "print bar code" commands: diff --git a/escpos/escpos.py b/escpos/escpos.py index c79bea4..df74fea 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -151,18 +151,18 @@ class Escpos: im = qr_img._img.convert("RGB") self.image(im) - def barcode(self, code, bc, width, height, pos, font): + def barcode(self, code, bc, height, width, pos, font): """ Print Barcode """ # Align Bar Code() self._raw(TXT_ALIGN_CT) # Height - if height >=2 or height <=6: - self._raw(BARCODE_HEIGHT) + if 1 <= height <= 255: + self._raw(BARCODE_HEIGHT + chr(height)) else: raise BarcodeSizeError() # Width - if width >= 1 or width <=255: - self._raw(BARCODE_WIDTH) + if 2 <= width <= 6: + self._raw(BARCODE_WIDTH + chr(width)) else: raise BarcodeSizeError() # Font