Open weiweihuanghuang opened 6 years ago
What happened when you tried it?
It seemed to just re-copy all @o kerning, so not changing the file in anyway
That is expected. What you need is to type oslash or ø as source glyph, and oslashacute as target. Blank field is treated as "anything involving the other glyph". And you may need to do it to both sides.
Oh I should've been clearer, I mean I entered oslash as source, and oslashacute as target, and it doesn't copy the exceptions.
Hi Tosche! I'm having an error that sounds similar to this. I'm copying kerning from @O
to @Oslash
and getting this:
Black10
@MMK_L_Oslash, @MMK_R_A, -32.0
@MMK_L_Oslash, @MMK_R_AE, -31.0
@MMK_L_Oslash, @MMK_R_C, 1.0
@MMK_L_Oslash, @MMK_R_Eth, 10.0
@MMK_L_Oslash, @MMK_R_G, 1.0
@MMK_L_Oslash, @MMK_R_J, -28.0
@MMK_L_Oslash, @MMK_R_O, 1.0
@MMK_L_Oslash, @MMK_R_T, -31.0
@MMK_L_Oslash, @MMK_R_V, -26.0
@MMK_L_Oslash, @MMK_R_W, -18.0
@MMK_L_Oslash, @MMK_R_X, -52.0
@MMK_L_Oslash, @MMK_R_Y, -44.0
@MMK_L_Oslash, @MMK_R_Z, -23.0
@MMK_L_Oslash, @MMK_R_f, 11.0
@MMK_L_Oslash, @MMK_R_parenright, -21.0
@MMK_L_Oslash, @MMK_R_period, -26.0
@MMK_L_Oslash, @MMK_R_slash, -31.0
@MMK_L_Oslash, @MMK_R_x, -10.0
@MMK_L_Oslash, A648FAE1-FF4C-4CC9-9272-0FAC2F8F849E, 25.0
Copy kerning Pairs Error (dupliKernPair): 'Glyphs with name: A648FAE1-FF4C-4CC9-9272-0FAC2F8F849E not found'
A648FAE1-FF4C-4CC9-9272-0FAC2F8F849E
is the glyph id of the first glyph for which there is an exception to @Oslash
.
Thanks! This is a G3-related issue in which the kerning structure has changed a bit. I'll update it soon.
@ethancohen Sorry, could you actually specify which versions of Glyphs and Python you use?
Yessir! Python 3.7.4, Glyphs 3.0.4 (3092). Also Glyphs crashes when I run it with "All masters" checked.
Please update to python 3.9. Either use the glyph python or update the one you installed.
I'm on Python 3.9.1 now and I get these errors:
When I run the script on @Oslash_1st:
Following pairs have been added.
Copy kerning Pairs Error (dupliKernPair): applyKern2() takes 7 positional arguments but 8 were given
When I run the script on @Oslash_2nd:
...
@MMK_L_quotedblleft, @MMK_R_Oslash, -20.0
@MMK_L_quotedblright, @MMK_R_Oslash, -36.0
@MMK_L_slash, @MMK_R_Oslash, -1.0
9701A7CD-72D3-4A63-AB4B-559D3CA04FC7, @MMK_R_Oslash, 14.0
Copy kerning Pairs Error (dupliKernPair): 'Glyphs with name: 9701A7CD-72D3-4A63-AB4B-559D3CA04FC7 not found'
@ethancohen I've updated the script. I'd love to know if it works for you this time.
Thanks, Tosche! Unfortunately I still get the same error for @Oslash_1st. But no more Glyphs with name: {glyph id} not found
!
Oslash_1st:
Following pairs have been added.
Copy kerning Pairs Error (dupliKernPair): applyKern2() takes 7 positional arguments but 8 were given
Also exceptions don't get copied... is that intentional?
Sorry about that. It's Glyphs 3's change in the internals of how single glyph entries are treated (it was all glyph names before, now mixed with glyph IDs depending on the function). Whenever you see an error relating to glyph ID, this is the reason. I haven't successfully got rid of those yet, and will give it another shot later today.
Thank you, Tosche! You are awesome.
And if there's any chance you would add functionality to copy exceptions you would be my hero.
Huh, I don't quite get how applyKern2() can receive extra arguments. I guess I need your file and to know exactly what you tried. Could you provide me with the data please? The outlines can be totally empty if you're concerned (but the glyphs need to exist). You can email me the file at tosche@mac.com
Tosche, can you send me some code samples where Glyphs 2 would return/expect names and Glyphs 3 is using IDs?
I have mentioned it before in the forum, it's GSFont.kerningDict() in G2 (at least earlier version of it) and GSFont.kerning in G3. The former reported single glyph in glyph name, and the latter reports in ID. To my knowledge, setKerningForPair() behave the same (accepts the name).
When I moved to G3, GSFont.kerning was recommended as the substitute for kerningDict(). When I changed it, things started to break around single glyphs because I couldn't simply apply what I read in the kerning dictionary anymore.
Now I see. The kerningDict
method is used internally when serialization of the data. It is still availably in G3: kerningDictForDirection_(direction)
(direction: LTR = 0, RTL = 2, Vertical = 4)
You should use those methods cautiously. It returns a copy of the kerning querying too often might be slow.
What API did you use to set the kerning?
And it is now difficult to convert IDs into names and back:
ID = Font.glyphs[name].id
name = Font.glyphForId_(ID).name
I've been using setKerningForPair() in both G2 and G3, which seems to accept glyph names. I honestly don't like dealing with glyph IDs in kerning though, it's also inconvenient when I need to print them out and need to convert to ID. What was wrong with glyph names? Kerning window displays single glyphs in names anyway.
As I wrote before, the only thing that has changed in G3 is that the .kerningDict
is .kerningDictForDirection_(direction)
now. Feel free to use it in place of .kerningDict
. All my other comments apply equally to G2 and G3.
I just tried to run this for this purpose and came back to the same problem of kerning exceptions not included when copying 😅
I wanted to copy any kerning pair exceptions that oslash had over to oslashacute (which has @o for both sides kerning groups in both glyphs), but it didn't run as expected, is there a way to restrict it to only kerning pair exceptions somewhere?