Uploaded image for project: 'FOP'
  1. FOP
  2. FOP-1559

Handling of font URL pointing to a JAR entry don't work

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Resolution: Fixed
    • 2.5
    • None
    • font/unqualified
    • None
    • Operating System: Linux
      Platform: PC
    • 45490

    Description

      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.)

      Attachments

        Issue Links

          Activity

            People

              fop-dev@xmlgraphics.apache.org fop-dev
              ths-fop@cm4all.com Thomas S.
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: