googlefonts / fontra

A browser-based font editor
https://fontra.xyz
GNU General Public License v3.0
518 stars 22 forks source link

[background image] Clean up unused background images from .ufo and .fontra #1813

Open justvanrossum opened 1 week ago

justvanrossum commented 1 week ago

Currently, background image data is never deleted, even if they are no longer referenced by any glyphs.

We need to determine a scheme when to delete the underlying image data. This is somewhat tricky, as the image data does not participate in undo and change objects.

This needs to be implemented both for the .designspace backend and for the .fontra backend.

ollimeier commented 6 days ago

Here some ideas:

1: I am wondering if we could have something like a removedDate-tag, which stores the date when the image got removed and then after XX days the image gets deleted based on the removedDate? And if removedDate=false, keep it.

2: When deleting the image a dialog could pop up with the question if you want to "delete forever" the image, no undo possible.

3 (only possible for Fontra Pak): Closing the app triggers a script which deletes the removed images. Not sure how this idea would work with Fontra running on a server.

ollimeier commented 6 days ago

Another idea: Fontra has somewhere a temporary folder, right? We could move the image to the temporary folder when removed and with undo we could get it back from the temporary folder. I expect that this temporary folder will be deleted some day, am I right?

justvanrossum commented 6 days ago

One complication (at least in UFO) is that background images can be reused in multiple glyphs. Perhaps designspace/ufo need a different approach from Fontra (where so far the concept is to never reuse images).

The "delayed" delete approach is what I was thinking of. But the temporary folder idea sounds usable. (Fontra doesn't have a dedicated temp folder, but we can make temp folders easily.)