Aaand font paths

This commit is contained in:
Christoffer Viken 2017-03-22 17:16:22 +00:00
parent 8e47a1848b
commit 5a0ba1523b
1 changed files with 5 additions and 2 deletions

View File

@ -1,3 +1,5 @@
import os
from PIL import ImageFont from PIL import ImageFont
from barcode.writer import ImageWriter, mm2px from barcode.writer import ImageWriter, mm2px
from brother_ql.devicedependent import label_type_specs from brother_ql.devicedependent import label_type_specs
@ -50,9 +52,10 @@ class BrotherLabelWriter(ImageWriter):
height = 0 height = 0
max_h = self._h - mm2px(self._yo, self.dpi) max_h = self._h - mm2px(self._yo, self.dpi)
fs = int(max_h / 1.2) fs = int(max_h / 1.2)
font = ImageFont.truetype("./arial.ttf", 10) font_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "Stranger back in the Night.ttf")
font = ImageFont.truetype(font_path, 10)
while width > self._w or height > max_h: while width > self._w or height > max_h:
font = ImageFont.truetype("./Stranger back in the Night.ttf", fs) font = ImageFont.truetype(font_path, fs)
width, height = font.getsize(self._title) width, height = font.getsize(self._title)
fs -= 1 fs -= 1
pos = ( pos = (