public static Font createFont( int fontFormat, File fontFile ) throws java.awt.FontFormatException, java.io.IOException {
if( fontFormat != Font.TRUETYPE_FONT && fontFormat != Font.TYPE1_FONT ) {
throw new IllegalArgumentException( "font format not recognized" );
}
// create a private Font Collection and add the font data
PrivateFontCollection pfc = new PrivateFontCollection();
try {
pfc.AddFontFile( fontFile.getPath() );
if(false){
throw new cli.System.IO.FileNotFoundException();
}
} catch( cli.System.IO.FileNotFoundException fnfe ) {
FileNotFoundException ex = new FileNotFoundException(fnfe.getMessage());
ex.initCause( fnfe );
throw ex;
}
// create the font object
Font2D font2D = FontManager.createFont2D( pfc.get_Families()[0], 0 );
Font font = new Font( font2D.getFontName( Locale.getDefault() ), PLAIN, 1 );
font.font2D = font2D;
return font;
}