You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Phillip B Oldham <ph...@gmail.com> on 2012/05/22 13:28:52 UTC

Is it possible to load & use a font at runtime?

Is it possible to start an app which uses the FOP jar and, at runtime,
load and use a font rather than "installing" it before running the
app? I'm developing an library for our team to use which will load an
FO file, any image assets and (hopefully) any fonts needed to render a
PDF. I've got everything working except the fonts, where I've hit a
bit of a wall. Is it possible?

-- 
Phillip B Oldham

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


Re: Is it possible to load & use a font at runtime?

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi,

FOP Fonts do not need to be installed on your system.
You just need to pass fonts location to FOP.

1/ register all used font files in configuration file (see [1], more 
precisely "register a particular font")

2/ depending on how you use fop (either command line or embedded in your 
app), provide your config file to FOP (see [2] or [3])

note that the <font-base> configuration option can be very usefull here, 
either directly set in config file, or using the 
fopFactory.setFontBaseURL() method (see [4]).


[1] http://xmlgraphics.apache.org/fop/1.0/fonts.html#register
[2] 
http://xmlgraphics.apache.org/fop/1.0/configuration.html#general-available
[3] http://xmlgraphics.apache.org/fop/1.0/embedding.html#config-external
[4] http://xmlgraphics.apache.org/fop/1.0/embedding.html#fop-factory

Le 22/05/2012 13:28, Phillip B Oldham a écrit :
> Is it possible to start an app which uses the FOP jar and, at runtime,
> load and use a font rather than "installing" it before running the
> app? I'm developing an library for our team to use which will load an
> FO file, any image assets and (hopefully) any fonts needed to render a
> PDF. I've got everything working except the fonts, where I've hit a
> bit of a wall. Is it possible?
>

-- 
Pascal

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


Re: Is it possible to load & use a font at runtime?

Posted by Rob Sargent <rs...@xmission.com>.
The is an api call for setting the location of fonts etc.

FopFactory.setFontBaseURL(Sting urlAsString);

You may need a new factory per invocation.

But I can't help wondering why you're not simply putting them all in the 
same place as you get them? Unless all fonts in fontBaseURL are cached?
However, there's a fair amount of convention in the naming etc. which 
you will want to load with setUserConfig( File fontNames.xml).  This 
puts the onus on the user to craft the appropriate font defn. file as 
well as specify the fonts and my be a bigger issue than simply finding 
the fonts (dynamically or not).

rjs


On 05/22/2012 02:26 PM, Phillip B Oldham wrote:
> Thanks Pascal. I need to keep the system running (FOP will be
> embedded), and the font will be chosen/added by the user, so it looks
> like I'll have to create a new config in memory and load it for each
> request. Would it be worth forking a thread for each "run" of FOP and
> loading the config/fonts locally to that thread? The docs say that FOP
> may not be completely thread safe... are there any techniques I can
> follow to reduce issues?
>
>> Hi,
>>
>> FOP Fonts do not need to be installed on your system.
>> You just need to pass fonts location to FOP.
>>
>> 1/ register all used font files in configuration file (see [1], more precisely "register a particular font")
>>
>> 2/ depending on how you use fop (either command line or embedded in your app), provide your config file to FOP (see [2] or [3])
>>
>> note that the<font-base>  configuration option can be very usefull here, either directly set in config file, or using the fopFactory.setFontBaseURL() method (see [4]).
>>
>>
>> [1] http://xmlgraphics.apache.org/fop/1.0/fonts.html#register
>> [2] http://xmlgraphics.apache.org/fop/1.0/configuration.html#general-available
>> [3] http://xmlgraphics.apache.org/fop/1.0/embedding.html#config-external
>> [4] http://xmlgraphics.apache.org/fop/1.0/embedding.html#fop-factory
>>
>> Le 22/05/2012 13:28, Phillip B Oldham a écrit :
>>> Is it possible to start an app which uses the FOP jar and, at runtime,
>>> load and use a font rather than "installing" it before running the
>>> app? I'm developing an library for our team to use which will load an
>>> FO file, any image assets and (hopefully) any fonts needed to render a
>>> PDF. I've got everything working except the fonts, where I've hit a
>>> bit of a wall. Is it possible?
>>>
>> --
>> Pascal
> ---------------------------------------------------------------------
> 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


Re: Is it possible to load & use a font at runtime?

Posted by Phillip B Oldham <ph...@gmail.com>.
Thanks Pascal. I need to keep the system running (FOP will be
embedded), and the font will be chosen/added by the user, so it looks
like I'll have to create a new config in memory and load it for each
request. Would it be worth forking a thread for each "run" of FOP and
loading the config/fonts locally to that thread? The docs say that FOP
may not be completely thread safe... are there any techniques I can
follow to reduce issues?

> Hi,
>
> FOP Fonts do not need to be installed on your system.
> You just need to pass fonts location to FOP.
>
> 1/ register all used font files in configuration file (see [1], more precisely "register a particular font")
>
> 2/ depending on how you use fop (either command line or embedded in your app), provide your config file to FOP (see [2] or [3])
>
> note that the <font-base> configuration option can be very usefull here, either directly set in config file, or using the fopFactory.setFontBaseURL() method (see [4]).
>
>
> [1] http://xmlgraphics.apache.org/fop/1.0/fonts.html#register
> [2] http://xmlgraphics.apache.org/fop/1.0/configuration.html#general-available
> [3] http://xmlgraphics.apache.org/fop/1.0/embedding.html#config-external
> [4] http://xmlgraphics.apache.org/fop/1.0/embedding.html#fop-factory
>
> Le 22/05/2012 13:28, Phillip B Oldham a écrit :
>>
>> Is it possible to start an app which uses the FOP jar and, at runtime,
>> load and use a font rather than "installing" it before running the
>> app? I'm developing an library for our team to use which will load an
>> FO file, any image assets and (hopefully) any fonts needed to render a
>> PDF. I've got everything working except the fonts, where I've hit a
>> bit of a wall. Is it possible?
>>
>
> --
> Pascal

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