« Return to Thread: Font registration in a static method

Re: Font registration in a static method

by Andreas Delmelle-2 :: Rate this Message:

Reply to Author | View in Thread

On 20 Jun 2009, at 22:23, Sam Fuqua wrote:

Hi Sam

> I have a FopFactory being declared in a static method.  I have no  
> control over changing the method to non-static.
> When the FopFacotry is created, I try to load a configuration that  
> auto-detects the fonts.  Unfortunately, before I even load the  
> configuration, the FopFactory seems to be created with an existing  
> FontCache with all of my fonts in the failedFontMap.  When I load  
> the configuration, nothing changes and I am unable to use any of my  
> fonts in the XSL.  I am using 0.94.

Just so I get the setup correctly: do the font-locations vary with  
each rendering run? If not, and they always remain the same, it's  
better practice (will yield better performance, in general) to share  
the FopFactory between multiple sessions. You could then include its  
configuration in the same code-block where you instantiate the factory.

> Is this affected by the fact that it is declared inside of a static  
> method?

I see a possibility that this could indeed have an influence: static  
code can be compiled, inlined and executed as soon as the class is  
loaded. If the FopFactory is not configured to use auto-detection, the  
font-triplets referenced in the eventual target process will not be  
found in the cache, and FOP will fall back on a value of 'any'.

> Is there anyway to clear the FontCache and still have it reloaded  
> with auto-detect?  I have been able to clear out the FontCache, but  
> it doesn't reload with the auto-detected fonts, so I am still unable  
> to use my fonts.

See above. I think all you need to do, is make sure that right after  
you instantiate the FopFactory, it is properly configured to auto-
detect OS installed fonts. If that still doesn't work, you'll have to  
activate debug-output, to check whether the referenced font was  
properly loaded.


HTH!

Regards,

Andreas Delmelle
mailto:andreas.delmelle.AT.telenet.be
jabber: mandreas@...
skype: adlm0608




---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@...
For additional commands, e-mail: fop-users-help@...

 « Return to Thread: Font registration in a static method