Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions barcode/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,13 +438,13 @@ def _paint_text(self, xpos, ypos):
font_size = int(mm2px(pt2mm(self.font_size), self.dpi))
font = ImageFont.truetype(self.font_path, font_size)
for subtext in self.text.split("\n"):
width, height = font.getsize(subtext)
# determine the maximum width of each line
pos = (
mm2px(xpos, self.dpi) - width // 2,
mm2px(ypos, self.dpi) - height,
mm2px(xpos, self.dpi),
mm2px(ypos, self.dpi),
)
self._draw.text(
pos, subtext, font=font, fill=self.foreground, anchor="md"
)
self._draw.text(pos, subtext, font=font, fill=self.foreground)
ypos += pt2mm(self.font_size) / 2 + self.text_line_distance

def _finish(self):
Expand Down