Menu

Fonts in headless Chromium: what your PDF really carries
πŸ“°

Fonts in headless Chromium: what your PDF really carries

DEV Community: cssΒ·Philipp StaudtΒ·9 days ago
#BJS3v8Xv
#devtocss#devto#dev#font#inter
Reading 0:00
15s threshold

A template looks right in the editor, the PDF comes back, and the text is a little wider, a little rounder, and the line that used to fit now wraps. Nothing failed. There was no error, no warning and no log line. The PDF simply carries a different font from the one the template asked for.

It can happen with any HTML-to-PDF service that runs Chromium on a Linux server, ours included. We rendered four one-line templates with our render worker (Chromium 153, the image we run in production) and read back which fonts each PDF embedded.

The template says The PDF carries

font-family: "Segoe UI", Helvetica, sans-serif Liberation Sans

font-family: Inter, sans-serif , nothing loaded Liberation Sans

font-family: Inter, sans-serif , Google Fonts <link> Inter

the same, text with βœ“ , βœ— and β†’ Inter, DejaVu Sans for βœ“ and βœ— , Liberation Sans for β†’

A family name is a wish

font-family is a list of names, and the browser takes the first one it has. On a Windows laptop that is Segoe UI.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.