try to deal with missing fonts

workspace
Brendan Howell 5 years ago
parent d41cbe33e4
commit 4a1dd71b2a

@ -1,5 +1,6 @@
# bureau
import functools
import glob
import inspect
import io
import json
@ -354,6 +355,10 @@ class Bureau(object):
pdfpath = tempfile.mkstemp(".pdf")[1]
self.log.debug("rendering to: " + pdfpath)
fontconfig = FontConfiguration()
fontsdir = os.path.join(self.mdir, "fonts")
for font in glob.glob(fontsdir + ".otf"):
fontconfig.add_font_face("file://" + font,
weasyprint.default_url_fetcher)
weasyprint.HTML(string=templ.render_unicode(**kwargs)).write_pdf(pdfpath, font_config=fontconfig)
subprocess.call("lpr -o sides=two-sided-long-edge -o InputSlot=Upper " + pdfpath, shell=True)

Loading…
Cancel
Save