diff --git a/tests/draw/test_text.py b/tests/draw/test_text.py index 16c9cb13..aeb9c46d 100644 --- a/tests/draw/test_text.py +++ b/tests/draw/test_text.py @@ -715,6 +715,29 @@ def test_zero_width_character():
a‌b
''') +def test_font_size_very_small(): + assert_pixels('font_size_very_small', 10, 4, ''' + __________ + __________ + __________ + __________ + ''', ''' + + test font size zero + ''') + + def test_tabulation_character(): # Test regression: https://github.com/Kozea/WeasyPrint/issues/1515 assert_pixels('zero_width_character', 10, 4, ''' diff --git a/weasyprint/draw.py b/weasyprint/draw.py index c9e16a48..e819dd56 100644 --- a/weasyprint/draw.py +++ b/weasyprint/draw.py @@ -1030,6 +1030,10 @@ def draw_emojis(stream, font_size, x, y, emojis): def draw_first_line(stream, textbox, text_overflow, block_ellipsis, x, y, angle=0): """Draw the given ``textbox`` line to the document ``stream``.""" + font_size = textbox.style['font_size'] + if font_size < 1e-6: # Default float precision used by pydyf + return [] + pango.pango_layout_set_single_paragraph_mode( textbox.pango_layout.layout, True) @@ -1072,7 +1076,6 @@ def draw_first_line(stream, textbox, text_overflow, block_ellipsis, x, y, textbox.pango_layout.set_text(new_text + ellipsis) first_line, index = textbox.pango_layout.get_first_line() - font_size = textbox.style['font_size'] utf8_text = textbox.pango_layout.text.encode() previous_utf8_position = 0