Skip to content

Commit

Permalink
Merge pull request #247 from googlefonts/assert-less
Browse files Browse the repository at this point in the history
affine_between: return None instead of assert when no significant x part is found
  • Loading branch information
anthrotype committed Oct 12, 2021
2 parents 516b2fa + 99f4546 commit 42c1ba9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/picosvg/svg_reuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ def affine_between(s1: SVGShape, s2: SVGShape, tolerance: float) -> Optional[Aff
# Align the first edge with a significant x part.
# Fixes rotation, x-scale, and uniform scaling.
s2_vec1x_idx, s2_vec1x = _first_significant(_vectors(s2), lambda v: v.x, tolerance)
assert s2_vec1x_idx != -1
if s2_vec1x_idx == -1:
# bail out if we find no first edge with significant x part
# https://github.com/googlefonts/picosvg/issues/246
return None

s1_vec1 = _nth_vector(s1, s2_vec1x_idx)

s1_to_origin = Affine2D.identity().translate(-s1x, -s1y)
Expand Down

0 comments on commit 42c1ba9

Please sign in to comment.