Faulty lerp() causes slightly off weight mapping
FcWeightFromOpenTypeDouble()
and FcWeightToOpenTypeDouble()
perform a non-monotonic mapping, reporting slightly off interpolated values (except where an exact match is found). It goes like this:
[...]
ot 395.0 -> fc 79.25
ot 396.0 -> fc 79.50
ot 397.0 -> fc 79.75
ot 398.0 -> fc 80.00
ot 399.0 -> fc 80.25
ot 400.0 -> fc 80.00
ot 401.0 -> fc 80.70
ot 402.0 -> fc 80.90
ot 403.0 -> fc 81.10
[...]
whereas 400.0 -> 80.0 is the only correct mapping, the rest are a bit off.
lerp()
does a (... + dx/2) / dx
which is the typical pattern for rounding to the nearest integer instead of rounding downwards. Probably a leftover from the days it operated on integers. Now that it operates in doubles, this off-by-dx/2 needs to go.
Please apply this patch: fontconfig-lerp.patch