soft_barcode: add new center=True option

This commit is contained in:
Romain Porte 2020-05-10 14:06:00 +02:00
parent ab30ef4a8c
commit 8ca682e3ac
2 changed files with 6 additions and 2 deletions

View File

@ -479,7 +479,8 @@ class Escpos(object):
self._raw(NUL) self._raw(NUL)
def soft_barcode(self, barcode_type, data, impl='bitImageColumn', def soft_barcode(self, barcode_type, data, impl='bitImageColumn',
module_height=5, module_width=0.2, text_distance=1): module_height=5, module_width=0.2, text_distance=1,
center=True):
image_writer = ImageWriter() image_writer = ImageWriter()
@ -502,7 +503,7 @@ class Escpos(object):
# Retrieve the Pillow image and print it # Retrieve the Pillow image and print it
image = my_code.writer._image image = my_code.writer._image
self.image(image, impl=impl) self.image(image, impl=impl, center=center)
def text(self, txt): def text(self, txt):
""" Print alpha-numeric text """ Print alpha-numeric text

View File

@ -12,3 +12,6 @@ def instance():
def test_soft_barcode_ean8(instance): def test_soft_barcode_ean8(instance):
instance.soft_barcode("ean8", "1234") instance.soft_barcode("ean8", "1234")
def test_soft_barcode_ean8_nocenter(instance):
instance.soft_barcode("ean8", "1234", center=False)