Title: macosx backend doesn't find fonts the same way as other backends · Issue #781 · matplotlib/matplotlib · GitHub
Open Graph Title: macosx backend doesn't find fonts the same way as other backends · Issue #781 · matplotlib/matplotlib
X Title: macosx backend doesn't find fonts the same way as other backends · Issue #781 · matplotlib/matplotlib
Description: All of the other backends appear to use matplotlib.font_manager.findfont() to look up the path for a given font file to use. However, the macosx backend has its own font-lookup mechanism: src/_macosx.m line 2256, setfont(). This mechanis...
Open Graph Description: All of the other backends appear to use matplotlib.font_manager.findfont() to look up the path for a given font file to use. However, the macosx backend has its own font-lookup mechanism: src/_maco...
X Description: All of the other backends appear to use matplotlib.font_manager.findfont() to look up the path for a given font file to use. However, the macosx backend has its own font-lookup mechanism: src/_maco...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/781
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"macosx backend doesn't find fonts the same way as other backends","articleBody":"All of the other backends appear to use `matplotlib.font_manager.findfont()` to look up the path for a given font file to use. However, the macosx backend has its own font-lookup mechanism: `src/_macosx.m` line 2256, `setfont()`.\n\nThis mechanism is essentially an odd way to look up the pre-defined PS fonts, and in particular:\n1. looks only at the font-family name, and does not defer to font-family preference lists from rcParams, such as \"font.sans-serif\" etc.\n2. does not take any properties into account except for a weight that is exactly \"bold\" or a variant that is exactly \"italic\".\n\nIt is possible to get this font-lookup to find an arbitrary font by passing a PS-style name such as \"MyriadPro-Semibold\" as the font-family, but this doesn't work for other backends. (`findfont()` requires the semibold to be passed in as a weight property, not the family name, even though the eventual file returned is named \"MyriadPro-Semibold.otf\")\n\nThere are several possible solutions; I'm not sure which is best:\n1. make `findfont()` look up fonts by fully-qualified name such as \"MyriadPro-Semibold\", so that this style could be used for all backends.\n2. make a function to return a compatible name for a given font found by `findfont()`. Perhaps this would just be the filename (sans extension) from the path returned by `findfont`?\n3. fix `src/_macosx.m:setfont()` to load a font from a path passed in. I get the feeling that this isn't exactly the \"encouraged\" way to deal with fonts on OS X though...\n\nThe downside of using `findfont()`, and why I presume the macosx backend doesn't, is that FreeType2 (and thus `findfont()`) can't deal with dfont and other font suitcase types, which can be easily loaded by the cocoa font-lookup routines in _macosx.m. But using such fonts results in the case where one can display a plot on OS X, but saving it creates an error. \n\nAny thoughts? Would it be better to funnel things through `findfont()` for consistency, at the cost of not being able to use some of the basic fonts on OS X (Helvetica, Courier, etc., are all dfonts -- but hence couldn't be used for figure-saving anyway)? That's option 2 or 3. Or better to leave OS X as it is, and just let other backends look up available fonts by filename too? (Option 1)\n","author":{"url":"https://github.com/zpincus","@type":"Person","name":"zpincus"},"datePublished":"2012-03-21T15:05:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/781/matplotlib/issues/781"}
| 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:3ebe85de-5b62-5e53-13c8-98ae50740e14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 876E:13266C:3E90F1:5546FD:6A5249C8 |
| html-safe-nonce | 42927e79319d1664a990e0d06870de1440f0e7077c524fb0f59c7275fc5189dc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzZFOjEzMjY2QzozRTkwRjE6NTU0NkZEOjZBNTI0OUM4IiwidmlzaXRvcl9pZCI6IjIyNzM3Mjc0ODc1MzA5MTIyMDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4edc946625aa029affb0e23422c834ed01319dfada38937ee5b10856b5e06da7 |
| hovercard-subject-tag | issue:3746972 |
| 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/781/issue_layout |
| twitter:image | https://opengraph.githubassets.com/251aa4e69b37deebd440a166930788f0e1000345a0549344bf865cf94f6004b6/matplotlib/matplotlib/issues/781 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/251aa4e69b37deebd440a166930788f0e1000345a0549344bf865cf94f6004b6/matplotlib/matplotlib/issues/781 |
| og:image:alt | All of the other backends appear to use matplotlib.font_manager.findfont() to look up the path for a given font file to use. However, the macosx backend has its own font-lookup mechanism: src/_maco... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zpincus |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width