How to implement outlining fonts as paths (also for SVG and PDF export)

Hi amazing people!

Many assets have a need to be resilient outside of PenPot.
Font embedding as path data achieves this for many use cases. (some call it font outlining)

Maybe this shouldn’t be the default export behaviour, but as an option it does mean PDF’s can suit many print use cases (vinyl stickers and screenprinting woo!)
it also means SVG files can be used as standalone assets in browsers and other design tools without the font being available to the 3rd party renderer/editor. (prevents logos, icons or just mockup from breaking)

Here’s a few ways to achieve this:

Browser side: see GitHub - opentypejs/opentype.js: Read and write OpenType fonts using JavaScript.
Which is honestly my preferred since the one operation will support SVG and PDF output

Server side see: ghostscript

gs -o file-outlined.pdf -dNoOutputFonts -sDEVICE=pdfwrite source-file.pdf

There’s also a fair few ways to do this to an SVG file on the server using other existing libraries. But again, client-side is king to save on cloud bills and create a fast UX.

If this is too heavy to run as an export function against a whole frame, I’d suggest a per-object ‘fonts to outline’ operation similar to those other people https://help.figma.com/hc/en-us/articles/360047239073-Convert-text-to-vector-paths

I hope this helps someone on their quest to make PenPot the ultimate hub for design!

Love what you do legends <3

2 Likes

+1 to this!

Definitely would be a killer feature for many use cases

1 Like

Fontkit can be a good option ?

opentype.js or Fontkit any feedback ?

Both Fontkit and opentype.js are distributed under the MIT license, allowing for flexible usage in both open-source and commercial projects.

1 Like

Server side python can do the job too → fonttools

Not an identical use case, but this might be of interest to this topic (Outlining Strokes) :slight_smile: I would hope that the implementation of this feature would naturally include/lead to font outlining as well. https://tree.taiga.io/project/penpot/us/2956

1 Like

is a great client-side tech demo of opentype.js doing it’s thing.