You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If text-align is set to justify and text-indent is set to a positive value, the first paragraph line ends before the trailing margin. This is due to reduced (instead of increased) inter-word spacing applied during justification, which may even make words overlap.
I've tracked down the bug to text_align() function in file layout/inlines.py. For the first line only, the offset variable stores a negative value, which is divided to line spaces and causes reduced or negative inter-word spacing.
MWE (larger values for text-indent worsen the result):
from weasyprint import HTML, CSS
html = HTML(
string='<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do'
' eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut'
' enim ad minim veniam, quis nostrud exercitation ullamco laboris'
' nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor'
' in reprehenderit in voluptate velit esse cillum dolore eu fugiat'
' nulla pariatur. Excepteur sint occaecat cupidatat non proident,'
' sunt in culpa qui officia deserunt mollit anim id est laborum.</p>')
css = CSS(string='@page { size: A4; margin: 25mm; } '
'p { text-align: justify; text-indent: 20mm; }')
html.write_pdf('bug-minimal.pdf', stylesheets=[css])
Environment: Python 3.6.3 and WeasyPrint 0.42, both under Arch Linux and Mac OS.
Result (default font varies with OS):
The text was updated successfully, but these errors were encountered:
Hello there,
If
text-align
is set tojustify
andtext-indent
is set to a positive value, the first paragraph line ends before the trailing margin. This is due to reduced (instead of increased) inter-word spacing applied during justification, which may even make words overlap.I've tracked down the bug to
text_align()
function in filelayout/inlines.py
. For the first line only, theoffset
variable stores a negative value, which is divided to line spaces and causes reduced or negative inter-word spacing.MWE (larger values for
text-indent
worsen the result):Environment: Python 3.6.3 and WeasyPrint 0.42, both under Arch Linux and Mac OS.
Result (default font varies with OS):
The text was updated successfully, but these errors were encountered: