From 8bbbf7ceac820d94d633679f705890a05c830ed7 Mon Sep 17 00:00:00 2001 From: "B. Howell" Date: Tue, 9 May 2023 01:07:56 +0200 Subject: [PATCH 1/3] soft_barcode to render directly (#469) Rendering to /dev/null by a call to .write causes an error. Calling .render directly is simpler and fixes the error. Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com> --- src/escpos/escpos.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index 3460fce..a5735e0 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -602,19 +602,16 @@ class Escpos(object): ) ) - # Render the barcode to a fake file + # Render the barcode barcode_class = barcode.get_barcode_class(barcode_type) my_code = barcode_class(data, writer=image_writer) - - with open(os.devnull, "wb") as nullfile: - my_code.write( - nullfile, - { - "module_height": module_height, - "module_width": module_width, - "text_distance": text_distance, - }, - ) + my_code.render( + writer_options={ + "module_height": module_height, + "module_width": module_width, + "text_distance": text_distance, + } + ) # Retrieve the Pillow image and print it image = my_code.writer._image From 25867f31962d822cf4778ebf4cd0f944af869e43 Mon Sep 17 00:00:00 2001 From: Patrick Kanzler <4189642+patkan@users.noreply.github.com> Date: Tue, 9 May 2023 01:15:34 +0200 Subject: [PATCH 2/3] update to most recent printer database (#513) --- capabilities-data | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capabilities-data b/capabilities-data index 3612db4..190a96d 160000 --- a/capabilities-data +++ b/capabilities-data @@ -1 +1 @@ -Subproject commit 3612db407d02a08acd93a1540f2b4823be3f020e +Subproject commit 190a96db4b90425b99fbb4f034c04a36cf1c2bf7 From 6849dd3979d38b2c1be6d8234c0d3b7e6f6432a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=9C=88=E7=A7=8B=E8=A7=81=E5=BF=83?= <10618381+NullYing@users.noreply.github.com> Date: Tue, 9 May 2023 07:18:00 +0800 Subject: [PATCH 3/3] Add Chinese support (#356) * Add Chinese support * Add author * Add newline * Revert "Add Chinese support" This reverts commit 110200dde678a165062707e8ccb985c837ed6f68. * Add Chinese support * Add Chinese support * update mailmap file * update formatting --------- Co-authored-by: Patrick Kanzler Co-authored-by: Patrick Kanzler <4189642+patkan@users.noreply.github.com> --- .mailmap | 1 + AUTHORS | 1 + src/escpos/magicencode.py | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/.mailmap b/.mailmap index fe88047..fb0069e 100644 --- a/.mailmap +++ b/.mailmap @@ -13,6 +13,7 @@ csoft2k Sergio Pulgarin reck31 Alex Debiasio +白月秋见心 Maximilian Wagenbach belono Benito López diff --git a/AUTHORS b/AUTHORS index 07c6bce..cc15f85 100644 --- a/AUTHORS +++ b/AUTHORS @@ -41,3 +41,4 @@ Thijs Triemstra Thomas van den Berg Yaisel Hurtado ysuolmai +白月秋见心 diff --git a/src/escpos/magicencode.py b/src/escpos/magicencode.py index 4b6f9cb..bc0bb7f 100644 --- a/src/escpos/magicencode.py +++ b/src/escpos/magicencode.py @@ -18,6 +18,7 @@ from .constants import CODEPAGE_CHANGE from .exceptions import Error from .codepages import CodePages import six +import re class Encoder(object): @@ -252,6 +253,10 @@ class MagicEncode(object): self.write_with_encoding(self.encoding, text) return + if re.findall(r"[\u4e00-\u9fa5]", text): + self.driver._raw(text.encode("GB18030")) + return + # See how far we can go into the text with the current encoding to_write, text = split_writable_text(self.encoder, text, self.encoding) if to_write: