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 je...@apache.org on 2007/05/28 16:31:33 UTC

svn commit: r542237 [4/5] - in /xmlgraphics/fop/trunk: ./ lib/ src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/area/ src/java/org/apache/fop/cli/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/...

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRenderer.java Mon May 28 07:31:24 2007
@@ -41,8 +41,6 @@
 import org.w3c.dom.Document;
 
 // Avalon
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.commons.io.IOUtils;
 
 // FOP
@@ -69,7 +67,6 @@
 import org.apache.fop.area.inline.SpaceArea;
 import org.apache.fop.fonts.Typeface;
 import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.image.FopImage;
 import org.apache.fop.image.ImageFactory;
 import org.apache.fop.image.XMLImage;
@@ -86,7 +83,6 @@
 import org.apache.fop.pdf.PDFGoTo;
 import org.apache.fop.pdf.PDFICCBasedColorSpace;
 import org.apache.fop.pdf.PDFICCStream;
-import org.apache.fop.pdf.PDFGoTo;
 import org.apache.fop.pdf.PDFInfo;
 import org.apache.fop.pdf.PDFLink;
 import org.apache.fop.pdf.PDFMetadata;
@@ -266,38 +262,6 @@
     public PDFRenderer() {
     }
 
-    /**
-     * Configure the PDF renderer.
-     * Get the configuration to be used for pdf stream filters,
-     * fonts etc.
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
-     */
-    public void configure(Configuration cfg) throws ConfigurationException {
-        //PDF filters
-        this.filterMap = PDFFilterList.buildFilterMapFromConfiguration(cfg);
-
-        //Font configuration
-        List cfgFonts = FontSetup.buildFontListFromConfiguration(cfg, this);
-        if (this.fontList == null) {
-            this.fontList = cfgFonts;
-        } else {
-            this.fontList.addAll(cfgFonts);
-        }
-        
-        String s = cfg.getChild(PDF_A_MODE, true).getValue(null);
-        if (s != null) {
-            this.pdfAMode = PDFAMode.valueOf(s);
-        }
-        s = cfg.getChild(PDF_X_MODE, true).getValue(null);
-        if (s != null) {
-            this.pdfXMode = PDFXMode.valueOf(s);
-        }
-        s = cfg.getChild(KEY_OUTPUT_PROFILE, true).getValue(null);
-        if (s != null) {
-            this.outputProfileURI = s;
-        }
-    }
-
     private boolean booleanValueOf(Object obj) {
         if (obj instanceof Boolean) {
             return ((Boolean)obj).booleanValue();
@@ -1890,6 +1854,22 @@
     /** @see org.apache.fop.render.AbstractRenderer */
     public String getMimeType() {
         return MIME_TYPE;
+    }
+    
+    public void setAMode(PDFAMode mode) {
+        this.pdfAMode = mode;
+    }
+
+    public void setXMode(PDFXMode mode) {
+        this.pdfXMode = mode;        
+    }
+
+    public void setOutputProfileURI(String outputProfileURI) {
+        this.outputProfileURI = outputProfileURI;
+    }
+
+    public void setFilterMap(Map filterMap) {
+        this.filterMap = filterMap;
     }
 }
 

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.pdf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.pdf.PDFAMode;
+import org.apache.fop.pdf.PDFFilterList;
+import org.apache.fop.pdf.PDFXMode;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.Renderer;
+import org.apache.fop.util.LogUtil;
+
+/**
+ * PDF renderer configurator 
+ */
+public class PDFRendererConfigurator extends PrintRendererConfigurator {
+
+    /**
+     * Default constructor
+     * @param userAgent user agent
+     */
+    public PDFRendererConfigurator(FOUserAgent userAgent) {
+        super(userAgent);
+    }
+
+    /**
+     * Configure the PDF renderer.
+     * Get the configuration to be used for pdf stream filters,
+     * fonts etc.
+     * @param renderer pdf renderer
+     * @throws FOPException fop exception
+     */
+    public void configure(Renderer renderer) throws FOPException {
+        Configuration cfg = super.getRendererConfig(renderer);
+        if (cfg != null) {
+            PDFRenderer pdfRenderer = (PDFRenderer)renderer;
+            //PDF filters
+            try {
+                Map filterMap = buildFilterMapFromConfiguration(cfg);
+                if (filterMap != null) {
+                    pdfRenderer.setFilterMap(filterMap);
+                }
+            } catch (ConfigurationException e) {
+                LogUtil.handleException(log, e, false);
+            }
+    
+            super.configure(renderer);
+    
+            String s = cfg.getChild(PDFRenderer.PDF_A_MODE, true).getValue(null);
+            if (s != null) {
+                pdfRenderer.setAMode(PDFAMode.valueOf(s));
+            }
+            s = cfg.getChild(PDFRenderer.PDF_X_MODE, true).getValue(null);
+            if (s != null) {
+                pdfRenderer.setXMode(PDFXMode.valueOf(s));
+            }
+            s = cfg.getChild(PDFRenderer.KEY_OUTPUT_PROFILE, true).getValue(null);
+            if (s != null) {
+                pdfRenderer.setOutputProfileURI(s);
+            }
+        }
+    }
+
+    /**
+     * Builds a filter map from an Avalon Configuration object.
+     * @param cfg the Configuration object
+     * @return Map the newly built filter map
+     * @throws ConfigurationException if a filter list is defined twice
+     */
+    public static Map buildFilterMapFromConfiguration(Configuration cfg) 
+                throws ConfigurationException {
+        Map filterMap = new java.util.HashMap();
+        Configuration[] filterLists = cfg.getChildren("filterList");
+        for (int i = 0; i < filterLists.length; i++) {
+            Configuration filters = filterLists[i];
+            String type = filters.getAttribute("type", null);
+            Configuration[] filt = filters.getChildren("value");
+            List filterList = new java.util.ArrayList();
+            for (int j = 0; j < filt.length; j++) {
+                String name = filt[j].getValue();
+                filterList.add(name);
+            }
+            
+            if (type == null) {
+                type = PDFFilterList.DEFAULT_FILTER;
+            }
+    
+            if (!filterList.isEmpty() && log.isDebugEnabled()) {
+                StringBuffer debug = new StringBuffer("Adding PDF filter");
+                if (filterList.size() != 1) {
+                    debug.append("s");
+                }
+                debug.append(" for type ").append(type).append(": ");
+                for (int j = 0; j < filterList.size(); j++) {
+                    if (j != 0) {
+                        debug.append(", ");
+                    }
+                    debug.append(filterList.get(j));
+                }
+                log.debug(debug.toString());
+            }
+            
+            if (filterMap.get(type) != null) {
+                throw new ConfigurationException("A filterList of type '" 
+                    + type + "' has already been defined");
+            }
+            filterMap.put(type, filterList);
+        }
+        return filterMap;                
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererConfigurator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFRendererMaker.java Mon May 28 07:31:24 2007
@@ -23,6 +23,7 @@
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.AbstractRendererMaker;
 import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
 
 /**
  * RendererMaker for the PDF Renderer.
@@ -31,12 +32,16 @@
 
     private static final String[] MIMES = new String[] {MimeConstants.MIME_PDF};
     
-    
-    /**@see org.apache.fop.render.AbstractRendererMaker */
-    public Renderer makeRenderer(FOUserAgent ua) {
+    /** @see org.apache.fop.render.AbstractRendererMaker#makeRenderer(FOUserAgent) */
+    public Renderer makeRenderer(FOUserAgent userAgent) {
         return new PDFRenderer();
     }
 
+    /** @see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+        return new PDFRendererConfigurator(userAgent);
+    }
+    
     /** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */
     public boolean needsOutputStream() {
         return true;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/print/PrintRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/print/PrintRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/print/PrintRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/print/PrintRendererMaker.java Mon May 28 07:31:24 2007
@@ -22,7 +22,9 @@
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.AbstractRendererMaker;
+import org.apache.fop.render.PrintRendererConfigurator;
 import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
 
 /**
  * RendererMaker for the Print Renderer.
@@ -31,10 +33,14 @@
 
     private static final String[] MIMES = new String[] {MimeConstants.MIME_FOP_PRINT};
     
-    
-    /**@see org.apache.fop.render.AbstractRendererMaker */
-    public Renderer makeRenderer(FOUserAgent ua) {
+    /**@see org.apache.fop.render.AbstractRendererMaker#makeRenderer(FOUserAgent) */
+    public Renderer makeRenderer(FOUserAgent userAgent) {
         return new PrintRenderer();
+    }
+
+    /** @see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+        return new PrintRendererConfigurator(userAgent);
     }
 
     /** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/NativeTextHandler.java Mon May 28 07:31:24 2007
@@ -159,7 +159,7 @@
         }
         int fontSize = 1000 * f.getSize();
         String style = f.isItalic() ? "italic" : "normal";
-        int weight = f.isBold() ? Font.BOLD : Font.NORMAL;
+        int weight = f.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;
                 
         FontTriplet triplet = fontInfo.findAdjustWeight(fontFamily, style, weight);
         if (triplet == null) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRenderer.java Mon May 28 07:31:24 2007
@@ -35,8 +35,6 @@
 import javax.xml.transform.Source;
 
 // FOP
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -61,7 +59,6 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.fonts.LazyFont;
 import org.apache.fop.fonts.Typeface;
 import org.apache.fop.image.EPSImage;
@@ -145,24 +142,6 @@
     /** This is a map of PSResource instances of all forms (key: uri) */
     private Map formResources;
     
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
-     */
-    public void configure(Configuration cfg) throws ConfigurationException {
-        super.configure(cfg);
-        this.autoRotateLandscape = cfg.getChild(AUTO_ROTATE_LANDSCAPE).getValueAsBoolean(false);
-        this.languageLevel = cfg.getChild(LANGUAGE_LEVEL).getValueAsInteger(this.languageLevel);
-        this.twoPassGeneration = cfg.getChild(OPTIMIZE_RESOURCES).getValueAsBoolean(false);
-
-        //Font configuration
-        List cfgFonts = FontSetup.buildFontListFromConfiguration(cfg, this);
-        if (this.fontList == null) {
-            this.fontList = cfgFonts;
-        } else {
-            this.fontList.addAll(cfgFonts);
-        }
-    }
-
     /**
      * @see org.apache.fop.render.Renderer#setUserAgent(FOUserAgent)
      */

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.ps;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.Renderer;
+
+/**
+ * Postscript renderer config 
+ */
+public class PSRendererConfigurator extends PrintRendererConfigurator {
+
+    /**
+     * Default constructor
+     * @param userAgent user agent
+     */
+    public PSRendererConfigurator(FOUserAgent userAgent) {
+        super(userAgent);
+    }
+
+    /**
+     * Configure the PS renderer.
+     * @param renderer postscript renderer
+     * @throws FOPException fop exception
+     */
+    public void configure(Renderer renderer) throws FOPException {
+        Configuration cfg = super.getRendererConfig(renderer);
+        if (cfg != null) {
+            super.configure(renderer);
+
+            PSRenderer psRenderer = (PSRenderer)renderer;
+            psRenderer.setAutoRotateLandscape(
+                cfg.getChild("auto-rotate-landscape").getValueAsBoolean(false));
+        }
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSRendererMaker.java Mon May 28 07:31:24 2007
@@ -23,6 +23,7 @@
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.AbstractRendererMaker;
 import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
 
 /**
  * RendererMaker for the PostScript Renderer.
@@ -31,12 +32,16 @@
 
     private static final String[] MIMES = new String[] {MimeConstants.MIME_POSTSCRIPT};
     
-    
-    /** @see org.apache.fop.render.AbstractRendererMaker */
-    public Renderer makeRenderer(FOUserAgent ua) {
+    /** @see org.apache.fop.render.AbstractRendererMaker#makeRenderer(FOUserAgent) */
+    public Renderer makeRenderer(FOUserAgent userAgent) {
         return new PSRenderer();
     }
 
+    /** @see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+        return new PSRendererConfigurator(userAgent);
+    }
+
     /** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */
     public boolean needsOutputStream() {
         return true;
@@ -46,5 +51,4 @@
     public String[] getSupportedMimeTypes() {
         return MIMES;
     }
-
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSTextPainter.java Mon May 28 07:31:24 2007
@@ -367,8 +367,8 @@
     private int getWeight(AttributedCharacterIterator aci) {
         Float taWeight = (Float)aci.getAttribute(TextAttribute.WEIGHT);
         return ((taWeight != null) &&  (taWeight.floatValue() > 1.0)) 
-                       ? Font.BOLD
-                       : Font.NORMAL;
+                       ? Font.WEIGHT_BOLD
+                       : Font.WEIGHT_NORMAL;
     }
 
     private Font makeFont(AttributedCharacterIterator aci) {
@@ -402,7 +402,7 @@
                 }
             }
         }
-        FontTriplet triplet = fontInfo.fontLookup("any", style, Font.NORMAL);
+        FontTriplet triplet = fontInfo.fontLookup("any", style, Font.WEIGHT_NORMAL);
         int fsize = (int)(fontSize.floatValue() * 1000);
         return fontInfo.getFontInstance(triplet, fsize);
     }
@@ -411,7 +411,7 @@
         final String style = getStyle(aci);
         final int weight = getWeight(aci);
         int fStyle = java.awt.Font.PLAIN;
-        if (weight == Font.BOLD) {
+        if (weight == Font.WEIGHT_BOLD) {
             fStyle |= java.awt.Font.BOLD;
         }
         if ("italic".equals(style)) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRenderer.java Mon May 28 07:31:24 2007
@@ -27,8 +27,6 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.CTM;
@@ -114,12 +112,6 @@
     /** @see org.apache.fop.render.AbstractRenderer#getMimeType() */
     public String getMimeType() {
         return "text/plain";
-    }
-
-    /** @see org.apache.fop.render.AbstractRenderer */
-    public void configure(Configuration conf) throws ConfigurationException {
-        super.configure(conf);
-        this.encoding = conf.getChild("encoding", true).getValue(null);
     }
     
     /**

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.render.txt;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.Renderer;
+
+/**
+ * TXT Renderer configurator 
+ */
+public class TXTRendererConfigurator extends PrintRendererConfigurator {
+
+    /**
+     * Default constructor
+     * @param userAgent user agent
+     */
+    public TXTRendererConfigurator(FOUserAgent userAgent) {
+        super(userAgent);
+    }
+
+    /**
+     * Configure the PS renderer.
+     * @param renderer TXT renderer
+     * @throws FOPException fop exception
+     */
+    public void configure(Renderer renderer) throws FOPException {
+        Configuration cfg = super.getRendererConfig(renderer);
+        if (cfg != null) {
+            TXTRenderer txtRenderer = (TXTRenderer)renderer;
+            txtRenderer.setEncoding(cfg.getChild("encoding", true).getValue(null));
+        }
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererConfigurator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/txt/TXTRendererMaker.java Mon May 28 07:31:24 2007
@@ -23,6 +23,7 @@
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.AbstractRendererMaker;
 import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
 
 /**
  * RendererMaker for the Plain Text Renderer.
@@ -31,12 +32,16 @@
 
     private static final String[] MIMES = new String[] {MimeConstants.MIME_PLAIN_TEXT};
     
-    
-    /**@see org.apache.fop.render.AbstractRendererMaker */
-    public Renderer makeRenderer(FOUserAgent ua) {
+    /**@see org.apache.fop.render.AbstractRendererMaker#makeRenderer(FOUserAgent) */
+    public Renderer makeRenderer(FOUserAgent userAgent) {
         return new TXTRenderer();
     }
 
+    /**@see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+        return new TXTRendererConfigurator(userAgent);
+    }
+
     /** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */
     public boolean needsOutputStream() {
         return true;
@@ -46,5 +51,4 @@
     public String[] getSupportedMimeTypes() {
         return MIMES;
     }
-
 }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRenderer.java Mon May 28 07:31:24 2007
@@ -41,8 +41,6 @@
 import org.xml.sax.ext.LexicalHandler;
 import org.xml.sax.helpers.AttributesImpl;
 
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.fop.util.QName;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
@@ -83,7 +81,6 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
 import org.apache.fop.fonts.FontInfo;
-import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.render.PrintRenderer;
 import org.apache.fop.render.Renderer;
@@ -137,22 +134,6 @@
      */
     public XMLRenderer() {
         context = new RendererContext(this, XML_MIME_TYPE);
-    }
-
-    /**
-     * Configure the XML renderer.
-     * Get the configuration to be used for fonts etc.
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
-     */
-    public void configure(Configuration cfg) throws ConfigurationException {
-        super.configure(cfg);
-        //Font configuration
-        List cfgFonts = FontSetup.buildFontListFromConfiguration(cfg, this);
-        if (this.fontList == null) {
-            this.fontList = cfgFonts;
-        } else {
-            this.fontList.addAll(cfgFonts);
-        }
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRendererMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRendererMaker.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRendererMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/xml/XMLRendererMaker.java Mon May 28 07:31:24 2007
@@ -22,7 +22,9 @@
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.render.AbstractRendererMaker;
+import org.apache.fop.render.PrintRendererConfigurator;
 import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
 
 /**
  * RendererMaker for the Area Tree XML Renderer.
@@ -31,10 +33,14 @@
 
     private static final String[] MIMES = new String[] {MimeConstants.MIME_FOP_AREA_TREE};
     
-    
-    /**@see org.apache.fop.render.AbstractRendererMaker */
-    public Renderer makeRenderer(FOUserAgent ua) {
+    /**@see org.apache.fop.render.AbstractRendererMaker#makeRenderer(FOUserAgent) */
+    public Renderer makeRenderer(FOUserAgent userAgent) {
         return new XMLRenderer();
+    }
+
+    /**@see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+    public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+        return new PrintRendererConfigurator(userAgent);
     }
 
     /** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFContext.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFContext.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFContext.java Mon May 28 07:31:24 2007
@@ -19,8 +19,6 @@
 
 package org.apache.fop.svg;
 
-import java.util.List;
-
 import org.apache.fop.pdf.PDFPage;
 
 /**
@@ -30,24 +28,10 @@
 public class PDFContext {
 
     private PDFPage currentPage;
-    private List fontList;
 
     /** number of pages generated */
     private int pagecount;
     
-    /**
-     * Sets the font list as creates by the FontSetup class.
-     * @param list the font list
-     */
-    public void setFontList(List list) {
-        this.fontList = list;
-    }
-
-    /** @return the font list */
-    public List getFontList() {
-        return this.fontList;
-    }
-
     /** @return true if a page is set up for painting. */
     public boolean isPagePending() {
         return this.currentPage != null;

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java Mon May 28 07:31:24 2007
@@ -19,6 +19,7 @@
 
 package org.apache.fop.svg;
 
+import org.apache.fop.Version;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFFilterList;
 import org.apache.fop.pdf.PDFPage;
@@ -28,13 +29,8 @@
 import org.apache.fop.pdf.PDFResources;
 import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.pdf.PDFAnnotList;
-import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.fonts.FontInfo;
-import org.apache.avalon.framework.CascadingRuntimeException;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fop.fonts.FontSetup;
 
 import java.awt.Graphics;
 import java.awt.Font;
@@ -56,8 +52,7 @@
  * @version $Id$
  * @see org.apache.fop.svg.PDFGraphics2D
  */
-public class PDFDocumentGraphics2D extends PDFGraphics2D
-            implements Configurable, Initializable {
+public class PDFDocumentGraphics2D extends PDFGraphics2D {
 
     private PDFContext pdfContext;
 
@@ -89,9 +84,6 @@
      */
     protected AffineTransform initialTransform;
 
-    //Avalon component
-    private Configuration cfg;
-
     /**
      * Create a new PDFDocumentGraphics2D.
      * This is used to create a new pdf document, the height,
@@ -106,19 +98,9 @@
     public PDFDocumentGraphics2D(boolean textAsShapes) {
         super(textAsShapes);
 
+        this.pdfDoc = new PDFDocument("Apache FOP Version " + Version.getVersion() 
+                + ": PDFDocumentGraphics2D");
         this.pdfContext = new PDFContext();
-        if (!textAsShapes) {
-            fontInfo = new FontInfo();
-            FontSetup.setup(fontInfo, null, null);
-            //FontState fontState = new FontState("Helvetica", "normal",
-            //                          FontInfo.NORMAL, 12, 0);
-        }
-        try {
-            initialize();
-        } catch (Exception e) {
-            //Should never happen
-            throw new CascadingRuntimeException("Internal error", e);
-        }
     }
 
     /**
@@ -154,33 +136,6 @@
     }
 
     /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
-     */
-    public void configure(Configuration cfg) throws ConfigurationException {
-        this.cfg = cfg;
-        this.pdfContext.setFontList(FontSetup.buildFontListFromConfiguration(cfg));
-    }
-
-    /**
-     * @see org.apache.avalon.framework.activity.Initializable#initialize()
-     */
-    public void initialize() throws Exception {
-        if (this.fontInfo == null || this.cfg != null) {
-            fontInfo = new FontInfo();
-            FontSetup.setup(fontInfo, this.pdfContext.getFontList(), null);
-            //FontState fontState = new FontState("Helvetica", "normal",
-            //                          FontInfo.NORMAL, 12, 0);
-        }
-
-        this.pdfDoc = new PDFDocument("Apache FOP: SVG to PDF Transcoder");
-
-        if (this.cfg != null) {
-            this.pdfDoc.setFilterMap(
-                PDFFilterList.buildFilterMapFromConfiguration(cfg));
-        }
-    }
-
-    /**
      * Setup the document.
      * @param stream the output stream to write the document
      * @param width the width of the page
@@ -197,6 +152,18 @@
     }
 
     /**
+     * Setup a default FontInfo instance if none has been setup before. 
+     */
+    public void setupDefaultFontInfo() {
+        if (fontInfo == null) {
+            //Default minimal fonts
+            FontInfo fontInfo = new FontInfo();
+            FontSetup.setup(fontInfo, null, null);
+            setFontInfo(fontInfo);
+        }
+    }
+    
+    /**
      * Set the device resolution for rendering.  Will take effect at the
      * start of the next page.
      * @param deviceDPI the device resolution (in dpi)
@@ -213,6 +180,14 @@
     }
 
     /**
+     * Sets the font info for this PDF document.
+     * @param fontInfo the font info object with all the fonts
+     */
+    public void setFontInfo(FontInfo fontInfo) {
+        this.fontInfo = fontInfo;
+    }
+    
+    /**
      * Get the font info for this pdf document.
      * @return the font information
      */
@@ -229,6 +204,14 @@
     }
 
     /**
+     * Return the PDFContext for this instance.
+     * @return the PDFContext
+     */
+    public PDFContext getPDFContext() {
+        return this.pdfContext;
+    }
+    
+    /**
      * Set the dimensions of the svg document that will be drawn.
      * This is useful if the dimensions of the svg document are different
      * from the pdf document that is to be created.
@@ -295,6 +278,10 @@
         if (pdfContext.isPagePending()) {
             return;
         }
+        //Setup default font info if no more font configuration has been done by the user.
+        if (!this.textAsShapes && getFontInfo() == null) {
+            setupDefaultFontInfo();
+        }
         try {
             startPage();
         } catch (IOException ioe) {
@@ -389,7 +376,6 @@
     public PDFDocumentGraphics2D(PDFDocumentGraphics2D g) {
         super(g);
         this.pdfContext = g.pdfContext;
-        this.cfg = g.cfg;
         this.width = g.width;
         this.height = g.height;
         this.svgWidth = g.svgWidth;

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Mon May 28 07:31:24 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.svg;
+
+import java.util.List;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontResolver;
+import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.pdf.PDFDocument;
+import org.apache.fop.render.PrintRendererConfigurator;
+import org.apache.fop.render.pdf.PDFRendererConfigurator;
+
+/**
+ * Configurator class for PDFDocumentGraphics2D.
+ */
+public class PDFDocumentGraphics2DConfigurator {
+
+    /**
+     * Configures a PDFDocumentGraphics2D instance using an Avalon Configuration object.
+     * @param graphics the PDFDocumentGraphics2D instance
+     * @param cfg the configuration
+     * @throws ConfigurationException if an error occurs while configuring the object
+     */
+    public void configure(PDFDocumentGraphics2D graphics, Configuration cfg) 
+            throws ConfigurationException {
+        PDFDocument pdfDoc = graphics.getPDFDocument();
+        
+        //Filter map
+        pdfDoc.setFilterMap(
+                PDFRendererConfigurator.buildFilterMapFromConfiguration(cfg));
+        
+        //Fonts
+        try {
+            FontResolver fontResolver = FontSetup.createMinimalFontResolver();
+            List fontList = PrintRendererConfigurator.buildFontListFromConfiguration(
+                    cfg, null, fontResolver, false, null);
+            FontInfo fontInfo = new FontInfo();
+            FontSetup.setup(fontInfo, fontList, fontResolver);
+            graphics.setFontInfo(fontInfo);
+        } catch (FOPException e) {
+            throw new ConfigurationException("Error while setting up fonts", e);
+        }
+    }
+    
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java Mon May 28 07:31:24 2007
@@ -1429,7 +1429,7 @@
             }
             float siz = gFont.getSize2D();
             String style = gFont.isItalic() ? "italic" : "normal";
-            int weight = gFont.isBold() ? Font.BOLD : Font.NORMAL;
+            int weight = gFont.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;
             FontTriplet triplet = fontInfo.fontLookup(n, style, weight);
             fontState = fontInfo.getFontInstance(triplet, (int)(siz * 1000 + 0.5));
         } else {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextElementBridge.java Mon May 28 07:31:24 2007
@@ -22,7 +22,6 @@
 import org.apache.batik.gvt.TextNode;
 import org.apache.batik.bridge.SVGTextElementBridge;
 import org.apache.batik.bridge.BridgeContext;
-import org.apache.batik.bridge.TextUtilities;
 import org.apache.batik.gvt.GraphicsNode;
 
 import org.apache.fop.fonts.FontInfo;
@@ -82,12 +81,16 @@
      *         easily rendered using normal drawString on the PDFGraphics2D
      */
     private boolean isSimple(BridgeContext ctx, Element element, GraphicsNode node) {
+        /* I cannot find any reference that 36pt is the maximum font size in PDF. Tests show
+         * no such restriction (jeremias, 28.5.2007)
+         * 
         // Font size, in user space units.
         float fs = TextUtilities.convertFontSize(element).floatValue();
         // PDF cannot display fonts over 36pt
         if (fs > 36) {
             return false;
         }
+        */
 
         Element nodeElement;
         for (Node n = element.getFirstChild();

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTextPainter.java Mon May 28 07:31:24 2007
@@ -160,8 +160,8 @@
         String style = ((posture != null) && (posture.floatValue() > 0.0))
                        ? "italic" : "normal";
         int weight = ((taWeight != null)
-                       &&  (taWeight.floatValue() > 1.0)) ? Font.BOLD
-                       : Font.NORMAL;
+                       &&  (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD
+                       : Font.WEIGHT_NORMAL;
 
         Font fontState = null;
         FontInfo fi = fontInfo;
@@ -187,7 +187,7 @@
             }
         }
         if (!found) {
-            FontTriplet triplet = fontInfo.fontLookup("any", style, Font.NORMAL);
+            FontTriplet triplet = fontInfo.fontLookup("any", style, Font.WEIGHT_NORMAL);
             int fsize = (int)(size.floatValue() * 1000);
             fontState = fontInfo.getFontInstance(triplet, fsize);
         } else {
@@ -196,7 +196,7 @@
             }
         }
         int fStyle = java.awt.Font.PLAIN;
-        if (weight == Font.BOLD) {
+        if (weight == Font.WEIGHT_BOLD) {
             if (style.equals("italic")) {
                 fStyle = java.awt.Font.BOLD | java.awt.Font.ITALIC;
             } else {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTranscoder.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTranscoder.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFTranscoder.java Mon May 28 07:31:24 2007
@@ -25,7 +25,6 @@
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.UnitProcessor;
 import org.apache.batik.bridge.UserAgent;
@@ -35,6 +34,9 @@
 import org.apache.batik.transcoder.TranscodingHints;
 import org.apache.batik.transcoder.image.ImageTranscoder;
 import org.apache.batik.transcoder.keys.FloatKey;
+import org.apache.fop.Version;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontSetup;
 import org.w3c.dom.Document;
 import org.w3c.dom.svg.SVGLength;
 
@@ -120,12 +122,16 @@
         throws TranscoderException {
 
         graphics = new PDFDocumentGraphics2D();
+        graphics.getPDFDocument().getInfo().setProducer("Apache FOP Version " 
+                + Version.getVersion() 
+                + ": PDF Transcoder for Batik");
         
         try {
             if (this.cfg != null) {
-                ContainerUtil.configure(graphics, this.cfg);
+                PDFDocumentGraphics2DConfigurator configurator
+                        = new PDFDocumentGraphics2DConfigurator();
+                configurator.configure(graphics, this.cfg);
             }
-            ContainerUtil.initialize(graphics);
         } catch (Exception e) {
             throw new TranscoderException(
                 "Error while setting up PDFDocumentGraphics2D", e);
@@ -133,7 +139,9 @@
 
         super.transcode(document, uri, output);
 
-        getLogger().trace("document size: " + width + " x " + height);
+        if (getLogger().isTraceEnabled()) {
+            getLogger().trace("document size: " + width + " x " + height);
+        }
         
         // prepare the image to be painted
         UnitProcessor.Context uctx = UnitProcessor.createContext(ctx, 
@@ -144,7 +152,9 @@
         float heightInPt = UnitProcessor.userSpaceToSVG(height, SVGLength.SVG_LENGTHTYPE_PT, 
                 UnitProcessor.HORIZONTAL_LENGTH, uctx);
         int h = (int)(heightInPt + 0.5);
-        getLogger().trace("document size: " + w + "pt x " + h + "pt");
+        if (getLogger().isTraceEnabled()) {
+            getLogger().trace("document size: " + w + "pt x " + h + "pt");
+        }
 
         // prepare the image to be painted
         //int w = (int)(width + 0.5);

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LogUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LogUtil.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LogUtil.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LogUtil.java Mon May 28 07:31:24 2007
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.util;
+
+import org.apache.commons.logging.Log;
+import org.apache.fop.apps.FOPException;
+
+/**
+ * Convenience Logging utility methods used in FOP 
+ */
+public class LogUtil {
+
+    /**
+     * Convenience method that handles any error appropriately
+     * @param log log
+     * @param errorStr error string
+     * @param strict validate strictly
+     * @throws FOPException fop exception
+     */
+    public static void handleError(Log log, String errorStr, boolean strict) throws FOPException {
+        handleException(log, new FOPException(errorStr), strict);
+    }
+
+    /**
+     * Convenience method that handles any error appropriately
+     * @param log log
+     * @param e exception
+     * @param strict validate strictly
+     * @throws FOPException fop exception
+     */
+    public static void handleException(Log log, Exception e, boolean strict) throws FOPException {
+        if (strict) {
+            if (e instanceof FOPException) {
+                throw (FOPException)e;
+            }
+            throw new FOPException(e);
+        }
+        log.error(e.getMessage());
+    }
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/util/LogUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/sandbox/org/apache/fop/render/svg/SVGRenderer.java Mon May 28 07:31:24 2007
@@ -26,8 +26,6 @@
 import java.io.OutputStream;
 import java.io.Writer;
 
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.batik.dom.GenericDOMImplementation;
 import org.apache.batik.svggen.SVGGeneratorContext;
 import org.apache.batik.svggen.SVGGraphics2D;
@@ -76,13 +74,6 @@
 
     /** Creates TIFF renderer. */
     public SVGRenderer() {
-    }
-
-    /**
-     * @see org.apache.fop.render.AbstractRenderer#configure(
-     *          org.apache.avalon.framework.configuration.Configuration)
-     */
-    public void configure(Configuration cfg) throws ConfigurationException {
     }
 
     /** @see org.apache.fop.render.Renderer#startRenderer(java.io.OutputStream) */

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Mon May 28 07:31:24 2007
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="add" fixes-bug="41831" due-to="Adrian Cumiskey">
+        Add support for font auto-detection (easier font configuration).
+      </action>
       <action context="Code" dev="JM" type="update" fixes-bug="42406" due-to="Hussein Shafie">
         Use source resolution setting for bitmap images which don't provide their own
         resolution.

Added: xmlgraphics/fop/trunk/test/config/test_font_attributes_missing.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_font_attributes_missing.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_font_attributes_missing.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_font_attributes_missing.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>
+
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+		<!-- this font is without a metrics-url -->
+		<font>
+          <font-triplet name="Gladiator" style="normal" weight="normal"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_font_attributes_missing.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/config/test_font_embedurl_bad.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_font_embedurl_bad.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_font_embedurl_bad.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_font_embedurl_bad.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+  
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+  
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+		<!-- this font has an embed-url that does not exist on filesystem -->
+		<font metrics-url="test/resources/fonts/glb12.ttf.xml" embed-url="test/resources/fonts/doesnotexist.ttf">
+          <font-triplet name="Gladiator-Ansi" style="normal" weight="normal"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_font_embedurl_bad.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/config/test_font_embedurl_malformed.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_font_embedurl_malformed.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_font_embedurl_malformed.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_font_embedurl_malformed.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+  
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+  
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+		<!-- this font has a malformed embed-url -->
+		<font metrics-url="test/resources/fonts/glb12.ttf.xml" embed-url="badprotocol:test/resources/fonts/glb12.ttf">
+          <font-triplet name="Gladiator-Ansi" style="normal" weight="normal"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_font_embedurl_malformed.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/config/test_font_metricsurl_bad.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_font_metricsurl_bad.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_font_metricsurl_bad.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_font_metricsurl_bad.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+  
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+  
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+		<!-- this font has a metrics-url that does not exist on filesystem -->
+        <font metrics-url="test/resources/fonts/doesnotexist.ttf.ansi.xml">
+          <font-triplet name="Gladiator-Ansi" style="normal" weight="normal"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_font_metricsurl_bad.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/config/test_font_metricsurl_malformed.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_font_metricsurl_malformed.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_font_metricsurl_malformed.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_font_metricsurl_malformed.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+  
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+  
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+		<!-- this font has a malformed metrics-url -->
+        <font metrics-url="badprotocol:test/resources/fonts/glb12.ttf.xml">
+          <font-triplet name="Gladiator" style="normal" weight="normal"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_font_metricsurl_malformed.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/config/test_font_tripletattribute_missing.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_font_tripletattribute_missing.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_font_tripletattribute_missing.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_font_tripletattribute_missing.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+  
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+        <font metrics-url="test/resources/fonts/glb12.ttf.xml">
+		  <!-- this font-triplet has a missing style attribute -->           
+          <font-triplet name="Gladiator" weight="normal"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_font_tripletattribute_missing.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/test/config/test_fontbase_bad.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_fontbase_bad.xconf?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_fontbase_bad.xconf (original)
+++ xmlgraphics/fop/trunk/test/config/test_fontbase_bad.xconf Mon May 28 07:31:24 2007
@@ -3,6 +3,9 @@
   <!-- Strict configuration On -->
   <strict-configuration>true</strict-configuration>
 
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+
   <!-- Base URL for resolving relative URLs -->
   <base>./</base>
 

Added: xmlgraphics/fop/trunk/test/config/test_fonts_autodetect.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_fonts_autodetect.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_fonts_autodetect.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_fonts_autodetect.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+  
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+      	<auto-detect/>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_fonts_autodetect.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/config/test_fonts_directory_bad.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_fonts_directory_bad.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_fonts_directory_bad.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_fonts_directory_bad.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+  
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+     	<directory>doesnotexist</directory>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_fonts_directory_bad.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/config/test_fonts_directory_recursive.xconf
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_fonts_directory_recursive.xconf?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_fonts_directory_recursive.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_fonts_directory_recursive.xconf Mon May 28 07:31:24 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<fop version="1.0">
+  <!-- Strict configuration On -->
+  <strict-configuration>true</strict-configuration>
+
+  <!-- Switch off font caching for the purposes of the unit test -->
+  <use-cache>false</use-cache>  
+
+  <!-- Base URL for resolving relative URLs -->
+  <base>./</base>
+
+  <!-- Font Base URL for resolving relative font URLs -->
+  <font-base>./</font-base>
+  
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+      	<directory recursive="true">test/resources/fonts</directory>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

Propchange: xmlgraphics/fop/trunk/test/config/test_fonts_directory_recursive.xconf
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java Mon May 28 07:31:24 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.config;
+
+public abstract class BaseConstructiveUserConfigTestCase extends BaseUserConfigTestCase {
+
+    /**
+     * @see junit.framework.TestCase#TestCase(String)
+     */
+    public BaseConstructiveUserConfigTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * Test using a standard FOP font
+     * @throws Exception checkstyle wants a comment here, even a silly one
+     */
+    public void testUserConfig() throws Exception {
+        try {
+            initConfig();
+            convertFO();
+        } catch (Exception e) {
+            // this should *not* happen!
+            e.printStackTrace();
+            fail(e.getMessage());
+        }
+    }
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseConstructiveUserConfigTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java Mon May 28 07:31:24 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.config;
+
+import org.apache.fop.apps.FOPException;
+
+public abstract class BaseDestructiveUserConfigTestCase extends BaseUserConfigTestCase {
+
+    /**
+     * @see junit.framework.TestCase#TestCase(String)
+     */
+    public BaseDestructiveUserConfigTestCase(String name) {
+        super(name);
+    }
+
+    public void testUserConfig() throws Exception {
+        try {
+            initConfig();
+            convertFO();
+            fail( getName() + ": Expected Configuration Exception" );
+        } catch (FOPException e) {
+            // this *should* happen!
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail( getName() + ": Expected FOPException but got: " + e.getMessage() );
+        }
+    }
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseDestructiveUserConfigTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java Mon May 28 07:31:24 2007
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-/* $Id$ */
+/* $Id: $ */
 
 package org.apache.fop.config;
 
@@ -28,7 +28,6 @@
 import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.FOUserAgent;
 import org.apache.fop.render.pdf.BasePDFTestCase;
 import org.xml.sax.SAXException;
@@ -39,7 +38,7 @@
  */
 public abstract class BaseUserConfigTestCase extends BasePDFTestCase {
 
-    protected static DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
+    protected DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
 
     /** logging instance */
     protected Log log = LogFactory.getLog(BaseUserConfigTestCase.class);
@@ -59,28 +58,19 @@
         // do nothing
     }
 
-    /**
-     * Test using a standard FOP font
-     * @throws Exception checkstyle wants a comment here, even a silly one
-     */
-    public void testUserConfig() throws Exception {
-        try {
-            fopFactory.setUserConfig(getUserConfig());        
-            final File baseDir = getBaseDir();
-            final String fontFOFilePath = getFontFOFilePath();
-            File foFile = new File(baseDir, fontFOFilePath);
-            final boolean dumpOutput = false;
-            FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
-            convertFO(foFile, foUserAgent, dumpOutput);
-            fail( getName() + ": Expected Configuration Exception" );
-        } catch (FOPException e) {
-            // this *should* happen!
-        } catch (Exception e) {
-            fail( getName() + ": Expected FOPException but got: " + e.getMessage() );
-        }
+    protected void initConfig() throws Exception {
+        fopFactory.setUserConfig(getUserConfig());                
     }
 
-
+    protected void convertFO() throws Exception {
+        final File baseDir = getBaseDir();
+        final String fontFOFilePath = getFontFOFilePath();
+        File foFile = new File(baseDir, fontFOFilePath);
+        final boolean dumpOutput = false;
+        FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
+        convertFO(foFile, foUserAgent, dumpOutput);
+    }
+    
     /**
      * get test FOP config File
      * @return fo test filepath
@@ -96,11 +86,31 @@
      * @throws SAXException 
      * @throws ConfigurationException 
      */
-    protected Configuration getUserConfig(String configString)
-            throws ConfigurationException, SAXException, IOException {
+    protected Configuration getUserConfig(String configString) throws ConfigurationException, SAXException, IOException {
         return cfgBuilder.build(new ByteArrayInputStream(configString.getBytes()));
     }
 
+    /** get base config directory */
+    protected String getBaseConfigDir() {
+        return "test/config";
+    }
+
+    /**
+     * @return user config File
+     */
+    abstract protected String getUserConfigFilename();
+
+    /*
+     * @see junit.framework.TestCase#getName()
+     */
+    public String getName() {
+        return getUserConfigFilename();
+    }
+
+    protected File getUserConfigFile() {
+        return new File(getBaseConfigDir() + File.separator + getUserConfigFilename());
+    }
+
     /**
      * get test FOP Configuration
      * @return fo test filepath
@@ -108,18 +118,7 @@
      * @throws SAXException 
      * @throws ConfigurationException 
      */
-    protected Configuration getUserConfig()
-            throws ConfigurationException, SAXException, IOException {
+    protected Configuration getUserConfig() throws ConfigurationException, SAXException, IOException {
         return cfgBuilder.buildFromFile(getUserConfigFile());
-    }
-    
-    /** get base config directory */
-    protected String getBaseConfigDir() {
-        return "test/config";
-    }
-    
-    /**
-     * @return user config File
-     */
-    protected abstract File getUserConfigFile();
+    }        
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontAttributesMissingTestCase.java Mon May 28 07:31:24 2007
@@ -19,20 +19,19 @@
 
 package org.apache.fop.config;
 
-import java.io.File;
-
-// this font is without a metrics-url or an embed-url
-public class FontAttributesMissingTestCase extends BaseUserConfigTestCase {
+/*
+ * this font is without a metrics-url or an embed-url
+ */
+public class FontAttributesMissingTestCase extends BaseDestructiveUserConfigTestCase {
 
     public FontAttributesMissingTestCase(String name) {
         super(name);
     }
 
-    protected File getUserConfigFile() {
-        return new File( getBaseConfigDir() + "/test_fontattributes_missing.xconf");
-    }
-    
-    public String getName() {
-        return "test_fontattributes_missing.xconf";
+    /**
+     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename()
+     */
+    public String getUserConfigFilename() {
+        return "test_font_attributes_missing.xconf";
     }
 }

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontBaseBadTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontBaseBadTestCase.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontBaseBadTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontBaseBadTestCase.java Mon May 28 07:31:24 2007
@@ -19,10 +19,10 @@
 
 package org.apache.fop.config;
 
-import java.io.File;
-
-// this font base does not exist and a relative font path is used
-public class FontBaseBadTestCase extends BaseUserConfigTestCase {
+/*
+ * this font base does not exist and a relative font path is used
+ */ 
+public class FontBaseBadTestCase extends BaseDestructiveUserConfigTestCase {
 
     public FontBaseBadTestCase(String name) {
         super(name);
@@ -34,16 +34,9 @@
     }
 
     /**
-     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFile()
-     */
-    protected File getUserConfigFile() {
-        return new File( getBaseConfigDir() + "/test_fontbase_bad.xconf");
-    }
-    
-    /**
-     * @return configuration filename
+     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename()
      */
-    public String getName() {
+    public String getUserConfigFilename() {
         return "test_fontbase_bad.xconf";
     }
 }

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java Mon May 28 07:31:24 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.config;
+
+/**
+ * this font has an embed-url that does not exist on filesystem.
+ */
+public class FontEmbedUrlBadTestCase extends BaseDestructiveUserConfigTestCase {
+
+    public FontEmbedUrlBadTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename()
+     */
+    public String getUserConfigFilename() {
+        return "test_font_embedurl_bad.xconf";
+    }
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlBadTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java Mon May 28 07:31:24 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.config;
+
+/** 
+ * this font has a malformed embed-url
+ */
+public class FontEmbedUrlMalformedTestCase extends BaseDestructiveUserConfigTestCase {
+
+    public FontEmbedUrlMalformedTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename()
+     */
+    public String getUserConfigFilename() {
+        return "test_font_embedurl_malformed.xconf";
+    }
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontEmbedUrlMalformedTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java Mon May 28 07:31:24 2007
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.config;
+
+/*
+ * this font has a metrics-url that does not exist on filesystem
+ */ 
+public class FontMetricsUrlBadTestCase extends BaseDestructiveUserConfigTestCase {
+
+    /**
+     * @see junit.framework.TestCase#TestCase(String)
+     */
+    public FontMetricsUrlBadTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename()
+     */
+    public String getUserConfigFilename() {
+        return "test_font_metricsurl_bad.xconf";
+    }
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlBadTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java Mon May 28 07:31:24 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.config;
+
+/*
+ * this font has a malformed metrics-url
+ */ 
+public class FontMetricsUrlMalformedTestCase extends BaseDestructiveUserConfigTestCase {
+
+    public FontMetricsUrlMalformedTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename()
+     */
+    public String getUserConfigFilename() {
+        return "test_font_metricsurl_malformed.xconf";
+    }
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontMetricsUrlMalformedTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java?view=diff&rev=542237&r1=542236&r2=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontTripletAttributeMissingTestCase.java Mon May 28 07:31:24 2007
@@ -19,20 +19,19 @@
 
 package org.apache.fop.config;
 
-import java.io.File;
-
-// this font has an embed-url that does not exist on filesystem
-public class FontTripletAttributeMissingTestCase extends BaseUserConfigTestCase {
+/*
+ * this font has a missing font triplet attribute
+ */ 
+public class FontTripletAttributeMissingTestCase extends BaseDestructiveUserConfigTestCase {
 
     public FontTripletAttributeMissingTestCase(String name) {
         super(name);
     }
 
-    protected File getUserConfigFile() {
-        return new File( getBaseConfigDir() + "/test_fonttripletattribute_missing.xconf");
-    }
-    
-    public String getName() {
-        return "test_fonttripletattribute_missing.xconf";
+    /**
+     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename()
+     */
+    public String getUserConfigFilename() {
+        return "test_font_tripletattribute_missing.xconf";
     }
 }

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java?view=auto&rev=542237
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java (added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java Mon May 28 07:31:24 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.config;
+
+public class FontsAutoDetectTestCase extends BaseConstructiveUserConfigTestCase {
+
+    public FontsAutoDetectTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * @see org.apache.fop.config.BaseUserConfigTestCase#getUserConfigFilename()
+     */
+    public String getUserConfigFilename() {
+        return "test_fonts_autodetect.xconf";
+    }
+}

Propchange: xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsAutoDetectTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native



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