Skip to content

instantiator: direct interpolation of component.transform elements is problematic with rotation #949

@anthrotype

Description

@anthrotype

the ufo2ft.instantiator which is used to generate UFO instances as well as to generate missing component glyph instances when decomposing composite glyphs in variable fonts uses fontMath to do the interpolation.

fontMath.MathGlyph, by default, interpolate component transformation matrices directly element by element, which works when the transformation only contains basic scale/skew/translation but could break badly if there was some rotation.

MathGlyph has an option which we currently do not use in the instantiator called scaleComponentTransform (True by default):

If scaleComponentTransform is False, then only the component's xOffset and yOffset attributes are scaled, whereas the xScale, xyScale, yxScale and yScale attributes are kept unchanged.

this would be equally wrong, and not what we want.

Ideally the transformation should be decomposed into its separate translate, rotation, scale and skew components (perhaps using the relatively recent fonttools.misc.transform.DecomposedTransform class?) and interpolate each of these independently and then finally recompose the affine transformation.

fontMath also has a very old module called mathTransform.py which doesn't seem to be even used within fontMath itself, which basically does exactly that. I wonder why it was never plugged into the main MathGlyph...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions