Title: Missing kerning for single-byte strings in PDF · Issue #19581 · matplotlib/matplotlib · GitHub
Open Graph Title: Missing kerning for single-byte strings in PDF · Issue #19581 · matplotlib/matplotlib
X Title: Missing kerning for single-byte strings in PDF · Issue #19581 · matplotlib/matplotlib
Description: Bug report Bug summary Kerning is not applied in the PDF output of pure single-byte strings which leads to inconsistencies between PDF and other output formats. Code for reproduction import matplotlib.pyplot as plt fig, ax = plt.subplots...
Open Graph Description: Bug report Bug summary Kerning is not applied in the PDF output of pure single-byte strings which leads to inconsistencies between PDF and other output formats. Code for reproduction import matplot...
X Description: Bug report Bug summary Kerning is not applied in the PDF output of pure single-byte strings which leads to inconsistencies between PDF and other output formats. Code for reproduction import matplot...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/19581
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Missing kerning for single-byte strings in PDF","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\nKerning is not applied in the PDF output of pure single-byte strings which leads to inconsistencies between PDF and other output formats.\r\n\r\n**Code for reproduction**\r\n```python\r\nimport matplotlib.pyplot as plt\r\n\r\nfig, ax = plt.subplots()\r\nax.text(0.1, 0.5, \"ATL\", size=120)\r\nfig.savefig(\"atl.pdf\")\r\nfig.savefig(\"atl.png\", dpi=300)\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\n**Expected outcome**\r\nI expected that the spacing between `A` and `T` is consistent between both formats. Besides this minor visual issues, I use `get_window_extent()` to place a second text item in bold next to the first one. The space between the two texts varies significantly between output formats. `get_window_extent()` considers the kerning information, so the space looks correct in PNG but is usually too small in PDF files.\r\n\r\nThe issue is related to https://github.com/matplotlib/matplotlib/issues/18282. Here the same issue was fixed for strings with multi-byte chars. I don't see the changes from https://github.com/matplotlib/matplotlib/issues/18282 in version 3.3.4, but they will not effect the single-byte string case.\r\n\r\nUnaware of https://github.com/matplotlib/matplotlib/issues/18282, I've implemented a fix for the single-byte case. I will open a PR, but you might have other ideas on how to implementation a fix.\r\n\r\n**Matplotlib version**\r\n * Operating system: Ubuntu 16.04\r\n * Matplotlib version: 3.3.4\r\n * Matplotlib backend: TkAgg (but actually PDF?)\r\n * Python version: 3.7.5\r\n * Font: DejaVuSans Type 3\r\n\r\nI've installed matplotlib in a virtualenv with pip.\r\n","author":{"url":"https://github.com/sauerburger","@type":"Person","name":"sauerburger"},"datePublished":"2021-02-25T20:19:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/19581/matplotlib/issues/19581"}
| 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:9816d981-b978-359d-4127-feba0cbde361 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF26:2052BE:19793B4:22F8D17:6A53EE91 |
| html-safe-nonce | 2b5b0f4c01f309e3ec8d2462dedae27d25e9b13d71117d0d58196f857486f38d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjI2OjIwNTJCRToxOTc5M0I0OjIyRjhEMTc6NkE1M0VFOTEiLCJ2aXNpdG9yX2lkIjoiNzk2MzEyNDc5ODg2MjkxMzE2OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0f2c3ae7e1f2211b1daac076c91ba23cbd99cb41272da8942e98c91d7bce8ffd |
| hovercard-subject-tag | issue:816770335 |
| 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/19581/issue_layout |
| twitter:image | https://opengraph.githubassets.com/37b32340ed5af91460df1aa7748fc088094d56a83d87b3dbbfea9f940e03836f/matplotlib/matplotlib/issues/19581 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/37b32340ed5af91460df1aa7748fc088094d56a83d87b3dbbfea9f940e03836f/matplotlib/matplotlib/issues/19581 |
| og:image:alt | Bug report Bug summary Kerning is not applied in the PDF output of pure single-byte strings which leads to inconsistencies between PDF and other output formats. Code for reproduction import matplot... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sauerburger |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width