13 Jun 2012 16:05
RE: Still having trouble loading fonts at runtime - suggestions?
Bernard Giannetti <thebernmeister <at> hotmail.com>
2012-06-13 14:05:41 GMT
2012-06-13 14:05:41 GMT
Hi Phill,
The PropertiesManager is a class of mine which basically extends java.util.Properties and essentially reads/writes a hash table of key/value pairs. I store in the properties a list of the font names and their respective font files (as discovered via FOP). For me on Ubuntu 12.04 I get:
FontList=Andale Mono,Arial,Arial Black,Bitstream Charter,Century Schoolbook L,Comic Sans MS,Courier,...
FontFiles=file\:/usr/share/fonts/truetype/openoffice/opens___.ttf,file\:/usr/share/fonts/truetype/ttf-khmeros-core/KhmerOS.ttf,...
I cannot remember precisely why I had to implement this "cache" but I think it had to do with supporting i18n. Originally I simply used the hard coded default fonts which FOP "provided" but I found on some non-English machines I'd get the 'square' symbol and so wanted to provide a way for a user to specify a font to use for the render. To do this I got FOP to tell me what fonts were available and present that to the user. I just cache that information so I don't have to ask FOP each time (which can take a few minutes).
When I do the render I pass the font name as one of the transformer parameters:
xslParams.put( "font-family", (String)m_fontName.getSelectedItem() );
where m_fontName is the selected font name in the JComboBox shown to the user.
Cheers,
Bernard.
> Date: Wed, 13 Jun 2012 06:41:58 -0700
> From: phillip.oldham <at> gmail.com
> To: fop-users <at> xmlgraphics.apache.org
> Subject: RE: Still having trouble loading fonts at runtime - suggestions?
>
>
> Hi Bernard
>
> Thanks for that code - that's really helpful.
>
> However, from what I can tell (java isn't one of my main languages, I'm a
> Python dev) it seems as though it doesn't actually tell FOP to reload any
> fonts, but rather gathers a list of fonts and then asks `PropertiesManager`
> to set the fonts. I can't see a reference to `PropertiesManager` in the FOP
> docs; is that a class in your app, or am I missing something?
>
> Cheers,
> Phill
> From: phillip.oldham <at> gmail.com
> To: fop-users <at> xmlgraphics.apache.org
> Subject: RE: Still having trouble loading fonts at runtime - suggestions?
>
>
> Hi Bernard
>
> Thanks for that code - that's really helpful.
>
> However, from what I can tell (java isn't one of my main languages, I'm a
> Python dev) it seems as though it doesn't actually tell FOP to reload any
> fonts, but rather gathers a list of fonts and then asks `PropertiesManager`
> to set the fonts. I can't see a reference to `PropertiesManager` in the FOP
> docs; is that a class in your app, or am I missing something?
>
> Cheers,
> Phill
RSS Feed