Copy (duplicate) only glyphs that don't exist in destination file

I’m wondering if anyone knows of an existing script that would copy glyphs from one open file to another, but only those glyphs that don’t exist in the destination file without overwriting any glyphs that are already present in the destination file.

(Note that a simple copy and paste almost works, but it makes a new glyph for every matching glyph in the destination file, eg. if A exists, then it will paste A as A.001.)

So sorry if this isn’t the right place for this request. Id be happy to modify a similar script even if it wasn’t quite what I want. I’m new to python but have written a fair bit of javascript.

None that I know of, but this one:

  • Copy layer to layer: Copies paths (and optionally, also components, anchors and metrics) from one Master to another. Needs Vanilla.

from mekkablue would be a good candidate for modification to do what you want. Currently it requires having empty cells with the same names in the target font and they all have to be selected in one of the fonts for the copy process to work.

He has another script which might also be modified but may require more extensive work:

  • Copy Glyphs from Other Font into Backup Layers: Creates backup layers for selected glyphs in target font, and fills them with the respective glyphs from source font. Useful if you want to add glyphs from one font as bracket layers in another.

After you copied all of them, you could search for ‘.001’ and delete the duplicates.

Or you build a list filter with the missing glyph.

Thanks very much George, that sounds like a good place to start!

You’re right Georg, but the problem in my case is I have glyphs suffixed with .001, .002 etc strewn around my file and it would be difficult to tell which needed deleting.

I did build a list filter for another purpose and I love it—great feature! However for this purpose I don’t want to have to maintain a list into which I will undoubtedly introduce errors.

Or do you mean “build a list filter” with a script? That might be a good approach. I wondered if there’s a way to mark a list filter to exclude the glyphs on the list? That would be helpful here.

Anyway thanks for replying so fast. I’ve got enough to go on now I think.

You can get the glyph list by selecting some/all glyphs and chose “Copy Glyph Names > One per Line” from the context menu.
Or, if you select glyph before adding a list filter, the filter will contain the selected glyphs already.

After adding the list filter, go to the other font, select all and mark all glyphs with a color label. Then select the new filter and remove the color from the filtered glyphs. Then use a smart filter to filter for that color. This will show all missing glyphs.

This is a bit to complicated, I’ll see if I can improve that.

Yes that would work for me. It is a bit arduous, and in my case I’m already using colour labels so I’d have to set them up as lists instead. I’ll work out a good way.

My ideal solution, might be to add some conflict-resolution options to the paste special dialog, eg:
41%20pm

(And in my case I’d choose the “Do not paste glyph” option.)

Just a thought. I understand there may be reasons that wouldn’t work.