1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-09-11 20:47:56 +03:00

Don’t draw invisible characters

Even spaces seem to be ignored by PDF readers, that probably rely more on text
layout than on actual word separators.
This commit is contained in:
Guillaume Ayoub 2023-03-21 14:58:09 +01:00
parent 4eb7fa38b8
commit 6b82aec103
2 changed files with 8 additions and 0 deletions

View File

@ -1052,6 +1052,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``."""
# Dont draw lines with only invisible characters
if not textbox.text.strip():
return []
font_size = textbox.style['font_size']
if font_size < 1e-6: # Default float precision used by pydyf
return []

View File

@ -12,6 +12,10 @@ class TextBox:
self.pango_layout = pango_layout
self.style = style
@property
def text(self):
return self.pango_layout.text
def text(svg, node, font_size):
"""Draw text node."""