Skip to content
Permalink
Browse files

Don't crash when using ex units in word-spacing in letter-spacing

  • Loading branch information...
liZe committed Sep 10, 2019
1 parent fb0887c commit f66df067a1bba4e4926326ada50b7300433700c3
Showing with 6 additions and 2 deletions.
  1. +6 −2 weasyprint/text.py
@@ -748,14 +748,18 @@ def set_text(self, text, justify=False):
self.text = bytestring.decode('utf-8')
pango.pango_layout_set_text(self.layout, text, -1)

word_spacing = self.style['word_spacing']
# Word spacing may not be set if we're trying to get word-spacing
# computed value using a layout, for example if its unit is ex.
word_spacing = self.style.get('word_spacing', 0)
if justify:
# Justification is needed when drawing text but is useless during
# layout. Ignore it before layout is reactivated before the drawing
# step.
word_spacing += self.justification_spacing

letter_spacing = self.style['letter_spacing']
# Letter spacing may not be set if we're trying to get letter-spacing
# computed value using a layout, for example if its unit is ex.
letter_spacing = self.style.get('letter_spacing', 'normal')
if letter_spacing == 'normal':
letter_spacing = 0

0 comments on commit f66df06

Please sign in to comment.
You can’t perform that action at this time.