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

Text not centered vertically inside rects? #14

Open
ghost opened this issue Jun 14, 2016 · 1 comment
Open

Text not centered vertically inside rects? #14

ghost opened this issue Jun 14, 2016 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 14, 2016

Would it be possible to add functionality for centering text inside a rect both vertically and horizontally?

Right now when you use FC_DrawBox with FC_ALIGN_CENTER it only centers the text horizontally inside the rect you provide.

What do you think about renaming FC_ALIGN_CENTER to FC_ALIGN_CENTERH, and adding FC_ALIGN_CENTERV? Then the new FC_ALIGN_CENTER would then center both vertically and horizontally while the other two would do one or the other.

To do the vertical alignmentent of text inside a rect I guess you would first need to know the total number of lines that are in the text. Then use that number to calculate the y position to start drawing the lines.

@grimfang4
Copy link
Owner

Vertical alignment would be nice. I think I had held off on implementing it because I hadn't fixed the font metrics (and still haven't). The vertical measurement of the font (i.e. FC_GetHeight()) isn't actually right. It returns something bigger than the full height of the glyphs and doesn't quite match the ascent+descent that I would expect. If I remember correctly, I traced this back to something SDL_ttf was doing (in TTF_FontHeight()), but I haven't looked at it in a long time.

As for the interface, I think the vertical alignment could be an extra parameter for FC_Effect. Adding it would affect only that struct and FC_MakeEffect().

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

1 participant