xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Sargent <rsarg...@xmission.com>
Subject Trouble with setting font base url which include space character
Date Tue, 17 Apr 2012 22:58:07 GMT
Seems to me FopFactory.setFontBaseURL(String s) is broken?

Forgive the reflection calls (long story).

     File fontsdir = new File(bundlePath + fopHome + "/fonts");

     URL fontsURL = fontsdir.toURI().toURL();
     setFontBaseURLMethod.invoke(fopFactory, fontsURL.toExternalForm());

works fine when the directory is, shall we say, normal, but if the 
directory has a space the method appears to eat the "%20".

Caused by: java.net.MalformedURLException: Illegal character in path at 
index 23: file:///d1/rework/acres 
install/ac47/eclipse/plugins/com.amirsys.console_4.6.0/fop/fop100/fop/fonts/


bundlePath=/d1/rework/acres install/ac47/eclipe/plugins
fopHome=com.amirsys.console_4.6.0/fop/fop100/fop

I've written a test jig to see what File.toURI().toURL() does:

    import java.net.URL;
    import java.io.File;

    public class FileURL {

         public static void main(String[] args) {
             try {
                 File f = new File(args[0]);
                 URL furl = f.toURI().toURL();
                 System.out.println(furl.toString());
                 System.out.println(furl.toExternalForm());
             }
             catch (java.net.MalformedURLException mue) {
                 mue.printStackTrace();
             }
         }
    }

And that reports what I expected, an encoded path:

    java -cp . FileURL /d1/rework/acres\ install/ac47
    file:/d1/rework/acres%20install/ac47/
    file:/d1/rework/acres%20install/ac47/


I hope someone has a better plan.

I do think that the FOP api should be changed to take a URL rather than 
a string, but that's for another day.



Mime
View raw message