added configuration option for the font #197 #207

This commit is contained in:
jonaswinkler
2020-12-29 12:26:41 +01:00
parent 39d1c051cf
commit f964dd5935
4 changed files with 15 additions and 3 deletions

View File

@@ -1,10 +1,9 @@
import os
import subprocess
from PIL import ImageDraw, ImageFont, Image
from django.conf import settings
from documents.parsers import DocumentParser, ParseError
from documents.parsers import DocumentParser
class TextDocumentParser(DocumentParser):
@@ -23,7 +22,8 @@ class TextDocumentParser(DocumentParser):
img = Image.new("RGB", (500, 700), color="white")
draw = ImageDraw.Draw(img)
font = ImageFont.truetype(
"/usr/share/fonts/liberation/LiberationSerif-Regular.ttf", 20,
font=settings.THUMBNAIL_FONT_NAME,
size=20,
layout_engine=ImageFont.LAYOUT_BASIC)
draw.text((5, 5), read_text(), font=font, fill="black")