def _paint_text(self, xpos, ypos): font = barcode.writer.ImageFont.truetype(barcode.writer.FONT, self.font_size) textwidth = self._draw.textsize(self.text, font=font)[0] pos = (mm2px(xpos, self.dpi) - textwidth / 2, mm2px(ypos, self.dpi)) self._draw.text(pos, self.text, font=font, fill=self.foreground)
def _paint_text(self, xpos, ypos): xpos = self.width / 2 letter_width = self.font_size * 0.78 # letter size = 23d x 18d -> ratio = 0.78 text_width = len(self.text) * letter_width * 0.065 * (float(300) / self.dpi) xpos -= text_width / 2 pos = (mm2px(xpos, self.dpi), mm2px(ypos, self.dpi)) font = ImageFont.truetype(FONT, self.font_size) self._draw.text(pos, self.text, font=font, fill=self.foreground)
def _paint_text(self, xpos, ypos): xpos = self.width/2 letter_width = self.font_size * 0.78 # letter size = 23d x 18d -> ratio = 0.78 text_width = len(self.text) * letter_width * 0.065 * (float(300) / self.dpi) xpos -= text_width/2 pos = (mm2px(xpos, self.dpi), mm2px(ypos, self.dpi)) font = ImageFont.truetype(FONT, self.font_size) self._draw.text(pos, self.text, font=font, fill=self.foreground)
def calculate_size(self, modules_per_line, number_of_lines, dpi=300): width = 2 * self.quiet_zone + modules_per_line * self.module_width height = 1.0 + self.module_height * number_of_lines if self.text: height += 2 * self.text_distance + self.font_size * 0.09 self.width = width self.height = height self.size = int(mm2px(width, dpi)), int(mm2px(height, dpi)) return self.size
def calculate_size(self, modules_per_line, number_of_lines, dpi=300): width, oldheight = barcode.writer.ImageWriter.calculate_size( self, modules_per_line, number_of_lines, dpi) height = 1.0 + self.module_height * number_of_lines if self.text: font_mm = (self.font_size * 25.4) / float(dpi) height += font_mm + self.text_distance * 2 return (width, int(mm2px(height, dpi)))
def calculate_size(self, modules_per_line, number_of_lines, dpi=300): width, oldheight = barcode.writer.ImageWriter.calculate_size(self, modules_per_line, number_of_lines, dpi) height = 1.0 + self.module_height * number_of_lines if self.text: font_mm = (self.font_size * 25.4) / float(dpi) height += font_mm + self.text_distance * 2 return (width, int(mm2px(height, dpi)))
def calculate_size(self, modules_per_line, number_of_lines, dpi=100): width = 2 * self.quiet_zone + modules_per_line * self.module_width height = 6 self.size = int(mm2px(width, dpi)), int(mm2px(height, dpi)) return self.size
def _paint_module(self, xpos, ypos, width, color): size = [(mm2px(xpos, self.dpi), mm2px(ypos, self.dpi)), (mm2px(xpos + width, self.dpi), mm2px(ypos + self.module_height, self.dpi))] self._draw.rectangle(size, outline=color, fill=color)