You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tight_layout and font hinting cuts text near the edge #11551
As you can see the PDF backend always uses LOAD_NO_HINTING while the Agg backend uses whatever the user specifies. The only workaround that I've found is enabling the commented out line in the testcase above.
I just tested with the latest main (8001579) and I still see the same problem. Can you share your reproduction script? Maybe the border fixes the original problem?
And it looks like I do not have access to reopen this issue so tagging @oscargus if he could reopen it. Thanks!
Can you share your reproduction script? Maybe the border fixes the original problem?
Sorry, didn't see this until now. I used exactly the same script as here (without anything in the matplotlibrc file IIRC). I was a bit unclear about the border though. That is the background from the PDF viewer (Drawboard PDF, hence the black background.) Seems to work for me with Acrobat reader, Firefox, Chrome and Edge as well.
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
Tested with latest main (bdbbb2d). The problem is still here. Note that a possible solution would be the following patch:
diff --git a/lib/matplotlib/mpl-data/matplotlibrc b/lib/matplotlib/mpl-data/matplotlibrc
index d419ed6..da30232 100644
--- a/lib/matplotlib/mpl-data/matplotlibrc+++ b/lib/matplotlib/mpl-data/matplotlibrc@@ -290,7 +290,7 @@
## ("native" is a synonym.)
## - force_autohint: Use FreeType's auto-hinter. ("auto" is a synonym.)
## - no_hinting: Disable hinting. ("none" is a synonym.)
-#text.hinting: force_autohint+#text.hinting: default
#text.hinting_factor: 8 # Specifies the amount of softness for hinting in the
# horizontal direction. A value of 1 will hint to full
It's worth noting that the change from LOAD_DEFAULT to LOAD_FORCE_AUTOHINT happened in commit 3299a39 by @mdboom.
Activity
prekageo commentedon Dec 17, 2019
For anyone who might try to resolve this issue, the relevant lines of code have changed. For the current master 303d515, the lines are:
matplotlib/lib/matplotlib/backends/_backend_pdf_ps.py
Line 102 in 303d515
matplotlib/lib/matplotlib/backends/backend_agg.py
Line 180 in 303d515
oscargus commentedon Jun 3, 2022
This seems to have been solved. The current output is:

(The black border is to make it more clear how much padding there is, indeed a bit more than in the "good.pdf" in the OP.)
prekageo commentedon Jun 10, 2022
I just tested with the latest main (8001579) and I still see the same problem. Can you share your reproduction script? Maybe the border fixes the original problem?
And it looks like I do not have access to reopen this issue so tagging @oscargus if he could reopen it. Thanks!
jklymak commentedon Jun 13, 2022
I can reproduce the problem with
tight_layout. If you used constrained_layout, things seem better?output.pdf
which makes it a bit mysterious why tight_layout is getting the wrong bbox, as the code should be the same.
oscargus commentedon Jun 13, 2022
Sorry, didn't see this until now. I used exactly the same script as here (without anything in the matplotlibrc file IIRC). I was a bit unclear about the border though. That is the background from the PDF viewer (Drawboard PDF, hence the black background.) Seems to work for me with Acrobat reader, Firefox, Chrome and Edge as well.
prekageo commentedon Jul 3, 2022
Sorry for the delay.
@jklymak Using
constrained, the problem goes away.@oscargus I've opened the attached PDF (https://github.com/matplotlib/matplotlib/files/2155253/bad.pdf) with Acrobat, Firefox and Chrome and it renders in the same way in all 3. The letters are cut near the edge. Can you share your generated PDF? I also opened it with Drawboard online (https://pdf.drawboard.com/documents/5d847711eca34829aabf472a0db7b759) and the text is still cut.
github-actions commentedon Jul 5, 2023
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
george-enf commentedon Jul 5, 2023
Tested with 3.7.1. The problem is still here.
github-actions commentedon Jul 24, 2024
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!
prekageo commentedon Jul 25, 2024
Tested with latest main (bdbbb2d). The problem is still here. Note that a possible solution would be the following patch:
It's worth noting that the change from
LOAD_DEFAULTtoLOAD_FORCE_AUTOHINThappened in commit 3299a39 by @mdboom.QuLogic commentedon Jul 1, 2025
#29816 will change hinting to default.