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:
parent
4eb7fa38b8
commit
6b82aec103
@ -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``."""
|
||||
# Don’t 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 []
|
||||
|
@ -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."""
|
||||
|
Loading…
Reference in New Issue
Block a user