
PDF Font Hell - Why Swapping Fonts in PDF Breaks Everything
You need to replace Source Sans with Open Sans across a batch of PDFs. Two similar sans-serif fonts. Same style, same weight, roughly the same proportions. Should be straightforward. You write a script, embed Open Sans, swap the font references, run it. The output looks wrong. Lines that used to fit now overflow. A few paragraphs reflow and gain an extra line, pushing content off the page. Some characters show up as tofu - little rectangles where glyphs should be. Others turn into question marks. The letter spacing is off - some pairs are too tight, others have visible gaps where the kerning made sense for Source Sans but not for Open Sans. The bounding boxes are wrong. The line spacing changed. Two fonts that look almost identical on screen, and yet switching from one to the other broke the layout in a dozen different ways. Fonts in PDF are not a style property. They are deeply wired into how every character is stored, positioned, encoded, and drawn. Changing a font - or even changing
Continue reading on Dev.to Tutorial
Opens in a new tab




