photopea / Typr.js

Typr.js - process fonts in Javascript
MIT License
914 stars 73 forks source link

Way to disable 'kerning' of svg path. #25

Closed vinaydotblog closed 5 years ago

vinaydotblog commented 5 years ago

I have noticed that fonts converted using glyphsToPath utility have 'kerning' applied to those by default. I tried tinkering with following piece of code in getPairAdjustment utility. But it produces the same result. Can you please suggest some way to remove kerning of fonts.

if(font.kern)
{
    var ind1 = font.kern.glyph1.indexOf(g1);
    if(ind1!=-1)
    {
        var ind2 = font.kern.rval[ind1].glyph2.indexOf(g2);
        if(ind2!=-1) return font.kern.rval[ind1].vals[ind2];
    }
}
photopea commented 5 years ago

Hi, this library tries to reproduce the text as its author wanted it.

To render text differently, I suggest that you write your own version of glyphsToPath (it is just 25 lines long). The X coordinate is adjusted at lines 376 and 377. You can delete these lines, or add your own X increment.

vinaydotblog commented 5 years ago

Just for the reference of future visitors, commenting following line in glyphsToPath utility function, disables the kerning of the generated svg path text. 👏

// if (i < gls.length - 1) x += Typr.U.getPairAdjustment(font, gid, gid2);