« Return to Thread: Font registration in a static method

Re: Font registration in a static method

by Sam Fuqua :: Rate this Message:

Reply to Author | View in Thread

Andreas,

I took your advice and have gotten some error output.  It doesn't print this every time, but it has printed for every font I have installed something to the effect of "Failed to load font file ___ .  Could not load InputStream".  If it could find the files itself, then I know that it wasn't me putting in a bad URL, but why would it be that it can't load any of them?  I'm trying to use a .ttf font.

I also tried loading the font manually by creating a FontTriplet and EmbedFontInfo and adding it to the FopFactory FontCache, which gave no error except for the usual "Substituting with 'any'".  Any ideas?

Sam

On Mon, Jun 22, 2009 at 2:57 PM, Andreas Delmelle <andreas.delmelle@...> wrote:
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:...
jabber: mandreas@...
skype: adlm0608




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




--
Sam Fuqua
ΣΝ ΘΗ 454

 « Return to Thread: Font registration in a static method