-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Font 42 kerning #20615
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
Font 42 kerning #20615
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -741,3 +741,10 @@ def test_parse_math(): | |
ax.text(0, 0, r"$ \wrong{math} $", parse_math=True) | ||
with pytest.raises(ValueError, match='Unknown symbol'): | ||
fig.canvas.draw() | ||
|
||
|
||
@image_comparison(['text_pdf_font42_kerning.pdf'], style='mpl20') | ||
def test_pdf_font42_kerning(): | ||
plt.rcParams['pdf.fonttype'] = 42 | ||
plt.figure() | ||
plt.figtext(0.1, 0.5, "ATAVATAVATAVATAVATA", size=30) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this the only kerning you were fixing? If not, maybe some of the other kerning pairs would be useful here rather than repeating the same one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean pairings of glyphs? I'd hope the font defines kerning correction for more pairs. I chose this string because there the effect is obvious even without a pixel-by-pixel comparison. For this specific issue, the test targets the presence of any kerning. However, I will modify the string in the next iteration. Or, are you more worried about single-byte vs multi-byte vs beyond-BMP character pairings? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, if you are sure this tests for any kerning and we don't need to test other kerning pairs, thats fine. (I have no idea what the different pairings are technically ;-)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The kerns come from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be explicit in the code and should we raise for other fonttypes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have rcParam checks that disallow other fonttypes..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've learned to be catious. If somebody implements a new fonttype, they may overlook this function. So, forcing future font types to make an explicit decision here is a plus (Unless you say that the default should generally be True and the Type-3 handling is a rare exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the moment, the function is only called in case of a Type 3 or 42, but I agree it's probably safer to raise a
NotImplementedError
(?) if the font type is neither.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could imagine an object-oriented solution where the different types of fonts are different classes, and this would be a method on the font. But that would likely be unnecessary overengineering. Perhaps the
NotImplementedError
is sufficient defence against future accidents.