If I create a PDF using Acrobat Professional 9, containing a single sentence and make that sentence “Georgia Bold”, then save, I end up with a PDF that references the font “Georgia,Bold”.
If I then take that font from c:\windows\fonts\georgiab.ttf and interrogate it using the following code and itext 4.2, I end up with a font name of “Georgia-Bold”
String path = "georgiab.ttf"; BaseFont baseFont = BaseFont.createFont( path, BaseFont.WINANSI, BaseFont.EMBEDDED ); System.out.println( "Font " + baseFont.getPostscriptFontName() + " found in " + path );
I’m trying to determine why when used in a PDF file, the font name has a comma whereas when used outside of a PDF file, the font name has a hyphen.
The name that you get from
getPostscriptFontName()is the actual name within the font file. For a TrueType font this is parsed in theBaseFontmethod ofTrueTypeFont.java(line 498 in 5.1.1.3).Why does Adobe use a comma? That’s just what they decided to use. If I were to guess they probably chose the comma because some fonts use hyphens in their name but most (if any at all) never use a comma. So instead of
My-Awesome-Font-Boldthey choseMy-Awesome-Font,Bold. Users can tell that they’re using a bold variant of a font instead of just a font that happens to have the word “bold” in it.