1
0
mirror of https://github.com/python-escpos/python-escpos synced 2025-09-13 09:09:58 +00:00

Add error checking on width and height fields:

This commit is contained in:
Dean Rispin
2016-03-01 16:25:38 -08:00
parent 8d00e63b87
commit e48755f7d0
2 changed files with 22 additions and 2 deletions

View File

@@ -492,17 +492,21 @@ class Escpos(object):
self._raw(TXT_2WIDTH)
elif width == 1 and height == 1:
self._raw(TXT_NORMAL)
else:
elif width >= 1 and width <= 8 and height >= 1 and height <= 8 and isinstance(width, int) and isinstance(height, int):
self._raw(TXT_SIZE + chr(TXT_WIDTH[width] + TXT_HEIGHT[height]))
# Type
else:
raise SetVariableError()
# Upside down
if flip == True:
self._raw(TXT_FLIP_ON)
else:
self._raw(TXT_FLIP_OFF)
# Smoothing
if smooth == True:
self._raw(TXT_SMOOTH_ON)
else:
self._raw(TXT_SMOOTH_OFF)
# Type
if text_type.upper() == "B":
self._raw(TXT_BOLD_ON)
self._raw(TXT_UNDERL_OFF)