xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Umberto Rustichelli aka Ubi <ope...@gt50.org>
Subject Re: fop 1.1 servlet ignores my custom TTF font
Date Tue, 05 Dec 2017 14:55:22 GMT

Thanks Simon, moved the code, it works.

Turned out that I already tried that (see the "POS-ALPHA" comment), but 
apparently at the time I was messing up somewhere else.


On 12/05/2017 03:32 PM, Simon Steiner wrote:
>
> Hi,
>
> You have
>
> this.fopFactory.setUserConfig(userConfigFile);
>
> before
>
> this.fopFactory = FopFactory.newInstance();
>
> Thanks
>
> *From:*Umberto Rustichelli aka Ubi [mailto:opensc@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
>
>
> -- 
> Questo messaggio e' stato analizzato con Libra ESVA ed e' risultato 
> non infetto.
> Clicca qui per segnalarlo come spam. 
> <https://esva.gt50.org/cgi-bin/learn-msg.cgi?id=BE6AC400C3.AED19>
> Clicca qui per metterlo in blacklist 
> <https://esva.gt50.org/cgi-bin/learn-msg.cgi?blacklist=1&id=BE6AC400C3.AED19>
>


Mime
View raw message