Hi,
You have this.fopFactory.setUserConfig(userConfigFile); before this.fopFactory = FopFactory.newInstance(); Thanks From: Umberto Rustichelli aka Ubi [mailto:ope...@gt50.org] Sent: 05 December 2017 14:18 To: fop-users@xmlgraphics.apache.org Subject: fop 1.1 servlet ignores my custom TTF font Respectable, I've been trying many ways to solve this, following online manuals, reading forum posts etc., but I miserably failed. I'm no Java expert. Environment is Linux, Java is 1.6.07, fop is version 1.1 To make sure I'm not stuck with some cache, everytime I have stopped Tomcat, remover webapps/fop* and put the new fop.war into webapps/, then re-run tomcat. I have some fonts that I must use in the PDF renderer (FO to PDF transformation), let's say I just have one that is /opt/fopTest/fonts/Ocrb.ttf After trying some recipes found on the web, like retouching fop.xconf before compiling or where I just put the fop configuration file somewhere... nada. Currently I have modified src/java/org/apache/fop/servlet/FopServlet.java this way: public void init() throws ServletException { this.uriResolver = new ServletContextURIResolver(getServletContext()); this.transFactory = TransformerFactory.newInstance(); this.transFactory.setURIResolver(this.uriResolver); // Ubi: here or in position POS-ALPHA, // the effect seems to be the same (fonts not found!) try { File userConfigFile = new File("/opt/fopTest/Ubi.fop-config.xml"); this.fopFactory.setUserConfig(userConfigFile); } catch (Exception exc) { // I don't see the point in catching this one, should I? } this.fopFactory = FopFactory.newInstance(); this.fopFactory.setURIResolver(this.uriResolver); // POS-ALPHA configureFopFactory(); } and /opt/fopTest/Ubi.fop-config.xml just contains <?xml version="1.0"?> <fop version="1.0"> <renderers> <renderer mime="application/pdf"> <fonts> <!-- Ubi: try this one... --> <directory>/opt/fopTest/fonts/Ocrb.ttf</directory> <auto-detect/> <!-- Ubi: (the previous was apprently insufficient for the servlet) ....try this one, too. See https://xmlgraphics.apache.org/fop/1.1/fonts.html#register --> <font embed-url= <file:///opt/fopTest/fonts/Ocrb.ttf> "file:///opt/fopTest/fonts/Ocrb.ttf" encoding-mode="auto"> <font-triplet name="OCRB" style="normal" weight="normal" /> </font> </fonts> </renderer> </renderers> </fop> By running tomcat with strace, I see that file /opt/fopTest/Ubi.fop-config.xml is actually read, but the font OCRB is not found when invoked (logs/catalina.out): WARNING: Font "OCRB,normal,400" not found. Substituting with "any,normal,400" On the command line, this one works, instead : java -cp build/fop.jar:lib/xmlgraphics-commons-1.5.jar:<the usual lib/*.jar files> \ org.apache.fop.tools.fontlist.FontListMain \ -c /etc/PeS/var/FOP/Ubi.fop-config.xml \ /tmp/test2.pdf and the OCRB font appears in the PDF. So, what am I doing wrong with the servlet??? Is there a bullet-proof way to exploit fonts, possibly with the standard fop servlet (without writing code)? Otherwise, how can I quickly debug/inspect the issue? Thanks a lot Ubi