You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2007/09/25 11:00:31 UTC

svn commit: r579136 [2/4] - in /xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking: ./ examples/fo/basic/ lib/ src/documentation/content/xdocs/ src/documentation/content/xdocs/0.20.5/ src/documentation/content/xdocs/0.93/ src/documentation/co...

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/fonts.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/fonts.xml?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/fonts.xml (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/fonts.xml Tue Sep 25 02:00:20 2007
@@ -24,6 +24,7 @@
     <authors>
       <person name="Jeremias Märki" email=""/>
       <person name="Tore Engvig" email=""/>
+      <person name="Adrian Cumiskey" email=""/>
     </authors>
   </header>
   <body>
@@ -129,8 +130,7 @@
 More information about fonts can be found at:</p>
       <ul>
         <li><a href="http://partners.adobe.com/asn/developer/type/ftypes.html">Adobe font types</a></li>
-        <li><a href="http://partners.adobe.com/asn/developer/technotes/fonts.html">Adobe Font Technote</a>
-</li>
+        <li><a href="http://partners.adobe.com/asn/developer/technotes/fonts.html">Adobe Font Technote</a></li>
       </ul>
       <section id="type1-metrics">
         <title>Type 1 Font Metrics</title>
@@ -236,10 +236,24 @@
       <section id="register">
         <title>Register Fonts with FOP</title>
         <p>You must tell FOP how to find and use the font metrics files by registering them in the <a href="configuration.html">FOP Configuration</a>. Add entries for your custom fonts, regardless of font type, to the configuration file in a manner similar to the following:</p>
-        <source><![CDATA[<font metrics-url="file:///C:/myfonts/FTL_____.xml" kerning="yes"
+        <source><![CDATA[
+<fonts>
+  <!-- register a particular font -->
+  <font metrics-url="file:///C:/myfonts/FTL_____.xml" kerning="yes"
       embed-url="file:///C:/myfonts/FTL_____.pfb">
-  <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
-</font>]]></source>
+     <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
+  </font>
+  
+  <!-- register all the fonts found in a directory -->
+  <directory>C:\MyFonts1</directory>
+  
+  <!-- register all the fonts found in a directory
+       and all of its sub directories (use with care) -->
+  <directory recursive="true">C:\MyFonts2</directory>
+
+  <!-- automatically detect operating system installed fonts -->
+  <auto-detect/>  
+</fonts>]]></source>
         <note>Review the documentation for <a href="configuration.html">FOP Configuration</a> for instructions on making the FOP configuration available to FOP when it runs. Otherwise, FOP has no way of finding your custom font information.</note>
         <ul>
           <li>
@@ -247,8 +261,14 @@
             Relative URLs are resolved relative to the font-base property (or base) if available.
             See <a href="configuration.html">FOP: Configuration</a> for more information.
           </li>
-          <li>The "kerning" and "embed-url" attributes are optional. Kerning is currently not used at all. If embedding is off, the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.</li>
-          <li>When setting the embed-url attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.</li>
+          <li>Either an "embed-url" or a "metrics-url" must be specified for font tag configurations.</li>
+          <li>The font "kerning" attribute is optional. Kerning is currently not used at all.</li>
+	      <li>If embedding is off, the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.</li>
+          <li>When setting the "embed-url" attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.</li>
+          <li>The fonts "directory" tag can be used to register fonts contained within a single or list of directory paths.  The "recursive" attribute can be specified to recursively add fonts from all sub directories.</li>
+          <li>The fonts "auto-detect" tag can be used to automatically register fonts that are found to be installed on the native operating system.</li>
+          <li>Fonts registered with "font" tag configurations override fonts found by means of "directory" tag definitions.</li>
+          <li>Fonts found as a result of a "directory" tag configuration override fonts found as a result of the "auto-detect" tag being specified.</li>
           <li>
             If relative URLs are specified, they are evaluated relative to the value of the 
             "font-base" setting. If there is no "font-base" setting, the fonts are evaluated 
@@ -281,7 +301,7 @@
 See <a href="#ttf-encoding">Table of TTF Encoding Options</a> for more details.</p>
       </section>
       <section id="embedding-base14">
-        <title>Explicitely embedding the base 14 fonts</title>
+        <title>Explicitly embedding the base 14 fonts</title>
         <p>
           There are cases where you might want to force the embedding of one or more of the base 14 fonts that
           can normally be considered available on the target platform (viewer, printer). One of these cases is

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/index.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/index.xml?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/index.xml (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/index.xml Tue Sep 25 02:00:20 2007
@@ -33,11 +33,10 @@
         this version.
       </p>
       <p>
-        The Apache FOP team is proud to present to you the largely rewritten codebase which is 
-        finally in a state where you can start to use it. It has taken over three years to get this
-        far and over two years without a new release from the FOP project. We're still in the process of adding new
-        features. We welcome any feedback you might have and even more, any
-        other form of help to get the project forward.
+        The Apache FOP team is proud to present to you this production quality codebase. It has taken
+        over three years to get this far and over two years without a new release from the FOP
+        project. We're still in the process of adding new features. We welcome any feedback you
+        might have and even more, any other form of help to get the project forward.
       </p>
     </section>
     <section id="upgrading">

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/pdfa.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/pdfa.xml?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/pdfa.xml (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/documentation/content/xdocs/trunk/pdfa.xml Tue Sep 25 02:00:20 2007
@@ -129,5 +129,31 @@
         activated at the same time.
       </p>
     </section>
+    <section id="interoperability">
+      <title>Interoperability</title>
+      <p>
+        There has been some confusion about the namespace for the PDF/A indicator in the XMP
+        metadata. At least three variants have been seen in the wild:
+      </p>
+      <table>
+        <tr>
+          <td>http://www.aiim.org/pdfa/ns/id.html</td>
+          <td><strong>obsolete</strong>, from an early draft of ISO-19005-1, used by Adobe Acrobat 7.x</td>
+        </tr>
+        <tr>
+          <td>http://www.aiim.org/pdfa/ns/id</td>
+          <td><strong>obsolete</strong>, found in the original ISO 19005-1:2005 document</td>
+        </tr>
+        <tr>
+          <td>http://www.aiim.org/pdfa/ns/id/</td>
+          <td><strong>correct</strong>, found in the technical corrigendum 1 of ISO 19005-1:2005</td>
+        </tr>
+      </table>
+      <p>
+        If you get an error validating a PDF/A file in Adobe Acrobat 7.x it doesn't mean that
+        FOP did something wrong. It's Acrobat that is at fault. This is fixed in Adobe Acrobat 8.x
+        which uses the correct namespace as described in the technical corrigendum 1.
+      </p>
+    </section>
   </body>
 </document>

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FOURIResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FOURIResolver.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FOURIResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FOURIResolver.java Tue Sep 25 02:00:20 2007
@@ -29,6 +29,7 @@
 import java.net.URLConnection;
 
 import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
 import javax.xml.transform.stream.StreamSource;
 
 // commons logging
@@ -47,9 +48,42 @@
 public class FOURIResolver
     implements javax.xml.transform.URIResolver {
     
+    // log
     private Log log = LogFactory.getLog("FOP");
+
+    // true if exceptions are to be thrown if the URIs cannot be resolved.
+    private boolean throwExceptions = false;
+
+    /**
+     * Default constructor
+     */
+    public FOURIResolver() {
+        this(false);
+    }
+    
+    /**
+     * Additional constructor
+     * @param throwExceptions true if exceptions are to be thrown if the URIs cannot be
+     *              resolved.
+     */
+    public FOURIResolver(boolean throwExceptions) {
+        this.throwExceptions = throwExceptions;
+    }
     
     /**
+     * Handles resolve exceptions appropriately.
+     * @param errorStr error string
+     * @param strict strict user config
+     */
+    private void handleException(Exception e, String errorStr, boolean strict)
+    throws TransformerException {
+        if (strict) {
+            throw new TransformerException(errorStr, e);
+        }
+        log.error(e.getMessage());
+    }
+
+    /**
      * Called by the processor through {@link FOUserAgent} when it encounters an 
      * uri in an external-graphic element.
      * (see also {@link javax.xml.transform.URIResolver#resolve(String, String)}
@@ -70,31 +104,25 @@
      * @throws javax.xml.transform.TransformerException Never thrown by this implementation.
      * @see javax.xml.transform.URIResolver#resolve(String, String)
      */
-    public Source resolve(String href, String base)
-        throws javax.xml.transform.TransformerException {
-        
-        //data URLs can be quite long so don't try to build a File (can lead to problems)
+    public Source resolve(String href, String base) throws TransformerException {        
+        // data URLs can be quite long so don't try to build a File (can lead to problems)
         if (href.startsWith("data:")) {
             return parseDataURI(href);
         }
-        
+
         URL absoluteURL = null;
-        File f = new File(href);
-        if (f.exists()) {
+        File file = new File(href);
+        if (file.canRead() && file.isFile()) {
             try {
-                absoluteURL = f.toURL();
+                absoluteURL = file.toURL();
             } catch (MalformedURLException mfue) {
-                log.error("Could not convert filename to URL: " + mfue.getMessage()); 
+                handleException(mfue,
+                        "Could not convert filename '" + href + "' to URL", throwExceptions);
             }
         } else {
-            URL baseURL = null;
-            try {
-                baseURL = toBaseURL(base);
-            } catch (MalformedURLException mfue) {
-                log.error("Error with base URL \"" + base + "\"): " + mfue.getMessage());
-            }
-            if (baseURL == null) {
-                // We don't have a valid baseURL just use the URL as given
+            // no base provided
+            if (base == null) {
+                // We don't have a valid file protocol based URL
                 try {
                     absoluteURL = new URL(href);
                 } catch (MalformedURLException mue) {
@@ -103,64 +131,78 @@
                         // the href contains only a path then file: is assumed
                         absoluteURL = new URL("file:" + href);
                     } catch (MalformedURLException mfue) {
-                        log.error("Error with URL '" + href + "': " + mue.getMessage());
-                        return null;
+                        handleException(mfue,
+                                "Error with URL '" + href + "'", throwExceptions);
                     }
                 }
+
+            // try and resolve from context of base
             } else {
+                URL baseURL = null;
                 try {
-                    /*
-                        This piece of code is based on the following statement in 
-                        RFC2396 section 5.2:
-
-                        3) If the scheme component is defined, indicating that the reference
-                           starts with a scheme name, then the reference is interpreted as an
-                           absolute URI and we are done.  Otherwise, the reference URI's
-                           scheme is inherited from the base URI's scheme component.
-
-                           Due to a loophole in prior specifications [RFC1630], some parsers
-                           allow the scheme name to be present in a relative URI if it is the
-                           same as the base URI scheme.  Unfortunately, this can conflict
-                           with the correct parsing of non-hierarchical URI.  For backwards
-                           compatibility, an implementation may work around such references
-                           by removing the scheme if it matches that of the base URI and the
-                           scheme is known to always use the <hier_part> syntax.
-
-                        The URL class does not implement this work around, so we do.
-                    */
-
-                    String scheme = baseURL.getProtocol() + ":";
-                    if (href.startsWith(scheme)) {
-                        href = href.substring(scheme.length());
-                        if ("file:".equals(scheme)) {
-                            int colonPos = href.indexOf(':');
-                            int slashPos = href.indexOf('/');
-                            if (slashPos >= 0 && colonPos >= 0 && colonPos < slashPos) {
-                                href = "/" + href; //Absolute file URL doesn't have a leading slash
-                            }
+                    baseURL = new URL(base);
+                } catch (MalformedURLException mfue) {
+                    handleException(mfue, "Error with base URL '" + base + "'", throwExceptions);
+                }
+
+                /*
+                 * This piece of code is based on the following statement in
+                 * RFC2396 section 5.2:
+                 * 
+                 * 3) If the scheme component is defined, indicating that the
+                 * reference starts with a scheme name, then the reference is
+                 * interpreted as an absolute URI and we are done. Otherwise,
+                 * the reference URI's scheme is inherited from the base URI's
+                 * scheme component.
+                 * 
+                 * Due to a loophole in prior specifications [RFC1630], some
+                 * parsers allow the scheme name to be present in a relative URI
+                 * if it is the same as the base URI scheme. Unfortunately, this
+                 * can conflict with the correct parsing of non-hierarchical
+                 * URI. For backwards compatibility, an implementation may work
+                 * around such references by removing the scheme if it matches
+                 * that of the base URI and the scheme is known to always use
+                 * the <hier_part> syntax.
+                 * 
+                 * The URL class does not implement this work around, so we do.
+                 */
+                String scheme = baseURL.getProtocol() + ":";
+                if (href.startsWith(scheme)) {
+                    href = href.substring(scheme.length());
+                    if ("file:".equals(scheme)) {
+                        int colonPos = href.indexOf(':');
+                        int slashPos = href.indexOf('/');
+                        if (slashPos >= 0 && colonPos >= 0 && colonPos < slashPos) {
+                            href = "/" + href; // Absolute file URL doesn't
+                                                // have a leading slash
                         }
                     }
+                }
+                try {
                     absoluteURL = new URL(baseURL, href);
                 } catch (MalformedURLException mfue) {
-                    log.error("Error with URL '" + href + "': " + mfue.getMessage());
-                    return null;
+                    handleException(mfue,
+                            "Error with URL; base '" + base + "' " + "href '" + href + "'",
+                            throwExceptions);                        
                 }
             }
         }
         
-        String effURL = absoluteURL.toExternalForm();
-        try {
-            URLConnection connection = absoluteURL.openConnection();
-            connection.setAllowUserInteraction(false);
-            connection.setDoInput(true);
-            updateURLConnection(connection, href);
-            connection.connect();
-            return new StreamSource(connection.getInputStream(), effURL);
-        } catch (FileNotFoundException fnfe) {
-            //Note: This is on "debug" level since the caller is supposed to handle this
-            log.debug("File not found: " + effURL);
-        } catch (java.io.IOException ioe) {
-            log.error("Error with opening URL '" + effURL + "': " + ioe.getMessage());
+        if (absoluteURL != null) {
+            String effURL = absoluteURL.toExternalForm();
+            try {
+                URLConnection connection = absoluteURL.openConnection();
+                connection.setAllowUserInteraction(false);
+                connection.setDoInput(true);
+                updateURLConnection(connection, href);
+                connection.connect();
+                return new StreamSource(connection.getInputStream(), effURL);
+            } catch (FileNotFoundException fnfe) {
+                //Note: This is on "debug" level since the caller is supposed to handle this
+                log.debug("File not found: " + effURL);
+            } catch (java.io.IOException ioe) {
+                log.error("Error with opening URL '" + effURL + "': " + ioe.getMessage());
+            }
         }
         return null;
     }
@@ -200,29 +242,6 @@
         }
     }
     
-    /**
-     * Returns the base URL as a java.net.URL.
-     * If the base URL is not set a default URL pointing to the
-     * current directory is returned.
-     * @param baseURL the base URL
-     * @returns the base URL as java.net.URL
-     */
-    private URL toBaseURL(String base) throws MalformedURLException {
-        if (base == null) {
-            return new java.io.File("").toURL();
-        }
-        if (!base.endsWith("/")) {
-            // The behavior described by RFC 3986 regarding resolution of relative
-            // references may be misleading for normal users:
-            // file://path/to/resources + myResource.res -> file://path/to/myResource.res
-            // file://path/to/resources/ + myResource.res -> file://path/to/resources/myResource.res
-            // We assume that even when the ending slash is missing, users have the second
-            // example in mind
-            base += "/";
-        }
-        return new URL(base);
-    }
-
     /**
      * Parses inline data URIs as generated by MS Word's XML export and FO stylesheet.
      * @see <a href="http://www.ietf.org/rfc/rfc2397">RFC 2397</a>

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FOUserAgent.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FOUserAgent.java Tue Sep 25 02:00:20 2007
@@ -63,19 +63,25 @@
 public class FOUserAgent {
 
     /** Defines the default target resolution (72dpi) for FOP */
-    public static final float DEFAULT_TARGET_RESOLUTION = FopFactory.DEFAULT_TARGET_RESOLUTION;
+    public static final float DEFAULT_TARGET_RESOLUTION = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
 
     private static Log log = LogFactory.getLog("FOP");
 
     private FopFactory factory;
     
-    /** The base URL for all URL resolutions, especially for external-graphics */
-    private String baseURL;
-    
+    /**
+     *  The base URL for all URL resolutions, especially for
+     *  external-graphics.
+     */
+    private String base = null;
+
+    /** The base URL for all font URL resolutions. */
+    private String fontBase = null;
+
     /** A user settable URI Resolver */
     private URIResolver uriResolver = null;
     
-    private float targetResolution = DEFAULT_TARGET_RESOLUTION;
+    private float targetResolution = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
     private Map rendererOptions = new java.util.HashMap();
     private File outputFile = null;
     private Renderer rendererOverride = null;
@@ -105,7 +111,6 @@
     
     /**
      * Default constructor
-     * @throws FOPException 
      * @see org.apache.fop.apps.FopFactory
      * @deprecated Provided for compatibility only. Please use the methods from 
      *             FopFactory to construct FOUserAgent instances!
@@ -126,6 +131,7 @@
         }
         this.factory = factory;
         setBaseURL(factory.getBaseURL());
+        setFontBaseURL(factory.getFontBaseURL());
         setTargetResolution(factory.getTargetResolution());
     }
     
@@ -277,10 +283,18 @@
     
     /**
      * Sets the base URL.
-     * @param baseURL base URL
+     * @param baseUrl base URL
      */
-    public void setBaseURL(String baseURL) {
-        this.baseURL = baseURL;
+    public void setBaseURL(String baseUrl) {
+        this.base = baseUrl;
+    }
+
+    /**
+     * sets font base URL
+     * @param fontBaseUrl font base URL
+     */
+    public void setFontBaseURL(String fontBaseUrl) {
+        this.fontBase = fontBaseUrl;
     }
 
     /**
@@ -288,7 +302,7 @@
      * @return the base URL
      */
     public String getBaseURL() {
-        return this.baseURL;
+        return this.base;
     }
 
     /**
@@ -410,8 +424,10 @@
      */
     public void setTargetResolution(float dpi) {
         this.targetResolution = dpi;
-        log.info("target-resolution set to: " + targetResolution 
-                + "dpi (px2mm=" + getTargetPixelUnitToMillimeter() + ")");
+        if (log.isDebugEnabled()) {
+            log.debug("target-resolution set to: " + targetResolution 
+                    + "dpi (px2mm=" + getTargetPixelUnitToMillimeter() + ")");
+        }
     }
 
     /**
@@ -429,8 +445,7 @@
 
     /** @return the font base URL */
     public String getFontBaseURL() {
-        String fontBaseURL = getFactory().getFontBaseURL(); 
-        return fontBaseURL != null ? fontBaseURL : getBaseURL();
+        return fontBase != null ? fontBase : getBaseURL();
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FopFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FopFactory.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FopFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/apps/FopFactory.java Tue Sep 25 02:00:20 2007
@@ -26,6 +26,7 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.MalformedURLException;
+import java.net.URL;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
@@ -39,14 +40,13 @@
 import org.xml.sax.SAXException;
 
 import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.fop.fo.ElementMapping;
 import org.apache.fop.fo.ElementMappingRegistry;
+import org.apache.fop.fonts.FontCache;
 import org.apache.fop.hyphenation.HyphenationTreeResolver;
 import org.apache.fop.image.ImageFactory;
 import org.apache.fop.layoutmgr.LayoutManagerMaker;
@@ -62,27 +62,6 @@
  */
 public class FopFactory {
     
-    /** Defines the default target resolution (72dpi) for FOP */
-    public static final float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi
-
-    /** Defines the default source resolution (72dpi) for FOP */
-    private static final float DEFAULT_SOURCE_RESOLUTION = 72.0f; //dpi
-
-    /** Defines the default page-height */
-    private static final String DEFAULT_PAGE_HEIGHT = "11in";
-    
-    /** Defines the default page-width */
-    private static final String DEFAULT_PAGE_WIDTH = "8.26in";
-    
-    /** Defines if FOP should use strict validation for FO and user config */
-    private static final boolean DEFAULT_STRICT_FO_VALIDATION = true;
-
-    /** Defines if FOP should validate the user config strictly */
-    private static final boolean DEFAULT_STRICT_USERCONFIG_VALIDATION = true;
-    
-    /** Defines if FOP should use an alternative rule to determine text indents */
-    private static final boolean DEFAULT_BREAK_INDENT_INHERITANCE = false;
-
     /** logger instance */
     private static Log log = LogFactory.getLog(FopFactory.class);
     
@@ -100,7 +79,7 @@
                 = new ContentHandlerFactoryRegistry();
     
     /** Our default resolver if none is set */
-    private URIResolver foURIResolver = new FOURIResolver();
+    private URIResolver foURIResolver = null;
     
     /** A user settable URI Resolver */
     private URIResolver uriResolver = null;
@@ -108,22 +87,23 @@
     /** The resolver for user-supplied hyphenation patterns */
     private HyphenationTreeResolver hyphResolver;
     
+    /** Image factory for creating fop image objects */
     private ImageFactory imageFactory = new ImageFactory();
 
-    /** user configuration */
-    private Configuration userConfig = null;
-
+    /** Configuration layer used to configure fop */
+    private FopFactoryConfigurator config = null;
+        
     /**
      *  The base URL for all URL resolutions, especially for
      *  external-graphics.
      */
-    private String baseURL;
+    private String base = null;
 
     /** The base URL for all font URL resolutions. */
-    private String fontBaseURL;
+    private String fontBase = null;
 
     /** The base URL for all hyphen URL resolutions. */
-    private String hyphenBaseURL;
+    private String hyphenBase = null;
 
     /**
      * FOP has the ability, for some FO's, to continue processing even if the
@@ -131,32 +111,36 @@
      * behavior for FOP.  However, this flag, if set, provides the user the
      * ability for FOP to halt on all content model violations if desired.
      */ 
-    private boolean strictFOValidation = DEFAULT_STRICT_FO_VALIDATION;
+    private boolean strictFOValidation = FopFactoryConfigurator.DEFAULT_STRICT_FO_VALIDATION;
 
     /**
      * FOP will validate the contents of the user configuration strictly
      * (e.g. base-urls and font urls/paths).
      */
-    private boolean strictUserConfigValidation = DEFAULT_STRICT_USERCONFIG_VALIDATION;
-    
+    private boolean strictUserConfigValidation
+        = FopFactoryConfigurator.DEFAULT_STRICT_USERCONFIG_VALIDATION;
+
+    /** Font cache to speed up auto-font configuration (null if disabled) */
+    private FontCache fontCache = null;
+
     /** Allows enabling kerning on the base 14 fonts, default is false */
     private boolean enableBase14Kerning = false;
     
     /** Source resolution in dpi */
-    private float sourceResolution = DEFAULT_SOURCE_RESOLUTION;
+    private float sourceResolution = FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION;
 
     /** Target resolution in dpi */
-    private float targetResolution = DEFAULT_TARGET_RESOLUTION;
+    private float targetResolution = FopFactoryConfigurator.DEFAULT_TARGET_RESOLUTION;
 
     /** Page height */
-    private String pageHeight = DEFAULT_PAGE_HEIGHT;
+    private String pageHeight = FopFactoryConfigurator.DEFAULT_PAGE_HEIGHT;
     
     /** Page width */
-    private String pageWidth = DEFAULT_PAGE_WIDTH;
+    private String pageWidth = FopFactoryConfigurator.DEFAULT_PAGE_WIDTH;
 
     /** @see #setBreakIndentInheritanceOnReferenceAreaBoundary(boolean) */
     private boolean breakIndentInheritanceOnReferenceAreaBoundary
-        = DEFAULT_BREAK_INDENT_INHERITANCE;
+        = FopFactoryConfigurator.DEFAULT_BREAK_INDENT_INHERITANCE;
 
     /** Optional overriding LayoutManagerMaker */
     private LayoutManagerMaker lmMakerOverride = null;
@@ -165,14 +149,17 @@
     
     /** Map with cached ICC based ColorSpace objects. */
     private Map colorSpaceMap = null;
-    
+        
     /**
      * Main constructor.
      */
     protected FopFactory() {
+        this.config = new FopFactoryConfigurator(this);
         this.elementMappingRegistry = new ElementMappingRegistry(this);
+        this.foURIResolver = new FOURIResolver(validateUserConfigStrictly());
         // Use a synchronized Map - I am not really sure this is needed, but better safe than sorry.
         this.colorSpaceMap = Collections.synchronizedMap(new java.util.HashMap());
+        setUseCache(FopFactoryConfigurator.DEFAULT_USE_CACHE);
     }
     
     /**
@@ -336,11 +323,42 @@
     }
 
     /**
+     * cleans the base url
+     * @param base
+     * @return
+     * @throws MalformedURLException
+     * @throws URISyntaxException 
+     */
+    private String checkBaseURL(String base) throws MalformedURLException {
+        if (!base.endsWith("/")) {
+            // The behavior described by RFC 3986 regarding resolution of relative
+            // references may be misleading for normal users:
+            // file://path/to/resources + myResource.res -> file://path/to/myResource.res
+            // file://path/to/resources/ + myResource.res -> file://path/to/resources/myResource.res
+            // We assume that even when the ending slash is missing, users have the second
+            // example in mind
+            base += "/";
+        }
+        File dir = new File(base);
+        try {
+            base = (dir.isDirectory() ? dir.toURL() : new URL(base)).toExternalForm(); 
+        } catch (MalformedURLException mfue) {
+            if (strictUserConfigValidation) {
+                throw mfue;
+            }
+            log.error(mfue.getMessage());
+        }
+        return base;
+    }
+    
+    /**
      * Sets the base URL.
-     * @param baseURL base URL
+     * @param base base URL
+     * @throws MalformedURLException 
+     * @throws URISyntaxException 
      */
-    void setBaseURL(String baseURL) {
-        this.baseURL = baseURL;
+    public void setBaseURL(String base) throws MalformedURLException {
+        this.base = checkBaseURL(base);
     }
 
     /**
@@ -348,42 +366,46 @@
      * @return the base URL
      */
     public String getBaseURL() {
-        return this.baseURL;
+        return this.base;
     }
-
+    
     /**
      * Sets the font base URL.
-     * @param fontBaseURL font base URL
+     * @param fontBase font base URL
+     * @throws MalformedURLException 
+     * @throws URISyntaxException 
      */
-    public void setFontBaseURL(String fontBaseURL) {
-        this.fontBaseURL = fontBaseURL;
+    public void setFontBaseURL(String fontBase) throws MalformedURLException {
+        this.fontBase = checkBaseURL(fontBase);
     }
 
     /** @return the font base URL */
     public String getFontBaseURL() {
-        return this.fontBaseURL;
+        return this.fontBase;
     }
 
     /** @return the hyphen base URL */
     public String getHyphenBaseURL() {
-        return hyphenBaseURL;
+        return this.hyphenBase;
     }
 
     /**
      * Sets the hyphen base URL.
-     * @param hyphenBaseURL hythen base URL
-     */
-    public void setHyphenBaseURL(final String hyphenBaseURL) {
-        if (hyphenBaseURL != null) {
+     * @param hyphenBase hythen base URL
+     * @throws MalformedURLException 
+     * @throws URISyntaxException 
+     * */
+    public void setHyphenBaseURL(final String hyphenBase) throws MalformedURLException {
+        if (hyphenBase != null) {
             this.hyphResolver = new HyphenationTreeResolver() {
                 public Source resolve(String href) {
-                    return resolveURI(href, hyphenBaseURL);
+                    return resolveURI(href, hyphenBase);
                 }
             };
         }
-        this.hyphenBaseURL = hyphenBaseURL;
+        this.hyphenBase = checkBaseURL(hyphenBase);
     }
-
+    
     /**
      * Sets the URI Resolver. It is used for resolving factory-level URIs like hyphenation
      * patterns and as backup for URI resolution performed during a rendering run. 
@@ -483,8 +505,10 @@
      */
     public void setSourceResolution(float dpi) {
         this.sourceResolution = dpi;
-        log.info("source-resolution set to: " + sourceResolution 
-                + "dpi (px2mm=" + getSourcePixelUnitToMillimeter() + ")");
+        if (log.isDebugEnabled()) {
+            log.debug("source-resolution set to: " + sourceResolution 
+                    + "dpi (px2mm=" + getSourcePixelUnitToMillimeter() + ")");
+        }
     }
 
     /** @return the resolution for resolution-dependant output */
@@ -538,7 +562,9 @@
      */
     public void setPageHeight(String pageHeight) {
         this.pageHeight = pageHeight;
-        log.info("Default page-height set to: " + pageHeight);
+        if (log.isDebugEnabled()) {
+            log.debug("Default page-height set to: " + pageHeight);
+        }
     }
     
     /**
@@ -559,7 +585,9 @@
      */
     public void setPageWidth(String pageWidth) {
         this.pageWidth = pageWidth;
-        log.info("Default page-width set to: " + pageWidth);
+        if (log.isDebugEnabled()) {
+            log.debug("Default page-width set to: " + pageWidth);
+        }
     }
     
     /**
@@ -595,7 +623,7 @@
     public Set getIgnoredNamespace() {
         return Collections.unmodifiableSet(this.ignoredNamespaces);
     }
-    
+
     //------------------------------------------- Configuration stuff
     
     /**
@@ -605,14 +633,9 @@
      * @throws SAXException if a parsing error occurs
      */
     public void setUserConfig(File userConfigFile) throws SAXException, IOException {
-        try {
-            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
-            setUserConfig(cfgBuilder.buildFromFile(userConfigFile));
-        } catch (ConfigurationException e) {
-            throw new FOPException(e);
-        }
+        config.setUserConfig(userConfigFile);
     }
-    
+
     /**
      * Set the user configuration from an URI.
      * @param uri the URI to the configuration file
@@ -620,12 +643,7 @@
      * @throws SAXException if a parsing error occurs
      */
     public void setUserConfig(String uri) throws SAXException, IOException {
-        try {
-            DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
-            setUserConfig(cfgBuilder.build(uri));
-        } catch (ConfigurationException e) {
-            throw new FOPException(e);
-        }
+        config.setUserConfig(uri);
     }
     
     /**
@@ -634,12 +652,7 @@
      * @throws FOPException if a configuration problem occurs 
      */
     public void setUserConfig(Configuration userConfig) throws FOPException {
-        this.userConfig = userConfig;
-        try {
-            configure(userConfig);
-        } catch (ConfigurationException e) {            
-            throw new FOPException(e);
-        }
+        config.setUserConfig(userConfig);
     }
 
     /**
@@ -647,162 +660,54 @@
      * @return the user configuration
      */
     public Configuration getUserConfig() {
-        return userConfig;
+        return config.getUserConfig();
     }
 
     /**
-     * Returns the configuration subtree for a specific renderer.
-     * @param mimeType MIME type of the renderer
-     * @return the requested configuration subtree, null if there's no configuration
+     * Is the user configuration to be validated?
+     * @param strictUserConfigValidation strict user config validation
      */
-    public Configuration getUserRendererConfig(String mimeType) {
-        if (userConfig == null || mimeType == null) {
-            return null;
-        }
-        
-        Configuration userRendererConfig = null;
-
-        Configuration[] cfgs
-            = userConfig.getChild("renderers").getChildren("renderer");
-        for (int i = 0; i < cfgs.length; ++i) {
-            Configuration child = cfgs[i];
-            try {
-                if (child.getAttribute("mime").equals(mimeType)) {
-                    userRendererConfig = child;
-                    break;
-                }
-            } catch (ConfigurationException e) {
-                // silently pass over configurations without mime type
-            }
-        }
-        log.debug((userRendererConfig == null ? "No u" : "U")
-                  + "ser configuration found for MIME type " + mimeType);
-        return userRendererConfig;
+    public void setStrictUserConfigValidation(boolean strictUserConfigValidation) {
+        this.strictUserConfigValidation = strictUserConfigValidation;
     }
 
     /**
-     * Initializes user agent settings from the user configuration
-     * file, if present: baseURL, resolution, default page size,...
-     * 
-     * @throws ConfigurationException when there is an entry that 
-     *          misses the required attribute
-     * Configures the FopFactory.
-     * @param cfg Avalon Configuration Object
-     * @see org.apache.avalon.framework.configuration.Configurable
+     * Is the user configuration to be validated?
+     * @return if the user configuration should be validated
      */
-    public void configure(Configuration cfg) throws ConfigurationException {        
-        log.info("Initializing FopFactory Configuration");        
-        
-        if (cfg.getChild("strict-configuration", false) != null) {
-            this.strictUserConfigValidation
-                    = cfg.getChild("strict-configuration").getValueAsBoolean();
-        }
-        if (cfg.getChild("strict-validation", false) != null) {
-            this.strictFOValidation = cfg.getChild("strict-validation").getValueAsBoolean();
-        }
-        if (cfg.getChild("base", false) != null) {
-            try {
-                setBaseURL(getBaseURLfromConfig(cfg, "base"));
-            } catch (ConfigurationException e) {
-                if (strictUserConfigValidation) {
-                    throw e;
-                }
-                log.error(e.getMessage());
-            }
-        }
-        if (cfg.getChild("font-base", false) != null) {
-            try {
-                setFontBaseURL(getBaseURLfromConfig(cfg, "font-base"));
-            } catch (ConfigurationException e) {
-                if (strictUserConfigValidation) {
-                    throw e;
-                }
-                log.error(e.getMessage());
-            }
-        }
-        if (cfg.getChild("hyphenation-base", false) != null) {
-            try {
-                setHyphenBaseURL(getBaseURLfromConfig(cfg, "hyphenation-base"));
-            } catch (ConfigurationException e) {
-                if (strictUserConfigValidation) {
-                    throw e;
-                }
-                log.error(e.getMessage());
-            }
-        }
-        if (cfg.getChild("source-resolution", false) != null) {
-            setSourceResolution(
-                    cfg.getChild("source-resolution").getValueAsFloat(DEFAULT_SOURCE_RESOLUTION));
-        }
-        if (cfg.getChild("target-resolution", false) != null) {
-            setTargetResolution(
-                    cfg.getChild("target-resolution").getValueAsFloat(DEFAULT_TARGET_RESOLUTION));
-        }
-        if (cfg.getChild("break-indent-inheritance", false) != null) {
-            setBreakIndentInheritanceOnReferenceAreaBoundary(
-                    cfg.getChild("break-indent-inheritance").getValueAsBoolean());
-        }        
-        Configuration pageConfig = cfg.getChild("default-page-settings");
-        if (pageConfig.getAttribute("height", null) != null) {
-            setPageHeight(pageConfig.getAttribute("height", DEFAULT_PAGE_HEIGHT));
-        }
-        if (pageConfig.getAttribute("width", null) != null) {
-            setPageWidth(pageConfig.getAttribute("width", DEFAULT_PAGE_WIDTH));
-        }
+    public boolean validateUserConfigStrictly() {
+        return this.strictUserConfigValidation;
     }
 
+    //------------------------------------------- Cache related stuff
+
     /**
-     * Retrieves and verifies a base URL.
-     * @param cfg The Configuration object to retrieve the base URL from
-     * @param name the element name for the base URL
-     * @return the requested base URL or null if not available
-     * @throws ConfigurationException 
-     */    
-    public static String getBaseURLfromConfig(Configuration cfg, String name)
-    throws ConfigurationException {
-        if (cfg.getChild(name, false) != null) {
-            try {
-                String cfgBasePath = cfg.getChild(name).getValue(null);
-                if (cfgBasePath != null) {
-                    // Is the path a dirname?
-                    File dir = new File(cfgBasePath);
-//                    if (!dir.exists()) {
-//                        throw new ConfigurationException("Base URL '" + name
-//                                + "' references non-existent resource '"
-//                                + cfgBasePath + "'");
-//                    } else if (dir.isDirectory()) {
-                    if (dir.isDirectory()) {
-                        // Yes, convert it into a URL
-                        cfgBasePath = dir.toURL().toExternalForm(); 
-                    }
-                    // Otherwise, this is already a URL
-                }
-                log.info(name + " set to: " + cfgBasePath);
-                return cfgBasePath;
-            } catch (MalformedURLException mue) {
-                throw new ConfigurationException("Base URL '" + name
-                        + "' in user config is malformed!");
+     * Whether or not to cache results of font triplet detection/auto-config
+     * @param useCache use cache or not
+     */
+    public void setUseCache(boolean useCache) {
+        if (useCache) {
+            this.fontCache = FontCache.load();
+            if (this.fontCache == null) {
+                this.fontCache = new FontCache();
             }
+        } else {
+            this.fontCache = null;
         }
-        return null;
     }
 
     /**
-     * Is the user configuration to be validated?
-     * @param strictUserConfigValidation strict user config validation
+     * Cache results of font triplet detection/auto-config?
+     * @return whether this factory is uses the cache
      */
-    public void setStrictUserConfigValidation(boolean strictUserConfigValidation) {
-        this.strictUserConfigValidation = strictUserConfigValidation;
+    public boolean useCache() {
+        return (this.fontCache != null);
     }
 
-    /**
-     * Is the user configuration to be validated?
-     * @return if the user configuration should be validated
-     */
-    public boolean validateUserConfigStrictly() {
-        return this.strictUserConfigValidation;
+    public FontCache getFontCache() {
+        return this.fontCache;
     }
-
+    
     //------------------------------------------- URI resolution
 
     /**
@@ -810,26 +715,29 @@
      * Will use the configured resolver and if not successful fall back
      * to the default resolver.
      * @param uri URI to access
-     * @param base the base URI to resolve against
+     * @param baseUri the base URI to resolve against
      * @return A {@link javax.xml.transform.Source} object, or null if the URI
      * cannot be resolved. 
      * @see org.apache.fop.apps.FOURIResolver
      */
-    public Source resolveURI(String uri, String base) {
+    public Source resolveURI(String uri, String baseUri) {
         Source source = null;
         //RFC 2397 data URLs don't need to be resolved, just decode them.
         boolean bypassURIResolution = uri.startsWith("data:");
         if (!bypassURIResolution && uriResolver != null) {
             try {
-                source = uriResolver.resolve(uri, base);
+                source = uriResolver.resolve(uri, baseUri);
             } catch (TransformerException te) {
                 log.error("Attempt to resolve URI '" + uri + "' failed: ", te);
+                if (validateUserConfigStrictly()) {
+                    return null;
+                }
             }
         }
         if (source == null) {
             // URI Resolver not configured or returned null, use default resolver
             try {
-                source = foURIResolver.resolve(uri, base);
+                source = foURIResolver.resolve(uri, baseUri);
             } catch (TransformerException te) {
                 log.error("Attempt to resolve URI '" + uri + "' failed: ", te);
             }
@@ -846,18 +754,18 @@
      * The FOP URI resolver is used to try and locate the ICC file. 
      * If that fails null is returned.
      * 
-     * @param base a base URI to resolve relative URIs
+     * @param baseUri a base URI to resolve relative URIs
      * @param iccProfileSrc ICC Profile source to return a ColorSpace for
      * @return ICC ColorSpace object or null if ColorSpace could not be created 
      */
-    public ColorSpace getColorSpace(String base, String iccProfileSrc) {
+    public ColorSpace getColorSpace(String baseUri, String iccProfileSrc) {
         ColorSpace colorSpace = null;
-        if (!this.colorSpaceMap.containsKey(base + iccProfileSrc)) {
+        if (!this.colorSpaceMap.containsKey(baseUri + iccProfileSrc)) {
             try {
                 ICC_Profile iccProfile = null;
                 // First attempt to use the FOP URI resolver to locate the ICC
                 // profile
-                Source src = this.resolveURI(iccProfileSrc, base);
+                Source src = this.resolveURI(iccProfileSrc, baseUri);
                 if (src != null && src instanceof StreamSource) {
                     // FOP URI resolver found ICC profile - create ICC profile
                     // from the Source
@@ -882,16 +790,16 @@
 
             if (colorSpace != null) {
                 // Put in cache (not when VM resolved it as we can't control
-                this.colorSpaceMap.put(base + iccProfileSrc, colorSpace);
+                this.colorSpaceMap.put(baseUri + iccProfileSrc, colorSpace);
             } else {
                 // TODO To avoid an excessive amount of warnings perhaps
                 // register a null ColorMap in the colorSpaceMap
                 log.warn("Color profile '" + iccProfileSrc + "' not found.");
             }
         } else {
-            colorSpace = (ColorSpace) this.colorSpaceMap.get(base
+            colorSpace = (ColorSpace) this.colorSpaceMap.get(baseUri
                     + iccProfileSrc);
         }
         return colorSpace;
-    }
+    }    
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/area/AreaTreeParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/area/AreaTreeParser.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/area/AreaTreeParser.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/area/AreaTreeParser.java Tue Sep 25 02:00:20 2007
@@ -1060,7 +1060,7 @@
                         if (fontName != null) {
                             String fontStyle = attributes.getValue("font-style");
                             int fontWeight = getAttributeAsInteger(
-                                    attributes, "font-weight", Font.NORMAL);
+                                    attributes, "font-weight", Font.WEIGHT_NORMAL);
                             area.addTrait(trait,
                                     FontInfo.createFontKey(fontName, fontStyle, fontWeight));
                         }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/area/Trait.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/area/Trait.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/area/Trait.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/area/Trait.java Tue Sep 25 02:00:20 2007
@@ -520,7 +520,8 @@
            String[] result = {null, null};
            if (attrValue != null) {
               int len = attrValue.length();
-              if (len >= 2 && attrValue.charAt(0) == '(' && attrValue.charAt(len - 1) == ')') {
+              if (len >= 2 && attrValue.charAt(0) == '(' && attrValue.charAt(len - 1) == ')'
+                      && attrValue.indexOf(',') != -1) {
                   String value = attrValue.substring(1, len - 1); // remove brackets
                   int delimIndex = value.indexOf(',');
                   result[0] = value.substring(0, delimIndex).trim(); // PV key

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/cli/CommandLineOptions.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/cli/CommandLineOptions.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/cli/CommandLineOptions.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/cli/CommandLineOptions.java Tue Sep 25 02:00:20 2007
@@ -143,7 +143,7 @@
                     dumpConfiguration();
                 }
                 checkSettings();
-                createUserConfig();
+                setUserConfig();
                 
                 //Factory config is set up, now we can create the user agent
                 foUserAgent = factory.newFOUserAgent();
@@ -772,11 +772,11 @@
     }    // end checkSettings
 
     /**
-     * Create the user configuration.
+     * Sets the user configuration.
      * @throws FOPException if creating the user configuration fails
      * @throws IOException
      */
-    private void createUserConfig() throws FOPException, IOException {
+    private void setUserConfig() throws FOPException, IOException {
         if (userConfigFile == null) {
             return;
         }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequence.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequence.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequence.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequence.java Tue Sep 25 02:00:20 2007
@@ -127,8 +127,6 @@
                 throw new ValidationException("master-reference '" + masterReference
                    + "' for fo:page-sequence matches no"
                    + " simple-page-master or page-sequence-master", locator);
-            } else {
-                pageSequenceMaster.reset();
             }
         }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java Tue Sep 25 02:00:20 2007
@@ -43,7 +43,7 @@
     private LayoutMasterSet layoutMasterSet;
     private List subSequenceSpecifiers;
     private SubSequenceSpecifier currentSubSequence;
-    private int currentSubSequenceNumber;
+    private int currentSubSequenceNumber = -1;
 
     // The terminology may be confusing. A 'page-sequence-master' consists
     // of a sequence of what the XSL spec refers to as
@@ -135,8 +135,10 @@
     public void reset() {
         currentSubSequenceNumber = -1;
         currentSubSequence = null;
-        for (int i = 0; i < subSequenceSpecifiers.size(); i++) {
-            ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset();
+        if (subSequenceSpecifiers != null) {
+            for (int i = 0; i < subSequenceSpecifiers.size(); i++) {
+                ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset();
+            }
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CustomFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CustomFont.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CustomFont.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/CustomFont.java Tue Sep 25 02:00:20 2007
@@ -30,8 +30,9 @@
             implements FontDescriptor, MutableFont {
 
     private String fontName = null;
+    private String fontSubName = null;
     private String embedFileName = null;
-    protected String embedResourceName = null;
+    private String embedResourceName = null;
     private FontResolver resolver = null;
     
     private int capHeight = 0;
@@ -51,7 +52,6 @@
 
     private boolean useKerning = true;
 
-
     /**
      * @see org.apache.fop.fonts.FontMetrics#getFontName()
      */
@@ -60,6 +60,21 @@
     }
 
     /**
+     * @see org.apache.fop.fonts.FontMetrics#getStrippedFontName()
+     */
+    public String getStrippedFontName() {
+        return FontUtil.stripWhiteSpace(fontName);
+    }
+
+    /**
+     * Returns font's subfamily name.
+     * @return the font's subfamily name
+     */
+    public String getFontSubName() {
+        return fontSubName;
+    }
+
+    /**
      * Returns an URI representing an embeddable font file. The URI will often
      * be a filename or an URL.
      * @return URI to an embeddable font file or null if not available.
@@ -238,6 +253,14 @@
         this.fontName = name;
     }
 
+    /**
+     * Sets the font's subfamily name.
+     * @param subFamilyName the subfamily name of the font
+     */
+    public void setFontSubFamilyName(String subFamilyName) {
+        this.fontSubName = subFamilyName;        
+    }
+    
     /**
      * @see org.apache.fop.fonts.MutableFont#setEmbedFileName(String)
      */

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/EmbedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/EmbedFontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/EmbedFontInfo.java Tue Sep 25 02:00:20 2007
@@ -19,17 +19,26 @@
  
 package org.apache.fop.fonts;
 
+import java.io.Serializable;
 import java.util.List;
 
 /**
  * FontInfo contains meta information on fonts (where is the metrics file etc.)
  */
-public class EmbedFontInfo {
+public class EmbedFontInfo implements Serializable {
     
-    private String metricsFile, embedFile;
-    private boolean kerning;
-    private List fontTriplets;
-
+    /** Serialization Version UID */
+    private static final long serialVersionUID = -9075848379822693399L;
+    
+    /** filename of the metrics file */
+    protected String metricsFile;
+    /** filename of the main font file */
+    protected String embedFile;
+    /** false, to disable kerning */
+    protected boolean kerning;
+    /** the list of associated font triplets */
+    protected List fontTriplets;
+      
     /**
      * Main constructor
      * @param metricsFile Path to the xml file containing font metrics
@@ -44,7 +53,7 @@
         this.kerning = kerning;
         this.fontTriplets = fontTriplets;
     }
-
+        
     /**
      * Returns the path to the metrics file
      * @return the metrics file path
@@ -76,6 +85,10 @@
     public List getFontTriplets() {
         return fontTriplets;
     }
-
+    
+    /** @see java.lang.Object#toString() */
+    public String toString() {
+        return "metrics-url=" + metricsFile + ",embed-url=" + embedFile
+            + ", kerning=" + kerning + ", font-triplet=" + fontTriplets; 
+    }
 }
-

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Font.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/Font.java Tue Sep 25 02:00:20 2007
@@ -27,12 +27,22 @@
  */
 public class Font {
 
-    /** Default fallback key */
-    public static final FontTriplet DEFAULT_FONT = new FontTriplet("any", "normal", 400);
-    /** Normal font weight */
-    public static final int NORMAL = 400;
     /** Bold font weight */
-    public static final int BOLD = 700;
+    public static final int WEIGHT_BOLD = 700;
+
+    /** Normal font weight */
+    public static final int WEIGHT_NORMAL = 400;
+
+    /** Normal font style */
+    public static final String STYLE_NORMAL = "normal";
+
+    /** Italic font style */
+    public static final String STYLE_ITALIC = "italic";
+
+    /** Default fallback key */
+    public static final FontTriplet DEFAULT_FONT = new FontTriplet(
+                    "any", STYLE_NORMAL, WEIGHT_NORMAL);
+
 
     private String fontName;
     private FontTriplet triplet;

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontInfo.java Tue Sep 25 02:00:20 2007
@@ -130,6 +130,9 @@
      */
     private FontTriplet fontLookup(String family, String style,
                              int weight, boolean substFont) {
+        if (log.isTraceEnabled()) {
+            log.trace("Font lookup: " + family + " " + style + " " + weight);
+        }
         FontTriplet startKey = createFontKey(family, style, weight); 
         FontTriplet key = startKey;
         // first try given parameters
@@ -146,13 +149,13 @@
             // only if the font may be substituted
             // fallback 1: try the same font-family and weight with default style
             if (f == null) {
-                key = createFontKey(family, "normal", weight);
+                key = createFontKey(family, Font.STYLE_NORMAL, weight);
                 f = getInternalFontKey(key);
             }
             
             // fallback 2: try the same font-family with default style and weight
             if (f == null) {
-                key = createFontKey(family, "normal", 400);
+                key = createFontKey(family, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
                 f = getInternalFontKey(key);
             }
             
@@ -426,8 +429,4 @@
             return 0;
         }
     }
-    
 }
-
-
-

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontLoader.java Tue Sep 25 02:00:20 2007
@@ -19,6 +19,7 @@
 
 package org.apache.fop.fonts;
 
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -28,6 +29,8 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fonts.truetype.TTFFontLoader;
 import org.apache.fop.fonts.type1.Type1FontLoader;
 
@@ -37,6 +40,51 @@
 public abstract class FontLoader {
 
     /**
+     * logging instance
+     */
+    protected static Log log = LogFactory.getLog(FontLoader.class);
+
+    /** URI representing the font file */
+    protected String fontFileURI = null;
+    /** the InputStream to load the font from */
+    protected InputStream in = null;
+    /** the FontResolver to use for font URI resolution */
+    protected FontResolver resolver = null;
+    /** the loaded font */
+    protected CustomFont returnFont = null;
+
+    /** true if the font has been loaded */
+    protected boolean loaded = false;
+
+    /**
+     * Default constructor.
+     * @param fontFileURI the URI to the PFB file of a Type 1 font
+     * @param in the InputStream reading the PFM file of a Type 1 font
+     * @param resolver the font resolver used to resolve URIs
+     */
+    public FontLoader(String fontFileURI, InputStream in, FontResolver resolver) {
+        this.fontFileURI = fontFileURI;
+        this.in = in;
+        this.resolver = resolver;
+    }
+
+    private static boolean isType1(String fontURI) {
+        return fontURI.toLowerCase().endsWith(".pfb");
+    }
+
+    /**
+     * Loads a custom font from a File. In the case of Type 1 fonts, the PFB file must be specified.
+     * @param fontFile the File representation of the font
+     * @param resolver the font resolver to use when resolving URIs
+     * @return the newly loaded font
+     * @throws IOException In case of an I/O error
+     */
+    public static CustomFont loadFont(File fontFile, FontResolver resolver)
+                throws IOException {
+        return loadFont(fontFile.getAbsolutePath(), resolver);
+    }
+        
+    /**
      * Loads a custom font from a URI. In the case of Type 1 fonts, the PFB file must be specified.
      * @param fontFileURI the URI to the font
      * @param resolver the font resolver to use when resolving URIs
@@ -45,21 +93,38 @@
      */
     public static CustomFont loadFont(String fontFileURI, FontResolver resolver)
                 throws IOException {
-        FontLoader loader;
         fontFileURI = fontFileURI.trim();
         String name = fontFileURI.toLowerCase();
         String effURI;
-        boolean type1 = false;
-        if (name.endsWith(".pfb")) {
-            type1 = true;
+        boolean type1 = isType1(fontFileURI);
+        if (type1) {
             effURI = name.substring(0, fontFileURI.length() - 4) + ".pfm";
         } else {
             effURI = fontFileURI;
         }
-        
+        if (log.isDebugEnabled()) {
+            log.debug("opening " + effURI);
+        }
         InputStream in = openFontFile(resolver, effURI);
+        return loadFontFromInputStream(fontFileURI, resolver, type1, in);
+    }
+
+    /**
+     * Loads and returns a font given an input stream.
+     * @param fontFileURI font file uri
+     * @param resolver font resolver
+     * @param isType1 is it a type1 font?
+     * @param in input stream
+     * @return the loaded font.
+     * @throws IOException In case of an I/O error
+     */
+    protected static CustomFont loadFontFromInputStream(
+            String fontFileURI, FontResolver resolver, boolean isType1,
+            InputStream in)
+                throws IOException {
+        FontLoader loader;
         try {
-            if (type1) {
+            if (isType1) {
                 loader = new Type1FontLoader(fontFileURI, in, resolver);
             } else {
                 loader = new TTFFontLoader(fontFileURI, in, resolver);
@@ -70,6 +135,14 @@
         }
     }
 
+    /**
+     * Opens a font file and returns an input stream.
+     * @param resolver the FontResolver to use for font URI resolution
+     * @param uri the URI representing the font
+     * @return the InputStream to read the font from.
+     * @throws IOException In case of an I/O error
+     * @throws MalformedURLException If an invalid URL is built
+     */
     private static InputStream openFontFile(FontResolver resolver, String uri) 
                     throws IOException, MalformedURLException {
         InputStream in = null;
@@ -96,11 +169,18 @@
         }
         return in;
     }
-    
+        
     /**
-     * @return the font loaded by this loader
+     * Reads/parses the font data.
+     * @throws IOException In case of an I/O error
      */
-    public abstract CustomFont getFont();
+    protected abstract void read() throws IOException;
 
-    
+    /** @see org.apache.fop.fonts.FontLoader#getFont() */
+    public CustomFont getFont() throws IOException {
+        if (!loaded) {
+            read();
+        }
+        return this.returnFont;
+    }
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontSetup.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontSetup.java Tue Sep 25 02:00:20 2007
@@ -34,16 +34,11 @@
 import org.apache.fop.fonts.base14.CourierBoldOblique;
 import org.apache.fop.fonts.base14.Symbol;
 import org.apache.fop.fonts.base14.ZapfDingbats;
-import org.apache.fop.render.PrintRenderer;
 
 // commons logging
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-// Avalon
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-
 // Java
 import java.util.List;
 
@@ -62,8 +57,8 @@
     /**
      * logging instance
      */
-    protected static Log log = LogFactory.getLog("org.apache.fop.fonts");
-    
+    protected static Log log = LogFactory.getLog(FontSetup.class);
+
     /**
      * Sets up the font info object.
      *
@@ -113,52 +108,52 @@
         // fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
 
         /* any is treated as serif */
-        fontInfo.addFontProperties("F5", "any", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "any", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "any", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F7", "any", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F8", "any", "italic", Font.BOLD);
-        fontInfo.addFontProperties("F8", "any", "oblique", Font.BOLD);
-
-        fontInfo.addFontProperties("F1", "sans-serif", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F2", "sans-serif", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F2", "sans-serif", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F3", "sans-serif", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F4", "sans-serif", "oblique", Font.BOLD);
-        fontInfo.addFontProperties("F4", "sans-serif", "italic", Font.BOLD);
-        fontInfo.addFontProperties("F5", "serif", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "serif", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "serif", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F7", "serif", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F8", "serif", "oblique", Font.BOLD);
-        fontInfo.addFontProperties("F8", "serif", "italic", Font.BOLD);
-        fontInfo.addFontProperties("F9", "monospace", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F10", "monospace", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F10", "monospace", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F11", "monospace", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F12", "monospace", "oblique", Font.BOLD);
-        fontInfo.addFontProperties("F12", "monospace", "italic", Font.BOLD);
-
-        fontInfo.addFontProperties("F1", "Helvetica", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F2", "Helvetica", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F2", "Helvetica", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F3", "Helvetica", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F4", "Helvetica", "oblique", Font.BOLD);
-        fontInfo.addFontProperties("F4", "Helvetica", "italic", Font.BOLD);
-        fontInfo.addFontProperties("F5", "Times", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "Times", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "Times", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F7", "Times", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F8", "Times", "oblique", Font.BOLD);
-        fontInfo.addFontProperties("F8", "Times", "italic", Font.BOLD);
-        fontInfo.addFontProperties("F9", "Courier", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F10", "Courier", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F10", "Courier", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F11", "Courier", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F12", "Courier", "oblique", Font.BOLD);
-        fontInfo.addFontProperties("F12", "Courier", "italic", Font.BOLD);
-        fontInfo.addFontProperties("F13", "Symbol", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", Font.NORMAL);
+        fontInfo.addFontProperties("F5", "any", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "any", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "any", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "any", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "any", "italic", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "any", "oblique", Font.WEIGHT_BOLD);
+
+        fontInfo.addFontProperties("F1", "sans-serif", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F2", "sans-serif", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F2", "sans-serif", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F3", "sans-serif", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F4", "sans-serif", "oblique", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F4", "sans-serif", "italic", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F5", "serif", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "serif", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "serif", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "serif", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "serif", "oblique", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "serif", "italic", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F9", "monospace", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F10", "monospace", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F10", "monospace", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F11", "monospace", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F12", "monospace", "oblique", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F12", "monospace", "italic", Font.WEIGHT_BOLD);
+
+        fontInfo.addFontProperties("F1", "Helvetica", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F2", "Helvetica", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F2", "Helvetica", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F3", "Helvetica", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F4", "Helvetica", "oblique", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F4", "Helvetica", "italic", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F5", "Times", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "Times", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times", "oblique", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times", "italic", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F9", "Courier", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F10", "Courier", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F10", "Courier", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F11", "Courier", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F12", "Courier", "oblique", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F12", "Courier", "italic", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F13", "Symbol", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", Font.WEIGHT_NORMAL);
 
         // Custom type 1 fonts step 2/2
         // fontInfo.addFontProperties("F15", "OMEP", "normal", FontInfo.NORMAL);
@@ -166,20 +161,20 @@
         // fontInfo.addFontProperties("F17", "BauerBodoni", "italic", FontInfo.BOLD);
 
         /* for compatibility with PassiveTex */
-        fontInfo.addFontProperties("F5", "Times-Roman", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "Times-Roman", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "Times-Roman", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F7", "Times-Roman", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F8", "Times-Roman", "oblique", Font.BOLD);
-        fontInfo.addFontProperties("F8", "Times-Roman", "italic", Font.BOLD);
-        fontInfo.addFontProperties("F5", "Times Roman", "normal", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "Times Roman", "oblique", Font.NORMAL);
-        fontInfo.addFontProperties("F6", "Times Roman", "italic", Font.NORMAL);
-        fontInfo.addFontProperties("F7", "Times Roman", "normal", Font.BOLD);
-        fontInfo.addFontProperties("F8", "Times Roman", "oblique", Font.BOLD);
-        fontInfo.addFontProperties("F8", "Times Roman", "italic", Font.BOLD);
+        fontInfo.addFontProperties("F5", "Times-Roman", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times-Roman", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times-Roman", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "Times-Roman", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times-Roman", "oblique", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times-Roman", "italic", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F5", "Times Roman", "normal", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times Roman", "oblique", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times Roman", "italic", Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "Times Roman", "normal", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times Roman", "oblique", Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times Roman", "italic", Font.WEIGHT_BOLD);
         fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
-                                   "normal", Font.NORMAL);
+                                   "normal", Font.WEIGHT_NORMAL);
 
         /* Add configured fonts */
         addConfiguredFonts(fontInfo, embedList, 15, resolver);
@@ -218,10 +213,7 @@
             reader.setFontEmbedPath(configFontInfo.getEmbedFile());
             fontInfo.addMetrics(internalName, reader.getFont());
             */
-            LazyFont font = new LazyFont(configFontInfo.getEmbedFile(),
-                                         metricsFile,
-                                         configFontInfo.getKerning(), 
-                                         resolver);
+            LazyFont font = new LazyFont(configFontInfo, resolver);
             fontInfo.addMetrics(internalName, font);
 
             List triplets = configFontInfo.getFontTriplets();
@@ -237,7 +229,7 @@
     }
 
     /** @return a new FontResolver to be used by the font subsystem */
-    private static FontResolver createMinimalFontResolver() {
+    public static FontResolver createMinimalFontResolver() {
         return new FontResolver() {
 
             /** @see org.apache.fop.fonts.FontResolver#resolve(java.lang.String) */
@@ -245,135 +237,6 @@
                 //Minimal functionality here
                 return new StreamSource(href);
             }
-            
         };
-    }
-   
-    /**
-     * Builds a list of EmbedFontInfo objects for use with the setup() method.
-     * 
-     * @param cfg Configuration object
-     * @param renderer calling Renderer object
-     * @return List the newly created list of fonts
-     * @throws ConfigurationException if something's wrong with the config data
-     */
-    public static List buildFontListFromConfiguration(Configuration cfg, PrintRenderer renderer)
-            throws ConfigurationException {
-        List fontList = new java.util.ArrayList();
-               
-        FontResolver fontResolver = (renderer != null ? renderer.getFontResolver() : null);
-        if (fontResolver == null) {
-            //Ensure that we have minimal font resolution capabilities
-            fontResolver = FontSetup.createMinimalFontResolver();
-        }
-       
-        boolean strict = false;
-        if (renderer != null) {
-            strict = renderer.getUserAgent().getFactory().validateUserConfigStrictly();
-        }
-        
-        Configuration[] fonts = cfg.getChildren("fonts");
-        for (int f = 0; f < fonts.length; f++) {
-                
-            Configuration[] font = fonts[f].getChildren("font");
-            for (int i = 0; i < font.length; i++) {
-    
-                String metricsUrl = font[i].getAttribute("metrics-url", null);
-                String embedUrl = font[i].getAttribute("embed-url", null);
-    
-                if (metricsUrl == null && embedUrl == null) {
-                    if (strict) {
-                        throw new ConfigurationException(
-                                "Font configuration without metric-url or embed-url");
-                    }
-                    log.error("Font configuration without metric-url or embed-url");
-                    continue;
-                }
-                
-                if (metricsUrl != null && fontResolver.resolve(metricsUrl) == null) {
-                    if (strict) {
-                        throw new ConfigurationException("Failed to resolve font metric-url '"
-                            + metricsUrl + "'");                    
-                    }
-                    log.error("Failed to resolve font metric-url '" + metricsUrl + "'");
-                    continue;
-                }
-                
-                if (embedUrl != null && fontResolver.resolve(embedUrl) == null) {
-                    if (strict) {
-                        throw new ConfigurationException("Failed to resolve font with embed-url '"
-                                + embedUrl + "'");
-                    }
-                    log.error("Failed to resolve font with embed-url '" + embedUrl + "'");
-                    continue;
-                }
-            
-                boolean useKerning = font[i].getAttributeAsBoolean("kerning", false);
-    
-                Configuration[] triple = font[i].getChildren("font-triplet");
-                List tripleList = new java.util.ArrayList();
-                for (int j = 0; j < triple.length; j++) {
-                    String name = triple[j].getAttribute("name");
-                    if (name == null) {
-                        if (strict) {
-                            throw new ConfigurationException("font-triplet without name");
-                        }
-                        log.error("font-triplet without name");
-                        continue;
-                    }
-                    
-                    String weightStr = triple[j].getAttribute("weight");
-                    if (weightStr == null) {
-                        if (strict) {
-                            throw new ConfigurationException("font-triplet without weight");
-                        }
-                        log.error("font-triplet without weight");
-                        continue;
-                    }
-                    int weight = FontUtil.parseCSS2FontWeight(weightStr);
-    
-                    String style = triple[j].getAttribute("style");
-                    if (style == null) {
-                        if (strict) {
-                            throw new ConfigurationException("font-triplet without style");
-                        }
-                        log.error("font-triplet without style");
-                        continue;
-                    }
-                    
-                    tripleList.add(FontInfo.createFontKey(name,
-                            style, weight));
-                }
-    
-                EmbedFontInfo configFontInfo = new EmbedFontInfo(metricsUrl, 
-                        useKerning, tripleList, embedUrl);
-                
-                if (log.isDebugEnabled()) {
-                    log.debug("Adding font " + configFontInfo.getEmbedFile()
-                            + ", metric file " + configFontInfo.getMetricsFile());
-                    for (int j = 0; j < tripleList.size(); ++j) {
-                        FontTriplet triplet = (FontTriplet) tripleList.get(j);
-                        log.debug("Font triplet "
-                                    + triplet.getName() + ", "
-                                    + triplet.getStyle() + ", "
-                                    + triplet.getWeight());
-                    }
-                }
-                fontList.add(configFontInfo);
-            }
-        }
-        return fontList;
-    }    
-
-    /**
-     * Builds a list of EmbedFontInfo objects for use with the setup() method.
-     * 
-     * @param cfg Configuration object
-     * @return List the newly created list of fonts
-     * @throws ConfigurationException if something's wrong with the config data
-     */
-    public static List buildFontListFromConfiguration(Configuration cfg)
-    throws ConfigurationException {
-        return buildFontListFromConfiguration(cfg, null);
-    }
+    }       
 }

Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontUtil.java?rev=579136&r1=579135&r2=579136&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/fonts/FontUtil.java Tue Sep 25 02:00:20 2007
@@ -57,4 +57,24 @@
         return weight;
     }
 
+    /**
+     * Removes all white space from a string (used primarily for font names)
+     * @param s the string
+     * @return the processed result
+     */
+    public static String stripWhiteSpace(String s) {
+        StringBuffer sb = new StringBuffer(s.length());
+        for (int i = 0, c = s.length(); i < c; i++) {
+            final char ch = s.charAt(i);
+            if (ch != ' ' 
+                    && ch != '\r' 
+                    && ch != '\n'
+                    && ch != '\t') {
+                sb.append(ch);
+            }
+        }
+        return sb.toString();
+    }
+
+    
 }



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