Skip to content
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

Introduce text_size_info and change back where text is positioned #692

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

vbfox
Copy link

@vbfox vbfox commented Oct 25, 2024

text_size_info can give both the box where the font wants to be logically placed to form a line (But depending on the font it might draw pixels out of this box) and the pixel-bounding box where pixels were really placed.

I know that it'll be controversial as it changes some details from #689 but I think it's the right choice:

  • Fonts can put pixels out of any of the "logical" bounds passed to them, most of the time it's a little overshoot but some fonts can draw widely out of their boxes. px_bounds doc essentially says "everything goes" and trying to guess the pixel size from the reported logical size by the font is bound to create errors.
  • Sometimes when positioning you want the logical box (To position more text after/under) and sometimes the pixels (To visually center the pixels)

By providing both, the consumer can take correct decisions.

I'm not sure what text_size should return, as the logical size is bound to be a bit surprising (some pixels would go out of there) but the pixel size is useless to position text relative to other text...

I'm opening this PR more as a discussion starter, as I think whatever design ends up being the final one the coordinate system and it's relation with the sizing methods need to be documented in the draw methods.

text_size_info can give both the box where the font wants to be
logically placed to form a line (But depending on the font it might draw
pixels out of this box) and the pixel-bounding box where pixels were
really placed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant