Title: PostScript Type42 embedding is broken in various ways · Issue #18191 · matplotlib/matplotlib · GitHub
Open Graph Title: PostScript Type42 embedding is broken in various ways · Issue #18191 · matplotlib/matplotlib
X Title: PostScript Type42 embedding is broken in various ways · Issue #18191 · matplotlib/matplotlib
Description: Bug report Bug summary As in the title. Code for reproduction from pylab import * rcParams["ps.fonttype"] = 42 figtext(.5, .5, "€"); savefig("/tmp/euro.ps"); close("all") figtext(.5, .5, "0€"); savefig("/tmp/zeroeuro.ps"); close("all") f...
Open Graph Description: Bug report Bug summary As in the title. Code for reproduction from pylab import * rcParams["ps.fonttype"] = 42 figtext(.5, .5, "€"); savefig("/tmp/euro.ps"); close("all") figtext(.5, .5, "0€"); sav...
X Description: Bug report Bug summary As in the title. Code for reproduction from pylab import * rcParams["ps.fonttype"] = 42 figtext(.5, .5, "€"); savefig("/tmp/euro.ps"); close(&qu...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/18191
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PostScript Type42 embedding is broken in various ways","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nAs in the title.\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug.\r\nPlease make sure to minimize the number of dependencies required, and provide\r\nany necessary plotted data.\r\nAvoid using threads, as Matplotlib is (explicitly) not thread-safe.--\u003e\r\n\r\n```python\r\nfrom pylab import *\r\nrcParams[\"ps.fonttype\"] = 42\r\nfigtext(.5, .5, \"€\"); savefig(\"/tmp/euro.ps\"); close(\"all\")\r\nfigtext(.5, .5, \"0€\"); savefig(\"/tmp/zeroeuro.ps\"); close(\"all\")\r\nfigtext(.5, .5, \"$\\sqrt{2}$\"); savefig(\"/tmp/sqrt.ps\"); close(\"all\")\r\n```\r\n\r\n**Actual outcome**\r\n\r\nIn `euro.ps` the font is actually embedded as Type 3, not Type 42 (as can be checked by opening the file in a text editor).\r\nIn `zeroeuro.ps` the font is correctly embedded as Type 42, but the euro sign fails to display correctly (we get a rectangular box instead).\r\n`sqrt.ps` causes an error with the viewer (`Error: /invalidfont in definefont`).\r\n\r\nGiven that in all likelihood this has been broken for a loooooong time (as ttconv is rarely touched) it may be worth waiting for a decision on https://github.com/matplotlib/matplotlib/pull/18143 first before trying to fix this.\r\n\r\nOn the other hand, note that this also affects the `ps.fonttype = 3` case when rendering more than 255 characters, because we fall back to type 42 in that case (example below). By the spec, a type 3 font cannot contain more than 255 glyphs, but empirically, things work just fine for us, likely because we always refer to glyphs by glyph name rather than by glyph index? If we want to be super safe wrt. the spec, I guess we could split a \u003e255-glyph font into multiple fonts and call `setfont` as needed (we're positioning glyphs one at a time anyways).\r\n```python\r\nimport textwrap\r\nfrom pylab import *\r\nfigtext(0, .5, \"\\n\".join(textwrap.wrap(\"\".join(c for c in map(chr, range(512)) if c.isprintable()))))\r\nsavefig(\"/tmp/test.ps\")\r\n```\r\n\r\nAs a side point, it seems likely that type 42 embedding is *also* broken for the pdf backend, per https://github.com/matplotlib/matplotlib/issues/12636...\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: linux\r\n * Matplotlib version: master\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): ps\r\n * Python version: 38\r\n * Jupyter version (if applicable):\r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2020-08-06T07:53:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/18191/matplotlib/issues/18191"}
| 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:05d2676c-a962-4e04-1471-9bb78be2854d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B6C2:215443:262DB91:3353C7E:6A539A2C |
| html-safe-nonce | fcbe5b13ab323b629ed4aa8f4b52fb2133eea92f40f35d79e3c3464da0437c31 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNkMyOjIxNTQ0MzoyNjJEQjkxOjMzNTNDN0U6NkE1MzlBMkMiLCJ2aXNpdG9yX2lkIjoiMjc4NjAyMjM2OTAzMDAxOTYyOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ffc7d93de88578a4fca68977f82ebddd72f6caa026440986e1f8737165a2e5ab |
| hovercard-subject-tag | issue:674103643 |
| 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/18191/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fde6776650a8e4dc99e64b9bc5bb01b37037f5d1b601c83fae98843045ca11ef/matplotlib/matplotlib/issues/18191 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fde6776650a8e4dc99e64b9bc5bb01b37037f5d1b601c83fae98843045ca11ef/matplotlib/matplotlib/issues/18191 |
| og:image:alt | Bug report Bug summary As in the title. Code for reproduction from pylab import * rcParams["ps.fonttype"] = 42 figtext(.5, .5, "€"); savefig("/tmp/euro.ps"); close("all") figtext(.5, .5, "0€"); sav... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| 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