Added: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Base14FontCollection.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Base14FontCollection.java?rev=653826&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Base14FontCollection.java
 (added)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Base14FontCollection.java
 Tue May  6 09:14:09 2008
@@ -0,0 +1,181 @@
+/*
+ * 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.java2d;
+
+import java.awt.Graphics2D;
+
+import org.apache.fop.fonts.Font;
+import org.apache.fop.fonts.FontCollection;
+import org.apache.fop.fonts.FontInfo;
+
+/**
+ * A base 14 font collection for graphics 2D
+ */
+public class Base14FontCollection implements FontCollection {
+
+    private Graphics2D graphics2d = null;
+    
+    /**
+     * Main constructor
+     * @param graphics2d a graphics 2D
+     */
+    public Base14FontCollection(Graphics2D graphics2d) {
+        this.graphics2d = graphics2d;
+    }
+    
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public int setup(int start, FontInfo fontInfo) {
+        /*
+         * available java fonts are:
+         * Serif - bold, normal, italic, bold-italic
+         * SansSerif - bold, normal, italic, bold-italic
+         * MonoSpaced - bold, normal, italic, bold-italic
+         */
+        final int normal = java.awt.Font.PLAIN;
+        final int bold = java.awt.Font.BOLD;
+        final int italic = java.awt.Font.ITALIC;
+        final int bolditalic = java.awt.Font.BOLD + java.awt.Font.ITALIC;
+
+        FontMetricsMapper metric;
+        metric = new SystemFontMetricsMapper("SansSerif", normal, graphics2d);
+        // --> goes to  F1
+        fontInfo.addMetrics("F1", metric);
+        metric = new SystemFontMetricsMapper("SansSerif", italic, graphics2d);
+        // --> goes to  F2
+        fontInfo.addMetrics("F2", metric);
+        metric = new SystemFontMetricsMapper("SansSerif", bold, graphics2d);
+        // --> goes to  F3
+        fontInfo.addMetrics("F3", metric);
+        metric = new SystemFontMetricsMapper("SansSerif", bolditalic, 
graphics2d);
+        // --> goes to  F4
+        fontInfo.addMetrics("F4", metric);
+
+
+        metric = new SystemFontMetricsMapper("Serif", normal, graphics2d);
+        // --> goes to  F5
+        fontInfo.addMetrics("F5", metric);
+        metric = new SystemFontMetricsMapper("Serif", italic, graphics2d);
+        // --> goes to  F6
+        fontInfo.addMetrics("F6", metric);
+        metric = new SystemFontMetricsMapper("Serif", bold, graphics2d);
+        // --> goes to  F7
+        fontInfo.addMetrics("F7", metric);
+        metric = new SystemFontMetricsMapper("Serif", bolditalic, graphics2d);
+        // --> goes to  F8
+        fontInfo.addMetrics("F8", metric);
+
+        metric = new SystemFontMetricsMapper("MonoSpaced", normal, graphics2d);
+        // --> goes to  F9
+        fontInfo.addMetrics("F9", metric);
+        metric = new SystemFontMetricsMapper("MonoSpaced", italic, graphics2d);
+        // --> goes to  F10
+        fontInfo.addMetrics("F10", metric);
+        metric = new SystemFontMetricsMapper("MonoSpaced", bold, graphics2d);
+        // --> goes to  F11
+        fontInfo.addMetrics("F11", metric);
+        metric = new SystemFontMetricsMapper("MonoSpaced", bolditalic, 
graphics2d);
+        // --> goes to  F12
+        fontInfo.addMetrics("F12", metric);
+
+        metric = new SystemFontMetricsMapper("Serif", normal, graphics2d);
+        //"Symbol" doesn't seem to work here, but "Serif" does the job just 
fine. *shrug*
+        // --> goes to  F13 and F14
+        fontInfo.addMetrics("F13", metric);
+        fontInfo.addMetrics("F14", metric);
+
+        // Custom type 1 fonts step 1/2
+        // fontInfo.addMetrics("F15", new OMEP());
+        // fontInfo.addMetrics("F16", new GaramondLightCondensed());
+        // fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
+
+        /* any is treated as serif */
+        fontInfo.addFontProperties("F5", "any", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "any", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "any", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "any", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "any", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "any", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+
+        fontInfo.addFontProperties("F1", "sans-serif", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F2", "sans-serif", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F2", "sans-serif", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F3", "sans-serif", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F4", "sans-serif", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F4", "sans-serif", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F5", "serif", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "serif", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "serif", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "serif", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "serif", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "serif", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F9", "monospace", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F10", "monospace", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F10", "monospace", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F11", "monospace", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F12", "monospace", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F12", "monospace", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+
+        fontInfo.addFontProperties("F1", "Helvetica", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F2", "Helvetica", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F2", "Helvetica", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F3", "Helvetica", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F4", "Helvetica", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F4", "Helvetica", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F5", "Times", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "Times", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F9", "Courier", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F10", "Courier", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F10", "Courier", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F11", "Courier", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F12", "Courier", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F12", "Courier", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F13", "Symbol", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F14", "ZapfDingbats", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+
+        // Custom type 1 fonts step 2/2
+        // fontInfo.addFontProperties("F15", "OMEP", "normal", 
FontInfo.NORMAL);
+        // fontInfo.addFontProperties("F16", "Garamond-LightCondensed", 
"normal", FontInfo.NORMAL);
+        // fontInfo.addFontProperties("F17", "BauerBodoni", "italic", 
FontInfo.BOLD);
+
+        /* for compatibility with PassiveTex */
+        fontInfo.addFontProperties("F5", "Times-Roman", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times-Roman", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times-Roman", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "Times-Roman", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times-Roman", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times-Roman", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F5", "Times Roman", Font.STYLE_NORMAL, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times Roman", Font.STYLE_OBLIQUE, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F6", "Times Roman", Font.STYLE_ITALIC, 
Font.WEIGHT_NORMAL);
+        fontInfo.addFontProperties("F7", "Times Roman", Font.STYLE_NORMAL, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times Roman", Font.STYLE_OBLIQUE, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F8", "Times Roman", Font.STYLE_ITALIC, 
Font.WEIGHT_BOLD);
+        fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
+                                   "normal", Font.WEIGHT_NORMAL);
+        
+        return 15;
+    }
+}

Added: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=653826&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
 (added)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
 Tue May  6 09:14:09 2008
@@ -0,0 +1,111 @@
+/*
+ * 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.java2d;
+
+import java.util.List;
+
+import javax.xml.transform.Source;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.EmbedFontInfo;
+import org.apache.fop.fonts.FontCollection;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontLoader;
+import org.apache.fop.fonts.FontManager;
+import org.apache.fop.fonts.FontResolver;
+import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.fonts.LazyFont;
+import org.apache.fop.render.PrintRenderer;
+
+/**
+ * A java2d configured font collection
+ */
+public class ConfiguredFontCollection implements FontCollection {
+
+    private static Log log = LogFactory.getLog(ConfiguredFontCollection.class);
+
+    private PrintRenderer renderer = null;
+
+    /**
+     * Main constructor
+     * 
+     * @param renderer a print renderer
+     */
+    public ConfiguredFontCollection(PrintRenderer renderer) {
+        this.renderer = renderer;
+    }
+    
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public int setup(int start, FontInfo fontInfo) {
+        List/*<EmbedFontInfo>*/ fontList = renderer.getFontList();
+        FontResolver resolver = renderer.getFontResolver();
+        int num = start;
+        if (fontList == null || fontList.size() < 1) {
+            log.debug("No user configured fonts found.");
+            return num;
+        }
+        if (resolver == null) {
+            // Ensure that we have minimal font resolution capabilities
+            resolver = FontManager.createMinimalFontResolver();
+        }
+        String internalName = null;
+
+        for (int i = 0; i < fontList.size(); i++) {
+
+            EmbedFontInfo configFontInfo = (EmbedFontInfo) fontList.get(i);
+            String fontFile = configFontInfo.getEmbedFile();
+            internalName = "F" + num;
+            num++;
+            try {
+                FontMetricsMapper font = null;
+                String metricsUrl = configFontInfo.getMetricsFile();
+                // If the user specified an XML-based metrics file, we'll use 
it
+                // Otherwise, calculate metrics directly from the font file.
+                if (metricsUrl != null) {
+                    LazyFont fontMetrics = new LazyFont(configFontInfo, 
resolver);
+                    Source fontSource = 
resolver.resolve(configFontInfo.getEmbedFile());
+                    font = new CustomFontMetricsMapper(fontMetrics, 
fontSource);
+                } else {
+                    CustomFont fontMetrics = FontLoader.loadFont(fontFile, 
null, resolver);
+                    font = new CustomFontMetricsMapper(fontMetrics);
+                }
+
+                fontInfo.addMetrics(internalName, font);
+
+                List triplets = configFontInfo.getFontTriplets();
+                for (int c = 0; c < triplets.size(); c++) {
+                    FontTriplet triplet = (FontTriplet) triplets.get(c);
+
+                    if (log.isDebugEnabled()) {
+                        log.debug("Registering: " + triplet + " under " + 
internalName);
+                    }
+                    fontInfo.addFontProperties(internalName, triplet);
+                }
+            } catch (Exception e) {
+                log.warn("Unable to load custom font from file '" + fontFile + 
"'", e);
+            }
+        }
+        return num;
+    }
+}

Added: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java?rev=653826&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java
 (added)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java
 Tue May  6 09:14:09 2008
@@ -0,0 +1,138 @@
+/*
+ * 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.java2d;
+
+import java.awt.Graphics2D;
+import java.awt.GraphicsEnvironment;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fonts.Font;
+import org.apache.fop.fonts.FontCollection;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.fonts.FontUtil;
+
+/**
+ * A custom AWT font collection
+ */
+public class InstalledFontCollection implements FontCollection {
+
+    private static Log log = LogFactory.getLog(InstalledFontCollection.class);
+
+    private static final Set HARDCODED_FONT_NAMES;
+
+    static {
+        HARDCODED_FONT_NAMES = new java.util.HashSet();
+        HARDCODED_FONT_NAMES.add("any");
+        HARDCODED_FONT_NAMES.add("sans-serif");
+        HARDCODED_FONT_NAMES.add("serif");
+        HARDCODED_FONT_NAMES.add("monospace");
+
+        HARDCODED_FONT_NAMES.add("Helvetica");
+        HARDCODED_FONT_NAMES.add("Times");
+        HARDCODED_FONT_NAMES.add("Courier");
+        HARDCODED_FONT_NAMES.add("Symbol");
+        HARDCODED_FONT_NAMES.add("ZapfDingbats");
+        HARDCODED_FONT_NAMES.add("Times Roman");
+        HARDCODED_FONT_NAMES.add("Times-Roman");
+        HARDCODED_FONT_NAMES.add("Computer-Modern-Typewriter");
+    }
+
+    private Graphics2D graphics2D = null;
+
+    /**
+     * Main constructor
+     * 
+     * @param graphics2D a graphics 2D
+     */
+    public InstalledFontCollection(Graphics2D graphics2D) {
+        this.graphics2D  = graphics2D;
+    }
+    
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public int setup(int start, FontInfo fontInfo) {
+        int num = start;
+        GraphicsEnvironment env = 
GraphicsEnvironment.getLocalGraphicsEnvironment();
+
+        java.awt.Font[] fonts = env.getAllFonts();
+        for (int i = 0; i < fonts.length; i++) {
+            java.awt.Font f = fonts[i];
+            if (HARDCODED_FONT_NAMES.contains(f.getName())) {
+                continue; //skip
+            }
+
+            if (log.isTraceEnabled()) {
+                log.trace("AWT Font: " + f.getFontName()
+                        + ", family: " + f.getFamily()
+                        + ", PS: " + f.getPSName()
+                        + ", Name: " + f.getName()
+                        + ", Angle: " + f.getItalicAngle()
+                        + ", Style: " + f.getStyle());
+            }
+
+            String searchName = 
FontUtil.stripWhiteSpace(f.getName()).toLowerCase();
+            String guessedStyle = FontUtil.guessStyle(searchName);
+            int guessedWeight = FontUtil.guessWeight(searchName);
+
+            num++;
+            String fontKey = "F" + num;
+            int style = convertToAWTFontStyle(guessedStyle, guessedWeight);
+            addFontMetricsMapper(fontInfo, f.getName(), fontKey, graphics2D, 
style);
+
+            //Register appropriate font triplets matching the font. Two 
different strategies:
+            //Example: "Arial Bold", normal, normal
+            addFontTriplet(fontInfo, f.getName(),
+                    Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, fontKey);
+            if (!f.getName().equals(f.getFamily())) {
+                //Example: "Arial", bold, normal
+                addFontTriplet(fontInfo, f.getFamily(),
+                        guessedStyle, guessedWeight, fontKey);
+            }
+        }
+        return num;
+    }
+
+    private static void addFontTriplet(FontInfo fontInfo, String fontName, 
String fontStyle,
+            int fontWeight, String fontKey) {
+        FontTriplet triplet = FontInfo.createFontKey(fontName, fontStyle, 
fontWeight);
+        fontInfo.addFontProperties(fontKey, triplet);
+    }
+
+    private static void addFontMetricsMapper(FontInfo fontInfo, String family, 
String fontKey,
+            Graphics2D graphics, int style) {
+        FontMetricsMapper metric = new SystemFontMetricsMapper(family, style, 
graphics);
+        fontInfo.addMetrics(fontKey, metric);
+    }
+
+    private static int convertToAWTFontStyle(String fontStyle, int fontWeight) 
{
+        int style = java.awt.Font.PLAIN;
+        if (fontWeight >= Font.WEIGHT_BOLD) {
+            style |= java.awt.Font.BOLD;
+        }
+        if (!"normal".equals(fontStyle)) {
+            style |= java.awt.Font.ITALIC;
+        }
+        return style;
+    }
+}

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java 
Tue May  6 09:14:09 2008
@@ -168,14 +168,15 @@
     public void setupFontInfo(FontInfo inFontInfo) {
         //Don't call super.setupFontInfo() here! Java2D needs a special font 
setup
         // create a temp Image to test font metrics on
-        fontInfo = inFontInfo;
+        this.fontInfo = inFontInfo;
         BufferedImage fontImage = new BufferedImage(100, 100,
                 BufferedImage.TYPE_INT_RGB);
-        Graphics2D g = fontImage.createGraphics();
+        Graphics2D graphics2D = fontImage.createGraphics();
         //The next line is important to get accurate font metrics!
-        g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
+        graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-        FontSetup.setup(fontInfo, fontList, fontResolver, g);
+        
+        userAgent.getFactory().getFontManager().setupRenderer(this, 
graphics2D);
     }
 
     /** [EMAIL PROTECTED] */

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java 
Tue May  6 09:14:09 2008
@@ -89,7 +89,6 @@
 import org.apache.fop.render.RendererContextConstants;
 import org.apache.fop.render.RendererEventProducer;
 import org.apache.fop.render.java2d.FontMetricsMapper;
-import org.apache.fop.render.java2d.FontSetup;
 import org.apache.fop.render.java2d.Java2DRenderer;
 import org.apache.fop.render.pcl.extensions.PCLElementMapping;
 import org.apache.fop.traits.BorderProps;
@@ -202,11 +201,12 @@
         fontInfo = inFontInfo;
         BufferedImage fontImage = new BufferedImage(100, 100,
                 BufferedImage.TYPE_INT_RGB);
-        Graphics2D g = fontImage.createGraphics();
+        Graphics2D graphics2D = fontImage.createGraphics();
         //The next line is important to get accurate font metrics!
-        g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
+        graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-        FontSetup.setup(fontInfo, fontList, fontResolver, g);
+        
+        userAgent.getFactory().getFontManager().setupRenderer(this, 
graphics2D);
     }
 
     /**

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
 (original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
 Tue May  6 09:14:09 2008
@@ -98,7 +98,7 @@
         if (!isTextStroked()) {
             FontInfo fontInfo = new FontInfo();   
             //TODO Do custom font configuration here somewhere/somehow 
-            FontSetup.setup(fontInfo, null, null);   
+            FontSetup.setup(fontInfo);   
             graphics.setCustomTextHandler(new NativeTextHandler(graphics, 
fontInfo));
         }
 

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?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
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 
Tue May  6 09:14:09 2008
@@ -71,7 +71,7 @@
     private void setupFontInfo() {
         //Sets up a FontInfo with default fonts
         fontInfo = new FontInfo();
-        FontSetup.setup(fontInfo, null, null);
+        FontSetup.setup(fontInfo);
     }
     
     /**

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?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java 
Tue May  6 09:14:09 2008
@@ -156,7 +156,7 @@
         if (fontInfo == null) {
             //Default minimal fonts
             FontInfo fontInfo = new FontInfo();
-            FontSetup.setup(fontInfo, null, null);
+            FontSetup.setup(fontInfo);
             setFontInfo(fontInfo);
         }
     }

Modified: 
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?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
 (original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
 Tue May  6 09:14:09 2008
@@ -26,6 +26,7 @@
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fonts.FontCache;
 import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontManager;
 import org.apache.fop.fonts.FontResolver;
 import org.apache.fop.fonts.FontSetup;
 import org.apache.fop.pdf.PDFDocument;
@@ -53,17 +54,20 @@
         
         //Fonts
         try {
-            FontResolver fontResolver = FontSetup.createMinimalFontResolver();
+            FontResolver fontResolver = 
FontManager.createMinimalFontResolver();
             //TODO The following could be optimized by retaining the FontCache 
somewhere
             FontCache fontCache = FontCache.load();
             if (fontCache == null) {
                 fontCache = new FontCache();
             }
-            List fontList = 
PrintRendererConfigurator.buildFontListFromConfiguration(
-                    cfg, null, fontResolver, false, fontCache);
+            //TODO Provide fontBaseURL to this method call
+            final String fontBaseURL = null;
+            List/*<EmbedFontInfo>*/ embedFontInfoList
+                = PrintRendererConfigurator.buildFontListFromConfiguration(
+                    cfg, fontBaseURL, fontResolver, false, fontCache);
             fontCache.save();
             FontInfo fontInfo = new FontInfo();
-            FontSetup.setup(fontInfo, fontList, fontResolver);
+            FontSetup.setup(fontInfo, embedFontInfoList, fontResolver);
             graphics.setFontInfo(fontInfo);
         } catch (FOPException e) {
             throw new ConfigurationException("Error while setting up fonts", 
e);

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?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java Tue 
May  6 09:14:09 2008
@@ -959,7 +959,7 @@
         preparePainting();
 
         FontInfo specialFontInfo = new FontInfo();
-        FontSetup.setup(specialFontInfo, null, null);
+        FontSetup.setup(specialFontInfo);
 
         PDFResources res = pdfDoc.getFactory().makeResources();
         PDFResourceContext context = new PDFResourceContext(res);

Modified: xmlgraphics/fop/trunk/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue May  6 09:14:09 2008
@@ -57,6 +57,10 @@
       <action context="Renderers" dev="AC" importance="high" type="add">
         Added SVG support for AFP (GOCA).
       </action -->
+      <action context="Fonts" dev="AC" type="add">
+        Add support for font substitution.
+      </action>
+      <action context="Code" dev="AD" type="fix" fixed-bug="44203">
       <action context="Renderers" dev="JM" type="fix" fixes-bug="43650">
         PCL Renderer: Improved page format selection so it doesn't interfere 
with
         duplex printing.

Added: xmlgraphics/fop/trunk/test/config/test_fonts_substitution.xconf
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/config/test_fonts_substitution.xconf?rev=653826&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/config/test_fonts_substitution.xconf (added)
+++ xmlgraphics/fop/trunk/test/config/test_fonts_substitution.xconf Tue May  6 
09:14:09 2008
@@ -0,0 +1,33 @@
+<?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>
+  
+  <fonts>
+     <substitutions>
+        <substitution>
+           <from font-family="Times" font-style="italic"/>
+           <to font-family="Gladiator" font-style="normal" font-weight="bold"/>
+        </substitution>
+     </substitutions>
+  </fonts>
+
+  <renderers>
+    <renderer mime="application/pdf">
+      <fonts>
+        <font metrics-url="test/resources/fonts/glb12.ttf.xml" 
embed-url="test/resources/fonts/glb12.ttf">
+          <font-triplet name="Gladiator" style="normal" weight="bold"/>
+        </font>
+      </fonts>
+    </renderer>
+  </renderers>
+</fop>

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?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/config/BaseUserConfigTestCase.java
 Tue May  6 09:14:09 2008
@@ -66,7 +66,7 @@
         final File baseDir = getBaseDir();
         final String fontFOFilePath = getFontFOFilePath();
         File foFile = new File(baseDir, fontFOFilePath);
-        final boolean dumpOutput = false;
+        final boolean dumpOutput = true;
         FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
         convertFO(foFile, foUserAgent, dumpOutput);
     }

Added: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java?rev=653826&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
 (added)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
 Tue May  6 09:14:09 2008
@@ -0,0 +1,63 @@
+/*
+ * 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 java.io.File;
+
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.apps.MimeConstants;
+import org.apache.fop.fonts.Font;
+import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontManager;
+import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.render.PrintRenderer;
+
+public class FontsSubstitutionTestCase extends 
BaseConstructiveUserConfigTestCase {
+
+    public FontsSubstitutionTestCase(String name) {
+        super(name);
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    protected byte[] convertFO(File foFile, FOUserAgent ua, boolean 
dumpPdfFile) throws Exception {
+        PrintRenderer renderer = 
(PrintRenderer)ua.getRendererFactory().createRenderer(ua, 
MimeConstants.MIME_PDF);
+        FontInfo fontInfo = new FontInfo();
+        renderer.setupFontInfo(fontInfo);
+        FontManager fontManager = ua.getFactory().getFontManager();
+        fontManager.setupRenderer(renderer);
+        FontTriplet triplet = new FontTriplet("Times", "italic", 
Font.WEIGHT_NORMAL);
+        String internalFontKey = fontInfo.getInternalFontKey(triplet);
+        // Times italic should now be mapped to the 15th font (custom font)
+        // not the original base 14 (F6)
+        if (!"F15".equals(internalFontKey)) {
+            throw new Exception("font substitution failed :" + triplet);
+        }
+        return null;
+    }
+
+    /**
+     * [EMAIL PROTECTED]
+     */
+    public String getUserConfigFilename() {
+        return "test_fonts_substitution.xconf";
+    }
+}

Modified: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java 
(original)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/config/UserConfigTestSuite.java 
Tue May  6 09:14:09 2008
@@ -44,6 +44,7 @@
         suite.addTest(new TestSuite(FontEmbedUrlMalformedTestCase.class));
         suite.addTest(new TestSuite(FontsDirectoryRecursiveTestCase.class));
         suite.addTest(new TestSuite(FontsAutoDetectTestCase.class));
+        suite.addTest(new TestSuite(FontsSubstitutionTestCase.class));
         //$JUnit-END$
         return suite;
     }

Modified: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
 (original)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
 Tue May  6 09:14:09 2008
@@ -95,8 +95,8 @@
      */
     public LayoutEngineTester(File areaTreeBackupDir) {
         this.areaTreeBackupDir = areaTreeBackupDir;
-        fopFactory.setBase14KerningEnabled(false);
-        fopFactoryWithBase14Kerning.setBase14KerningEnabled(true);
+        fopFactory.getFontManager().setBase14KerningEnabled(false);
+        
fopFactoryWithBase14Kerning.getFontManager().setBase14KerningEnabled(true);
     }
     
     private Templates getTestcase2FOStylesheet() throws 
TransformerConfigurationException {

Modified: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java 
(original)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java 
Tue May  6 09:14:09 2008
@@ -101,7 +101,7 @@
         }
     }
 
-    private static Exception extractOriginalException(Exception e) {
+    protected static Exception extractOriginalException(Exception e) {
         if (e.getCause() != null) {
             return extractOriginalException((Exception)e.getCause());
         } else if (e instanceof SAXException) {

Modified: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java?rev=653826&r1=653825&r2=653826&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
 (original)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
 Tue May  6 09:14:09 2008
@@ -44,9 +44,9 @@
      *  @return an initialized FOUserAgent
      * */
     protected FOUserAgent getUserAgent() {
-        final FOUserAgent a = fopFactory.newFOUserAgent();
-        a.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
-        return a;
+        final FOUserAgent userAgent = fopFactory.newFOUserAgent();
+        userAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
+        return userAgent;
     }
     
     /**
@@ -104,5 +104,5 @@
             //Good!
         }
     }
-    
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to