kateliev / TypeRig

Proxy API and Font Development Toolkit for FontLab
https://kateliev.github.io/TypeRig/
BSD 3-Clause "New" or "Revised" License
48 stars 3 forks source link

[Proxy] Glyph and Font .update() #77

Open kateliev opened 1 year ago

kateliev commented 1 year ago

As discussed with Yury i need to check and refactor my object update routines. Some of the api calls used so far are way to expensive and in the wrong order.

...there is AcceptChanges, UpdateActiveCanvas and UpdateAll.
AcceptChanges will update data without refresh. It has optional bool parameter that if it is true, then it updates and forgets about changes if false (default) it updates, but UpdateAll will refresh everything anyway... UpdateActiveCanvas is good, will work on current GW only and it will call AcceptChanges(true)

... calling notifyGlyphUpdated with some package id, but with glyph id == 0, means that ALL glyphs should be updated in FW, preview panel, etc. You may also have a call notifyGlyphsUpdated and provide a list of glyph's fgId. This should be that's FINAL call - you call it when operation is DONE (when mouse is released). Same is true for notifyChangesApplied, it is final call it triggers undo system which is expensive...

fl6.flitems.notifyGlyphUpdated(glyph.package.fgId(), glyph.fgGlyphId())

In many cases you may prefer to call AcceptChanges with parameter or without it. If you know, you will call for notifyChangesApplied and notifyGlyphUpdated at the end (which will redraw GW). You may use AcceptChanges(true) if you don't need to refresh GW content. If you know you have active GW, try to call UpdateActiveCanvas. If in doubt, call UpdateAll, it will refresh data and also refresh GW.

... flPreferences::editorFastPreview() ... ...if editorFastPreview is true, then UpdateAll should also mean notifyGlyphUpdated...