Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Missing kerning for single-byte strings in PDF #19581

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

Closed
sauerburger opened this issue Feb 25, 2021 · 1 comment
Closed

Missing kerning for single-byte strings in PDF #19581

sauerburger opened this issue Feb 25, 2021 · 1 comment

Comments

@sauerburger
Copy link
Member

sauerburger commented Feb 25, 2021

Bug report

Bug summary
Kerning is not applied in the PDF output of pure single-byte strings which leads to inconsistencies between PDF and other output formats.

Code for reproduction

import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.text(0.1, 0.5, "ATL", size=120)
fig.savefig("atl.pdf")
fig.savefig("atl.png", dpi=300)

Actual outcome
text4900

Expected outcome
I expected that the spacing between A and T is consistent between both formats. Besides this minor visual issues, I use get_window_extent() to place a second text item in bold next to the first one. The space between the two texts varies significantly between output formats. get_window_extent() considers the kerning information, so the space looks correct in PNG but is usually too small in PDF files.

The issue is related to #18282. Here the same issue was fixed for strings with multi-byte chars. I don't see the changes from #18282 in version 3.3.4, but they will not effect the single-byte string case.

Unaware of #18282, I've implemented a fix for the single-byte case. I will open a PR, but you might have other ideas on how to implementation a fix.

Matplotlib version

  • Operating system: Ubuntu 16.04
  • Matplotlib version: 3.3.4
  • Matplotlib backend: TkAgg (but actually PDF?)
  • Python version: 3.7.5
  • Font: DejaVuSans Type 3

I've installed matplotlib in a virtualenv with pip.

@sauerburger sauerburger changed the title Wrong/missing kerning for single-byte strings in PDF Missing kerning for single-byte strings in PDF Feb 25, 2021
@QuLogic QuLogic added this to the v3.4.0 milestone Mar 2, 2021
@QuLogic
Copy link
Member

QuLogic commented Mar 4, 2021

Fixed by #19582.

@QuLogic QuLogic closed this as completed Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants