/// <summary> /// Process the font information that was parsed from the input. /// @since 2.0.8 /// </summary> private void processFont() { _fontName = _fontName.Trim(); if (_fontName.Length == 0) { return; } if (_fontNr.Length == 0) { return; } if (_fontName.Length > 0 && _fontName.IndexOf(";", StringComparison.Ordinal) >= 0) { _fontName = _fontName.Substring(0, _fontName.IndexOf(";", StringComparison.Ordinal)); } if (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 (!_importHeader.ImportFont(_fontNr, _fontName, int.Parse(_charset == "" ? CharsetDefault : _charset))) { if (_falt.Length > 0) { _importHeader.ImportFont(_fontNr, _falt, int.Parse(_charset == "" ? CharsetDefault : _charset)); } } // } } if (RtfParser.IsConvert()) { // This could probably be written as a better font matching function string fName = _fontName; // work variable for trimming name if needed. Font f1 = createfont(fName); if (f1.BaseFont == null && _falt.Length > 0) { f1 = createfont(_falt); } if (f1.BaseFont == null) { // Did not find a font, let's try a substring of the first name. if (FontFactory.COURIER.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1) { f1 = FontFactory.GetFont(FontFactory.COURIER); } else if (FontFactory.HELVETICA.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1) { f1 = FontFactory.GetFont(FontFactory.HELVETICA); } else if (FontFactory.TIMES.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1) { f1 = FontFactory.GetFont(FontFactory.TIMES); } else if (FontFactory.SYMBOL.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -1) { f1 = FontFactory.GetFont(FontFactory.SYMBOL); } else if (FontFactory.ZAPFDINGBATS.IndexOf(fName, StringComparison.OrdinalIgnoreCase) > -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[_fontNr] = f1; //System.out.Println(f1.GetFamilyname()); } SetToDefaults(); }