fontMath icon indicating copy to clipboard operation
fontMath copied to clipboard

italicAngle with anisotropic interpolations

Open typemytype opened this issue 11 months ago • 6 comments

The big picture:

from fontMath import MathInfo
from defcon import Info

i1 = Info()
i1.italicAngle = 0
i2 = Info()
i2.italicAngle = 0

mi1 = MathInfo(i1)
mi2 = MathInfo(i2)

r = mi1 + (mi2 - mi1) * (-0.21, -0.386)

print(r.italicAngle)

This prints out -180.0 as a interpolation result for the italicAngle.

Narrowed down to the factorAngle function:

from fontMath.mathFunctions import factorAngle
from fontMath.mathFunctions import mul

r = factorAngle(0, (-0.21, -0.21), mul)
print(r)

I have no solution, factorAngle divides the angle to sin/cos mimicking x/y and applies the anisotropic factor, which makes sense, only the result is not as expected.

typemytype avatar Apr 08 '25 12:04 typemytype

See also https://github.com/robotools/fontMath/issues/236

LettError avatar Apr 08 '25 13:04 LettError

In the factor (-0.21, -0.21) the x and y are flipping to negative. That would make all points flip to below the baseline, and left of the leftMargin. What value would we expect for the italic angle in this case? -180 is vertical, down, right? It might make sense?

LettError avatar Apr 08 '25 13:04 LettError

the math makes totally sense, only unexpected when the starting italic angle is 0 and you get -180.

typemytype avatar Apr 08 '25 13:04 typemytype

Do you really need to scale (-0.21, -0.386) or was that for the demo?

LettError avatar Apr 08 '25 13:04 LettError

its a sliders setting from UFOStretch

typemytype avatar Apr 08 '25 13:04 typemytype

Is the input being 0 the only case that this is unintuitive? If so, would it be inelegant to just add a check and zero it out?

def factorAngle(angle, f, func):
    if angle == 0 and func in (mul, div):
        return 0.0
    # ...

Otherwise, is there a way to use tan or something, rather than separating out x and y using sin and cos?

ryanbugden avatar Apr 08 '25 16:04 ryanbugden