-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
some FreeSans characters distorted in PDF backend #903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can't see any obvious way of attaching a file in GitHub. Here's the output: http://devio.us/~mspacek/freesans_example.png I've looked at the PDF in evince, which seems to indicate that FreeSans is indeed embedded in the file. I've also viewed it with PDF XChange Viewer, which shows the same distortion. |
I'm running the latest from git by the way. |
Can you post a screen capture of what you are seeing? This is unlikely to be a bug in mpl, but rather in the PDF renderer. Some PDF viewers share similar renderers, so the same distortion could show up in multiple readers. |
Sure, here it is: http://devio.us/~mspacek/freesans_screenshot.png I can confirm that I get the same artifacts in Adobe Reader on my Android phone. The system generating these PDFs is Ubuntu 11.04 with ttf-freefont 20090104-7 |
I can confirm this with version 20100919-5 of FreeSans and matplotlib git master. As a workaround for now (as we get to the bottom of this bug), you can set the rcParam "pdf.fonttype" to 42. This will embed the entire TrueType font verbatim, so will result in larger PDF files, but the font glitches don't appear to be there. |
Looks like ttconv has a bug in converting TrueType. The zero glyph in the pdf file includes this as the inner contour:
Compare this with the fontforge output from FreeSans.ttf:
The inner curveto endpoints match (133 342, 273 50, 382 122, 417 345) but the first and final points don't (417 631 vs 275 631; note that 417 631 looks like it's a control point of the final curveto in the ttf data). Also, the pdf data ends with a lineto but the ttf data ends with a curveto. |
Does pull request #905 fix the problem? |
Yes, #905 fixes it for me. Thanks Jouni! |
Actually, I just noticed that in the .pdf, the FreeSans '1' doesn't align properly on both the x and y axes labels (see attachments above). It's too far to the right. This isn't really apparent in the .png, and doesn't happen with the default sans-serif font. Is this another truetype conversion bug? Should I file another bug? |
Does changing pdf.fontType to 42 fix the alignment issue? If it does, then it could be another TTF to Type 3 conversion bug, but if it doesn't, it sounds more like a font metrics issue. |
Changing pdf.fonttype to 42 doesn't seem to change the alignment of the FreeSans '1' on the axes. As before, the axes as displayed on screen and as saved to .png are fine, but in the .pdf the '1' is aligned somewhat too far to the right. I can tell I've correctly switched to using type 42 because the output .pdf files are much bigger than before. |
Then I don't think it's a bug in the same component as the first one. Possibly the font metrics are read wrong. |
OK, should I open up a separate issue for the alignment problem? |
Yes, I'd suggest a separate issue for that. Please see if it is backend-dependent, or occurs in both agg and pdf (and possibly svg). |
If I enable svg, I see artifacts in the resulting file that look like there are similar bugs as matplotlib#903 in svg.
Merged into v1.1.x. |
Having just tried saving to .pdf with MPL for the first time in years (potentially in place of .png, for embedding in .tex files), it looks great, except for an obvious glitch. I'm using FreeSans as my default font in rcParams, 13 pt size, and when saving to .pdf, the '0' character comes out distorted. Same goes for 'B' and '8', but none others that I can tell. This doesn't happen when saving to .png. Here's the example code
You'll have to set FreeSans as your default in rcParams to replicate this, or pass it the appropriate way when plotting or adding the text. I'll see if I can attach the output.
I suppose since this doesn't happen in the .png, this must be a PDF backend bug, and not some quirk in FreeSans?
Martin
The text was updated successfully, but these errors were encountered: