SOLVED Check Kerning
thom last edited by gferreira
I want to improve my script for generating images of sample texts in (tiny)DrawBot directly from the ufo.
Is there an easy way to check if two glyphs has a kerning value?
FYI: fontParts has
font.kerning.find(("A", "V"))dont know why its not in the documentation.
ArrowType last edited by
This is a super late reply, but I wanted to know this for another task, and the thread didn’t really tell me how to find kerning info, because (at least currently)
f.kerning[('A', 'V')]requires you to look up kerning by group names, not just glyph names.
Here’s a RoboFont script that will work to find kerning values for any two glyphs, just by there glyph names:
from ufoLib2 import Font from fontTools.ufoLib.kerning import lookupKerningValue # open the font with ufoLib2 font = Font(CurrentFont().path) # show kerning value print(lookupKerningValue(("A","V"), font.kerning, font.groups))
To run the script outside of RoboFont, just feed in a file path for the font:
from ufoLib2 import Font from fontTools.ufoLib.kerning import lookupKerningValue # open the font with ufoLib2 # replace the path with a relevant one font = Font("src/ufo/sans/Recursive Sans-Casual A.ufo") # show kerning value print(lookupKerningValue(("A","V"), font.kerning, font.groups))
thom last edited by
Indeed, there is some group-group and glyph-group and glyph-glyph kerning. So no way to get directly a value out the ufo?
Will try the temp dict.
There is the kerning attribute of a font
f = CurrentFont() print f.kerning[('A', 'V')]
If there is group kerning, maybe you should flatten the kerning dict in a temporary dict.
If the kerning is only available in the features, best is to compile the font it and read it back into RoboFont.