Hi, I am trying to embed fonts in a program. I was able to get my fonts to work when I run fop.bat standalone. Here were the relevant lines from the config xml.
<font-base>file:///C:/programs/apache/fop-0.94-bin-jdk1.3/fonts/</font-base> <!-- not sure if font tags will display on web site --> <fonts> <font-triplet name="Verdana" style="normal" weight="normal"/> <font-triplet name="Verdana" style="normal" weight="bold"/> <font-triplet name="Verdana" style="italic" weight="bold"/> </fonts> Like I said, this one works. Now, in an application, I am trying to do the same using the API. // Set the Font Base URL fopFactory.setFontBaseURL("file:///C:/programs/apache/fop-0.94-bin-jdk1.3/fonts/"); String font1 = "verdana.xml"; String font1Url = "verdana.ttf"; String font2 = "verdanab.xml"; String font2Url = "verdanab.ttf"; String font3 = "verdanaz.xml"; String font3Url = "verdanaz.ttf"; FontTriplet fontTriplet1 = new FontTriplet("Verdana", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL); FontTriplet fontTriplet2 = new FontTriplet("Verdana", Font.STYLE_NORMAL, Font.WEIGHT_BOLD); FontTriplet fontTriplet3 = new FontTriplet("Verdana", Font.STYLE_ITALIC, Font.WEIGHT_BOLD); List fontTriplets1 = new ArrayList(); fontTriplets1.add(fontTriplet1); List fontTriplets2 = new ArrayList(); fontTriplets2.add(fontTriplet2); List fontTriplets3 = new ArrayList(); fontTriplets3.add(fontTriplet3); EmbedFontInfo verdanaFontInfo = new EmbedFontInfo(font1, true, fontTriplets1, font1Url); EmbedFontInfo verdanaBoldFontInfo = new EmbedFontInfo(font2, true, fontTriplets2, font2Url); EmbedFontInfo verdanaBoldItalicFontInfo = new EmbedFontInfo(font3, true, fontTriplets3, font3Url); FontCache fontCache = fopFactory.getFontCache(); fontCache.addFont(verdanaFontInfo); fontCache.addFont(verdanaBoldFontInfo); fontCache.addFont(verdanaBoldItalicFontInfo); fontCache.save(); I test the cache using the following: log.debug("Contains verdana font: " + fontCache.containsFont(verdanaFontInfo)); log.debug("Verdana font info is: " + fontCache.getFont("verdana.ttf").toString()); log.debug("Contains verdana-bold font: " + fontCache.containsFont(verdanaBoldFontInfo)); log.debug("Verdana-bold font info is: " + fontCache.getFont("verdanab.ttf").toString()); log.debug("Contains verdana-bold-italic font: " + fontCache.containsFont(verdanaBoldItalicFontInfo)); log.debug("Verdana-bold-italic font info is: " + fontCache.getFont("verdanaz.ttf").toString()); In the log, I get the following: 2008-09-05 12:05:12,014 [main] DEBUG embedding.ExampleXML2PDF(ExampleXML2PDF.java:153) - Contains verdana font: true 2008-09-05 12:05:12,014 [main] DEBUG embedding.ExampleXML2PDF(ExampleXML2PDF.java:154) - Verdana font info is: metrics-url=verdana.xml,embed-url=verdana.ttf, kerning=true, font-triplet=[Verdana,normal,400], lastModified=-1 2008-09-05 12:05:12,014 [main] DEBUG embedding.ExampleXML2PDF(ExampleXML2PDF.java:156) - Contains verdana-bold font: true 2008-09-05 12:05:12,014 [main] DEBUG embedding.ExampleXML2PDF(ExampleXML2PDF.java:157) - Verdana-bold font info is: metrics-url=verdanab.xml,embed-url=verdanab.ttf, kerning=true, font-triplet=[Verdana,normal,700], lastModified=-1 2008-09-05 12:05:12,014 [main] DEBUG embedding.ExampleXML2PDF(ExampleXML2PDF.java:159) - Contains verdana-bold-italic font: true 2008-09-05 12:05:12,014 [main] DEBUG embedding.ExampleXML2PDF(ExampleXML2PDF.java:160) - Verdana-bold-italic font info is: metrics-url=verdanaz.xml,embed-url=verdanaz.ttf, kerning=true, font-triplet=[Verdana,italic,700], lastModified=-1 However, when it actually tries to convert the XML to PDF, I see the following message in the log: 2008-09-05 12:05:26,905 [main] DEBUG org.apache.fop.fonts.FontInfo(FontInfo.java:134) - Font lookup: Verdana normal 400 2008-09-05 12:05:26,905 [main] WARN org.apache.fop.fonts.FontInfo(FontInfo.java:263) - Font 'Verdana,normal,400' not found. Substituting with 'any,normal,400'. So, I am obviously doing something wrong. Can someone see what the problem is? Thanks, Eric -- View this message in context: http://www.nabble.com/Trying-to-programmatically-add-fonts-tp19334713p19334713.html Sent from the FOP - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]