Title: [Bug]: problem with font property in text elements of svg figures · Issue #22528 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: problem with font property in text elements of svg figures · Issue #22528 · matplotlib/matplotlib
X Title: [Bug]: problem with font property in text elements of svg figures · Issue #22528 · matplotlib/matplotlib
Description: Bug summary Starting with 3.5.0, figures exported as SVG without font embedded in the file (i.e. “svg.fonttype” set to “none”) use the font CSS shorthand property. The problem is that the font-family generic name is quoted and some viewe...
Open Graph Description: Bug summary Starting with 3.5.0, figures exported as SVG without font embedded in the file (i.e. “svg.fonttype” set to “none”) use the font CSS shorthand property. The problem is that the font-fami...
X Description: Bug summary Starting with 3.5.0, figures exported as SVG without font embedded in the file (i.e. “svg.fonttype” set to “none”) use the font CSS shorthand property. The problem is that the font-fami...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/22528
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: problem with font property in text elements of svg figures","articleBody":"### Bug summary\r\n\r\nStarting with 3.5.0, figures exported as SVG without font embedded in the file (i.e. “svg.fonttype” set to “none”) use the `font` CSS shorthand property.\r\nThe problem is that the font-family generic name is quoted and some viewers don’t like it (chrome for exemple). My understanding (reading https://developer.mozilla.org/en-US/docs/Web/CSS/font-family) is that only the family name should be quoted if it contains spaces.\r\n\r\n### Code for reproduction\r\n\r\n```python\r\nimport matplotlib\r\nimport matplotlib.pyplot\r\nmatplotlib.rcParams[\"svg.fonttype\"] = \"none\"\r\nmatplotlib.rcParams[\"font.family\"] = \"sans-serif\"\r\nmatplotlib.use(\"SVG\")\r\n \r\nfig = matplotlib.pyplot.figure()\r\naxes = fig.add_subplot()\r\naxes.plot([1, 2], [3, 4], label=\"test\")\r\naxes.legend()\r\nfig.savefig(f\"test.svg\")\r\n```\r\n\r\n\r\n### Actual outcome\r\n\r\nIn the text elements, the generic name of the font-family is quoted (here 'sans-serif')\r\n`\u003ctext style=\"font: 10px 'sans-serif'; text-anchor: start\" x=\"94.6\" y=\"57.629812\" transform=\"rotate(-0, 94.6, 57.629812)\"\u003etest\u003c/text\u003e`\r\n\r\n### Expected outcome\r\n\r\nThe generic name of the font-family should not be quoted\r\n`\u003ctext style=\"font: 10px sans-serif; text-anchor: start\" x=\"94.6\" y=\"57.629812\" transform=\"rotate(-0, 94.6, 57.629812)\"\u003etest\u003c/text\u003e`\r\n \r\n\r\n### Additional information\r\n\r\n_No response_\r\n\r\n### Operating system\r\n\r\n_No response_\r\n\r\n### Matplotlib Version\r\n\r\n3.5.1\r\n\r\n### Matplotlib Backend\r\n\r\nSVG\r\n\r\n### Python version\r\n\r\n3.9.10\r\n\r\n### Jupyter version\r\n\r\n_No response_\r\n\r\n### Installation\r\n\r\nconda","author":{"url":"https://github.com/cderemble","@type":"Person","name":"cderemble"},"datePublished":"2022-02-22T09:10:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/22528/matplotlib/issues/22528"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:081dccaa-6cc1-1474-6626-78c10510077e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D026:1179A2:2BF7D7B:3DD8101:6A50DD36 |
| html-safe-nonce | d8c457aafcb78c8916b648fc4621c4a445cf941ac816b85c67597ff4a4848802 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDI2OjExNzlBMjoyQkY3RDdCOjNERDgxMDE6NkE1MEREMzYiLCJ2aXNpdG9yX2lkIjoiNjg5ODg5Mzc1NDczNzk0MTgxNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d4c9259164b2ca4d13dbaacf8c11b0fa972fc584e0f435a774fa7efad9a62298 |
| hovercard-subject-tag | issue:1146640834 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/22528/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6ff674b881c6ff29c9b49be9028ef7328397f39b189a22c4aa53cb0edbef778e/matplotlib/matplotlib/issues/22528 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6ff674b881c6ff29c9b49be9028ef7328397f39b189a22c4aa53cb0edbef778e/matplotlib/matplotlib/issues/22528 |
| og:image:alt | Bug summary Starting with 3.5.0, figures exported as SVG without font embedded in the file (i.e. “svg.fonttype” set to “none”) use the font CSS shorthand property. The problem is that the font-fami... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cderemble |
| hostname | github.com |
| expected-hostname | github.com |
| None | 72b13e0e8d0319acdd27a145cfe73f4f06c791713d0ac4690e41fb68ad28cac0 |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 17290b65caabb92b271e0949d1bf147b63deab41 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width