@@ -269,18 +269,22 @@ def _create_text(self, xpos, ypos):
269269 if self .human != '' :
270270 barcodetext = self .human
271271 else :
272- barcodetext = self .text
272+ barcodetext = self .text
273273 for subtext in barcodetext .split ('\n ' ):
274- element = self ._document .createElement ('text' )
275- attributes = dict (x = SIZE .format (xpos ), y = SIZE .format (ypos ),
276- style = 'fill:{0};font-size:{1}pt;text-anchor:'
277- 'middle;' .format (self .foreground ,
278- self .font_size ))
279- _set_attributes (element , ** attributes )
280- text_element = self ._document .createTextNode (subtext )
281- element .appendChild (text_element )
282- self ._group .appendChild (element )
283- ypos += pt2mm (self .font_size ) + self .text_line_distance
274+ element = self ._document .createElement ('text' )
275+ attributes = dict (
276+ x = SIZE .format (xpos ),
277+ y = SIZE .format (ypos ),
278+ style = 'fill:{0};font-size:{1}pt;text-anchor:middle;' .format (
279+ self .foreground ,
280+ self .font_size ,
281+ )
282+ )
283+ _set_attributes (element , ** attributes )
284+ text_element = self ._document .createTextNode (subtext )
285+ element .appendChild (text_element )
286+ self ._group .appendChild (element )
287+ ypos += pt2mm (self .font_size ) + self .text_line_distance
284288
285289 def _finish (self ):
286290 if self .compress :
@@ -328,13 +332,13 @@ def _paint_module(self, xpos, ypos, width, color):
328332
329333 def _paint_text (self , xpos , ypos ):
330334 for subtext in self .text .split ('\n ' ):
331- font = ImageFont .truetype (FONT , self .font_size * 2 )
332- width , height = font .getsize (subtext )
333- # determine the maximum width of each line
334- pos = (mm2px (xpos , self .dpi ) - width // 2 ,
335- mm2px (ypos , self .dpi ) - height // 4 )
336- self ._draw .text (pos , subtext , font = font , fill = self .foreground )
337- ypos += pt2mm (self .font_size ) / 2 + self .text_line_distance
335+ font = ImageFont .truetype (FONT , self .font_size * 2 )
336+ width , height = font .getsize (subtext )
337+ # determine the maximum width of each line
338+ pos = (mm2px (xpos , self .dpi ) - width // 2 ,
339+ mm2px (ypos , self .dpi ) - height // 4 )
340+ self ._draw .text (pos , subtext , font = font , fill = self .foreground )
341+ ypos += pt2mm (self .font_size ) / 2 + self .text_line_distance
338342
339343 def _finish (self ):
340344 return self ._image
0 commit comments