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

Support vertical alignment #79

Open
dhardy opened this issue Feb 23, 2023 · 2 comments
Open

Support vertical alignment #79

dhardy opened this issue Feb 23, 2023 · 2 comments

Comments

@dhardy
Copy link

dhardy commented Feb 23, 2023

Often for a simple layout it's desirable to centre vertically. Since a Buffer considers the size an input, this library should probably also support top/center/bottom vertical alignment?

#70 affects this slightly; there's still a need to be able to measure height after layout (also #42).

@therocode
Copy link

Also hitting the lack of this feature - I was actually a bit surprised, seems like a very basic thing to expect from a text API. Pretty much all text APIs I've worked with before would at least have horizontal align (Left, Center, Right) and vertical align (Top, Center, Bottom).

Does anyone know a good way to approximate, or hack this behaviour?

@bschwind
Copy link

@therocode I don't know how useful this is, but I do my own vertical alignment by shaping the text and measuring its height, then offsetting the Y value accordingly:

https:/bschwind/simple-game/blob/12187d4b8df413cb4cae136b43ffd6e870a7488a/src/graphics/text.rs#L618-L637

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

No branches or pull requests

3 participants