From 8faab42c21e565d859e8caa0c56df1c2a8748dea Mon Sep 17 00:00:00 2001 From: Manuel Mall Date: Sat, 7 Jan 2006 13:15:53 +0000 Subject: Added support for relative font config URLs (metrics-url and embed-url). These URLs are now resolved through the FOP config URI resolver. A new configuration item font-base has been added which defines the base URL to be used for resolution of the font URLs. If it is not given the normal FOP base URL is used. Unrelated to this feature the patch also contains a new image class (java 1.4 specific) for JPEG images. This is for renderers (e.g. AFP) which require access to the decoded JPEG. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@366718 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fonts/FontReader.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/java/org/apache/fop/fonts/FontReader.java') diff --git a/src/java/org/apache/fop/fonts/FontReader.java b/src/java/org/apache/fop/fonts/FontReader.java index 5953c91fb..74ed06579 100644 --- a/src/java/org/apache/fop/fonts/FontReader.java +++ b/src/java/org/apache/fop/fonts/FontReader.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004,2006 The Apache Software Foundation. + * Copyright 1999-2006 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +34,8 @@ import org.xml.sax.helpers.DefaultHandler; //FOP import org.apache.fop.apps.FOPException; +import org.apache.fop.apps.FOUserAgent; +import org.xml.sax.InputSource; /** * Class for reading a metric.xml file and creating a font object. @@ -61,7 +63,7 @@ public class FontReader extends DefaultHandler { private List bfranges = null; - private void createFont(String path) throws FOPException { + private void createFont(InputSource source) throws FOPException { XMLReader parser = null; try { @@ -86,7 +88,7 @@ public class FontReader extends DefaultHandler { parser.setContentHandler(this); try { - parser.parse(path); + parser.parse(source); } catch (SAXException e) { throw new FOPException(e); } catch (IOException e) { @@ -111,6 +113,14 @@ public class FontReader extends DefaultHandler { returnFont.setKerningEnabled(enabled); } + /** + * Sets the user agent environment. Needed for URI resolution + * @param userAgent the user agent + */ + public void setUserAgent(FOUserAgent userAgent) { + returnFont.setUserAgent(userAgent); + } + /** * Get the generated font object @@ -123,11 +133,11 @@ public class FontReader extends DefaultHandler { /** * Construct a FontReader object from a path to a metric.xml file * and read metric data - * @param path URI to the font metric file + * @param source Source of the font metric file * @throws FOPException if loading the font fails */ - public FontReader(String path) throws FOPException { - createFont(path); + public FontReader(InputSource source) throws FOPException { + createFont(source); } /** -- cgit v1.2.3