Skip to content

Font size rendering #1580

Closed Answered by nothings
rjopek asked this question in Q&A
Nov 21, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

There isn't actually a guaranteed simple ratio, as the two are computed via different mechanisms.

stbtt_ScaleForPixelHeight (used by BakeFontBitmap) looks at the (reported) font bounding box info and is guaranteed to produce reasonable results (as long as the bounding box info is correct, which it basically always is).

stbtt_ScaleForMappingEmToPixels (used for STBTT_POINT_SIZE) uses the reported "unitsPerEm" field of the font, which I found through experience was sometimes wildly wrong in amateur fonts. This can be seen in programs that use traditional font units; as you cycle through fonts in photoshop, you may see the text size change radically if you've installed non-standard fonts.

Si…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@nothings
Comment options

Answer selected by rjopek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants