Well, that's just the way it is implemented right now (with my fix or
without). I know exactly how expensive the operation is. Adrian has done
a good job with the new functionality but it's only half the way to the
ultimate goal. The whole font system has grown over the years and is now
just less than optimal.

PrintRendererConfigurator.buildFontListFromConfiguration() is called
each time a Renderer is instantiated and configured. That means the
whole font list is recreated each time. If we had the "FontSource"
idea/concept in place, this data could be attached to the FopFactory and
reused. This way, each Renderer has its own configuration and due to the
dynamic registration that is possible with Renderers, it's difficult to
attach the gathered information to the FopFactory for later reuse. I
don't remember exactly but maybe Adrian actually tried to do something
like that with statics and I told him I didn't want statics. Not
Adrian's fault at any rate.

The only optimization right now is the FontCache which saves us from
reparsing all the font files each time. And that's the major part in all
that. Still, 60ms on my machine each time for setting up the fonts is a
lot. That's currently the price to pay if you want to use <auto-detect/>.

My change really just fixed a bug. That static variable didn't work at
all. It would have had to work in concert with something else that kept
the gathered information but it didn't, so I removed it. I've stumbled
over it while testing SVG painting. I was running multiple SVGs through
the PDFTransformer and just couldn't explain why my Verdana text was
always painted as Times. When I found that it works the first time, but
not afterwards, I retested with XSL-FO and the same problem appeared.

The whole font refresh is less of a concern to me. Once we can properly
attach the data to the FopFactory it is easy to just "forget" it there
and let FOP recreate it. The problem lies deeper as I hope I was able to
show.

Jeremias Maerki



On 16.10.2007 17:33:17 Chris Bowditch wrote:
> [EMAIL PROTECTED] wrote:
> 
> > Author: jeremias
> > Date: Tue Oct 16 08:12:45 2007
> > New Revision: 585167
> > 
> > URL: http://svn.apache.org/viewvc?rev=585167&view=rev
> > Log:
> > Bugfix: If auto-detection is enabled, auto-detection didn't get done 
> > starting with the second rendering run in the same JVM. Static variables 
> > are dangerous!
> 
> Hi Jeremias,
> 
> auto detecting the Fonts is a very expensive operation. I'm not sure I 
> want it to happen everytime I create an instance of a Renderer object. 
> The way Adrian implemented it avoided calling this expensive operation 
> each time a Renderer was implemented. The drawback is that if the Fonts 
> are changing on a regular basis on the system then theres no way to tell 
> FOP to refresh its auto-detected Fonts without restarting the JVM. 
> Perhaps we need some sort of method which allows the auto-detected Fonts 
> to be refreshed.
> 
> Chris
> 

Reply via email to