Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem where axis with no mappings was erroring out during roundtrip #630

Merged
merged 1 commit into from
Nov 5, 2020

Conversation

tomarcher101
Copy link
Contributor

Problem: during to_designspace execution in the to_glyphs, to_designspace roundtrip, an error occurs when a custom axis contains no mappings.

ValueError: min() arg is an empty sequence

This occurs because Glyphs.app does not store an axis' minimum, maximum and default values, and therefore these values are wiped during to_glyphs conversion. Normally, to_designspace recalculates these values using the sources and the axis' mapping values. However if there are no mappings in the axis, to_designspace will error.

This error can be avoided by adding identity mappings to the designspace, as to_glyphs will keep these mappings, which then provides to_designspace with the required mappings it needs to calculate the minimum and maximum values of the custom axis. However, during runtime to_designspace deletes all identity mappings, thus causing the roundtrip to fail.

The fix is to make to_glyphs create an identity mapping if one is needed (when the are no axis mappings provided in the designspace) using the axis' minimum and maximum values, so that this information is not lost. This identity mapping can then be used to recalculate the min, max values on the next to_designspace trip (which still deletes the identity mappings). Thus allowing roundtrips to not lose information.

Summary:

  • to_glyphs now stores axis min, max information as identity mappings to stop the loss of this information which previously caused errors during roundtrip.

@google-cla
Copy link

google-cla bot commented Nov 4, 2020

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@belluzj
Copy link
Collaborator

belluzj commented Nov 4, 2020

@tomarcher101 Try to remove the merge commit from master in the Dalton Maag repository, I think that's the one causing the Google CLA problem.
image

@belluzj
Copy link
Collaborator

belluzj commented Nov 4, 2020

LGTM (I reviewed this with Tom already). @anthrotype or @m4rc1e what do you think?

@belluzj belluzj merged commit 5c7c3a4 into googlefonts:master Nov 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants