From 2e726a3965638785a83a0f67bba39a6df8688c2c Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Fri, 15 Apr 2022 14:53:19 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20generate=20PDF=20with=200-scale?= =?UTF-8?q?=20transformation=20matrices=20for=20text?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/draw/test_text.py | 23 +++++++++++++++++++++++ weasyprint/draw.py | 5 ++++- 2 files changed, 27 insertions(+), 1 deletion(-) 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