public BuiltinFont(String baseFont,PDFObject fontObj,PDFFontDescriptor descriptor) throws IOException {
  super(baseFont,fontObj,descriptor);
  String fontName=descriptor.getFontName();
  for (int i=0; i < baseFonts.length; i++) {
    if (fontName.equalsIgnoreCase(baseFonts[i])) {
      parseFont(fontName);
      return;
    }
  }
  for (int i=0; i < mappedFonts.length; i+=2) {
    if (fontName.equalsIgnoreCase(mappedFonts[i])) {
      parseFont(mappedFonts[i + 1]);
      return;
    }
  }
  int flags=descriptor.getFlags();
  int style=((flags & PDFFontDescriptor.FORCEBOLD) != 0) ? Typeface.BOLD : Typeface.NORMAL;
  if (fontName.indexOf("Bold") > 0) {
    style|=Typeface.BOLD;
  }
  if ((descriptor.getItalicAngle() != 0) || ((flags & PDFFontDescriptor.NONSYMBOLIC) != 0)) {
    style|=Typeface.ITALIC;
  }
  String name=null;
  if ((flags & PDFFontDescriptor.FIXED_PITCH) != 0) {
    if (((style & Typeface.BOLD) > 0) && ((style & Typeface.ITALIC) > 0)) {
      name="Courier-BoldOblique";
    }
 else     if ((style & Typeface.BOLD) > 0) {
      name="Courier-Bold";
    }
 else     if ((style & Typeface.ITALIC) > 0) {
      name="Courier-Oblique";
    }
 else {
      name="Courier";
    }
  }
 else   if ((flags & PDFFontDescriptor.SERIF) != 0) {
    if (((style & Typeface.BOLD) > 0) && ((style & Typeface.ITALIC) > 0)) {
      name="Times-BoldItalic";
    }
 else     if ((style & Typeface.BOLD) > 0) {
      name="Times-Bold";
    }
 else     if ((style & Typeface.ITALIC) > 0) {
      name="Times-Italic";
    }
 else {
      name="Times-Roman";
    }
  }
 else {
    if (((style & Typeface.BOLD) > 0) && ((style & Typeface.ITALIC) > 0)) {
      name="Helvetica-BoldOblique";
    }
 else     if ((style & Typeface.BOLD) > 0) {
      name="Helvetica-Bold";
    }
 else     if ((style & Typeface.ITALIC) > 0) {
      name="Helvetica-Oblique";
    }
 else {
      name="Helvetica";
    }
  }
  parseFont(name);
}

public BuiltinFont ( String baseFont , PDFObject fontObj , PDFFontDescriptor descriptor ) throws IOException { super ( baseFont , fontObj , descriptor ) ; String fontName = descriptor . getFontName ( ) ; for ( int i = 0 ; i < baseFonts . length ; i ++ ) { if ( fontName . equalsIgnoreCase ( baseFonts [ i ] ) ) { parseFont ( fontName ) ; return ; } } for ( int i = 0 ; i < mappedFonts . length ; i += 2 ) { if ( fontName . equalsIgnoreCase ( mappedFonts [ i ] ) ) { parseFont ( mappedFonts [ i + 1 ] ) ; return ; } } int flags = descriptor . getFlags ( ) ; int style = ( ( flags & PDFFontDescriptor . FORCEBOLD ) != 0 ) ? Typeface . BOLD : Typeface . NORMAL ; if ( fontName . indexOf ( "Bold" ) > 0 ) { style |= Typeface . BOLD ; } if ( ( descriptor . getItalicAngle ( ) != 0 ) || ( ( flags & PDFFontDescriptor . NONSYMBOLIC ) != 0 ) ) { style |= Typeface . ITALIC ; } String name = null ; if ( ( flags & PDFFontDescriptor . FIXED_PITCH ) != 0 ) { if ( ( ( style & Typeface . BOLD ) > 0 ) && ( ( style & Typeface . ITALIC ) > 0 ) ) { name = "Courier-BoldOblique" ; } else if ( ( style & Typeface . BOLD ) > 0 ) { name = "Courier-Bold" ; } else if ( ( style & Typeface . ITALIC ) > 0 ) { name = "Courier-Oblique" ; } else { name = "Courier" ; } } else if ( ( flags & PDFFontDescriptor . SERIF ) != 0 ) { if ( ( ( style & Typeface . BOLD ) > 0 ) && ( ( style & Typeface . ITALIC ) > 0 ) ) { name = "Times-BoldItalic" ; } else if ( ( style & Typeface . BOLD ) > 0 ) { name = "Times-Bold" ; } else if ( ( style & Typeface . ITALIC ) > 0 ) { name = "Times-Italic" ; } else { name = "Times-Roman" ; } } else { if ( ( ( style & Typeface . BOLD ) > 0 ) && ( ( style & Typeface . ITALIC ) > 0 ) ) { name = "Helvetica-BoldOblique" ; } else if ( ( style & Typeface . BOLD ) > 0 ) { name = "Helvetica-Bold" ; } else if ( ( style & Typeface . ITALIC ) > 0 ) { name = "Helvetica-Oblique" ; } else { name = "Helvetica" ; } } parseFont ( name ) ; }
create a new builtingfont object based on a description of the font from the pdf file . parse the description for key information and use that to generate an appropriate font .
