← All posts

Why typing in a PDF changes the font mid-line

You clicked into a line, retyped the name, and the words you typed came back in a different typeface from the words either side of them. Not the whole page. Not even the whole paragraph. The bit you touched.

The odd part is that it worked a minute ago. You changed a figure on page two and it matched perfectly. You changed a name on page four and got grey Helvetica in the middle of a sentence set in the company's own font.

It is not random, and it is not the length of what you typed. It is one character. Almost always you can find out which one in about ten seconds, and change it.

Why one character decides the whole run

A PDF carries its fonts inside itself, and it carries them cut down: a subset containing only the glyphs that document actually drew. The full explanation, and the two other reasons a typeface can change, are in why the font changes when you edit text in a PDF. The part that matters here is the consequence.

The subset is not a font with some characters missing in the way a keyboard is missing a few keys. It is a font whose character set was decided by the text that was already on the page. Ask it for anything outside that set and it cannot draw the character at all — there is no outline in the file to draw with.

And the check is all or nothing across the run you are replacing, because a PDF draws text with one instruction naming one font. There is no way to set four words in the document's font and the fifth character in something else within the same instruction. So a single unavailable character does not appear as a box or a blank: it changes the appearance of everything you typed alongside it.

That is why the failure looks so arbitrary. One edit lands, the next one does not, and the visible difference between them is a punctuation mark.

The characters that do it

In descending order of how often they are the culprit:

The pattern behind the list: what you type has to have already existed in that font, on that page, in that document.

Finding out before you spend the afternoon on it

Two routes, one quick and one exact.

The document is its own character map. Search the PDF for the character you want to type. If it is already printed somewhere in the same typeface, the glyph is in the file. This is a good enough test most of the time, with one trap: bold, italic and regular are three separate fonts with three separate subsets, and a merged document can easily carry the same face twice with different character sets, which is why the same edit can work on page two and fail on page four.

The exact answer is in the font program. mutool extract report.pdf (from MuPDF, free) writes out every embedded font as a file. Then ttx -t cmap font-0001.ttf, from fontTools, lists every code point that font can actually draw. pdffonts report.pdf from poppler-utils is the faster first check: the sub column tells you which fonts are subsets and therefore which ones can bite.

One thing our PDF inspector will not tell you is the font list. It reads page count, page sizes, encryption and whether the file has a real text layer, in your browser and without uploading anything, which answers a different set of questions. For fonts, use the commands above.

Typing round it

The fix is nearly always to change your replacement text rather than the file.

  1. Type it, do not paste it. Typing directly gives you straight quotes and hyphens. Pasting carries whatever the source had, including the invisible characters, and pasting through a plain text editor does not fix it — a curly quote is a character, not formatting, and it survives.
  2. Replace the punctuation by hand. A straight apostrophe for a curly one, a hyphen for a dash, three full stops for an ellipsis, and delete-and-retype every space if a non-breaking one might have come along for the ride.
  3. Watch the preview while you type in our PDF editor. It resolves the font the same way the server will, so the letterforms on screen change the instant the offending character lands. That is your ten-second test: type the replacement, see it switch, delete the suspect character, see it switch back.
  4. Reword to avoid the character. EUR for €, cafe for café, and for an ampersand the font never carried. Ugly, and it takes a second.
  5. Or accept it deliberately. If the character has to stay, choose the substitute face yourself for the whole block rather than leaving half a sentence patched — a uniform line in the wrong font reads as a design decision, and a three-word patch reads as a mistake.
  6. Read the notes after you apply. Any page where the original face lost is listed there, which is the written version of what the preview already showed you. If a substitution turns up that none of the steps above accounts for, the cause may not be the subset at all.

When it is a form field, nothing above applies

If you are typing into a fillable form rather than into the page, this is a different mechanism with the same symptom. A form field is not part of the page. It carries its own default appearance — a font name and size, taken from the form's own resource list, and overwhelmingly that font is Helvetica. The reader draws the field's contents in that font whatever the printed form around it is set in, and some files ask the reader to regenerate every field's appearance on open, so the same form can look different in Acrobat, in Preview and in a browser.

Nothing you do in the field changes that, because the choice was made when the form was built. What you can do is stop it moving again: Flatten PDF draws the current appearance of every field into the page and deletes the field objects, so the answers stop being live text and everybody sees the same rendering. Keep the unflattened copy, because that is one way.

What no tool can do

Add a glyph to a subset. If the font program in the file contains no Cyrillic, no editor can produce Cyrillic in that font. The file does not have the shapes.

Install your local copy of the font into the document. Even with the real Calibri on your machine, licensing and file structure are against you, and the editor works with what the PDF carries.

Draw a glyph that does not exist. There is one workaround worth knowing when the character you need is already printed somewhere in the document as artwork — a tick, a logo, a symbol in a heading. Extract images from PDF pulls the pictures out at their real pixel size, and you can place the one you want back on the page as an image. It is a picture, not a character, so it will not be searchable, but it looks right.

Reflow the page around a longer replacement. That is the other job entirely, and whether you need Word at all is the question worth asking before you start.

Fixing it properly, at the source

If you own the document, the real repair is one export setting. Acrobat, Distiller and most export dialogues have an option along the lines of do not subset embedded fonts when the percentage of characters used is less than 100% — set that threshold to 100 and the whole typeface goes into the file. The PDF gets a few hundred kilobytes bigger and everyone who ever has to correct a name in it gets the font they expected.

And if you need to see what a font actually contains, or build a version that contains more, FontForge is free, opens the files mutool extracted, and shows you the character set in a grid. It is the tool for the day you decide the problem is the font rather than the sentence.