nothings / stb

stb single-file public domain libraries for C/C++

Home Page:https://twitter.com/nothings

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

stb_truetype: GPOS advance always 0 (while GPOS and KERN tables exist), while KERN works fine

Bohaterowicz opened this issue · comments

Describe the bug
I am trying to get kerning advance positions for 'Times New Roman' font from Window 11 fonts. The stbtt_fontinfo seems to be correctly populated and I get proper glyphs and advance/lsb values, but when getting kerning offsets it always results in 0 even though both kern and gpos tables are set. While investigating this I manually disabled gpos table in 'stbtt_GetGlyphKernAdvance' which resulted in getting offset value from kern table which resulted in proper (seemingly correct) offset. From quick debugging session it seems that the code gets stuck in 'stbtt__GetGlyphGPOSInfoAdvance' and never gets past the 'if (lookupType != 2)' check. My test case I used while debugging was to try and get 'stbtt_GetGlyphKernAdvance' value between 'T' and 'e' codepoints with a 'Times new roman' font. The result is 0 (it uses GPOS by default), when forced to use KERN it returns -143.
To Reproduce

  1. Init "Times New Roman" font.
  2. Call 'stbtt_GetGlyphKernAdvance' with the initialized font and codepoints of 'T' and 'e'
  3. Result should be 0, if one forces 'kern' and not 'gpos' result should be non-zero.

Expected behavior
Advanace should be non-zero when calling 'stbtt_GetGlyphKernAdvance' with 'Times new roman' and codepoints 'T' and 'e', as the 'e' glyph is slightly pushed into the 'T' glyph bounding box