Skip to content

Commit

Permalink
take the min(sx,sy) when decomposing scale transform to minimise Over…
Browse files Browse the repository at this point in the history
…flowErrors
  • Loading branch information
anthrotype committed Mar 14, 2023
1 parent 5e6281b commit 7d341f5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/nanoemoji/paint.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ def round(self, ndigits: int) -> "PaintLinearGradient":

def _decompose_uniform_transform(transform: Affine2D) -> Tuple[Affine2D, Affine2D]:
scale, remaining_transform = transform.decompose_scale()
s = max(*scale.getscale())
# we take the minimum of (sx, sy) to try to minimize the risk of OverflowErrors
# when encoding these to F16Dot16
s = min(*scale.getscale())
# most transforms will contain a Y-flip component as result of mapping from SVG to
# font coordinate space. Here we keep this negative Y sign as part of the uniform
# transform since it does not affect the circle-ness, and also makes so that the
Expand Down

0 comments on commit 7d341f5

Please sign in to comment.