defcon
defcon copied to clipboard
[idea] hashing for data comparison
I understand that since glyphs and data inside a ufo are mutable, the idea of hashing is counter-intuitive. But I was wondering if there was a way to make a hash of a glyph to compare if it has changed, then it's possible to reduce the compile time in ufo2ft by not compiling all the glyphs or even not all the binary tables. When a hash method is called, the glyph data is converted into tuples and then its hash is returned. This could also be used in more places to make sure if a part of the font has been changed on disk.
I've been doing a similar thing to create a JIT compiler but it does not use hashes. instead, I use the notifications to make changes to the binary. Do you think if I start something like this, is any PR acceptable or the idea is not sensible?
FYI Adobe ufoTools uses the HashPointPen to store a hash and not rehint an outline that hasn't changed.
Thank you, my idea is actually based on that pen. I'm still not sure here was the right place to bring it up or I should take it to fontpens
or ufo2ft
. The only reason to talk about it here is to come up with a more universal solution than tool-based solutions. @LettError already gave me an idea that I built something upon it and it's by creating a md5 hash from digestPointPen
data in fontpens
package.
I recommend using a representation factory for this. The representation system will handle creation of the hash when called, store it internally for speed and destroy it when the glyph changes. Documentation on this is here.
Thank you Tal, seems super interesting! I will try to see how can I use that.