Skip to content

added: TTF_GetFontCapHeight() and TTF_GetFontXHeight()#612

Open
ProPuke wants to merge 3 commits intolibsdl-org:mainfrom
ProPuke:feature/cap-and-x-height
Open

added: TTF_GetFontCapHeight() and TTF_GetFontXHeight()#612
ProPuke wants to merge 3 commits intolibsdl-org:mainfrom
ProPuke:feature/cap-and-x-height

Conversation

@ProPuke
Copy link
Copy Markdown
Contributor

@ProPuke ProPuke commented Feb 19, 2026

When it comes to aligning text, it helps to know the standard height of letters.

This isn't quite the same as the ascent, as that tends to include extra space above characters for accents and things.

So this adds the ability to query the cap and x-height of letters (the standard "approximate" height of upper and lowercase characters)

If this info isn't available then it falls back to being the ascent value and 3/5ths of that for lowercase.
(I've no idea if 3/5ths is a good approximation but it looked about right, so seemed reasonable)

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