-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
stb_truetype: Weird kerning #281
Comments
I didn't write the kerning code and I've never used it. I don't know when I'll get a chance to look at it. |
(Also, btw, note that your code won't actually work correctly if a pair of characters does get kerned together tightly, as the later character will partially erase the earlier character if their bounding boxes overlap (which often happens with kerning). The sample code at the top of stb_truetype explains how this is a bug.) |
That looks pretty wrong without kerning too. Ok, I guess the big question is whether the reference image you say 'came from microsoft' was actually directly rendered, or whether someone hand-kerned it. If the former, then clearly there's info in the font to fix it; if the latter, it may not be a bug at all. |
You might try taking the second value from GetHMetrics ("left side bearing" or "lsb") and using that as an extra horizontal offset for each character (not applied as an advance, just to offset the x position of each char). I don't know if this is necessary, I don't do it anywhere so I thought it wasn't, but maybe it is. |
I'm leaving this open since I need to fix the samples. |
Actually I suspect this isn't a bug and the issue isn't that you should use lsb, but rather that you're not using x1 (which may or may not have the same functionality, but is the approved way to do it). |
I'm getting weird kernings on stb_truetype in any recent version up to the latest, v1.11. And I'm unsure if this is an issue with my code, the fonts I'm using or stb_truetype. This has happened to me so far with Segoe UI Light (5.53) and Source Sans Pro Light (2.020).
The problem is,
stbtt_GetCodepointKernAdvance
is returning almost always 0 (sometimes uppercase followed by lowercase is non-zero). This is how my text renderer works:This is the output with Segoe UI Light:
Expected result:
Sorry about the diffent font size, the second image comes from Microsoft. Looking for support on the internet about this, I've also seen other people noticing this kerning issue.
The text was updated successfully, but these errors were encountered: