René's URL Explorer Experiment


Title: Fix usetex path optical sizing by krishsinghhura · Pull Request #32392 · matplotlib/matplotlib · GitHub

Open Graph Title: Fix usetex path optical sizing by krishsinghhura · Pull Request #32392 · matplotlib/matplotlib

X Title: Fix usetex path optical sizing by krishsinghhura · Pull Request #32392 · matplotlib/matplotlib

Description: PR summary Closes #32389 Problem In usetex mode, TextToPath.get_glyphs_tex hardcoded LaTeX compilation to a fixed FONT_SCALE = 100 pt. Because TeX fonts have size-specific optical designs, TeX selected the large 17 pt design (CMSS17) and scaled it down, while layout measurement (TexManager.get_text_width_height_descent) typeset at the actual text size (e.g. CMSS8 for 6–8 pt). This caused: Font mismatch: SVG output used CMSS17 while PDF output used CMSS8. Alignment errors: Right-aligned text with path_effects was narrower than its layout box and ended short of the alignment boundary. TextPath(size=...) issue: TextPath accepted size separately without propagating it to prop. Solution Updated TextToPath.get_glyphs_tex to typeset at the requested font size (fontsize = prop.get_size_in_points()) and rescale DVI coordinates and boxes back to FONT_SCALE units via scale = self.FONT_SCALE / fontsize. Normalizes prop via FontProperties._from_any(prop) for defensive input handling. Forwards explicit size in TextPath.__init__ to a copy of prop. Added unit tests in test_usetex.py covering optical font selection and TextPath size propagation. Reproduction & Verification Click to view reproduction code import re import matplotlib as mpl import matplotlib.patheffects as pe import matplotlib.pyplot as plt mpl.rcParams["text.usetex"] = True s = "Hamburgefonstiv" # 1. 6 pt text saved as SVG and as PDF fig = plt.figure(figsize=(2, 1)) fig.text(0.1, 0.5, s, fontsize=6) fig.savefig("usetex.svg") fig.savefig("usetex.pdf") with open("usetex.svg", encoding="utf-8") as f: svg = f.read() with open("usetex.pdf", "rb") as f: pdf = f.read() print("SVG fonts:", sorted(set(re.findall(r'id="(CM[A-Z]+\d+)-', svg)))) print("PDF fonts:", sorted({m.decode() for m in re.findall(rb"/BaseFont\s*/(?:[A-Z]{6}\+)?(\w+)", pdf)})) # 2. Right-aligned 8 pt text on Agg, without and with path effects fig = plt.figure(figsize=(1.6, 0.5), dpi=600) fig.add_artist(plt.Line2D([0.93, 0.93], [0, 1], lw=0.3, color="tab:red")) fig.text(0.93, 0.62, s, fontsize=8, ha="right", va="center") fig.text(0.93, 0.25, s, fontsize=8, ha="right", va="center", path_effects=[pe.Normal()]) fig.savefig("usetex_path_effects.png") Expected Results with this PR: Output: SVG fonts: ['CMSS8'] PDF fonts: ['CMSS8'] (Before: SVG used ['CMSS17']) Image: In usetex_path_effects.png, both lines of text align flush with the red guide line. Tests Run: pytest lib/matplotlib/tests/test_usetex.py -k "optical_sizing or textpath_size" (Passed) Regression suite: test_mathdefault, test_multiline_eqnarray, test_usetex_with_underscore, test_usetex_fallback, test_rotation, test_unicode_sizing (All passed) Code checks: git diff --check passed, no trailing whitespace or lint issues. AI Disclosure I used AI assistance to investigate the issue, trace relevant rendering paths, draft the implementation and tests, and help analyze test output. I reviewed the resulting changes, ran verification steps, and am responsible for the final contribution. PR quality check Use an expressive title (e.g. Fix usetex path font optical sizing and alignment) New and changed code is tested [N/A] Plotting related features are demonstrated in an example [N/A] New features and API changes have release notes Documentation complies with general and docstring guidelines

Open Graph Description: PR summary Closes #32389 Problem In usetex mode, TextToPath.get_glyphs_tex hardcoded LaTeX compilation to a fixed FONT_SCALE = 100 pt. Because TeX fonts have size-specific optical designs, TeX sele...

X Description: PR summary Closes #32389 Problem In usetex mode, TextToPath.get_glyphs_tex hardcoded LaTeX compilation to a fixed FONT_SCALE = 100 pt. Because TeX fonts have size-specific optical designs, TeX sele...

Opengraph URL: https://github.com/matplotlib/matplotlib/pull/32392

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.3

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:ef362ef7-0a2a-9efe-dbe8-6a940983764e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9758:1577AD:66E018:8C9A8B:6B06859B
html-safe-noncec147b5d20c97f4d2a6e471566ac300e386f7880dbd6fb899a3acb07df304974f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzU4OjE1NzdBRDo2NkUwMTg6OEM5QThCOjZCMDY4NTlCIiwidmlzaXRvcl9pZCI6IjY4NDA3ODM2ODA0NTg2MjIzNjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacc542d22671a2f83ce07d95fbde4b37f632572050266c626db1dac12f5b0704a4
hovercard-subject-tagpull_request:4632137603
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/32392/files
twitter:imagehttps://avatars.githubusercontent.com/u/95937258?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/95937258?s=400&v=4
og:image:altPR summary Closes #32389 Problem In usetex mode, TextToPath.get_glyphs_tex hardcoded LaTeX compilation to a fixed FONT_SCALE = 100 pt. Because TeX fonts have size-specific optical designs, TeX sele...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4462ff7ebfd3d551f202659f2423dae617b6849d23b1df6465dc504ef497d14a
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release6d3909414814ff86ce7da4c51a0f4918a13fb41b
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/matplotlib/matplotlib/pull/32392/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fpull%2F32392%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmatplotlib%2Fmatplotlib%2Fpull%2F32392%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=matplotlib%2Fmatplotlib
Reloadhttps://github.com/matplotlib/matplotlib/pull/32392/files
Reloadhttps://github.com/matplotlib/matplotlib/pull/32392/files
Reloadhttps://github.com/matplotlib/matplotlib/pull/32392/files
matplotlibhttps://github.com/matplotlib
matplotlibhttps://github.com/matplotlib/matplotlib
Codehttps://github.com/matplotlib/matplotlib
Issues1k (1k)https://github.com/matplotlib/matplotlib/issues
Pull requests429 (429)https://github.com/matplotlib/matplotlib/pulls
Actionshttps://github.com/matplotlib/matplotlib/actions
Projectshttps://github.com/matplotlib/matplotlib/projects
Wikihttps://github.com/matplotlib/matplotlib/wiki
Security and qualityhttps://github.com/matplotlib/matplotlib/security
Insightshttps://github.com/matplotlib/matplotlib/insights
Sign up for GitHub https://github.com/signup?return_to=%2Fmatplotlib%2Fmatplotlib%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmatplotlib%2Fmatplotlib%2Fissues%2Fnew%2Fchoose
krishsinghhurahttps://github.com/krishsinghhura
matplotlib:mainhttps://github.com/matplotlib/matplotlib/tree/main
krishsinghhura:fix/usetex-optical-sizinghttps://github.com/krishsinghhura/matplotlib/tree/fix/usetex-optical-sizing
Conversation 10 https://github.com/matplotlib/matplotlib/pull/32392
Commits 4 https://github.com/matplotlib/matplotlib/pull/32392/commits
Checks 38 https://github.com/matplotlib/matplotlib/pull/32392/checks
Files changed https://github.com/matplotlib/matplotlib/pull/32392/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/32392/files
Fix usetex path optical sizing https://github.com/matplotlib/matplotlib/pull/32392/files#top
Show all changes 4 commits https://github.com/matplotlib/matplotlib/pull/32392/files
191f6b2 Fix usetex path optical sizing krishsinghhura Sep 24, 2026 https://github.com/matplotlib/matplotlib/pull/32392/commits/191f6b233cb6dccf811d7542bfb5f5bbbf7e9ba0
09111da Update usetex SVG rotation baseline krishsinghhura Sep 25, 2026 https://github.com/matplotlib/matplotlib/pull/32392/commits/09111da3737aec89b216be16f6c965328cf4dfd0
fd2327d Regenerate usetex TextPath on resize krishsinghhura Oct 2, 2026 https://github.com/matplotlib/matplotlib/pull/32392/commits/fd2327df8fefecf8cabe51dec48ba0db51ff92c1
d5c90fb Preserve readonly TextPath data after usetex resize krishsinghhura Oct 2, 2026 https://github.com/matplotlib/matplotlib/pull/32392/commits/d5c90fbaad6cff39a0867763d55e72508fd2bdde
Clear filters https://github.com/matplotlib/matplotlib/pull/32392/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/32392/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/32392/files
rotation.svg https://github.com/matplotlib/matplotlib/pull/32392/files#diff-35ae85fcf8ad9611debcad28f918d3f2bc75c080e0e940ce456ad62fc3db36d6
test_backend_svg.py https://github.com/matplotlib/matplotlib/pull/32392/files#diff-596c8e30ca12976a87641765ff0dcb16ce3da0c8af5525b8067b5f1c03831a2f
test_usetex.py https://github.com/matplotlib/matplotlib/pull/32392/files#diff-0680f8d39441f209b641018044255dd0c54003866ab8d8975efc18fe372289a9
textpath.py https://github.com/matplotlib/matplotlib/pull/32392/files#diff-574862438bd94ff599818f86767104b56673fa6df2ecb067a1254c842f281f4d
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/32392/files
Please reload this pagehttps://github.com/matplotlib/matplotlib/pull/32392/files
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlno-cache

Viewport: width=device-width


URLs of crawlers that visited me.