1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 16:37:47 +03:00

Adjust line lengths to pass style acceptance tests

This commit is contained in:
Joel Steres 2015-09-02 18:52:32 -07:00
parent 97e87d54af
commit 73b7c23d4a
2 changed files with 10 additions and 5 deletions

View File

@ -2929,7 +2929,8 @@ def test_letter_spacing():
# an embedded tag should not affect the single-line letter spacing
page, = parse('''
<style>strong { letter-spacing: 11px }</style>
<body><strong>Supercali<span>fragilistic</span>expialidocious</strong>''')
<body><strong>Supercali<span>fragilistic</span>expialidocious''' +
'</strong>')
html, = page.children
body, = html.children
line, = body.children
@ -2940,8 +2941,12 @@ def test_letter_spacing():
# Note work-around for word-wrap bug (issue #163) by marking word
# as an inline-block
page, = parse('''
<style>strong { letter-spacing: 11px; max-width: %dpx } span { display: inline-block }</style>
<body><strong><span>Supercali<i>fragilistic</i>expialidocious</span> <span>Supercali<i>fragilistic</i>expialidocious</span></strong>''' % (strong_3.width * 1.5))
<style>strong { letter-spacing: 11px; max-width: %dpx }
span { display: inline-block }</style>
<body><strong>%s %s</strong>''' %
((strong_3.width * 1.5),
'<span>Supercali<i>fragilistic</i>expialidocious</span>',
'<span>Supercali<i>fragilistic</i>expialidocious</span>'))
html, = page.children
body, = html.children
line1, line2 = body.children

View File

@ -316,7 +316,7 @@ class Layout(object):
pango.pango_font_description_set_absolute_size(
font, units_from_double(font_size))
pango.pango_layout_set_font_description(self.layout, font)
self.is_spaced_letter_workaround_enabled = (style.letter_spacing != 'normal')
self.is_letter_space_fix_enabled = (style.letter_spacing != 'normal')
def iter_lines(self):
layout_iter = ffi.gc(
@ -328,7 +328,7 @@ class Layout(object):
return
def set_text(self, text):
if self.is_spaced_letter_workaround_enabled and len(text) > 0:
if self.is_letter_space_fix_enabled and len(text) > 0:
# add zero-length-space so that pango letter-spacing will
# adjust space following the last letter in the box
text = text + u'\u200b'