https://issues.apache.org/bugzilla/show_bug.cgi?id=45490

           Summary: Handling of font URL pointing to a JAR entry don't work
           Product: Fop
           Version: all
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: fonts
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


There are a few lines of code in method
public Source org.apache.fop.apps.FOURIResolver.resolve(String href, String
base), which inhibit inclusion of fonts from a JAR file.

If we have a JAR-File /path_to_jar/file.jar in filesystem, and within this JAR
the font metrics exists in the JAR entry
/path_within_jar/fonts/ttfnewsgothic.xml, then a valid URL to this entry is:

  jar:file:/path_to_jar/file.jar!/path_within_jar/fonts/ttfnewsgothic.xml

If you use this URL, the method FOURIResolver.resolve(String href, String base)
is called with the two arguments
href:   jar:file:/path_to_jar/file.jar!/path_within_jar/fonts/ttfnewsgothic.xml
base: jar:file:/path_to_jar/file.jar!/path_within_jar/

The problem is, that lines 194-196 remove "jar:" from href, and we run into
the problem, that in line 208 the constructor new URL(URL basURL, String href)
is called with a href still containing a protocol (file:), which is different
from the protocol of the baseURL (jar:), so
absoluteURL = new URL(baseURL, href) sets absoluteURL to
file:/path_to_file/file.jar!/path_within_jar/fonts/ttfnewsgothic.xml.

This URL doesn't work, cause it's missing the proper protocol specification
(jar:).

I have to admit, that I don't understand, what lines 197-203 should do (Ok, we
prepend a slash to the url, if there is a colon and a slash in the url, and the
colon is places before the slash, but why?), so I'm not sure that I can give a
proper solution for that problem.

But if it's not needed to remove the scheme from the url, if scheme isn't 
"file:" (cause only for this scheme, the slash is prepended), this diff whould
help:

195c236
<                     if (href.startsWith(scheme)) {
---
>                     if (href.startsWith(scheme) && "file:".equals(scheme)) {
197d237
<                         if ("file:".equals(scheme)) {
206d245
<                     }


(I already tried a posting on fop-dev, but actually I didn't get a proper
contact person, so I try it this way.)


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to