René's URL Explorer Experiment


Title: [Bug]: `backend_pdf` gives `TTLibError` with `pdf.fonttype : 42` · Issue #21893 · matplotlib/matplotlib · GitHub

Open Graph Title: [Bug]: `backend_pdf` gives `TTLibError` with `pdf.fonttype : 42` · Issue #21893 · matplotlib/matplotlib

X Title: [Bug]: `backend_pdf` gives `TTLibError` with `pdf.fonttype : 42` · Issue #21893 · matplotlib/matplotlib

Description: Bug summary On macOS 12, fresh install of conda-forge matplotlib 3.5.0, when saving a figure to pdf, I get: TTLibError: specify a font number between 0 and 5 (inclusive) which I can trace to: ... ~/miniconda3/lib/python3.8/site-packages/...

Open Graph Description: Bug summary On macOS 12, fresh install of conda-forge matplotlib 3.5.0, when saving a figure to pdf, I get: TTLibError: specify a font number between 0 and 5 (inclusive) which I can trace to: ... ~...

X Description: Bug summary On macOS 12, fresh install of conda-forge matplotlib 3.5.0, when saving a figure to pdf, I get: TTLibError: specify a font number between 0 and 5 (inclusive) which I can trace to: ... ~...

Opengraph URL: https://github.com/matplotlib/matplotlib/issues/21893

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: `backend_pdf` gives `TTLibError` with `pdf.fonttype : 42`","articleBody":"### Bug summary\n\nOn macOS 12, fresh install of conda-forge matplotlib 3.5.0, when saving a figure to pdf, I get:\r\n\r\n```python\r\nTTLibError: specify a font number between 0 and 5 (inclusive)\r\n```\r\n\r\nwhich I can trace to:\r\n```python\r\n...\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backends/backend_pdf.py in embedTTF(self, filename, characters)\r\n   1424             return embedTTFType3(font, characters, descriptor)\r\n   1425         elif fonttype == 42:\r\n-\u003e 1426             return embedTTFType42(font, characters, descriptor)\r\n   1427 \r\n   1428     def alphaState(self, alpha):\r\n...\r\n```\r\n\r\nEverything works as expected if I save to a png or if I set `pdf.fonttype : 3` in my `matplotlibrc` file and save to pdf.\r\n\r\nI can see that `Helvetica*.afm` is present under `~/miniconda3/lib/python3.8/site-packages/matplotlib/mpl-data/fonts/pdfcorefonts` but not under `.../ttf`\n\n### Code for reproduction\n\n```python\nimport matplotlib.pyplot as plt\r\nplt.plot((1,2,3))\r\nplt.title('Axes Title', font='Helvetica')\r\nplt.savefig('text.pdf')\n```\n\n\n### Actual outcome\n\n```python\r\n---------------------------------------------------------------------------\r\nTTLibError                                Traceback (most recent call last)\r\n/var/folders/bj/czjbfh496258q1lc3p01lyz00000gn/T/ipykernel_58793/3096390865.py in \u003cmodule\u003e\r\n      2 plt.plot((1,2,3))\r\n      3 plt.title('Axes Title', font='Helvetica')\r\n----\u003e 4 plt.savefig('text.pdf')\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/pyplot.py in savefig(*args, **kwargs)\r\n    956 def savefig(*args, **kwargs):\r\n    957     fig = gcf()\r\n--\u003e 958     res = fig.savefig(*args, **kwargs)\r\n    959     fig.canvas.draw_idle()   # need this if 'transparent=True' to reset colors\r\n    960     return res\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/figure.py in savefig(self, fname, transparent, **kwargs)\r\n   3010                         ax.patch._cm_set(facecolor='none', edgecolor='none'))\r\n   3011 \r\n-\u003e 3012             self.canvas.print_figure(fname, **kwargs)\r\n   3013 \r\n   3014     def ginput(self, n=1, timeout=30, show_clicks=True,\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)\r\n   2312                 # force the figure dpi to 72), so we need to set it again here.\r\n   2313                 with cbook._setattr_cm(self.figure, dpi=dpi):\r\n-\u003e 2314                     result = print_method(\r\n   2315                         filename,\r\n   2316                         facecolor=facecolor,\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backend_bases.py in wrapper(*args, **kwargs)\r\n   1641             kwargs.pop(arg)\r\n   1642 \r\n-\u003e 1643         return func(*args, **kwargs)\r\n   1644 \r\n   1645     return wrapper\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/_api/deprecation.py in wrapper(*inner_args, **inner_kwargs)\r\n    384             # Early return in the simple, non-deprecated case (much faster than\r\n    385             # calling bind()).\r\n--\u003e 386             return func(*inner_args, **inner_kwargs)\r\n    387         arguments = signature.bind(*inner_args, **inner_kwargs).arguments\r\n    388         if is_varargs and arguments.get(name):\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backends/backend_pdf.py in print_pdf(self, filename, dpi, bbox_inches_restore, metadata)\r\n   2786             renderer.finalize()\r\n   2787             if not isinstance(filename, PdfPages):\r\n-\u003e 2788                 file.finalize()\r\n   2789         finally:\r\n   2790             if isinstance(filename, PdfPages):  # finish off this page\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backends/backend_pdf.py in finalize(self)\r\n    792         self.endStream()\r\n    793         self._write_annotations()\r\n--\u003e 794         self.writeFonts()\r\n    795         self.writeExtGSTates()\r\n    796         self._write_soft_mask_groups()\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backends/backend_pdf.py in writeFonts(self)\r\n    925                 chars = self._character_tracker.used.get(filename)\r\n    926                 if chars:\r\n--\u003e 927                     fonts[Fx] = self.embedTTF(filename, chars)\r\n    928         self.writeObject(self.fontObject, fonts)\r\n    929 \r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backends/backend_pdf.py in embedTTF(self, filename, characters)\r\n   1424             return embedTTFType3(font, characters, descriptor)\r\n   1425         elif fonttype == 42:\r\n-\u003e 1426             return embedTTFType42(font, characters, descriptor)\r\n   1427 \r\n   1428     def alphaState(self, alpha):\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backends/backend_pdf.py in embedTTFType42(font, characters, descriptor)\r\n   1230             subset_str = \"\".join(chr(c) for c in characters)\r\n   1231             _log.debug(\"SUBSET %s characters: %s\", filename, subset_str)\r\n-\u003e 1232             fontdata = _backend_pdf_ps.get_glyphs_subset(filename, subset_str)\r\n   1233             _log.debug(\r\n   1234                 \"SUBSET %s %d -\u003e %d\", filename,\r\n\r\n~/miniconda3/lib/python3.8/site-packages/matplotlib/backends/_backend_pdf_ps.py in get_glyphs_subset(fontfile, characters)\r\n     40     options.drop_tables += ['FFTM', 'PfEd']\r\n     41 \r\n---\u003e 42     with subset.load_font(fontfile, options) as font:\r\n     43         subsetter = subset.Subsetter(options=options)\r\n     44         subsetter.populate(text=characters)\r\n\r\n~/miniconda3/lib/python3.8/site-packages/fontTools/misc/loggingTools.py in wrapper(*args, **kwds)\r\n    370                         def wrapper(*args, **kwds):\r\n    371                                 with self:\r\n--\u003e 372                                         return func(*args, **kwds)\r\n    373                         return wrapper\r\n    374                 else:\r\n\r\n~/miniconda3/lib/python3.8/site-packages/fontTools/subset/__init__.py in load_font(fontFile, options, checkChecksums, dontLoadGlyphNames, lazy)\r\n   3006 \t      lazy=True):\r\n   3007 \r\n-\u003e 3008 \tfont = ttLib.TTFont(fontFile,\r\n   3009                             checkChecksums=checkChecksums,\r\n   3010                             recalcBBoxes=options.recalc_bounds,\r\n\r\n~/miniconda3/lib/python3.8/site-packages/fontTools/ttLib/ttFont.py in __init__(self, file, res_name_or_index, sfntVersion, flavor, checkChecksums, verbose, recalcBBoxes, allowVID, ignoreDecompileErrors, recalcTimestamp, fontNumber, lazy, quiet, _tableCache)\r\n    141                         file = tmp\r\n    142                 self._tableCache = _tableCache\r\n--\u003e 143                 self.reader = SFNTReader(file, checkChecksums, fontNumber=fontNumber)\r\n    144                 self.sfntVersion = self.reader.sfntVersion\r\n    145                 self.flavor = self.reader.flavor\r\n\r\n~/miniconda3/lib/python3.8/site-packages/fontTools/ttLib/sfnt.py in __init__(self, file, checkChecksums, fontNumber)\r\n     58                         numFonts = header.numFonts\r\n     59                         if not 0 \u003c= fontNumber \u003c numFonts:\r\n---\u003e 60                                 raise TTLibError(\"specify a font number between 0 and %d (inclusive)\" % (numFonts - 1))\r\n     61                         self.numFonts = numFonts\r\n     62                         self.file.seek(header.offsetTable[fontNumber])\r\n\r\nTTLibError: specify a font number between 0 and 5 (inclusive)\r\n```\n\n### Expected outcome\n\nA pdf file saved to filesystem\n\n### Additional information\n\n_No response_\n\n### Operating system\n\nmacOS 12, M1 pro, arm64\n\n### Matplotlib Version\n\n3.5.0\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n3.8.12\n\n### Jupyter version\n\n6.4.6\n\n### Installation\n\nconda","author":{"url":"https://github.com/shaharkadmiel","@type":"Person","name":"shaharkadmiel"},"datePublished":"2021-12-09T17:23:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/21893/matplotlib/issues/21893"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:9d7ecc9b-5344-18c6-a202-f2232109357b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9CC8:2FD3E:1A8CA11:2334D3F:6A52CD2D
html-safe-nonce4d1ea7d51b13603d62af49722c6ffa68042bb60568e320be4efd2d6a71fc24eb
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Q0M4OjJGRDNFOjFBOENBMTE6MjMzNEQzRjo2QTUyQ0QyRCIsInZpc2l0b3JfaWQiOiI2MTg3OTc0NDU1NjE4MzU4NTc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac223ca8e89d9c96fc042bbdab8ebae498fccdf5216dc2b89f90d35e3fdf461c6e
hovercard-subject-tagissue:1075819791
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/21893/issue_layout
twitter:imagehttps://opengraph.githubassets.com/55620c46293d5e7f46b43d82dcade6484c626ae765127c9bd4c364eab06656c4/matplotlib/matplotlib/issues/21893
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/55620c46293d5e7f46b43d82dcade6484c626ae765127c9bd4c364eab06656c4/matplotlib/matplotlib/issues/21893
og:image:altBug summary On macOS 12, fresh install of conda-forge matplotlib 3.5.0, when saving a figure to pdf, I get: TTLibError: specify a font number between 0 and 5 (inclusive) which I can trace to: ... ~...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameshaharkadmiel
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
turbo-cache-controlno-preview
go-importgithub.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git
octolytics-dimension-user_id215947
octolytics-dimension-user_loginmatplotlib
octolytics-dimension-repository_id1385122
octolytics-dimension-repository_nwomatplotlib/matplotlib
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1385122
octolytics-dimension-repository_network_root_nwomatplotlib/matplotlib
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/issues/21893#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F21893
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fissues%2F21893
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/issues/21893
Reloadhttps://github.com/matplotlib/matplotlib/issues/21893
Reloadhttps://github.com/matplotlib/matplotlib/issues/21893
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/21893
matplotlib https://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Please reload this pagehttps://github.com/matplotlib/matplotlib/issues/21893
Notifications https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Fork 8.4k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Star 23k https://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib
Code https://github.com/matplotlib/matplotlib
Issues 1.1k https://github.com/matplotlib/matplotlib/issues
Pull requests 408 https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality 0 https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
Code https://github.com/matplotlib/matplotlib
Issues https://github.com/matplotlib/matplotlib/issues
Pull requests https://github.com/matplotlib/matplotlib/pulls
Actions https://github.com/matplotlib/matplotlib/actions
Projects https://github.com/matplotlib/matplotlib/projects
Wiki https://github.com/matplotlib/matplotlib/wiki
Security and quality https://github.com/matplotlib/matplotlib/security
Insights https://github.com/matplotlib/matplotlib/pulse
#22284https://github.com/matplotlib/matplotlib/pull/22284
[Bug]: backend_pdf gives TTLibError with pdf.fonttype : 42https://github.com/matplotlib/matplotlib/issues/21893#top
#22284https://github.com/matplotlib/matplotlib/pull/22284
backend: pdfhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22backend%3A%20pdf%22
status: confirmed bughttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22status%3A%20confirmed%20bug%22
topic: text/fontshttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22topic%3A%20text%2Ffonts%22
v3.5.2https://github.com/matplotlib/matplotlib/milestone/69
https://github.com/shaharkadmiel
shaharkadmielhttps://github.com/shaharkadmiel
on Dec 9, 2021https://github.com/matplotlib/matplotlib/issues/21893#issue-1075819791
backend: pdfhttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22backend%3A%20pdf%22
status: confirmed bughttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22status%3A%20confirmed%20bug%22
topic: text/fontshttps://github.com/matplotlib/matplotlib/issues?q=state%3Aopen%20label%3A%22topic%3A%20text%2Ffonts%22
v3.5.2https://github.com/matplotlib/matplotlib/milestone/69
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.