xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ali Shaheen <ali.n...@coeus-solutions.de>
Subject Re: Custom font issue
Date Sat, 11 Sep 2010 10:52:13 GMT
Hi all, 

I was finally able to solve the problem... so for future reference, here is what happened
and how i solved it:

Problem:

While generating pdf, if we provided configuration file the pdf was generated fine however
system consumed too much memory and cpu (100%, 100mb+ memory). 
If we did not provide configuration file, pdf was generated without the custom fonts (not
acceptable) and just regular memory and cpu. 

What I tried:

1. Provided metrics and font files in configuration file - but processing and memory stayed
same.
2. Tried to compile fop source to build examples and modify code there - but could not compile
because kept getting memory issues. 
3. Reviewed the configuration file in detail, removed all unnecessary things - processing
and memory stayed same.
4. Removed <auto-detect/> from fonts: processing and memory was perfect then.. !! 

So it turned out that the culprit was auto-detect functionality which is hogging the system.
Here is what my configuration file looks like finally:

<?xml version="1.0"?>
<!-- $Id: fop.xconf 901793 2010-01-21 17:37:07Z jeremias $ -->

<!--
I have removed everything not needed. For example
page width and heigth are supplied in fo files anyway. 
also no need for dpi as its set to default 72. 
also removed unnecessary renderers as we are using pdf only. 
 -->

<!-- NOTE: This is the version of the configuration -->
<fop version="1.0">
  <!-- Base URL for resolving relative URLs -->
  <base>.</base>
  <renderers>
    <renderer mime="application/pdf">
      <fonts>
        <font metrics-url="AVGARDM.xml" kerning="yes" embed-url="fonts/AVGARDM.ttf" encoding-mode="cid">
          <font-triplet name="AvantGarde Md BT" style="normal" weight="700"/>
          <font-triplet name="AvantGarde Md BT" style="normal" weight="400"/>
        </font>
      </fonts>
    </renderer>
		
    <renderer mime="image/svg+xml">
        <format type="paginated"/>
        <link value="true"/>
      <strokeText value="false"/>
    </renderer>
  </renderers>	
</fop>

So I guess we need to have an optimal configuration file, and i believe the fo file can be
further optimized to improve performance too so i will focus on that to improve performance.


Thanks everyone for the help.

Best wishes from Munich,
Ali

On Sep 11, 2010, at 9:12 AM, Glenn Adams wrote:

> I would suggest you ask a colleague that is more familiar with Java to help you if you
want to compile and build FOP. Yes, it builds fine on Mac OS X 10.6 which I am using for FOP
dev work.
> 
> Note that the high memory usage only occurs once when you are building the FOP font cache.
Subsequently, it will not use that much memory. [In building the font cache, it loads and
parses all of the fonts on the system, which is why you need to increase the memory size for
that initial step.]
> 
> Regards,
> Glenn
> 
> On Sat, Sep 11, 2010 at 2:41 PM, ali naqi <ali.naqi@coeus-solutions.de> wrote:
> Thanks. 
> 
> Actually the thing is: WITH command line option -c $configpath, DESPITE the errors, PDF
is generated fine with the correct fonts loaded. However it takes TOO much memory and CPU.

> 
> WITHOUT command line option -c $configpath, it doesn't take too much memory and CPU (we
have to generate hundereds of letters on runtime as the software is for a debt collection
agency whose staff constantly generates reminder letters and then there are automated letters
based on the workflow defined) but doesn't load fonts at all (it gives warnings on AventGarde
Md BT as well as Arial - the two fonts we use in our letters).
> 
> I thought it might be something to do with the paths in the config so I tried placing
fonts and metrics file in the root fop folder and that doesn't work either. 
> 
> By the way, the barcode example in fop doesn't work either. And while looking at it's
instructions, I decided to compile fop from source. However, while compiling javac gives error
of memory and somehow on mac I can't increase the memory with 
> java -Xms2G. It says:
> 
> Error occurred during initialization of VM
> Incompatible minimum and maximum heap sizes specified
> 
> My programming background is system programming with C/C++ (on *nix and Windows) with
some exposure to Java. I just need some pointers moving forward. 
> 
> a. How can I solve the java compilation issue for fop (has anyone ever faced this on
MAC, I couldn't find it much Google)?
> b. Can someone explain how fop loads fonts or finds fonts? May be if I understand what's
going underneath, I can solve this. 
> 
> Best wishes and thanks for the help so far.
> 
> Ali
> 
> On Fri, Sep 10, 2010 at 10:37 AM, Glenn Adams <glenn@skynav.com> wrote:
> inline
> 
> On Fri, Sep 10, 2010 at 4:04 PM, ali naqi <ali.naqi@coeus-solutions.de> wrote:
> By the way..
> 
> if I execute ./fop example.fo example.pdf
> 
> The output is as follows:
> 
> [GA] The following errors could mean that the family name "AvantGarde Md BT" does not
match the name used in the font. Check that with the "Font Book" application in your application
folder. It could also mean that it didn't find the font in the font cache because it was not
able to complete processing the auto-detect process. See more below.
>  
> 
> Sep 10, 2010 10:01:30 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "AvantGarde Md BT,normal,700" not found. Substituting with "any,normal,700".
> Sep 10, 2010 10:01:30 AM org.apache.fop.events.LoggingEventListener processEvent
> INFO: table-layout="fixed" and width="auto", but auto-layout not supported => assuming
width="100%". (See position 20:197)
> Sep 10, 2010 10:01:31 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "Arial,normal,400" not found. Substituting with "any,normal,400".
> Sep 10, 2010 10:01:31 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "Arial,normal,700" not found. Substituting with "any,normal,700".
> Sep 10, 2010 10:01:31 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "Symbol,normal,700" not found. Substituting with "Symbol,normal,400".
> Sep 10, 2010 10:01:31 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "ZapfDingbats,normal,700" not found. Substituting with "ZapfDingbats,normal,400".
> Sep 10, 2010 10:01:31 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "Arial,italic,700" not found. Substituting with "any,italic,700".
> Sep 10, 2010 10:01:31 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "Arial,italic,400" not found. Substituting with "any,italic,400".
> Sep 10, 2010 10:01:31 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "AvantGarde Md BT,normal,400" not found. Substituting with "any,normal,400".
> Sep 10, 2010 10:01:31 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Font "AvantGarde Bk BT,normal,400" not found. Substituting with "any,normal,400".
> [Deprecated] Xalan: org.apache.xml.serializer.XMLEntities
> 
> The PDF is generated without the fonts.
> 
> And if I execute:
> 
> ./fop example.fo example.pdf -c conf/fop.xconf
> 
> I get errors like:
> 
> [GA] Sometime it is useful to read the error messages. As you can see below, you ran
out of Java heap space before FOP finished processing the auto-detect process, this resulted
in not populating the FOP font cache correctly. Try repeating the procedure I gave before,
but before doing so, add an environment variable as follows:
> 
> export FOP_OPTS='-Xmx512m'
> 
> or if that doesn't work, then
> 
> export FOP_OPTS='-Xmx1024m'
> 
> This will cause the JVM to be invoked with the -Xmx option increasing the maximum java
heap size. You need to ensure that FOP finishes the font auto-detect process without error
in order to subsequently access all the auto detected fonts. Note that once FOP builds its
font cache, it will not have to process those fonts in the future (until the FOP font cache
is deleted).
>  
> 
> Sep 10, 2010 10:03:45 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Unable to load font file: file:/Library/Fonts/Raanana.ttf. Reason: java.io.IOException:
TrueType font is not supported: file:/Library/Fonts/Raanana.ttf
> Sep 10, 2010 10:03:45 AM org.apache.fop.fonts.truetype.TTFFile readCMAP
> SEVERE: Unsupported TrueType font: No Unicode or Symbol cmap table not present. Aborting
> Sep 10, 2010 10:03:45 AM org.apache.fop.events.LoggingEventListener processEvent
> WARNING: Unable to load font file: file:/Library/Fonts/RaananaBold.ttf. Reason: java.io.IOException:
TrueType font is not supported: file:/Library/Fonts/RaananaBold.ttf
> ...
> WARNING: Unable to load font file: file:/Library/Fonts/Skia.ttf. Reason: java.io.IOException:
TrueType font is not supported: file:/Library/Fonts/Skia.ttf
> Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
> 	at org.apache.commons.io.output.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:237)
> 	at org.apache.commons.io.IOUtils.toByteArray(IOUtils.java:219)
> 	at org.apache.fop.fonts.truetype.FontFileReader.init(FontFileReader.java:45)
> 	at org.apache.fop.fonts.truetype.FontFileReader.<init>(FontFileReader.java:74)
> 	at org.apache.fop.fonts.autodetect.FontInfoFinder.find(FontInfoFinder.java:204)
> 	at org.apache.fop.fonts.FontAdder.add(FontAdder.java:60)
> 	at org.apache.fop.fonts.FontDetector.detect(FontDetector.java:90)
> 	at org.apache.fop.fonts.FontInfoConfigurator.configure(FontInfoConfigurator.java:92)
> 	at org.apache.fop.render.PrintRendererConfigurator.buildFontList(PrintRendererConfigurator.java:106)
> 	at org.apache.fop.render.PrintRendererConfigurator.setupFontInfo(PrintRendererConfigurator.java:129)
> 	at org.apache.fop.render.intermediate.IFUtil.setupFonts(IFUtil.java:165)
> 	at org.apache.fop.render.intermediate.IFRenderer.setupFontInfo(IFRenderer.java:181)
> 	at org.apache.fop.area.RenderPagesModel.<init>(RenderPagesModel.java:73)
> 	at org.apache.fop.area.AreaTreeHandler.setupModel(AreaTreeHandler.java:130)
> 	at org.apache.fop.area.AreaTreeHandler.<init>(AreaTreeHandler.java:102)
> 	at org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:359)
> 	at org.apache.fop.fo.FOTreeBuilder.<init>(FOTreeBuilder.java:105)
> 	at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:101)
> 	at org.apache.fop.apps.Fop.<init>(Fop.java:79)
> 	at org.apache.fop.apps.FopFactory.newFop(FopFactory.java:271)
> 	at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:109)
> 	at org.apache.fop.cli.Main.startFOP(Main.java:174)
> 	at org.apache.fop.cli.Main.main(Main.java:205)
> 
> What could be wrong?
> 
> On Fri, Sep 10, 2010 at 9:49 AM, ali naqi <ali.naqi@coeus-solutions.de> wrote:
> 1. copy avgardm.ttf into ~/Library/Fonts ... DONE
> 
> 2. remove ~/.fop/fop-fonts.cache ... Could not find .fop/fop-fonts.cache
> 
> 3. change your config to: ... DONE
> 
>       <fonts>
> 	<auto-detect/>
>       </fonts>
> 
> 4. re-run FOP (but don't run TTFReader) ... DONE
> 
> Result: didn't work :(
> 
> On Fri, Sep 10, 2010 at 8:04 AM, Glenn Adams <glenn@skynav.com> wrote:
> i would suggest the following:
> 
> 1. copy avgardm.ttf into ~/Library/Fonts
> 
> 2. remove ~/.fop/fop-fonts.cache
> 
> 3. change your config to:
> 
>       <fonts>
> 	<auto-detect/>
>       </fonts>
> 
> 4. re-run FOP (but don't run TTFReader)
> 
> On Fri, Sep 10, 2010 at 1:53 PM, ali naqi <ali.naqi@coeus-solutions.de> wrote:
> Okay here are more details. 
> 
> Front I am trying to use: AvantGarde Md BT. This is Windows TrueType fonts. 
> 
> My fo file looks like this:
> 
> <fo:inline font-family="AvantGarde Md BT" font-size="9pt" font-weight="bold" color="rgb(135,135,135)">
> 
> In config file I have done this:
> 
> <renderers>
>     <renderer mime="application/pdf">
>       <fonts>
> 	<font embed-url="/fop/fop-1.0/fonts/AVGARDM.ttf">
>             <font-triplet name="AvantGarde Md BT" style="normal" weight="normal"/>
>          </font>
> 	<directory>/fop/fop-1.0/fonts</directory>
> 	<directory recursive="true">/fop/fop-1.0/fonts</directory>
> 	<auto-detect/>
>       </fonts>
> 
> My director structure is this:
> /fop/fop-1.0/
> 
> Operating system is Mac OS X 10.6.4. 
> Jave version is 1.6.0_15
> 
> I also tried to use matrics file. The commandline to use matrics file was:
> 
> java -cp build/fop.jar:lib/avalon-framework-4.2.0.jar:lib/commons-logging-1.0.4.jar:lib/commons-io-1.3.1.jar:lib/xmlgraphics-commons-1.4.jar
org.apache.fop.fonts.apps.TTFReader -enc ansi /fop/fop-1.0/fonts/AVGARDM.ttf AVGARDM.xml
> 
> I also tried without using -enc ansi parameter. 
> 
> Furthermore in config file I have also tried kerning=yes parameter. 
> 
> Looking forward... 
> 
> On Thu, Sep 9, 2010 at 8:18 PM, Eric Douglas <edouglas@blockhouse.com> wrote:
> This web site explains how to reference fonts.
> http://xmlgraphics.apache.org/fop/0.95/fonts.html
> What syntax are you using in your config file to reference the fonts?
> What type of fonts are they?
> Do you have metrics files?
> 
> 
> -----Original Message-----
> From: Ali Naqi [mailto:ali.naqi@coeus-solutions.de]
> Sent: Thursday, September 09, 2010 2:09 PM
> To: fop-users@xmlgraphics.apache.org
> Subject: Re: Custom font issue
> 
> what i am trying to say is that custom fonts load fine when we specify
> -c $fop-config-path, however when we do this a single file takes 300mb
> and over 30 seconds.
> 
> while debugging this we tried to convert with default option ie no
> config path. Simple fop input.fo ouput.pdf. it works like a charm except
> that it didnt load our custom fonts.
> 
> so we tried to put config in system wide path, modified config to load
> custom fonts explicitly etc. Nothing works... and i have lost 15% of my
> hair in the process.
> 
> Hope this helps in some / any pointers in any direction !!
> 
> Thanks
> Ali
> 
> 
> 
> Sent from my iPhone
> 
> On 09.09.2010, at 19:22, "Eric Douglas" <edouglas@blockhouse.com> wrote:
> 
> > What are you trying to say?
> > You're saying you got it to work with the configuration file?
> > What are you trying to do which isn't working?
> > Are you saying using the configuration file without modification works
> 
> > but takes up too much resources?
> > I just tested FOP 0.95 on mine using a configuration file and a
> > command line and it ran really fast and produced proper output.
> > I think we need more details.
> >
> > -----Original Message-----
> > From: Ali Shaheen [mailto:ali.naqi@coeus-solutions.de]
> > Sent: Thursday, September 09, 2010 1:16 PM
> > To: fop-users@xmlgraphics.apache.org
> > Subject: Custom font issue
> >
> > Hello guys,
> >
> > We have a strange issue. We are using some custom fonts in and we
> > generate pdfs using command line. IF we specify the fop configuration
> > file (not edited) via -c , the custom fonts are loaded fine. If not
> > they aren't loaded!
> >
> > We tried changing system wide path, embedding fonts directly in fop
> > configuration as per the online guideline but nothing works.
> >
> > It only works via command line -c switch and if we use that each
> > document takes 350Mb and 100% CPU - without this parameter, it's fine.
> >
> > We are using FOP 0.95.
> >
> > Please see the example fo file too.
> >
> > What to do?
> >
> > Best wishes,
> > Ali
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 
> 
> -- 
> Ali Naqi Shaheen
> Geschäftsführer
> 
> -----------------------------------
> Coeus Solutions GmbH,
> Finkenstr 7, 
> 80333 Munich,
> 
> Mob.: +49-151-51633365
> E-Mail: ali.naqi@coeus-solutions.de
> Web: http://www.coeus-solutions.de
> 
> Geschäftsführer: Ali Naqi Shaheen
> Registergericht München
> HRB: 172737
> 
> 
> 
> 
> -- 
> Ali Naqi Shaheen
> Geschäftsführer
> 
> -----------------------------------
> Coeus Solutions GmbH,
> Finkenstr 7, 
> 80333 Munich,
> 
> Mob.: +49-151-51633365
> E-Mail: ali.naqi@coeus-solutions.de
> Web: http://www.coeus-solutions.de
> 
> Geschäftsführer: Ali Naqi Shaheen
> Registergericht München
> HRB: 172737
> 
> 
> 
> -- 
> Ali Naqi Shaheen
> Geschäftsführer
> 
> -----------------------------------
> Coeus Solutions GmbH,
> Finkenstr 7, 
> 80333 Munich,
> 
> Mob.: +49-151-51633365
> E-Mail: ali.naqi@coeus-solutions.de
> Web: http://www.coeus-solutions.de
> 
> Geschäftsführer: Ali Naqi Shaheen
> Registergericht München
> HRB: 172737
> 
> 
> 
> 
> -- 
> Ali Naqi Shaheen
> Geschäftsführer
> 
> -----------------------------------
> Coeus Solutions GmbH,
> Finkenstr 7, 
> 80333 Munich,
> 
> Mob.: +49-151-51633365
> E-Mail: ali.naqi@coeus-solutions.de
> Web: http://www.coeus-solutions.de
> 
> Geschäftsführer: Ali Naqi Shaheen
> Registergericht München
> HRB: 172737
> 


Mime
View raw message