Skip to content

Commit

Permalink
Don't crash when using ex units in word-spacing in letter-spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Sep 10, 2019
1 parent fb0887c commit f66df06
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions weasyprint/text.py
Expand Up @@ -748,14 +748,18 @@ def set_text(self, text, justify=False):
self.text = bytestring.decode('utf-8') self.text = bytestring.decode('utf-8')
pango.pango_layout_set_text(self.layout, text, -1) 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: if justify:
# Justification is needed when drawing text but is useless during # Justification is needed when drawing text but is useless during
# layout. Ignore it before layout is reactivated before the drawing # layout. Ignore it before layout is reactivated before the drawing
# step. # step.
word_spacing += self.justification_spacing 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': if letter_spacing == 'normal':
letter_spacing = 0 letter_spacing = 0


Expand Down

0 comments on commit f66df06

Please sign in to comment.