Comments (9)
You could subscribe to both Font.Changed and Glyph.Changed
In Glyph.Changed you just collect the names of glyphs that has changed
And in the single Font.Changed notification you perform your task only on the collected changed glyphs
from defcon.
knowing which glyph belongs to which font requires to run getParent on each glyphs which is also an extra task
Or glyph.font, it's just an attribute lookup.
from defcon.
All good points. Still if any notification fe: "Font.Changed" holds a dictionary of changed parts of its child fe: font.lib or glyphs it would be more convenient to deal with all the changes in one place and also could reduce number of tasks.
from defcon.
I can't see how this could be done without the same performance penalty as what you did yourself since notifications propagate upwards, there's one Font.Changed after each Glyph.Changed. Font.Changed notifications aren't an accumulation of multiple changes.
from defcon.
Maybe it doesn't have any effect in defcon but in usage it makes it possible to have all the information in one place. For example instead of adding multiple observers, one observer provides all the info about which part was changed. Then user could choose which part to deal with. Doesn't it make the code cleaner?
from defcon.
I also found another issue with the order of notifications in the first scenario. I realized that 'Font.Changed' posts first so if a glyph has been changed and I want to collect it through 'Glyph.Changed' and my task is executed in the 'Font.Changed', then no glyphs are collected and no task will be performed since 'Font.Changed' was posted first then the glyph was collected after in the 'Glyph.Changed'. I added the observers in different order but result was same.
from defcon.
Ok I realized that my algorithm was written before I knew how things work in defcon. Now I do only glyph related tasks in 'Glyph.Changed' and do the major task that could be heavy after 'Font.Changed' was posted and it works well. Thanks and sorry for the inconvenience.
from defcon.
Forgot to add this. 'Font.Changed' will be posted before the 'Glyph.Changed' so anyway the major task also has to be done inside the 'Glyph.Changed'. I hold off the heavy task by checking if the glyph is used as component in other glyphs then when all of them posted their notifications I perform the task. So using 'Font.Changed' in this case is not good way of making things faster.
from defcon.
'Font.Changed' will be posted before the 'Glyph.Changed'
That's odd, normally notifications propagate upwards, i.e. Contour -> Glyph -> Layer -> LayerSet -> Font
from defcon.
Related Issues (20)
- Infinite loop on notification HOT 1
- follow glyphs.unicode changes from fontParts HOT 1
- [idea] hashing for data comparison HOT 4
- Point Observation HOT 3
- Forced upgrade to UFO3, group name conversion problems HOT 2
- Add postscriptNames and openTypeMeta HOT 1
- Destructive notification from a different object than the representation factory object HOT 1
- only reload glyphSet when the layer actually exists or within the same ufo version
- FilesystemClosed error when loading glyph after font.save() HOT 1
- LayerSet does not behave like a dict HOT 2
- Create a more robust removeObserver method. HOT 1
- Improve notification debugging with observer identifier. HOT 4
- baseDict eq should happen on object id instead of object data
- copyDataFromGlyph method from glyph object can create duplicate unicodes HOT 2
- Contour._get_segments does not handle all off-curves contours HOT 2
- It seems like `uni2010` might not be sorted by sortGlyphNames type="cannedDesign" HOT 6
- Source zip file posted on PyPi isn't source build HOT 23
- splitAndInsertPointAtSegmentAndT doesn't handle quadric curves HOT 3
- Use Bidi Mirroring
- guideline with no name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from defcon.