PDF with odd Type3 fonts in Ghostscript 8.50

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.

 

Related Posts:

The following two tabs change content below.

Mark Stephens

System Architect and Lead Developer at IDRSolutions
Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.
Markee174

About Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>