Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5c54324

Browse filesBrowse files
committed
Preserve whitespace in svg output.
See https://www.w3.org/TR/css-text-3/#white-space-property, which replaces the deprecated https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/xml:space (which wasn't used before either).
1 parent 093d582 commit 5c54324
Copy full SHA for 5c54324

File tree

Expand file treeCollapse file tree

3 files changed

+34
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+34
-1
lines changed

‎lib/matplotlib/backends/backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_svg.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ def _write_default_style(self):
318318
writer = self.writer
319319
default_style = generate_css({
320320
'stroke-linejoin': 'round',
321-
'stroke-linecap': 'butt'})
321+
'stroke-linecap': 'butt',
322+
'white-space': 'pre',
323+
})
322324
writer.start('defs')
323325
writer.start('style', type='text/css')
324326
writer.data('*{%s}\n' % default_style)
+24Lines changed: 24 additions & 0 deletions
Loading

‎lib/matplotlib/tests/test_backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_svg.py
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ def test_text_urls():
7676
assert expected in buf
7777

7878

79+
@image_comparison(baseline_images=['white_space_pre'], extensions=['svg'])
80+
def test_white_space_pre():
81+
plt.rcParams["svg.fonttype"] = "none"
82+
fig = plt.figure()
83+
fig.text(.5, .5, "a b c")
84+
85+
7986
@image_comparison(baseline_images=['bold_font_output'], extensions=['svg'])
8087
def test_bold_font_output():
8188
fig = plt.figure()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.