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) check whether this is the solution for #26
This commit is contained in:
parent
4e1f9db5c7
commit
f7a2caee72
|
@ -98,8 +98,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_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_FONT_B = _SET_HRI_FONT('\x01') # Font type B for HRI barcode chars
|
||||||
|
|
||||||
BARCODE_HEIGHT = GS + 'h' + '\x64' # Barcode Height [1-255]
|
BARCODE_HEIGHT = GS + 'h' # Barcode Height [1-255]
|
||||||
BARCODE_WIDTH = GS + 'w' + '\x03' # Barcode Width [2-6]
|
BARCODE_WIDTH = GS + 'w' # Barcode Width [2-6]
|
||||||
|
|
||||||
#NOTE: This isn't actually an ESC/POS command. It's the common prefix to the
|
#NOTE: This isn't actually an ESC/POS command. It's the common prefix to the
|
||||||
# two "print bar code" commands:
|
# two "print bar code" commands:
|
||||||
|
|
|
@ -268,7 +268,7 @@ class Escpos(object):
|
||||||
else:
|
else:
|
||||||
raise CharCodeError()
|
raise CharCodeError()
|
||||||
|
|
||||||
def barcode(self, code, bc, width, height, pos, font):
|
def barcode(self, code, bc, height, width, pos, font):
|
||||||
""" Print Barcode
|
""" Print Barcode
|
||||||
|
|
||||||
:param code: alphanumeric data to be printed as bar code
|
:param code: alphanumeric data to be printed as bar code
|
||||||
|
@ -283,10 +283,10 @@ class Escpos(object):
|
||||||
* NW7
|
* NW7
|
||||||
|
|
||||||
If none is specified, the method raises :py:exc:`~escpos.exceptions.BarcodeTypeError`.
|
If none is specified, the method raises :py:exc:`~escpos.exceptions.BarcodeTypeError`.
|
||||||
:param width: barcode width, has to be between 1 and 255
|
|
||||||
*default*: 64
|
|
||||||
:param height: barcode height, has to be between 2 and 6
|
:param height: barcode height, has to be between 2 and 6
|
||||||
*default*: 3
|
*default*: 3
|
||||||
|
:param width: barcode width, has to be between 1 and 255
|
||||||
|
*default*: 64
|
||||||
:param pos: where to place the text relative to the barcode, *default*: below
|
:param pos: where to place the text relative to the barcode, *default*: below
|
||||||
|
|
||||||
* ABOVE
|
* ABOVE
|
||||||
|
@ -306,13 +306,13 @@ class Escpos(object):
|
||||||
# Align Bar Code()
|
# Align Bar Code()
|
||||||
self._raw(TXT_ALIGN_CT)
|
self._raw(TXT_ALIGN_CT)
|
||||||
# Height
|
# Height
|
||||||
if height >= 2 or height <= 6:
|
if 1 <= height <= 255:
|
||||||
self._raw(BARCODE_HEIGHT)
|
self._raw(BARCODE_HEIGHT + chr(height))
|
||||||
else:
|
else:
|
||||||
raise BarcodeSizeError()
|
raise BarcodeSizeError()
|
||||||
# Width
|
# Width
|
||||||
if width >= 1 or width <= 255:
|
if 2 <= width <= 6:
|
||||||
self._raw(BARCODE_WIDTH)
|
self._raw(BARCODE_WIDTH + chr(width))
|
||||||
else:
|
else:
|
||||||
raise BarcodeSizeError()
|
raise BarcodeSizeError()
|
||||||
# Font
|
# Font
|
||||||
|
|
Loading…
Reference in New Issue