Implement TTF_GetFontBBox() which returns font's extremum bounding box #583
+56
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #536
(This is a remake of #538 ported to SDL3-backed branch)
This adds a new function called TTF_GetFontBBox:
This function returns font's bounding box, which defines the maximal bounds enough to contain any glyph from the font.
My understanding is this information is only available when reading the scalable font formats, so for non-scalable fonts this function always returns "false". (If that's wrong, then the function may be trivially updated to cover bitmap fonts as well.)
TTF_GetFontBBox complements TTF_GetGlyphMetrics, and is useful in a case when you need to know max possible bounds instead of particular glyph's bounds. The "bbox" information is available in the format header, thus it can be obtained without measuring every single glyph.
Since I was previously asked to explain use cases for this function, here are couple of real examples from my practice: