diff --git a/weasyprint/layout/inlines.py b/weasyprint/layout/inlines.py index 96824bda..4d7de167 100644 --- a/weasyprint/layout/inlines.py +++ b/weasyprint/layout/inlines.py @@ -116,7 +116,7 @@ def get_next_linebox(context, linebox, position_y, skip_stack, new_position_x, _, new_available_width = avoid_collisions( context, linebox, containing_block, outer=False) alignment_available_width = ( - new_available_width + new_position_x - position_x) + new_available_width + new_position_x - linebox.position_x) offset_x = text_align( context, line, alignment_available_width, last=(resume_at is None or preserved_line_break)) diff --git a/weasyprint/tests/test_text.py b/weasyprint/tests/test_text.py index 9dbb1d60..97799412 100644 --- a/weasyprint/tests/test_text.py +++ b/weasyprint/tests/test_text.py @@ -266,6 +266,43 @@ def test_text_align_justify(): text, = line_1.children assert text.position_x == 0 + # text-indent + page, = parse(''' + +

+ + + + ''') + html, = page.children + body, = html.children + paragraph, = body.children + line_1, line_2 = paragraph.children + image_1, space_1, strong = line_1.children + image_2, space_2, image_3, space_3, image_4 = strong.children + image_5, = line_2.children + assert space_1.text == ' ' + assert space_2.text == ' ' + assert space_3.text == ' ' + + assert image_1.position_x == 3 + assert space_1.position_x == 43 + assert strong.position_x == 72 + assert image_2.position_x == 72 + assert space_2.position_x == 132 + assert image_3.position_x == 161 + assert space_3.position_x == 171 + assert image_4.position_x == 200 + assert strong.width == 228 + + assert image_5.position_x == 0 + @assert_no_logs def test_word_spacing():