There are multiple hints in the OpenType spec that rounding of fixed coordinates should be done towards infinity. Currently font-types implements round away from zero.
https://learn.microsoft.com/en-us/typography/opentype/otspec181/otvaroverview
"for fractional values of 0.5 and higher, take the next higher integer; for other fractional values, truncate"
I think this should do the trick:
diff --git a/font-types/src/fixed.rs b/font-types/src/fixed.rs
index af00c765..4033738b 100644
--- a/font-types/src/fixed.rs
+++ b/font-types/src/fixed.rs
@@ -180,7 +180,7 @@ macro_rules! fixed_mul_div {
#[inline(always)]
fn mul(self, other: Self) -> Self::Output {
let ab = self.0 as i64 * other.0 as i64;
- Self(((ab + 0x8000 - i64::from(ab < 0)) >> 16) as i32)
+ Self(((ab + 0x8000) >> 16) as i32)
}
}
Both HarfBuzz and FontTools round towards infinity and don't rely on system round.
Please discuss. @rsheeter @dfrg @cmyr @anthrotype
There are multiple hints in the OpenType spec that rounding of fixed coordinates should be done towards infinity. Currently font-types implements round away from zero.
https://learn.microsoft.com/en-us/typography/opentype/otspec181/otvaroverview
"for fractional values of 0.5 and higher, take the next higher integer; for other fractional values, truncate"
I think this should do the trick:
Both HarfBuzz and FontTools round towards infinity and don't rely on system round.
Please discuss. @rsheeter @dfrg @cmyr @anthrotype