mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-09-11 20:47:56 +03:00
Merge pull request #2043 from michaellisitsa/fix-tspan-not-respecting-text-anchor
Fix tspan not respecting text-anchor
This commit is contained in:
commit
4edb03d905
@ -281,6 +281,44 @@ def test_text_tspan(assert_pixels):
|
||||
''')
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_text_tspan_anchor_middle(assert_pixels):
|
||||
assert_pixels('''
|
||||
_______BBBBBB_______
|
||||
_______BBBBBB_______
|
||||
''', '''
|
||||
<style>
|
||||
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
|
||||
@page { size: 20px 2px }
|
||||
svg { display: block }
|
||||
</style>
|
||||
<svg width="20px" height="2px" xmlns="http://www.w3.org/2000/svg">
|
||||
<text x="10" y="10" font-family="weasyprint" font-size="2" fill="blue">
|
||||
<tspan x="10" y="1.5" text-anchor="middle">ABC</tspan>
|
||||
</text>
|
||||
</svg>
|
||||
''')
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_text_tspan_anchor_end(assert_pixels):
|
||||
assert_pixels('''
|
||||
____________BBBBBB__
|
||||
____________BBBBBB__
|
||||
''', '''
|
||||
<style>
|
||||
@font-face { src: url(weasyprint.otf); font-family: weasyprint }
|
||||
@page { size: 20px 2px }
|
||||
svg { display: block }
|
||||
</style>
|
||||
<svg width="20px" height="2px" xmlns="http://www.w3.org/2000/svg">
|
||||
<text x="10" y="10" font-family="weasyprint" font-size="2" fill="blue">
|
||||
<tspan x="18" y="1.5" text-anchor="end">ABC</tspan>
|
||||
</text>
|
||||
</svg>
|
||||
''')
|
||||
|
||||
|
||||
@assert_no_logs
|
||||
def test_text_rotate(assert_pixels):
|
||||
assert_pixels('''
|
||||
|
@ -445,7 +445,7 @@ class SVG:
|
||||
|
||||
# Handle text anchor
|
||||
text_anchor = node.get('text-anchor')
|
||||
if node.tag == 'text' and text_anchor in ('middle', 'end'):
|
||||
if TAGS.get(node.tag) == text and text_anchor in ('middle', 'end'):
|
||||
group = self.stream.add_group(0, 0, 0, 0) # BBox set after drawing
|
||||
original_streams.append(self.stream)
|
||||
self.stream = group
|
||||
@ -473,7 +473,7 @@ class SVG:
|
||||
node.text_bounding_box, ((x1, y1), (x2, y2)))
|
||||
|
||||
# Handle text anchor
|
||||
if node.tag == 'text' and text_anchor in ('middle', 'end'):
|
||||
if TAGS.get(node.tag) == text and text_anchor in ('middle', 'end'):
|
||||
group_id = self.stream.id
|
||||
self.stream = original_streams.pop()
|
||||
self.stream.push_state()
|
||||
|
Loading…
Reference in New Issue
Block a user