Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[read-fonts] revert midpoint change to match FT (#1294)
A recent PR to fix an overflow changed the midpoint calculation from `(a + b) / 2` to the "equivalent" `a + (b - a) / 2` to attempt to avoid overflow with large values but this ends up producing results that don't exactly match FreeType in some cases. The results differ when `a > b` and the sum is not even. For example, when a = 7 and b = 4, the first expression is `(7 + 4) / 2` which yields 5 (and matches FreeType) while the second is `7 + (4 - 7) / 2` which yields 6. This just changes the expression to `a.wrapping_add(b) / 2` to restore compatibility while still avoiding the panic on overflow.
- Loading branch information