mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-04 07:57:52 +03:00
Don’t generate PDF with 0-scale transformation matrices for text
This commit is contained in:
parent
ac176a8fd4
commit
2e726a3965
@ -715,6 +715,29 @@ def test_zero_width_character():
|
|||||||
<div>a‌b</div>''')
|
<div>a‌b</div>''')
|
||||||
|
|
||||||
|
|
||||||
|
def test_font_size_very_small():
|
||||||
|
assert_pixels('font_size_very_small', 10, 4, '''
|
||||||
|
__________
|
||||||
|
__________
|
||||||
|
__________
|
||||||
|
__________
|
||||||
|
''', '''
|
||||||
|
<style>
|
||||||
|
@font-face {src: url(weasyprint.otf); font-family: weasyprint}
|
||||||
|
@page {
|
||||||
|
size: 10px 4px;
|
||||||
|
background: white;
|
||||||
|
margin: 1px;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
font-family: weasyprint;
|
||||||
|
font-size: 0.00000001px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
test font size zero
|
||||||
|
''')
|
||||||
|
|
||||||
|
|
||||||
def test_tabulation_character():
|
def test_tabulation_character():
|
||||||
# Test regression: https://github.com/Kozea/WeasyPrint/issues/1515
|
# Test regression: https://github.com/Kozea/WeasyPrint/issues/1515
|
||||||
assert_pixels('zero_width_character', 10, 4, '''
|
assert_pixels('zero_width_character', 10, 4, '''
|
||||||
|
@ -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,
|
def draw_first_line(stream, textbox, text_overflow, block_ellipsis, x, y,
|
||||||
angle=0):
|
angle=0):
|
||||||
"""Draw the given ``textbox`` line to the document ``stream``."""
|
"""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(
|
pango.pango_layout_set_single_paragraph_mode(
|
||||||
textbox.pango_layout.layout, True)
|
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)
|
textbox.pango_layout.set_text(new_text + ellipsis)
|
||||||
first_line, index = textbox.pango_layout.get_first_line()
|
first_line, index = textbox.pango_layout.get_first_line()
|
||||||
|
|
||||||
font_size = textbox.style['font_size']
|
|
||||||
utf8_text = textbox.pango_layout.text.encode()
|
utf8_text = textbox.pango_layout.text.encode()
|
||||||
previous_utf8_position = 0
|
previous_utf8_position = 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user