-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Font::getVerticalSize computes incorrect ascenders and descenders for TTF fonts #1287
Comments
I'm afraid I can't recall stuff from 12 years ago. The change must have been made to address an issue experience some some user at some point, perhaps archive of osg-users mailing list. |
Understandable. I worked around this by using Freetype directly. Fixing this properly would be a breaking change, as users might be relying on the current implementation. Giving OSG's state, I'm guessing it's not worth it. Should I leave this open as documentation that it's a known bug? |
FreeTypeFont::getVerticalSize
relies onFreeTypeFont::getCoordScale
instead ofunitsPerEm
to compute the ascender and descender.FreeTypeFont::getCoordScale
uses_currentRes.second * 64
where _currentRes.second is initialized to 32 and then changes arbitrarily whenever a glyph is computed. So if a font happens to have 2048unitsPerEm
, and nothing ever calledgetGlyph
yet, the font will return the correct ascender and descender. Otherwise you get an arbitrary number that can't be used.I wanted to use that to compute a stable height for my text that won't jump up and down as the text contents change dynamically (see #1269).
I see that there was initially code scaling the ascender and descender correctly with
unitsPerEm
but that is currently disabled with#if 0
. Any idea why that is? It seems to come from here, but that's a very old commit with very little context.The text was updated successfully, but these errors were encountered: