PIL
text provider: Ensure consistent text height to prevent text from bouncing when typing
#8511
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using the
PIL
text provider to render text, the height of the text will be computed incorrectly. When typing text, for example, the text will be "jumping/bouncing". The code in this PR gets the actual height of the font, in order to get a consistent height for the text, and prevent this type of behavior from occurring.Before:
before.mp4
After:
after.mp4
Test code:
Note: Use "d" and "f" to change fonts.
This PR also removes the deprecated
FreeTypeFont.getsize()
.FreeTypeFont.getsize()
is deprecated since version 9.2.0Maintainer merge checklist
Component: xxx
label.api-deprecation
orapi-break
label.release-highlight
label to be highlighted in release notes.versionadded
,versionchanged
as needed.