axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

Bug in FreeType lib for certain fonts #2034

Closed smilediver closed 4 months ago

smilediver commented 4 months ago

There's a bug in FreeType lib that manifests only for certain fonts:

https://github.com/axmolengine/axmol/blob/d8343ea6ad914790c6cedc2b31661dba65771f6b/3rdparty/freetype/src/sfnt/sfobjs.c#L1357-L1365

face->os2.fsSelection & 128 should be face->os2.fsSelection & 64. Even the comment says it should test bit 7, but it's testing bit 8. This sets wrong font ascender, descender and height.

I'll raise the issue with FreeType devs, but we should fix it locally too.

Issue on FreeType repo: https://gitlab.freedesktop.org/freetype/freetype/-/issues/1286

smilediver commented 4 months ago

Nevermind, the code is correct, since the bits start counting from 0...