As the developers of a PDF renderer, we spend a lot of time analysing PDF files and working out exactly what is going on. Recently we came across an intriguing font issue with a PDF file created in Ghostscript. It is worth relating as it is interesting in terms of Font technologies and for seeing what might be happening in Ghostscript…
Over the years, Adobe has added several font technologies to the PDF specification, including Type3, Type1, Truetype and OpenType. Type3 was one of the first and is not often used now because the quality of the other font technolgies is superior. However, one tool which does make extensive use of Type3 fonts is Ghostscript – the Open Source PDF ‘printing’ library.
The way Type 3 works is that it allows you to define each character using the same commands as are used to define the PDF itself – so each character can be like a mini-PDF drawn in the space of the character. Most examples we have seen up until now have been reasonably simple with either images or shapes used to drawn the letters.
We were sent a PDF file last week to look at – it still amazes me after 10 years of developing a PDF library how many different ways people have managed to interpret the Specification and produce files which still work in Acrobat. We drilled down and fixed the issue, but what made it interesting was what was happening in the file.
In this file, each Type 3 font character had been created by adding instructions to draw a Type1 font character – so the Type3 font definition for the letter A just drew a letter A, and so forth. The Type 3 font is essentially acting as a wrapper for a Type1 font. This works but it is a fairly hacky and inefficient way to do things – it would be far better to just use a Type1 font which would also offer lots of other advantages. But PDFs are often created by tools which are just patched and patched – most users do not see the internal guts of a PDF so they do not appreciate what is going on. If it looks okay, they are happy with that.
This suggests to me that maybe Ghostscript is being patched and patched – sometimes code reaches a point where it is time to take a block and rewrite it properly…
This post is part of our “Fonts Articles Index” in these articles we explore Fonts.
Are you a Developer working with PDF files?
Our developers guide contains a large number of technical posts to help you understand the PDF file Format.
Find out more about our software for Developers
|Convert PDF to HTML5 or SVG|
|Convert AcroForms and XFA to HTML5|
|Java PDF SDK for working with PDF files|