mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
PDF: Fail gracefully on unknown font
This commit is contained in:
@@ -827,6 +827,12 @@ class Renderer:
|
|||||||
if o['italic']:
|
if o['italic']:
|
||||||
font += ' I'
|
font += ' I'
|
||||||
|
|
||||||
|
try:
|
||||||
|
ad = getAscentDescent(font, float(o['fontsize']))
|
||||||
|
except KeyError: # font not known, fall back
|
||||||
|
logger.warning(f'Use of unknown font "{font}"')
|
||||||
|
font = 'Open Sans'
|
||||||
|
|
||||||
align_map = {
|
align_map = {
|
||||||
'left': TA_LEFT,
|
'left': TA_LEFT,
|
||||||
'center': TA_CENTER,
|
'center': TA_CENTER,
|
||||||
@@ -856,7 +862,6 @@ class Renderer:
|
|||||||
p = Paragraph(text, style=style)
|
p = Paragraph(text, style=style)
|
||||||
w, h = p.wrapOn(canvas, float(o['width']) * mm, 1000 * mm)
|
w, h = p.wrapOn(canvas, float(o['width']) * mm, 1000 * mm)
|
||||||
# p_size = p.wrap(float(o['width']) * mm, 1000 * mm)
|
# p_size = p.wrap(float(o['width']) * mm, 1000 * mm)
|
||||||
ad = getAscentDescent(font, float(o['fontsize']))
|
|
||||||
canvas.saveState()
|
canvas.saveState()
|
||||||
# The ascent/descent offsets here are not really proven to be correct, they're just empirical values to get
|
# The ascent/descent offsets here are not really proven to be correct, they're just empirical values to get
|
||||||
# reportlab render similarly to browser canvas.
|
# reportlab render similarly to browser canvas.
|
||||||
|
|||||||
Reference in New Issue
Block a user