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 

bundlePath=/d1/rework/acres install/ac47/eclipe/plugins

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();
             catch (java.net.MalformedURLException mue) {

And that reports what I expected, an encoded path:

    java -cp . FileURL /d1/rework/acres\ install/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.

View raw message