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 2008/01/07 16:06:26 UTC

svn commit: r609627 - in /xmlgraphics/fop/trunk: ./ src/java/org/apache/fop/render/bitmap/ src/java/org/apache/fop/render/java2d/ src/java/org/apache/fop/render/pcl/

Author: jeremias
Date: Mon Jan  7 07:06:24 2008
New Revision: 609627

URL: http://svn.apache.org/viewvc?rev=609627&view=rev
Log:
Bugzilla #44176:
Support for custom fonts in Java2DRenderer and derived renderers.
Submitted by: Patrick Jaromin <patrick.at.jgsullivan.dot.com>

Patch modified slightly by jeremias.

Added:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java   (with props)
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java
      - copied, changed from r602053, xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRenderer.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java?rev=609627&r1=609626&r2=609627&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/bitmap/TIFFRendererConfigurator.java Mon Jan  7 07:06:24 2008
@@ -68,5 +68,6 @@
                 log.info("TIFF compression set to " + name);
             }
         }
+        super.configure(renderer);
     }
 }

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java?rev=609627&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java Mon Jan  7 07:06:24 2008
@@ -0,0 +1,205 @@
+/*
+ * 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.Font;
+import java.awt.FontFormatException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.fop.fonts.CustomFont;
+import org.apache.fop.fonts.FontType;
+import org.apache.fop.fonts.LazyFont;
+import org.apache.fop.fonts.Typeface;
+
+/**
+ * FontMetricsMapper that delegates most methods to an underlying
+ * <tt>FontMetrics</tt> instance. This class was designed to allow
+ * the underlying <tt>java.awt.Font</tt> to be loaded from a
+ * user-configured file not registered in the current graphics environment.
+ */
+public class CustomFontMetricsMapper extends Typeface implements FontMetricsMapper {
+
+    /**
+     * Font metrics for the font this class models.
+     */
+    private Typeface typeface;
+
+    /**
+     * The font required by the Java2D renderer.
+     */
+    private java.awt.Font font;
+
+    /**
+     * Maintains the most recently requested size.
+     */
+    private float size = 1;
+
+    /**
+     * Construction of this class results in the immediate construction.
+     * of the underlying <tt>java.awt.Font</tt>
+     * @param fontMetrics
+     * @throws FontFormatException
+     * @throws IOException
+     */
+    public CustomFontMetricsMapper(final CustomFont fontMetrics)
+    	throws FontFormatException, IOException {
+        this.typeface = fontMetrics;
+        initialize(fontMetrics.getEmbedFileSource());
+    }
+
+    /**
+     * Construction of this class results in the immediate construction
+     * of the underlying <tt>java.awt.Font</tt>
+     * @param fontMetrics
+     * @throws FontFormatException
+     * @throws IOException
+     */
+    public CustomFontMetricsMapper(final LazyFont fontMetrics, final Source fontSource)
+    		throws FontFormatException, IOException {
+        this.typeface = fontMetrics;
+        initialize(fontSource);
+    }
+
+    private static final int TYPE1_FONT = 1; //Defined in Java 1.5
+    
+    /**
+     * Loads the java.awt.Font
+     * @param source
+     * @throws FontFormatException
+     * @throws IOException
+     */
+    private void initialize(final Source source)
+                throws FontFormatException, IOException {
+        int type = Font.TRUETYPE_FONT;
+        if (FontType.TYPE1.equals(typeface.getFontType())) {
+            type = TYPE1_FONT; //Font.TYPE1_FONT; only available in Java 1.5
+        }
+
+        InputStream is = null;
+        if (source instanceof StreamSource) {
+            is = ((StreamSource) source).getInputStream();
+        } else if (source.getSystemId() != null) {
+            is = new java.net.URL(source.getSystemId()).openStream();
+        } else {
+            throw new IllegalArgumentException("No font source provided.");
+        }
+
+        this.font = Font.createFont(type, is);
+        is.close();
+
+    }
+
+    /** {@inheritDoc} */
+    public final String getEncoding() {
+        return null; //Not applicable to Java2D rendering
+    }
+
+    /** {@inheritDoc} */
+    public final boolean hasChar(final char c) {
+        return font.canDisplay(c);
+    }
+
+    /** {@inheritDoc} */
+    public final char mapChar(final char c) {
+        return typeface.mapChar(c);
+    }
+
+    /** {@inheritDoc} */
+    public final Font getFont(final int size) {
+        if (this.size == size) {
+            return font;
+        }
+
+        this.size = size / 1000f;
+        font = font.deriveFont(this.size);
+        return font;
+    }
+
+    /** {@inheritDoc} */
+    public final int getAscender(final int size) {
+        return typeface.getAscender(size);
+    }
+
+    /** {@inheritDoc} */
+    public final int getCapHeight(final int size) {
+        return typeface.getCapHeight(size);
+    }
+
+    /** {@inheritDoc} */
+    public final int getDescender(final int size) {
+        return typeface.getDescender(size);
+    }
+
+    /** {@inheritDoc} */
+    public final String getEmbedFontName() {
+        return typeface.getEmbedFontName();
+    }
+
+    /** {@inheritDoc} */
+    public final Set getFamilyNames() {
+        return typeface.getFamilyNames();
+    }
+
+    /** {@inheritDoc} */
+    public final String getFontName() {
+        return typeface.getFontName();
+    }
+
+    /** {@inheritDoc} */
+    public final FontType getFontType() {
+        return typeface.getFontType();
+    }
+
+    /** {@inheritDoc} */
+    public final String getFullName() {
+        return typeface.getFullName();
+    }
+
+    /** {@inheritDoc} */
+    public final Map getKerningInfo() {
+        return typeface.getKerningInfo();
+    }
+
+    /** {@inheritDoc} */
+    public final int getWidth(final int i, final int size) {
+        return typeface.getWidth(i, size);
+    }
+
+    /** {@inheritDoc} */
+    public final int[] getWidths() {
+        return typeface.getWidths();
+    }
+
+    /** {@inheritDoc} */
+    public final int getXHeight(final int size) {
+        return typeface.getXHeight(size);
+    }
+
+    /** {@inheritDoc} */
+    public final boolean hasKerningInfo() {
+        return typeface.hasKerningInfo();
+    }
+
+}

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

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java?rev=609627&r1=609626&r2=609627&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java Mon Jan  7 07:06:24 2008
@@ -16,183 +16,23 @@
  */
 
 /* $Id$ */
- 
-package org.apache.fop.render.java2d;
 
-// Java
-import java.awt.Graphics2D;
-import java.util.Map;
-import java.util.Set;
+package org.apache.fop.render.java2d;
 
 import org.apache.fop.fonts.FontMetrics;
-import org.apache.fop.fonts.FontType;
-import org.apache.fop.fonts.Typeface;
-
 
 /**
- * This class implements org.apache.fop.layout.FontMetrics and
- * is added to the hash table in FontInfo. It  deferes the
- * actual calculation of the metrics to
- * Java2DFontMetrics.  It only keeps the java name and
- * style as member varibles
+ * Adds method to retrieve the actual <tt>java.awt.Font</tt>
+ * for use by <tt>Java2DRenderer</tt>s.
  */
-
-public class FontMetricsMapper extends Typeface implements FontMetrics {
-
-    /**
-     * This is a Java2DFontMetrics that does the real calculation.
-     * It is only one class that dynamically determines the font-size.
-     */
-    private static Java2DFontMetrics metric = null;
-
-    /**
-     * The java name of the font.
-     * #  Make the family name immutable.
-     */
-    private final String family;
-
-    /**
-     * The java style of the font.
-     * #  Make the style immutable.
-     */
-    private final int style;
-
-    /**
-     * Constructs a new Font-metrics.
-     * @param family the family name of the font (java value)
-     * @param style the java type style value of the font
-     * @param graphics a Graphics2D object - this is needed  so
-     * that we can get an instance of java.awt.FontMetrics
-     */
-    public FontMetricsMapper(String family, int style, Graphics2D graphics) {
-        this.family = family;
-        this.style = style;
-        if (metric == null) {
-            metric = new Java2DFontMetrics(graphics);
-        }
-    }
-
-    /** {@inheritDoc} */
-    public String getFontName() {
-        return family;
-    }
-
-    /** {@inheritDoc} */
-    public String getEmbedFontName() {
-        return getFontName();
-    }
-
-    /** {@inheritDoc} */
-    public String getFullName() {
-        return getFontName();
-    }
-
-    /** {@inheritDoc} */
-    public Set getFamilyNames() {
-        Set s = new java.util.HashSet();
-        s.add(this.family);
-        return s;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public FontType getFontType() {
-        return FontType.OTHER;
-    }
-    
-    /**
-     * {@inheritDoc}
-     */
-    public int getMaxAscent(int size) {
-        return metric.getMaxAscent(family, style, size);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int getAscender(int size) {
-        return metric.getAscender(family, style, size);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int getCapHeight(int size) {
-        return metric.getCapHeight(family, style, size);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int getDescender(int size) {
-        return metric.getDescender(family, style, size);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public int getXHeight(int size) {
-        return metric.getXHeight(family, style, size);
-    }
-
-    /**
-     * {@inheritDoc} 
-     */
-    public int getWidth(int i, int size) {
-        return metric.width(i, family, style, size);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public int[] getWidths() {
-        return metric.getWidths(family, style, Java2DFontMetrics.FONT_SIZE);
-    }
+public interface FontMetricsMapper extends FontMetrics {
 
     /**
      * Gets a Font instance  of the Font that this
      * FontMetrics describes in the desired size.
      * @param size font size
-     * @return font with the desired characeristics.
-     */
-    public java.awt.Font getFont(int size) {
-        return metric.getFont(family, style, size);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public Map getKerningInfo() {
-        return java.util.Collections.EMPTY_MAP;
-    }
-
-    /**
-     * {@inheritDoc}
+     * @return font with the desired characteristics.
      */
-    public boolean hasKerningInfo() {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    public String getEncoding() {
-        return null; //Not applicable to Java2D rendering
-    }
-
-    /** {@inheritDoc} */
-    public char mapChar(char c) {
-        return c;
-    }
-
-    /** {@inheritDoc} */
-    public boolean hasChar(char c) {
-        return metric.hasChar(family, style, Java2DFontMetrics.FONT_SIZE, c);
-    }
-
+    java.awt.Font getFont(int size);
+    
 }
-
-
-
-
-

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java?rev=609627&r1=609626&r2=609627&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontSetup.java Mon Jan  7 07:06:24 2008
@@ -5,9 +5,9 @@
  * 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.
@@ -22,14 +22,23 @@
 // FOP
 import java.awt.Graphics2D;
 import java.awt.GraphicsEnvironment;
+import java.util.List;
 import java.util.Set;
 
+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.Font;
 import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontLoader;
+import org.apache.fop.fonts.FontResolver;
 import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.fonts.FontUtil;
+import org.apache.fop.fonts.LazyFont;
 
 /**
  * Sets up the Java2D/AWT fonts. It is similar to
@@ -70,10 +79,13 @@
      * triplets for lookup.
      *
      * @param fontInfo the font info object to set up
-     * @param graphics needed for acces to font metrics
+     * @param configuredFontList of fop config fonts
+     * @param resolver for resolving the font file URI
+     * @param graphics needed for access to font metrics
      */
-    public static void setup(FontInfo fontInfo, Graphics2D graphics) {
-        FontMetricsMapper metric;
+    public static void setup(FontInfo fontInfo, List configuredFontList,
+            FontResolver resolver, Graphics2D graphics) {
+	FontMetricsMapper metric;
         int normal, bold, bolditalic, italic;
 
         /*
@@ -87,47 +99,47 @@
         italic = java.awt.Font.ITALIC;
         bolditalic = java.awt.Font.BOLD + java.awt.Font.ITALIC;
 
-        metric = new FontMetricsMapper("SansSerif", normal, graphics);
+        metric = new SystemFontMetricsMapper("SansSerif", normal, graphics);
         // --> goes to  F1
         fontInfo.addMetrics("F1", metric);
-        metric = new FontMetricsMapper("SansSerif", italic, graphics);
+        metric = new SystemFontMetricsMapper("SansSerif", italic, graphics);
         // --> goes to  F2
         fontInfo.addMetrics("F2", metric);
-        metric = new FontMetricsMapper("SansSerif", bold, graphics);
+        metric = new SystemFontMetricsMapper("SansSerif", bold, graphics);
         // --> goes to  F3
         fontInfo.addMetrics("F3", metric);
-        metric = new FontMetricsMapper("SansSerif", bolditalic, graphics);
+        metric = new SystemFontMetricsMapper("SansSerif", bolditalic, graphics);
         // --> goes to  F4
         fontInfo.addMetrics("F4", metric);
 
 
-        metric = new FontMetricsMapper("Serif", normal, graphics);
+        metric = new SystemFontMetricsMapper("Serif", normal, graphics);
         // --> goes to  F5
         fontInfo.addMetrics("F5", metric);
-        metric = new FontMetricsMapper("Serif", italic, graphics);
+        metric = new SystemFontMetricsMapper("Serif", italic, graphics);
         // --> goes to  F6
         fontInfo.addMetrics("F6", metric);
-        metric = new FontMetricsMapper("Serif", bold, graphics);
+        metric = new SystemFontMetricsMapper("Serif", bold, graphics);
         // --> goes to  F7
         fontInfo.addMetrics("F7", metric);
-        metric = new FontMetricsMapper("Serif", bolditalic, graphics);
+        metric = new SystemFontMetricsMapper("Serif", bolditalic, graphics);
         // --> goes to  F8
         fontInfo.addMetrics("F8", metric);
 
-        metric = new FontMetricsMapper("MonoSpaced", normal, graphics);
+        metric = new SystemFontMetricsMapper("MonoSpaced", normal, graphics);
         // --> goes to  F9
         fontInfo.addMetrics("F9", metric);
-        metric = new FontMetricsMapper("MonoSpaced", italic, graphics);
+        metric = new SystemFontMetricsMapper("MonoSpaced", italic, graphics);
         // --> goes to  F10
         fontInfo.addMetrics("F10", metric);
-        metric = new FontMetricsMapper("MonoSpaced", bold, graphics);
+        metric = new SystemFontMetricsMapper("MonoSpaced", bold, graphics);
         // --> goes to  F11
         fontInfo.addMetrics("F11", metric);
-        metric = new FontMetricsMapper("MonoSpaced", bolditalic, graphics);
+        metric = new SystemFontMetricsMapper("MonoSpaced", bolditalic, graphics);
         // --> goes to  F12
         fontInfo.addMetrics("F12", metric);
 
-        metric = new FontMetricsMapper("Serif", normal, graphics);
+        metric = new SystemFontMetricsMapper("Serif", normal, graphics);
         //"Symbol" doesn't seem to work here, but "Serif" does the job just fine. *shrug*
         // --> goes to  F13 and F14
         fontInfo.addMetrics("F13", metric);
@@ -207,10 +219,11 @@
         fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
                                    "normal", Font.WEIGHT_NORMAL);
         
-        configureInstalledAWTFonts(fontInfo, graphics, LAST_PREDEFINED_FONT_NUMBER + 1);
+	int lastNum = configureInstalledAWTFonts(fontInfo, graphics, LAST_PREDEFINED_FONT_NUMBER + 1);
+	addConfiguredFonts(fontInfo, configuredFontList, resolver, lastNum++);
     }
 
-    private static void configureInstalledAWTFonts(FontInfo fontInfo, Graphics2D graphics, 
+    private static int configureInstalledAWTFonts(FontInfo fontInfo, Graphics2D graphics, 
             int startNumber) {
         int num = startNumber;
         GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
@@ -250,9 +263,69 @@
                         guessedStyle, guessedWeight, fontKey);
             }
         }
+        return num;
 
     }
 
+    /**
+     * Add fonts from configuration file starting with internal name F<num>.
+     *
+     * @param fontInfo the font info object to set up
+     * @param fontList a list of EmbedFontInfo objects
+     * @param num starting index for internal font numbering
+     * @param resolver the font resolver
+     */
+    private static void addConfiguredFonts(FontInfo fontInfo, List fontList, FontResolver resolver, int num) {
+
+        if (fontList == null || fontList.size() < 1) {
+            log.debug("No user configured fonts found.");
+            return;
+        }
+        if (resolver == null) {
+            // Ensure that we have minimal font resolution capabilities
+            resolver = org.apache.fop.fonts.FontSetup
+                .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, 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);
+            }
+        }
+    }
+
+    
     private static void addFontTriplet(FontInfo fontInfo, String fontName, String fontStyle,
             int fontWeight, String fontKey) {
         FontTriplet triplet = FontInfo.createFontKey(fontName, fontStyle, fontWeight);
@@ -261,7 +334,7 @@
 
     private static void addFontMetricsMapper(FontInfo fontInfo, String family, String fontKey,
             Graphics2D graphics, int style) {
-        FontMetricsMapper metric = new FontMetricsMapper(family, style, graphics);
+	FontMetricsMapper metric = new SystemFontMetricsMapper(family, style, graphics);
         fontInfo.addMetrics(fontKey, metric);
     }
 

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=609627&r1=609626&r2=609627&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 Mon Jan  7 07:06:24 2008
@@ -179,7 +179,7 @@
         //The next line is important to get accurate font metrics!
         g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-        FontSetup.setup(fontInfo, g);
+        FontSetup.setup(fontInfo, fontList, fontResolver, g);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java?rev=609627&r1=609626&r2=609627&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Java2DRendererConfigurator.java Mon Jan  7 07:06:24 2008
@@ -53,5 +53,6 @@
                 java2dRenderer.setTransparentPageBackground("true".equalsIgnoreCase(value));
             }
         }
+        super.configure(renderer);
     }
 }

Copied: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java (from r602053, xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java?p2=xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java&p1=xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java&r1=602053&r2=609627&rev=609627&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/FontMetricsMapper.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/SystemFontMetricsMapper.java Mon Jan  7 07:06:24 2008
@@ -24,7 +24,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.fop.fonts.FontMetrics;
 import org.apache.fop.fonts.FontType;
 import org.apache.fop.fonts.Typeface;
 
@@ -37,7 +36,7 @@
  * style as member varibles
  */
 
-public class FontMetricsMapper extends Typeface implements FontMetrics {
+public class SystemFontMetricsMapper extends Typeface implements FontMetricsMapper {
 
     /**
      * This is a Java2DFontMetrics that does the real calculation.
@@ -64,7 +63,7 @@
      * @param graphics a Graphics2D object - this is needed  so
      * that we can get an instance of java.awt.FontMetrics
      */
-    public FontMetricsMapper(String family, int style, Graphics2D graphics) {
+    public SystemFontMetricsMapper(String family, int style, Graphics2D graphics) {
         this.family = family;
         this.style = style;
         if (metric == null) {
@@ -100,7 +99,7 @@
     public FontType getFontType() {
         return FontType.OTHER;
     }
-    
+
     /**
      * {@inheritDoc}
      */
@@ -137,7 +136,7 @@
     }
 
     /**
-     * {@inheritDoc} 
+     * {@inheritDoc}
      */
     public int getWidth(int i, int size) {
         return metric.width(i, family, style, size);
@@ -152,10 +151,7 @@
     }
 
     /**
-     * Gets a Font instance  of the Font that this
-     * FontMetrics describes in the desired size.
-     * @param size font size
-     * @return font with the desired characeristics.
+     * {@inheritDoc}
      */
     public java.awt.Font getFont(int size) {
         return metric.getFont(family, style, size);

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=609627&r1=609626&r2=609627&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 Mon Jan  7 07:06:24 2008
@@ -48,8 +48,12 @@
 import java.util.Map;
 import java.util.Stack;
 
+import org.w3c.dom.Document;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.xmlgraphics.java2d.GraphicContext;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.MimeConstants;
 import org.apache.fop.area.Area;
@@ -86,8 +90,6 @@
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.util.QName;
 import org.apache.fop.util.UnitConv;
-import org.apache.xmlgraphics.java2d.GraphicContext;
-import org.w3c.dom.Document;
 
 /**
  * Renderer for the PCL 5 printer language. It also uses HP GL/2 for certain graphic elements.
@@ -182,7 +184,7 @@
         //The next line is important to get accurate font metrics!
         g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, 
                 RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-        FontSetup.setup(fontInfo, g);
+        FontSetup.setup(fontInfo, fontList, fontResolver, g);
     }
 
     /**

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java?rev=609627&r1=609626&r2=609627&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java Mon Jan  7 07:06:24 2008
@@ -20,6 +20,7 @@
 package org.apache.fop.render.pcl;
 
 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;
@@ -73,5 +74,6 @@
             
             pclRenderer.setPJLDisabled(cfg.getChild("disable-pjl").getValueAsBoolean(false));
         }
+        super.configure(renderer);
     }
 }

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=609627&r1=609626&r2=609627&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Mon Jan  7 07:06:24 2008
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="add" fixes-bug="44176" due-to="Patrick Jaromin">
+        Added support for custom fonts in Java2DRenderer and derived renderers.
+      </action>
       <action context="Code" dev="JM" type="add">
         Added new extension element: fox:external-document. It allows to add whole documents
         such as multi-page TIFF images to be inserted as peers to a page-sequence. Each image



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