PostScript fonts and PDFsharp

Modified on 2009/08/05 17:32 by Thomas Hövel — Categorized as: Articles, MigraDoc Articles, PDFsharp Articles

PDFsharp cannot use PostScript fonts to draw text in a PDF file. Only TrueType fonts and OpenType fonts with TrueType outlines can be used with PDFsharp.

PDFsharp can open and manipulate existing PDF documents that contain PostScript fonts. The restriction applies only to text created with PDFsharp.

Background

The PostScript font technology was invented by Adobe in 1984. From 1990 to 2000 the Adobe Type Manager had to be installed to use PostScript fonts under Windows 3.x to Windows 98. For Windows 2000 and Windows XP (and the corresponding Server editions) Microsoft licensed the Adobe Type Manager and integrated it into GDI. Therefore PostScript fonts can be used like TrueType fonts from programs that use the Win32 API. PDFsharp is based on GDI+ or WPF. GDI+ was originally developed by Microsoft for internal use in the Microsoft Office products. The public version of GDI+ was introduced with Windows XP (as gdiplus.dll) and with the .NET framework as the foundation of the System.Drawing namespace. GDI+ can neither handle PostScript fonts nor OpenType fonts with PostScript outlines. PDFsharp was designed to draw on all windows, printers and PDF pages. The GDI+ build of PDFsharp therefore cannot handle PostScript fonts. It would be possible to implement PostSript font handling directly in PDFsharp, but this was not intended. PostScript fonts are not very important today anymore, because of OpenType. Newer Microsoft products like Windows Vista, Windows 7 or Office 2007 do not support PostSript fonts at all. If you use one in a document, it is rendered as a bitmap image when the document is printed or saved as PDF.

The WPF build of PDFsharp is based on Windows Presentation Foundation which fully supports OpenType fonts. Very roughly spoken an OpenType file is a unified container of either a TrueType or a PostScript font. As an example the font manager of Windows reports “OpenType with TrueType Outlines” for most fonts that comes with Windows and “OpenType with PostScript Outlines” for fonts that come e. g. with the Adobe Creative Suite. Because OpenType technology unifies font handling the WPF build of PDFsharp can indirectly handle PostScript fonts when they come as an OpenType font with PostScript outline.

Workarounds

The best you can do if you have a PostScript font and want to use it with PDFsharp is to convert it into a TrueType font or an OpenType font. A reliable commercial tool for such conversions is TransTypePro from FontLab.

If you use the GDI+ build of PDFsharp, you can convert the PostScript font into a TrueType font. Because of mathematical reasons the hinting table of a font cannot be completely transformed from PostScript hinting to TrueType hinting. That leads to less readably glyphs on computer displays. On printers with several hundred dpi this effect becomes invisible.

If you use the WPF build of PDFsharp, you can convert the PostScript font either in a TrueType or an OpenType font.

Note: Fonts are a significantly much more complicated topic than this brief article may show.