@ SuppressWarnings ( "WeakerAccess" ) protected PDFont mapFont ( final Font font , final IFontTextDrawerEnv env ) throws IOException , FontFormatException { /* * If we have any font registering's, we must perform them now */ for ( final FontEntry fontEntry : fontFiles ) { if ( fontEntry . overrideName == null ) { Font javaFont = Font . createFont ( Font . TRUETYPE_FONT , fontEntry . file ) ; fontEntry . overrideName = javaFont . getFontName ( ) ; } if ( fontEntry . file . getName ( ) . toLowerCase ( Locale . US ) . endsWith ( ".ttc" ) ) { TrueTypeCollection collection = new TrueTypeCollection ( fontEntry . file ) ; collection . processAllFonts ( new TrueTypeCollection . TrueTypeFontProcessor ( ) { @ Override public void process ( TrueTypeFont ttf ) throws IOException { PDFont pdFont = PDType0Font . load ( env . getDocument ( ) , ttf , true ) ; fontMap . put ( fontEntry . overrideName , pdFont ) ; fontMap . put ( pdFont . getName ( ) , pdFont ) ; } } ) ; } else { /* * We load the font using the file. */ PDFont pdFont = PDType0Font . load ( env . getDocument ( ) , fontEntry . file ) ; fontMap . put ( fontEntry . overrideName , pdFont ) ; } } fontFiles . clear ( ) ; return fontMap . get ( font . getFontName ( ) ) ; }
Try to map the java . awt . Font to a PDFont .