FremyCompany
FremyCompany

Reputation: 2840

FontForge Script: how to add kerning between two glyphs to a font

I would like to add kerning between the letter A and itself so that the two letters stack on top of each other, over many font files.

How would I achieve this using a FontForge script?

Upvotes: 1

Views: 472

Answers (1)

FremyCompany
FremyCompany

Reputation: 2840

Here is a script to add kerning between the letter A and itself to a font that previously had no kerning table:

(1) Open your font

Open($1);

(2) Add a lookup with the gpos_pair type, and "kern" as feature, then create a subtable inside

AddLookup("kern","gpos_pair",0,[["kern",[["latn",["dflt"]]]]]); 
AddLookupSubtable("kern","kern-1");

(3) Select your first glyph by name

Select("A");

(4) Add kerning from this glyph to another glyph:

AddPosSub("kern-1",GlyphInfo("Name"),0,0,-2883,0,0,0,0,0);

(5) Generate your font

Generate($1:r + "-kerned.ttf");

I am adding this here because I could not find a single example of AddPosSub for character pairs (and it is really difficult to figure out where all the 0 should go without randomly trying.

Upvotes: 2

Related Questions