From 8ca682e3acf19f0b599235b22d9fb711c368e047 Mon Sep 17 00:00:00 2001 From: Romain Porte Date: Sun, 10 May 2020 14:06:00 +0200 Subject: [PATCH] soft_barcode: add new center=True option --- src/escpos/escpos.py | 5 +++-- test/test_function_softbarcode.py | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index 17e0d12..24f6475 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -479,7 +479,8 @@ class Escpos(object): self._raw(NUL) 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() @@ -502,7 +503,7 @@ class Escpos(object): # Retrieve the Pillow image and print it image = my_code.writer._image - self.image(image, impl=impl) + self.image(image, impl=impl, center=center) def text(self, txt): """ Print alpha-numeric text diff --git a/test/test_function_softbarcode.py b/test/test_function_softbarcode.py index f9288f7..fc702d7 100644 --- a/test/test_function_softbarcode.py +++ b/test/test_function_softbarcode.py @@ -12,3 +12,6 @@ def instance(): def test_soft_barcode_ean8(instance): instance.soft_barcode("ean8", "1234") + +def test_soft_barcode_ean8_nocenter(instance): + instance.soft_barcode("ean8", "1234", center=False)