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

Assertion failure in _setGlyphMargin #849

Closed
simoncozens opened this issue Jun 5, 2024 · 2 comments · Fixed by #850
Closed

Assertion failure in _setGlyphMargin #849

simoncozens opened this issue Jun 5, 2024 · 2 comments · Fixed by #850

Comments

@simoncozens
Copy link
Contributor

The dottedCircle filter is dying for me, and the reason seems to be due to this assert in _setGlyphMargin:

    if hasattr(glyph, f"set{side.title()}Margin"):  # ufoLib2
        getattr(glyph, f"set{side.title()}Margin")(margin)
        assert getattr(glyph, f"get{side.title()}Margin")() == margin
In [5]: glyph.setRightMargin(160)

In [6]: glyph.getRightMargin()
Out[6]: 160.00000000000003

I don't know why ufoLib2 is doing that, but maybe the assert should be loosened to within epsilon?

@anthrotype
Copy link
Member

looks like it's using getBounds (the actual bounds, not the control points bounding box which are usually rounded to int already) to set the right margin here:

https://github.com/fonttools/ufoLib2/blob/9a238a627adc9a756eed9fd82a88e2b1858be18d/src/ufoLib2/objects/glyph.py#L507

it's probably as intended and to match defcon API so that should probably stay as is.
The assertions should probably just be removed altogether. It's as if we don't trust our own libs.. PR?

@anthrotype
Copy link
Member

@simoncozens I pushed a bugfix release v3.2.5, should be published shortly

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 a pull request may close this issue.

2 participants