Giter Club home page Giter Club logo

Comments (9)

typemytype avatar typemytype commented on August 19, 2024

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.

adrientetar avatar adrientetar commented on August 19, 2024

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.

typoman avatar typoman commented on August 19, 2024

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.

adrientetar avatar adrientetar commented on August 19, 2024

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.

typoman avatar typoman commented on August 19, 2024

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.

typoman avatar typoman commented on August 19, 2024

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.

typoman avatar typoman commented on August 19, 2024

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.

typoman avatar typoman commented on August 19, 2024

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.

adrientetar avatar adrientetar commented on August 19, 2024

'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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.