foliojs / fontkit

An advanced font engine for Node and the browser
1.47k stars 219 forks source link

fix the entrySelector calculation #178

Closed Pomax closed 5 years ago

Pomax commented 5 years ago

The spec for the searchRange and entrySelector specifies the following constraints:

searchRange: (Maximum power of 2 <= numTables) x 16 entrySelector: Log2(maximum power of 2 <= numTables) rangeShift: NumTables x 16-searchRange

But the code was computing searchRange as just the power index, not the actual power of two that it should be.

Fixes #149 Fixes #179

Pomax commented 5 years ago

@devongovett ?

Pomax commented 5 years ago

Bump, again, because it's getting new issues filed over it. Can this be landed @devongovett?

Pomax commented 5 years ago

@devongovett switched ** to Math.pow and added a test to the PR to catch any future regression.

devongovett commented 5 years ago

Thanks @Pomax!