No kern for accented letters

Post Reply
synthview
Posts: 11
Joined: 23 Apr 2021

No kern for accented letters

Post by synthview »

Hello Tim!
I have started using KO lately and it is amazing!
However some couples are not kerned when one of the glyphs has diacritict (the base glyph is kerned).
In my case, I need to kern elements like ◆■ ‣ • with shapes like V W Y T K L. I set the 1st group as "special kerning" > "spaced-off" and set "auto" for each combination between 1st and 2nd group.
So for instance now W◆W◆ are kerned. But not ẂŴẄẀ. How can I solve it other than manually hit "auto" for each combo?

Thank you in advance for you help :)
User avatar
Tim Ahrens
Site Admin
Posts: 424
Joined: 11 Jul 2019

Re: No kern for accented letters

Post by Tim Ahrens »

This seems to be a unique use case. Right now, there is no elegant, built-in way of achieving what you want. Maybe I should add a feature that allows to specify user-set autopairs for groups of glyphs.

For now, you can use this code:

Code: Select all

characters_1st = '◆■‣•'
characters_2nd = 'ÁĂÂÄÀĀĄÅÃÆĆČÇĈĎĐÐÉĚÊËĖÈĒĘĞĜĢĤÍÎÏİÌĪĮĨĴĶĹĽĻŁŃŇŅÑÓÔÖÒŐŌØÕŒÞŔŘŚŠŞŜȘŤȚÚŬÛÜÙŰŪŲŮŨẂŴẀÝŶŸỲŹŽŻ'
string = '\n'.join([c1 + c2 for c1 in characters_1st for c2 in characters_2nd])
print(string)
Glyphs.font.currentTab.text = string
Just paste it in to the Macro Panel and push the “Run” button. Then you can select all text in the tab and switch the pairs to Auto.
synthview
Posts: 11
Joined: 23 Apr 2021

Re: No kern for accented letters

Post by synthview »

Ok thank you! Stupid question... which the syntax is if I need to put into the list a .xxx glyph?
User avatar
Tim Ahrens
Site Admin
Posts: 424
Joined: 11 Jul 2019

Re: No kern for accented letters

Post by Tim Ahrens »

You can also work with glyph names, with space in-between:

Code: Select all

characters_1st = 'f.calt g.calt t.calt f.liga t.low e.ss04'.split()
characters_2nd = 'Aacute Abreve Acircumflex Adieresis Agrave Amacron Aogonek Aring Atilde AE Cacute Ccaron Ccedilla Ccircumflex Dcaron Dcroat Eth Eacute Ecaron Ecircumflex Edieresis Edotaccent Egrave Emacron Eogonek Gbreve Gcircumflex Gcommaaccent Hcircumflex Iacute Icircumflex Idieresis Idotaccent Igrave Imacron Iogonek Itilde Jcircumflex Kcommaaccent Lacute Lcaron Lcommaaccent Lslash Nacute Ncaron Ncommaaccent Ntilde Oacute Ocircumflex Odieresis'
string = '\n'.join( ['/'+c1 + '/'+c2 for c1 in characters_1st for c2 in characters_2nd] )
print( string )
Glyphs.font.currentTab.text = string
Note that you can select several glyphs, right-click and choose Copy Glyph Names > Space Separated. That’s quite convenient in this case.
synthview
Posts: 11
Joined: 23 Apr 2021

Re: No kern for accented letters

Post by synthview »

Georg helped me with the code. The following syntax will work

font = Glyphs.font
names_1st = ["blackDiamond", "blackSquare", "triangularbullet", "bullet"]
names_2nd = ["A", "Aacute", "Abreve", "Acircumflex", "Adieresis", "Agrave", "Amacron", "Aogonek", "Aring", "Atilde", "AE", "C", "Cacute", "Ccaron", "Ccedilla", "Ccircumflex", "D", "Dcaron", "Dcroat", "Eth", "J", "J.ss02", "Jacute", "Jacute.ss02","Jcircumflex", "Jcircumflex.ss02", "K", "Kcommaaccent", "L", "Lacute", "Lcaron", "Lcommaaccent", "Lslash", "O", "Oacute", "Obreve", "Ocircumflex", "Odieresis", "Odotbelow", "Ograve", "Ohungarumlaut", "Omacron", "Oogonek", "Oslash", "Oslashacute", "Otilde", "T", "Tcaron", "Tcommaaccent", "W", "Wacute", "Wcircumflex", "Wgrave", "Y", "Yacute", "Ycircumflex", "Ydieresis", "Ygrave", "Z", "Zacute", "Zcaron", "Zdotaccent", "k", "kcommaaccent", "racute", "rcaron", "rcommaaccent", "t", "tbar", "tcaron", "tcedilla", "tcommaaccent", "v", "w", "wacute", "wcircumflex", "wdieresis", "wgrave", "x", "y", "y.ss04", "yacute", "yacute.ss04", "ycircumflex", "ycircumflex.ss04", "ydieresis", "ydieresis.ss04", "ygrave", "ygrave.ss04", "ymacron", "ymacron.ss04", "ytilde", "ytilde.ss04", "z", "zacute", "zcaron", "zdotaccent"]
pairs = []
for name1 in names_1st:
glyph1 = font.glyphs[name1]
if not glyph1:
continue
char1 = font.characterForGlyph(glyph1)
for name2 in names_2nd:
glyph2 = font.glyphs[name2]
if not glyph2:
continue
char2 = font.characterForGlyph(glyph2)
pairs.append(chr(char1) + chr(char2) + chr(char1))
string = '\n'.join(pairs)
print(string)
font.currentTab.text = string
User avatar
Tim Ahrens
Site Admin
Posts: 424
Joined: 11 Jul 2019

Re: No kern for accented letters

Post by Tim Ahrens »

This code should do practically the same but it is more complicated to set up. ;-)
synthview
Posts: 11
Joined: 23 Apr 2021

Re: No kern for accented letters

Post by synthview »

your doesn't work in the sense that for instance outputs:
J
.
s
s
0
2

I have posted it just in case someone else would need it :)
User avatar
Tim Ahrens
Site Admin
Posts: 424
Joined: 11 Jul 2019

Re: No kern for accented letters

Post by Tim Ahrens »

Maybe you omitted the .split() at the end of the first line?
synthview
Posts: 11
Joined: 23 Apr 2021

Re: No kern for accented letters

Post by synthview »

nope, never mind anyway. thanks for the support :)
Post Reply