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: stbtt_GetCodepointHMetrics() outputs weird advanceWidth values after being called several times

Alihene opened this issue · comments

Describe the bug
When calling stbtt_GetCodepointHMetrics() on every character of a string, after a certain point the advanceWidth ends up being set to weird values. When using Arial, the advance width gets set to 13235 at a certain character and then 0 for the remaining characters. The point at which the values get weird varies for every string, The values are sometimes negative as well, for example -32548. however it mostly occurs in strings that are 30+ characters long. As a side note, no kerning is present.

To Reproduce

  1. Init "Arial" font
  2. Loop through every character in the string abcdefghijklmnopqrstuvwxyz1234567890 and call stbtt_GetCodepointHMetrics() on every character (the advanceWidth should become 13235 for the character 8)

Expected behavior
The advanceWidth should be the correct advance width for the character.

Screenshots
Screenshot_20240128_152223