Skip to content

Commit cc5ba96

Browse files
committed
Use real style when drawing emoji in SVG.
Fix #2683.
1 parent 1f182df commit cc5ba96

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

tests/draw/svg/test_text.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,3 +710,23 @@ def test_text_fill_opacity(assert_pixels):
710710
</text>
711711
</svg>
712712
''')
713+
714+
715+
@assert_no_logs
716+
def test_emoji_text_svg(assert_pixels):
717+
# Regression text for #2683.
718+
assert_pixels('''
719+
zzzzz
720+
zzzzz
721+
zzzzz
722+
zzzzz
723+
zzzzz
724+
''', '''
725+
<style>
726+
@page { size: 5px 5px }
727+
svg { display: block }
728+
</style>
729+
<svg viewBox="0 0 5 5">
730+
<text>🚀</text>
731+
</svg>
732+
''')

weasyprint/svg/text.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,10 @@ def text(svg, node, font_size):
168168
matrix = Matrix(a, -c, c, a) @ matrix
169169
emojis = draw_first_line(
170170
svg.stream, TextBox(layout, style), 'none', 'none', matrix)
171-
emoji_lines.append((font_size, x, y, emojis))
171+
emoji_lines.append((x, y, emojis))
172172

173173
svg.stream.end_text()
174174
svg.stream.pop_state()
175175

176-
for font_size, x, y, emojis in emoji_lines:
177-
# TODO: pass real style instead of dict.
178-
style = {'font_size': font_size}
176+
for x, y, emojis in emoji_lines:
179177
draw_emojis(svg.stream, style, x, y, emojis)

0 commit comments

Comments
 (0)