Pack and Optimize Fonts in PDF Documents with GdPicture.NET

Hi Everyone,

Speaking about PDF format, one of its robust features is to accurately display your document regardless of software, hardware, or the operating system.
Therefore fonts used to render the document content become an essential part of the document structure. And because the size matters, let’s try to reduce the file size by packing the fonts.

Characters, glyphs, and fonts

When you talk, you use characters. They are abstract.
When you write, you use graphical symbols to render these abstract characters. They are called glyphs.
Glyphs are grouped into a set of glyphs called font.
Each font contains the glyph descriptions composed as a program designed for direct use. The result is a font file with a specific extension characterising the font format.
Such a font file precisely describes how to draw characters and symbols used in content.
The next step is to keep the same document layout for other users, so they get the same file.
A challenging factor here is the file size of the resulting PDF document.

Fonts in PDF

As said above, mentioned font programs are a necessary part of the PDF document structure. The reason is apparent – to preserve the visual document layout same on all devices.
Generally, including font files in PDF documents happens in two ways. Fonts can be embedded or non-embedded in the document structure.

Non-embedded fonts only specify some of the required font parameters, like font family, font style, or encoding to tell the viewer which font should it use to render the text. PDF viewers try to substitute absenting glyphs with some predefined ones. This way some symbols can have different visual appearances as when they were created or even they are impossible to draw.
This approach has the lowest impact on the resulting document size but often leads to insufficiency in rendering.

Embedded fonts are stored as complete font programs, means a full set of characters, in a PDF document itself. The document content renders in the precisely same layout as when designing it, for every user and on every device.
The only consequence here is the highest impact on the document size as the whole font file is inserted inside the document structure.