Skip to content

Commit

Permalink
[write-fonts] iup: fixup vector distance calculation
Browse files Browse the repository at this point in the history
We were checking the axes independently, instead of checking the overall
length of the vector.
  • Loading branch information
cmyr committed Sep 27, 2023
1 parent d0a208b commit c4679e5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion write-fonts/src/tables/gvar/iup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,12 @@ fn can_iup_in_between(

let real_values = &deltas[(from + 1) as usize..to];

// compute this once here instead of in the loop
let tolerance_sq = tolerance.powi(2);
Ok(real_values
.iter()
.zip(iup_values)
.all(|(d, i)| (d.x - i.x).abs() <= tolerance && (d.y - i.y).abs() <= tolerance))
.all(|(d, i)| (*d - i).hypot2() <= tolerance_sq))
}

/// <https://github.com/fonttools/fonttools/blob/6a13bdc2e668334b04466b288d31179df1cff7be/Lib/fontTools/varLib/iup.py#L327>
Expand Down

0 comments on commit c4679e5

Please sign in to comment.