Reputation: 1906
I'm trying to use some of the fonts embedded in PDF files in a Java application. Apparently, Java is able to load Type1 and TrueType fonts. According to several websites the Type1c fonts in a PDF are basically a CFF or Type2 font. A new feature of Java 7 is to load CFF font but Font.createFont() by this doesn't work.
So where am I going wrong? Is a Type1c font really a CFF/OpenType font? Is there any conversion required?
Upvotes: 2
Views: 2015
Reputation: 3184
Is the font subsetted? (in which case it will contain only some characters and not the whole font).
In general CFF fonts embedded in PDFs can need a lot of conversion work to make them generally usable - if you have been following the development of our PDF to HTML5 converter on our blog (http://blog.idrsolutions.com), you will have seen lots of posts about various issues with fonts.
sfntly and fontforge are useful tools for font manipulation.
Upvotes: 2
Reputation: 381
FontVerter is an open source java lib I wrote a little bit ago that can convert bare CFF* and Type0/composite fonts that come from PDFs into OTF/TTFs and WOFF1/2. It can also attempt to fix and normalize OTF/TTF fonts that don't work correctly in browsers, I found open type fonts embedded in PDFs often had various issues like missing tables which would prevent chrome from rendering them correctly.
(*bare CFF = type1c I believe?, it's been a little and I'm forgetting which type is which)
Upvotes: 0
Reputation: 7046
You're going to have to find out exactly what battle you're trying to fight I'm afraid. Don't believe web sites about fonts, read the PDF specification: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
Specifically you're looking for chapter 9.6 - Simple Fonts and 9.7 - Composite fonts.
To summarize, the fonts in a PDF file can be a number of types: - Type 0 - Type 1 - Type 3 - TrueType
Type 1 and TrueType are the simplest ones and you're very likely to encounter them in PDF files. Type 3 is a font type where you can use graphics to draw the characters. Not very common.
Type 0 is a more complex font type which was originally devised to allow you to use large character sets (think Japanese / Chinese), but it is now also routinely generated by many professional design and layout applications. There are two subtypes of this Type 0 font type: - SubType 0, which is a Type 1 font massaged into a Type 0 jacket, and - SubType 2, which is a TrueType font massages into a Type 0 jacket
In all cases there are significant differences between "real" fonts that live on your system and those same fonts embedded in a PDF file.
Start by having a look at the PDF file with the fonts you want to use. Use a tool such as pdfToolbox from callas (http://www.callassoftware.com/callas/doku.php/en:download) or Browser from Enfocus (http://www.enfocus.com/en/products/browser). Both of these tools allow you to investigate the low-level structure of a PDF file, including looking at the actual page description code and looking at the font dictionaries. pdfToolbox is particularly good at diving into the fonts in a PDF file, including looking at the actual shapes and the instructions used to draw those shapes.
Upvotes: 1