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

Filters (shallow-)copy glyph set by default #708

Open
madig opened this issue Feb 14, 2023 · 2 comments
Open

Filters (shallow-)copy glyph set by default #708

madig opened this issue Feb 14, 2023 · 2 comments

Comments

@madig
Copy link
Collaborator

madig commented Feb 14, 2023

The filter seems to not draw a dottedCircle into a UFO, unless you pass in the glyphset/layer expliticly:

from ufoLib2 import Font
from ufo2ft.filters.dottedCircleFilter import DottedCircleFilter
ufo = Font()
ufo.info.xHeight = 500
philter = DottedCircleFilter()
philter(ufo)
assert "dottedCircle" in ufo or "uni25CC" in ufo

Fails on the assert. It passes if you call philter(ufo, ufo.layers.defaultLayer).

Is this intended behavior?

@anthrotype
Copy link
Member

definitely not intended behaviour. is this only happening with DottedCircleFilter or with any other filter?

@madig madig changed the title DottedCircleFilter copies glyphset by default? Filters (shallow-)copy glyph set by default Feb 14, 2023
@madig
Copy link
Collaborator Author

madig commented Feb 14, 2023

As Cosimo found:

self = cls((g.name, g) for g in layer)

This shallow copy is fine if you mod existing glyphs, but here we add a glyph, landing it in nirvana. @anthrotype says we should maybe change all instances of glyphSet = _GlyphSet.from_layer(font) to glyphSet = font.layers.defaultLayer in filters. The problem doesn't typically come up because ufo2ft's preprocessor code makes and uses its own glyphsets and passes them in explicitly, whereas here we implicitly want the current UFO to be modified.

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

No branches or pull requests

2 participants