-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Implement anchor for TrueType fonts #4930
Conversation
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.
f-strings!
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Horizontal anchor alignment | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
``l`` --- left |
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.
Nit: and for these triple dashes?
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.
- A colon or shorter dash made the description too close and a little harder to read.
- According to most style guides, the em-dash is an alternative to the colon, see https://en.wikipedia.org/wiki/Dash#Usage_2
(side note: --
is an en-dash and ---
is an em-dash with Sphinx by default: https://www.sphinx-doc.org/en/master/usage/configuration.html?highlight=em-dash#confval-smartquotes_action)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
if direction == "ttb": | ||
raise ValueError("ttb direction is unsupported for multiline text") |
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.
Forgot to mention: I didn't implement anchor handling for vertical multiline text due to #4945, so instead this raises an error to avoid confusion due to unexpected anchor values.
Second part of #4724, implementing anchor parameter to fix #4511.
Changes proposed in this pull request:
Implement
anchor
parameter for text positioning.See proposed documentation for details: https://pillow--4930.org.readthedocs.build/en/4930/handbook/text-anchors.html
Add tests for Vertical text alignment ignores yOffset #4553 and related issues (fixed in Refactor font_getsize and font_render #4910). Closes Vertical text alignment ignores yOffset #4553.
Remove the additional offset caused by stroking text.
This was incompatible with the anchor implementation and I believe it to be a bug; I don't think users should need to offset text just to stroke a single word in the middle of a line.