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 u <ul...@denic.de> on 2011/04/13 13:12:33 UTC

Fop 1.0: resolving relative Font URLs

Hi all,

this is a new problem with fop 1.0, it does not occur in fop 0.95.

In my application I am setting the base font directory programmatically like
so:

fopFactory.setFontBaseURL("/my/font/dir");

And then I have entries like this in my fop.xconf:

&lt;font kerning="yes" embed-url="myfont.ttf"> ... &lt;/font>

This works perfectly in Fop 0.95 and earlier versions, but in Fop 1.0 it
throws an exception:

org.apache.fop.apps.FOPException: Failed to resolve font with embed-url
'myfont.ttf'
        at org.apache.fop.util.LogUtil.handleError(LogUtil.java:38)
        at
org.apache.fop.fonts.FontInfoConfigurator.getFontInfo(FontInfoConfigurator.java:212)
        at
org.apache.fop.fonts.FontInfoConfigurator.addFonts(FontInfoConfigurator.java:168)
        at
org.apache.fop.fonts.FontInfoConfigurator.configure(FontInfoConfigurator.java:100)
        at
org.apache.fop.render.PrintRendererConfigurator.buildFontList(PrintRendererConfigurator.java:106)

The release notes do say that changes with respect to font substitution have
taken place, but I believe an incompatibility like this should explicitly be
mentioned. Any ideas for a workaround?

Ulrich
-- 
View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31386824.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Fop 1.0: resolving relative Font URLs

Posted by Vaclav Tregner <vt...@csas.cz>.
You need to set font-base property or programmatically:
fopFactory.getFontManager().setFontBaseURL("file:///C:/Temp/fonts");


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


Re: Fop 1.0: resolving relative Font URLs

Posted by Ulrich Mayring <ul...@denic.de>.
I already tried the trailing slash yesterday, when you first suggested it.
However, I had to change the code of our application for that, as it doesn't
honor the setting in fop.xconf normally. The result was the same, though.

Normally our application sets the font path programmatically and it does a
number of checks, such as whether the directory exists etc. and then calls
fopFactory.setFontBaseURL with an absolute path to the font directory.

Ulrich
-- 
View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31398355.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Fop 1.0: resolving relative Font URLs

Posted by "Andreas L. Delmelle" <an...@telenet.be>.
On 14 Apr 2011, at 17:28, Andreas L. Delmelle wrote:

> In that case, can you check what happens if you use
> a trailing slash in the embed-url? 
                         ^^^^^^
Errmm... Sorry, too quick. I obviously meant 'the font-base'.

Regards

Andreas
---

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


Re: Fop 1.0: resolving relative Font URLs

Posted by "Andreas L. Delmelle" <an...@telenet.be>.
On 14 Apr 2011, at 17:15, Ulrich Mayring wrote:

Hi Ulrich

> Hm, maybe it's not a problem with the FOP code itself, but with the new
> version of xmlgraphics-commons included in FOP 1.0. At least there seems to
> be a new class called CommonURIResolve involved, which wasn't used in FOP
> 0.95.

In that case, can you check what happens if you use a trailing slash in the embed-url? 

Strictly speaking, according to the RFC, if there is no trailing slash, the base URI (if you would use java.net.URI.resolve(), which CommonURIResolver does) would be the part up to and including the last slash. If one specifies '/my/absolute/path', then the base would be '/my/absolute/', so the 'path' subdirectory would not be included...

I know FOP used to work around this as a convenience, since a lot of people appear to be unaware of that fact.


Regards

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


Re: Fop 1.0: resolving relative Font URLs

Posted by Ulrich Mayring <ul...@denic.de>.
Hm, maybe it's not a problem with the FOP code itself, but with the new
version of xmlgraphics-commons included in FOP 1.0. At least there seems to
be a new class called CommonURIResolve involved, which wasn't used in FOP
0.95.

Ulrich
-- 
View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31398003.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Fop 1.0: resolving relative Font URLs

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

Relative font path works for me on embed-url attribute (Windows + JDK
6.0.20), whatever FOP version (0.95, 1.0, or TRUNK):

Either on my dev machine (invoking FOP via CLI):
<snip>
<font-base>file:///D:/fonts</font-base>
<font kerning="yes" embed-url="dejavu/DejaVuSans.ttf">...</font>
</snip>

Or in production env (WinServer + JRE5 + Jboss):
 - same font element in fop.xconf,
 - but font-base set via
fopFactory.setFontBaseURL("file:///my/absolute/path")



no
Le 13/04/2011 18:26, Terence M. Bandoian a écrit :
>   On 4/13/2011 10:54 AM, Andreas L. Delmelle wrote:
>> On 13 Apr 2011, at 17:33, Ulrich Mayring wrote:
>>
>> Hi Ulrich
>>
>>> All I'm doing is replace fop-0.95.jar with fop-1.0.jar and our
>>> application ceases to work.
>> Just a thought: it might be that the font-cache has also changed slightly between the two versions.
>>
>> Try adding a line to your code like
>>
>>    fopFactory.getFontManager().setUseCache(false);
>>
>> If that works, the more permanent solution would be to delete and regenerate the font-cache to get everything to work as expected with 1.0.
>>
> 
> Hi, Ulrich-
> 
> That matches my experience with 1.0.  Setting font-base works with 
> metric-url but I've used absolute paths for embed-url.
> 
> -Terence Bandoian
-- 
Pascal

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


Re: Fop 1.0: resolving relative Font URLs

Posted by "Terence M. Bandoian" <te...@tmbsw.com>.
  Hi, Ulrich-

I took another look at my configuration and wanted to clarify.  I ended 
up using absolute paths for the embed-urls because the font files were 
in a different directory than the metrics files.

However, I did have to place the <font-base> tag at the top level in the 
configuration file for it to work at all.  I initially located it within 
the <fonts> section without any success but it worked fine when I moved 
it to the top, directly following the <base> tag.

As a test, I copied the font files to the same directory as the metrics 
files and used relative paths for both the metrics files and the font 
files.  No problems.

Sorry for the confusion.

-Terence Bandoian


On 4/13/2011 11:26 AM, Terence M. Bandoian wrote:
>  On 4/13/2011 10:54 AM, Andreas L. Delmelle wrote:
>> On 13 Apr 2011, at 17:33, Ulrich Mayring wrote:
>>
>> Hi Ulrich
>>
>>> All I'm doing is replace fop-0.95.jar with fop-1.0.jar and our
>>> application ceases to work.
>> Just a thought: it might be that the font-cache has also changed 
>> slightly between the two versions.
>>
>> Try adding a line to your code like
>>
>>    fopFactory.getFontManager().setUseCache(false);
>>
>> If that works, the more permanent solution would be to delete and 
>> regenerate the font-cache to get everything to work as expected with 
>> 1.0.
>>
>
> Hi, Ulrich-
>
> That matches my experience with 1.0.  Setting font-base works with 
> metric-url but I've used absolute paths for embed-url.
>
> -Terence Bandoian

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


Re: Fop 1.0: resolving relative Font URLs

Posted by Ulrich Mayring <ul...@denic.de>.

mehdi houshmand wrote:
> 
> Sorry for the late reply, but "/my/font/path" isn't a reference to a
> relative path. That's an absolute path. If the absolute path of your
> font were /my/font/path/myfont.ttf, then your config is correct, and
> you are right in issuing a bug.
Mehdi,

I think I know the difference between an absolute and a relative path :)

Again, I believe you're looking down the wrong path if you're looking for an
error in my configuration, because it works with FOP 0.95 and has been
working for years and years all the way back to FOP 0.20.5. It simply
stopped working with FOP 1.0.

That being said, yes, my fonts are located in /my/font/path/myfont.ttf.

Ulrich
-- 
View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31395115.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Fop 1.0: resolving relative Font URLs

Posted by mehdi houshmand <me...@gmail.com>.
Hi Ulrich,

Sorry for the late reply, but "/my/font/path" isn't a reference to a
relative path. That's an absolute path. If the absolute path of your
font were /my/font/path/myfont.ttf, then your config is correct, and
you are right in issuing a bug. But if your font is located at
<directory of fop.xconf>/my/font/path/myfont.ttf, then you need to
remove the prefixed "/". I think this may be the issue here, I
remember a commit about changing the relative directory to be relative
to the fop.xconf rather than the fop.jar.

Also, strictly speaking the proper format of a file URI in Unix based
systems is  "file:///" not "file:/", though IIRC FOP treats them both
the same anyway.

I may have completely got the wrong end of the stick here, if so, my apologies.

Mehdi

On 14 April 2011 08:39, Ulrich Mayring <ul...@denic.de> wrote:
>
>
> Terence M. Bandoian wrote:
>>
>> Hi, Ulrich-
>>
>> That matches my experience with 1.0.  Setting font-base works with
>> metric-url but I've used absolute paths for embed-url.
>>
> So then it appears to be a bug. I'll report it.
>
> Ulrich
> --
> View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31394545.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Fop 1.0: resolving relative Font URLs

Posted by Ulrich Mayring <ul...@denic.de>.

Terence M. Bandoian wrote:
> 
> Hi, Ulrich-
> 
> That matches my experience with 1.0.  Setting font-base works with 
> metric-url but I've used absolute paths for embed-url.
> 
So then it appears to be a bug. I'll report it.

Ulrich
-- 
View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31394545.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Fop 1.0: resolving relative Font URLs

Posted by "Terence M. Bandoian" <te...@tmbsw.com>.
  On 4/13/2011 10:54 AM, Andreas L. Delmelle wrote:
> On 13 Apr 2011, at 17:33, Ulrich Mayring wrote:
>
> Hi Ulrich
>
>> All I'm doing is replace fop-0.95.jar with fop-1.0.jar and our
>> application ceases to work.
> Just a thought: it might be that the font-cache has also changed slightly between the two versions.
>
> Try adding a line to your code like
>
>    fopFactory.getFontManager().setUseCache(false);
>
> If that works, the more permanent solution would be to delete and regenerate the font-cache to get everything to work as expected with 1.0.
>

Hi, Ulrich-

That matches my experience with 1.0.  Setting font-base works with 
metric-url but I've used absolute paths for embed-url.

-Terence Bandoian

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


Re: Fop 1.0: resolving relative Font URLs

Posted by "Andreas L. Delmelle" <an...@telenet.be>.
On 13 Apr 2011, at 17:33, Ulrich Mayring wrote:

Hi Ulrich

> All I'm doing is replace fop-0.95.jar with fop-1.0.jar and our
> application ceases to work.

Just a thought: it might be that the font-cache has also changed slightly between the two versions.

Try adding a line to your code like

  fopFactory.getFontManager().setUseCache(false);

If that works, the more permanent solution would be to delete and regenerate the font-cache to get everything to work as expected with 1.0.



Regards

Andreas
---

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


Re: Fop 1.0: resolving relative Font URLs

Posted by Ulrich Mayring <ul...@denic.de>.

Pascal Sancho wrote:
> 
> Hi Ulrich,
> 
> I have no solution, only questions:
> 
>  - Are the 2 FOP versions run on the same host?
>  - What OS do you experiment?
>  - Have you tried direct access to "/path/to/fonts" + "/" + "myfont.ttf"
>  (either with ls or dir) ?
>  - Does FOP 1.0 load the right fop.xconf file, if any?
> 
Hi Pascal,

we are running Fop embedded in a custom Java application that generates
PDFs. All I'm doing is replace fop-0.95.jar with fop-1.0.jar and our
application ceases to work. It runs on Linux. I am not changing fop.xconf at
all, neither do I change its location or anything in the directory structure
- I simply copy fop.jar and xmlgraphics-commons.jar over the old files and
restart the application.

In my mind Fop loads the correct fop.xconf file, because it contains the
very font definitions that Fop complains about not being able to resolve
(Dingbats.ttf).

Ulrich
-- 
View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31389153.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Fop 1.0: resolving relative Font URLs

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

I have no solution, only questions:

 - Are the 2 FOP versions run on the same host?
 - What OS do you experiment?
 - Have you tried direct access to "/path/to/fonts" + "/" + "myfont.ttf"
 (either with ls or dir) ?
 - Does FOP 1.0 load the right fop.xconf file, if any?


Le 13/04/2011 16:29, Ulrich Mayring a écrit :
> I have tried both suggestions, using a file-url and appending a slash, but to
> no avail.
> 
> Please keep in mind that this is a regression, i. e. not I am doing
> something wrong, but something changed from fop 0.95 to fop 1.0. Take
> another look at the error message:
> 
> Failed to resolve font with embed-url 'Dingbats.ttf'
> 
> The problem is not the font-base directory, but the embed-url itself, which
> apparently does not work in a relative fashion anymore. Indeed, if I specify
> an absolute path in the embed-url, then the font is found.
> 
> Ulrich

--
Pascal

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


Re: Fop 1.0: resolving relative Font URLs

Posted by Ulrich Mayring <ul...@denic.de>.
I have tried both suggestions, using a file-url and appending a slash, but to
no avail.

Please keep in mind that this is a regression, i. e. not I am doing
something wrong, but something changed from fop 0.95 to fop 1.0. Take
another look at the error message:

Failed to resolve font with embed-url 'Dingbats.ttf'

The problem is not the font-base directory, but the embed-url itself, which
apparently does not work in a relative fashion anymore. Indeed, if I specify
an absolute path in the embed-url, then the font is found.

Ulrich
-- 
View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31388588.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Fop 1.0: resolving relative Font URLs

Posted by mehdi houshmand <me...@gmail.com>.
Hi Ulrich,

Have you tried using file URIs for the font-base? This would be in the
format file:///path/to/font (for unix), for windows based ones, google
will help you, I don't use Windows regularly so I wouldn't want to
speculate

Mehdi


On 13 April 2011 13:58, Ulrich Mayring <ul...@denic.de> wrote:
>
>
> mehdi houshmand wrote:
>>
>> Hi Ulrich,
>>
>> Have you tried setting the font-base in your fop.xconf? I must admit I
>> haven't used the API much but you can set the font-base by inserting
>> following in the fop.xconf:
>> <font-base> ** the base directory ** </font-base>
>>
>
> Hi Mehdi,
>
> we have set the font-base to a non-existing directory and overwrite that
> programmatically when the application starts. That being said, I just tried
> your suggestion and it didn't work either.
>
> Ulrich
> --
> View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31387759.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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: Fop 1.0: resolving relative Font URLs

Posted by Sergiu Dumitriu <se...@xwiki.com>.
On 04/13/2011 02:58 PM, Ulrich Mayring wrote:
>
>
> mehdi houshmand wrote:
>>
>> Hi Ulrich,
>>
>> Have you tried setting the font-base in your fop.xconf? I must admit I
>> haven't used the API much but you can set the font-base by inserting
>> following in the fop.xconf:
>> <font-base>  ** the base directory **</font-base>
>>
>
> Hi Mehdi,
>
> we have set the font-base to a non-existing directory and overwrite that
> programmatically when the application starts. That being said, I just tried
> your suggestion and it didn't work either.
>
> Ulrich

Works for me with 1.0, also setting it dynamically. Try appending a 
trailing slash to the font-base directory.

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

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


Re: Fop 1.0: resolving relative Font URLs

Posted by Ulrich Mayring <ul...@denic.de>.

mehdi houshmand wrote:
> 
> Hi Ulrich,
> 
> Have you tried setting the font-base in your fop.xconf? I must admit I
> haven't used the API much but you can set the font-base by inserting
> following in the fop.xconf:
> <font-base> ** the base directory ** </font-base>
> 

Hi Mehdi,

we have set the font-base to a non-existing directory and overwrite that
programmatically when the application starts. That being said, I just tried
your suggestion and it didn't work either.

Ulrich
-- 
View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31387759.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Fop 1.0: resolving relative Font URLs

Posted by mehdi houshmand <me...@gmail.com>.
Hi Ulrich,

Have you tried setting the font-base in your fop.xconf? I must admit I
haven't used the API much but you can set the font-base by inserting
following in the fop.xconf:
<font-base> ** the base directory ** </font-base>

The configuration page on the fop website may help you,
http://xmlgraphics.apache.org/fop/0.95/configuration.html, if you have
more questions, if that doesn't help, don't hesitate to ask.

Mehdi

On 13 April 2011 12:12, u <ul...@denic.de> wrote:
>
> Hi all,
>
> this is a new problem with fop 1.0, it does not occur in fop 0.95.
>
> In my application I am setting the base font directory programmatically like
> so:
>
> fopFactory.setFontBaseURL("/my/font/dir");
>
> And then I have entries like this in my fop.xconf:
>
> &lt;font kerning="yes" embed-url="myfont.ttf"> ... &lt;/font>
>
> This works perfectly in Fop 0.95 and earlier versions, but in Fop 1.0 it
> throws an exception:
>
> org.apache.fop.apps.FOPException: Failed to resolve font with embed-url
> 'myfont.ttf'
>        at org.apache.fop.util.LogUtil.handleError(LogUtil.java:38)
>        at
> org.apache.fop.fonts.FontInfoConfigurator.getFontInfo(FontInfoConfigurator.java:212)
>        at
> org.apache.fop.fonts.FontInfoConfigurator.addFonts(FontInfoConfigurator.java:168)
>        at
> org.apache.fop.fonts.FontInfoConfigurator.configure(FontInfoConfigurator.java:100)
>        at
> org.apache.fop.render.PrintRendererConfigurator.buildFontList(PrintRendererConfigurator.java:106)
>
> The release notes do say that changes with respect to font substitution have
> taken place, but I believe an incompatibility like this should explicitly be
> mentioned. Any ideas for a workaround?
>
> Ulrich
> --
> View this message in context: http://old.nabble.com/Fop-1.0%3A-resolving-relative-Font-URLs-tp31386824p31386824.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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