Skip to content

Commit b767a4c

Browse files
amarjenWhyNotHugo
authored andcommitted
Update writer.py
Added human text option to ImageWriter
1 parent 980f3ff commit b767a4c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

barcode/writer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,11 +465,16 @@ def _paint_module(self, xpos: float, ypos: float, width: float, color):
465465

466466
def _paint_text(self, xpos, ypos):
467467
assert ImageFont is not None
468+
469+
# check option to override self.text with self.human (barcode as
470+
# human readable data, can be used to print own formats)
471+
barcodetext = self.human if self.human != "" else self.text
472+
468473
font_size = int(mm2px(pt2mm(self.font_size), self.dpi))
469474
if font_size <= 0:
470475
return
471476
font = ImageFont.truetype(self.font_path, font_size)
472-
for subtext in self.text.split("\n"):
477+
for subtext in barcodetext.split("\n"):
473478
pos = (
474479
mm2px(xpos, self.dpi),
475480
mm2px(ypos, self.dpi),

0 commit comments

Comments
 (0)