Hello All, I'm facing a problem using itext (version 2.1.4, also 2.1.7) when registering and retrieving a font using an alias:
FontFactory.register("c:\\windows\\fonts\\arial.ttf", "arial.ttf"); Font alias = FontFactory.getFont("arial.ttf"); Font original = FontFactory.getFont("arial"); System.out.println("Alias BaseFont: "+alias.getBaseFont()); System.out.println("Original BaseFont: "+original.getBaseFont()); Output: Alias BaseFont: null Original BaseFont: com.lowagie.text.pdf.truetypef...@186c730 Stepping through the FontFactoryImp.java I found an explanation for this behaviour, but does not know if this is wanted. As You can see, it is tried first to get the font via the BaseFont.createFont(...) method. Unfortunately running this method with the alias name throws an IOException, so the lookup in the trueTypeFonts.getProperty is never run through. Here is the responsible code: BaseFont basefont = null; try { try { // the font is a type 1 font or CJK font basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null, true); } catch(DocumentException de) { } if (basefont == null) { // the font is a true type font or an unknown font fontname = trueTypeFonts.getProperty(fontname.toLowerCase()); // the font is not registered as truetype font if (fontname == null) return new Font(Font.UNDEFINED, size, style, color); // the font is registered as truetype font basefont = BaseFont.createFont(fontname, encoding, embedded, cached, null, null); } } catch(DocumentException de) { // this shouldn't happen throw new ExceptionConverter(de); } catch(IOException ioe) { // the font is registered as a true type font, but the path was wrong return new Font(Font.UNDEFINED, size, style, color); } To fix this, the catched IOEception should be close behind the first DocumentException. Any other ideas? When i put the C:\windows\fonts directory in the classpath the problem does not occur! Best regards Sascha Friederich -- Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3 - sicherer, schneller und einfacher! http://portal.gmx.net/de/go/atbrowser ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/