private void processFont ( ) { this . fontName = this . fontName . trim ( ) ; if ( fontName . length ( ) == 0 ) return ; if ( fontNr . length ( ) == 0 ) return ; if ( fontName . length ( ) > 0 && fontName . indexOf ( ' ' ) >= 0 ) { fontName = fontName . substring ( 0 , fontName . indexOf ( ' ' ) ) ; } if ( this . rtfParser . isImport ( ) ) { //TODO: If primary font fails, use the alternate //TODO: Problem: RtfFont defaults family to \froman and doesn't allow any other family. // if you set the family, it changes the font name and not the family in the Font.java class. // if(this.fontFamily.length() > 0) { // if(this.importHeader.importFont(this.fontNr, this.fontName, this.fontFamily, Integer.parseInt(this.charset)) == false) { // if(this.falt.length() > 0) { // this.importHeader.importFont(this.fontNr, this.falt, this.fontFamily, Integer.parseInt(this.charset)); // } // } // } else { if ( ! this . importHeader . importFont ( this . fontNr , this . fontName , Integer . parseInt ( "" . equals ( this . charset ) ? CHARSET_DEFAULT : this . charset ) ) ) { if ( this . falt . length ( ) > 0 ) { this . importHeader . importFont ( this . fontNr , this . falt , Integer . parseInt ( "" . equals ( this . charset ) ? CHARSET_DEFAULT : this . charset ) ) ; } } // } } if ( this . rtfParser . isConvert ( ) ) { // This could probably be written as a better font matching function String fName = this . fontName ; // work variable for trimming name if needed. Font f1 = createfont ( fName ) ; if ( f1 . getBaseFont ( ) == null && this . falt . length ( ) > 0 ) f1 = createfont ( this . falt ) ; if ( f1 . getBaseFont ( ) == null ) { // Did not find a font, let's try a substring of the first name. if ( FontFactory . COURIER . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . COURIER ) ; } else if ( FontFactory . HELVETICA . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . HELVETICA ) ; } else if ( FontFactory . TIMES . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . TIMES ) ; } else if ( FontFactory . SYMBOL . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . SYMBOL ) ; } else if ( FontFactory . ZAPFDINGBATS . indexOf ( fName ) > - 1 ) { f1 = FontFactory . getFont ( FontFactory . ZAPFDINGBATS ) ; } else { // we did not find a matching font in any form. // default to HELVETICA for now. f1 = FontFactory . getFont ( FontFactory . HELVETICA ) ; } } fontMap . put ( this . fontNr , f1 ) ; //System.out.println(f1.getFamilyname()); } this . setToDefaults ( ) ; }
Process the font information that was parsed from the input .