public static String[] readFontNames(final FontData fontData){
  final String[] fontNames=new String[1];
  fontNames[0]=null;
  final BufferedReader br=new BufferedReader(new StringReader(new String(fontData.getBytes(0,fontData.length()))));
  String line=null;
  while (true) {
    try {
      line=br.readLine();
    }
 catch (    final IOException e) {
      LogWriter.writeLog("Exception: " + e.getMessage());
    }
    if (line == null) {
      break;
    }
    if (line.startsWith("/FontName")) {
      final int nameStart=line.indexOf('/',9);
      if (nameStart != -1) {
        final int nameEnd=line.indexOf(' ',nameStart);
        if (nameEnd != -1) {
          final String name=line.substring(nameStart + 1,nameEnd);
          fontNames[0]=name.toLowerCase();
          break;
        }
      }
    }
  }
  if (br != null) {
    try {
      br.close();
    }
 catch (    final Exception e) {
      LogWriter.writeLog("Exception " + e + " closing stream");
    }
  }
  if (fontData != null) {
    fontData.close();
  }
  return fontNames;
}

public static String [ ] readFontNames ( final FontData fontData ) { final String [ ] fontNames = new String [ 1 ] ; fontNames [ 0 ] = null ; final BufferedReader br = new BufferedReader ( new StringReader ( new String ( fontData . getBytes ( 0 , fontData . length ( ) ) ) ) ) ; String line = null ; while ( true ) { try { line = br . readLine ( ) ; } catch ( final IOException e ) { LogWriter . writeLog ( "Exception: " + e . getMessage ( ) ) ; } if ( line == null ) { break ; } if ( line . startsWith ( "/FontName" ) ) { final int nameStart = line . indexOf ( '/' , 9 ) ; if ( nameStart != - 1 ) { final int nameEnd = line . indexOf ( ' ' , nameStart ) ; if ( nameEnd != - 1 ) { final String name = line . substring ( nameStart + 1 , nameEnd ) ; fontNames [ 0 ] = name . toLowerCase ( ) ; break ; } } } } if ( br != null ) { try { br . close ( ) ; } catch ( final Exception e ) { LogWriter . writeLog ( "Exception " + e + " closing stream" ) ; } } if ( fontData != null ) { fontData . close ( ) ; } return fontNames ; }
return name of font name will be lowercase to avoid issues of capitalisation when used for lookup - if no name , will default to null mode is pdfdecoder . substitute_ * constant . runtimeexception will be thrown on invalid value
