public BaseFont awtToPdf ( Font font ) { try { BaseFontParameters p = getBaseFontParameters ( font . getFontName ( ) ) ; if ( p != null ) return BaseFont . createFont ( p . fontName , p . encoding , p . embedded , p . cached , p . ttfAfm , p . pfb ) ; String fontKey = null ; String logicalName = font . getName ( ) ; if ( logicalName . equalsIgnoreCase ( "DialogInput" ) || logicalName . equalsIgnoreCase ( "Monospaced" ) || logicalName . equalsIgnoreCase ( "Courier" ) ) { if ( font . isItalic ( ) ) { if ( font . isBold ( ) ) { fontKey = BaseFont . COURIER_BOLDOBLIQUE ; } else { fontKey = BaseFont . COURIER_OBLIQUE ; } } else { if ( font . isBold ( ) ) { fontKey = BaseFont . COURIER_BOLD ; } else { fontKey = BaseFont . COURIER ; } } } else if ( logicalName . equalsIgnoreCase ( "Serif" ) || logicalName . equalsIgnoreCase ( "TimesRoman" ) ) { if ( font . isItalic ( ) ) { if ( font . isBold ( ) ) { fontKey = BaseFont . TIMES_BOLDITALIC ; } else { fontKey = BaseFont . TIMES_ITALIC ; } } else { if ( font . isBold ( ) ) { fontKey = BaseFont . TIMES_BOLD ; } else { fontKey = BaseFont . TIMES_ROMAN ; } } } else { // default, this catches Dialog and SansSerif if ( font . isItalic ( ) ) { if ( font . isBold ( ) ) { fontKey = BaseFont . HELVETICA_BOLDOBLIQUE ; } else { fontKey = BaseFont . HELVETICA_OBLIQUE ; } } else { if ( font . isBold ( ) ) { fontKey = BaseFont . HELVETICA_BOLD ; } else { fontKey = BaseFont . HELVETICA ; } } } return BaseFont . createFont ( fontKey , BaseFont . CP1252 , false ) ; } catch ( Exception e ) { throw new ExceptionConverter ( e ) ; } }
Returns a BaseFont which can be used to represent the given AWT Font