foliojs / fontkit

An advanced font engine for Node and the browser
1.44k stars 210 forks source link

Trouble with Kerning / Letter Spacing #328

Open alexthegoodman opened 4 months ago

alexthegoodman commented 4 months ago

Hello fontkit!

I really appreciate this fantastic library and am excited to be building a multi-page document editor with it and canvas.

I, probably like other amateurs, have ran into some issues calculating the correct sizing and thus positioning of my characters.

Thankfully, all of my code is easily accessed here in a single React Hook: https://github.com/alexthegoodman/commonos/blob/feature/multi-page-docs/hooks/useCanvasRTE.ts

As you can see in getCharacterBoundingBox(), I must be calculating something incorrectly. Basically, my characters are off. See the attached image.

GIVjB8UWIAAQkwK

Thank you for any assistance!

alexthegoodman commented 4 months ago

It appears that I had loaded Inter as a font for fontkit, but was rendering some system font.

Feel free to delete this issue or keep it as reference for others! Thanks!