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 Peter Verhoye <pe...@synergetic-solutions.be> on 2005/08/08 15:16:00 UTC

Font loading part 2

Hi there,

First already thanks for helping me with my previous question. I've 
found the solution. Seems a collegue of mine made a dirty fix to one of 
his problems. The project on which I work consists of two clients: a fat 
(swing) and a web. The swing app is deployed using Java Webstart.

Now, since our fonts are located in a jar file, and due to webstart 
(according to my collegue) which prohibits you to load from a specific 
jar file, he had 'overriden' the FontInfo class and decide not to use 
the URLBuilder but to use an other method (code shown):
public URL getMetricsFile() throws FOPException {
  try {
   return this.getClass().getResource(metricsFile);
   // return URLBuilder.buildURL(Configuration.getFontBaseURL(), 
metricsFile);
  } catch (Exception e) {
   throw new FOPException("Invalid font metrics file: " + metricsFile
                     + " (" + e.getMessage() + ")");
  }
}

But since I was doing my test on Linux in a shell, this seemed to fail. 
Anyway, on to the next problem.

As said, we have a jar file which is both used in the fat client and the 
web client. In this jar, the fonts are to be found in fonts/metrics/... 
and fonts/truetype/...

Now, I've found a post that says that if you want to load a font from a 
jar, you should use:
jar:file:///home/peter/fop/fop-0.20.5/lib/labeling.jar!fonts/metrics/arial.xml
or something like this.

Now, my problem is that when I use the above statement in my userconfig 
(again I'm testing in a shell with no fontBaseDir or baseDir set in the 
userconfig), I get an error that says:
Failed to read a font metrics file: Invalid font metrics file: 
jar:file:///home/peter/fop/fop-0.20.5/lib/labeling.jar!fonts/metrics/arial.xml 
(no !/ in spec)

I've also tried variations but the result goes from other Exceptions to 
the same error. Anyway, what I would like to have is a solutions where 
the userconfig may be different for each deployment (fat or web) but 
that the fonts are in a jar file and are found :-)

BB
Peter


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


Re: Font loading part 2

Posted by Jeremias Maerki <de...@greenmail.ch>.
Well, it's a relative path. You'd need to make sure that the base
directory is set correctly, so the labeling.jar can be found in the
first place.

On 08.08.2005 15:26:07 Peter Verhoye wrote:
> About this mail:
> 
> When I use the following:
> 
> jar:file://labeling.jar!/fonts/metrics/arial.xml
> 
> I get:
> 
> java.lang.RuntimeException: java.lang.NullPointerException
>          at 
> org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3407)
>          at 
> org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:433)
>          at 
> org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
>          at 
> org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
>          at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown 
> Source)
>          at 
> org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(Unknown Source)
>          at 
> org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipSpaces(Unknown 
> Source)
>          at 
> org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown 
> Source)
>          at 
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
> Source)
>          at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>          at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
>          at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>          at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown 
> Source)
>          at 
> org.apache.xalan.transformer.TrAXFilter.parse(TrAXFilter.java:134)
>          at org.apache.fop.apps.Driver.render(Driver.java:498)
>          at 
> org.apache.fop.apps.CommandLineStarter.run(CommandLineStarter.java:106)
>          at org.apache.fop.apps.Fop.main(Fop.java:62)
> 
> 
> I think xalan can't find the jar file.


Jeremias Maerki


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


Re: Font loading part 2

Posted by Peter Verhoye <pe...@synergetic-solutions.be>.
About this mail:

When I use the following:

jar:file://labeling.jar!/fonts/metrics/arial.xml

I get:

java.lang.RuntimeException: java.lang.NullPointerException
         at 
org.apache.xalan.transformer.TransformerImpl.run(TransformerImpl.java:3407)
         at 
org.apache.xalan.transformer.TransformerHandlerImpl.endDocument(TransformerHandlerImpl.java:433)
         at 
org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
         at 
org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
         at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown 
Source)
         at 
org.apache.xerces.impl.XMLEntityManager$EntityScanner.load(Unknown Source)
         at 
org.apache.xerces.impl.XMLEntityManager$EntityScanner.skipSpaces(Unknown 
Source)
         at 
org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown 
Source)
         at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown 
Source)
         at 
org.apache.xalan.transformer.TrAXFilter.parse(TrAXFilter.java:134)
         at org.apache.fop.apps.Driver.render(Driver.java:498)
         at 
org.apache.fop.apps.CommandLineStarter.run(CommandLineStarter.java:106)
         at org.apache.fop.apps.Fop.main(Fop.java:62)


I think xalan can't find the jar file.

BB
Peter


Peter Verhoye wrote:
> Hi there,
> 
> First already thanks for helping me with my previous question. I've 
> found the solution. Seems a collegue of mine made a dirty fix to one of 
> his problems. The project on which I work consists of two clients: a fat 
> (swing) and a web. The swing app is deployed using Java Webstart.
> 
> Now, since our fonts are located in a jar file, and due to webstart 
> (according to my collegue) which prohibits you to load from a specific 
> jar file, he had 'overriden' the FontInfo class and decide not to use 
> the URLBuilder but to use an other method (code shown):
> public URL getMetricsFile() throws FOPException {
>  try {
>   return this.getClass().getResource(metricsFile);
>   // return URLBuilder.buildURL(Configuration.getFontBaseURL(), 
> metricsFile);
>  } catch (Exception e) {
>   throw new FOPException("Invalid font metrics file: " + metricsFile
>                     + " (" + e.getMessage() + ")");
>  }
> }
> 
> But since I was doing my test on Linux in a shell, this seemed to fail. 
> Anyway, on to the next problem.
> 
> As said, we have a jar file which is both used in the fat client and the 
> web client. In this jar, the fonts are to be found in fonts/metrics/... 
> and fonts/truetype/...
> 
> Now, I've found a post that says that if you want to load a font from a 
> jar, you should use:
> jar:file:///home/peter/fop/fop-0.20.5/lib/labeling.jar!fonts/metrics/arial.xml 
> 
> or something like this.
> 
> Now, my problem is that when I use the above statement in my userconfig 
> (again I'm testing in a shell with no fontBaseDir or baseDir set in the 
> userconfig), I get an error that says:
> Failed to read a font metrics file: Invalid font metrics file: 
> jar:file:///home/peter/fop/fop-0.20.5/lib/labeling.jar!fonts/metrics/arial.xml 
> (no !/ in spec)
> 
> I've also tried variations but the result goes from other Exceptions to 
> the same error. Anyway, what I would like to have is a solutions where 
> the userconfig may be different for each deployment (fat or web) but 
> that the fonts are in a jar file and are found :-)
> 
> BB
> Peter
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org

-- 
Peter Verhoye

Synergetic Solutions nv (www.synergetic-solutions.be)
Crystal Palace
Paalstraat 14
B-1080 Brussel
Tel : +32 (0)2 219.10.12
Fax : +32 (0)2 219.40.28
GSM : +32 (0)475 60.12.61


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


Re: Font loading part 2

Posted by Jeremias Maerki <de...@greenmail.ch>.
The easiest thing is probably to hack URLBuilder (again) and define an
interface (or use URIResolver or EntityResolver) that lets you do custom
URI resolution. Then you create an implementation of that interface for
both deployment variants so you can use logical names (URIs) for the
resources and map them to their effecting URLs. Or might even go as far
as hack into the code to provide custom InputStreams based on URI like
we do now in FOP trunk.

The error message "(no !/ in spec)" should be obvious, not? You need to
begin the in-JAR-part after the "!" with a slash, i.e. an absolute path.
http://java.sun.com/j2se/1.4.2/docs/api/java/net/JarURLConnection.html

On 08.08.2005 15:16:00 Peter Verhoye wrote:
> Hi there,
> 
> First already thanks for helping me with my previous question. I've 
> found the solution. Seems a collegue of mine made a dirty fix to one of 
> his problems. The project on which I work consists of two clients: a fat 
> (swing) and a web. The swing app is deployed using Java Webstart.
> 
> Now, since our fonts are located in a jar file, and due to webstart 
> (according to my collegue) which prohibits you to load from a specific 
> jar file, he had 'overriden' the FontInfo class and decide not to use 
> the URLBuilder but to use an other method (code shown):
> public URL getMetricsFile() throws FOPException {
>   try {
>    return this.getClass().getResource(metricsFile);
>    // return URLBuilder.buildURL(Configuration.getFontBaseURL(), 
> metricsFile);
>   } catch (Exception e) {
>    throw new FOPException("Invalid font metrics file: " + metricsFile
>                      + " (" + e.getMessage() + ")");
>   }
> }
> 
> But since I was doing my test on Linux in a shell, this seemed to fail. 
> Anyway, on to the next problem.
> 
> As said, we have a jar file which is both used in the fat client and the 
> web client. In this jar, the fonts are to be found in fonts/metrics/... 
> and fonts/truetype/...
> 
> Now, I've found a post that says that if you want to load a font from a 
> jar, you should use:
> jar:file:///home/peter/fop/fop-0.20.5/lib/labeling.jar!fonts/metrics/arial.xml
> or something like this.
> 
> Now, my problem is that when I use the above statement in my userconfig 
> (again I'm testing in a shell with no fontBaseDir or baseDir set in the 
> userconfig), I get an error that says:
> Failed to read a font metrics file: Invalid font metrics file: 
> jar:file:///home/peter/fop/fop-0.20.5/lib/labeling.jar!fonts/metrics/arial.xml 
> (no !/ in spec)
> 
> I've also tried variations but the result goes from other Exceptions to 
> the same error. Anyway, what I would like to have is a solutions where 
> the userconfig may be different for each deployment (fat or web) but 
> that the fonts are in a jar file and are found :-)


Jeremias Maerki


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