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 ac...@apache.org on 2008/07/17 19:44:08 UTC

svn commit: r677651 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp: AFPRenderer.java fonts/AFPFontCollection.java

Author: acumiskey
Date: Thu Jul 17 10:44:08 2008
New Revision: 677651

URL: http://svn.apache.org/viewvc?rev=677651&view=rev
Log:
Moved font setup stuff from setupFontInfo() in AFPRenderer and delegated this stuff to an AFPFontCollection class.

Added:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java   (with props)
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java?rev=677651&r1=677650&r2=677651&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/AFPRenderer.java Thu Jul 17 10:44:08 2008
@@ -74,8 +74,12 @@
 import org.apache.fop.events.ResourceEventProducer;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.extensions.ExtensionAttachment;
+import org.apache.fop.fonts.CustomFontCollection;
+import org.apache.fop.fonts.FontCollection;
 import org.apache.fop.fonts.FontInfo;
+import org.apache.fop.fonts.FontManager;
 import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.fonts.base14.Base14FontCollection;
 import org.apache.fop.fonts.base14.Courier;
 import org.apache.fop.fonts.base14.Helvetica;
 import org.apache.fop.fonts.base14.TimesRoman;
@@ -85,6 +89,7 @@
 import org.apache.fop.render.afp.extensions.AFPElementMapping;
 import org.apache.fop.render.afp.extensions.AFPPageSetup;
 import org.apache.fop.render.afp.fonts.AFPFont;
+import org.apache.fop.render.afp.fonts.AFPFontCollection;
 import org.apache.fop.render.afp.fonts.AFPFontInfo;
 import org.apache.fop.render.afp.fonts.CharacterSet;
 import org.apache.fop.render.afp.fonts.FopCharacterSet;
@@ -279,53 +284,11 @@
      */
     public void setupFontInfo(FontInfo inFontInfo) {
         this.fontInfo = inFontInfo;
-        int num = 1;
-        if (super.embedFontInfoList != null && super.embedFontInfoList.size() > 0) {
-            for (Iterator it = super.embedFontInfoList.iterator(); it.hasNext();) {
-                AFPFontInfo afi = (AFPFontInfo)it.next();
-                AFPFont bf = (AFPFont)afi.getAFPFont();
-                for (Iterator it2 = afi.getFontTriplets().iterator(); it2.hasNext();) {
-                    FontTriplet ft = (FontTriplet)it2.next();
-                    this.fontInfo.addFontProperties("F" + num, ft.getName()
-                                                    , ft.getStyle(), ft.getWeight());
-                    this.fontInfo.addMetrics("F" + num, bf);
-                    num++;
-                }
-            }
-        } else {
-            AFPEventProducer eventProducer = AFPEventProducer.Provider.get(
-                    getUserAgent().getEventBroadcaster());
-            eventProducer.warnDefaultFontSetup(this);
-        }
-        if (this.fontInfo.fontLookup("sans-serif", "normal", 400) == null) {
-            CharacterSet cs  = new FopCharacterSet("T1V10500", "Cp500", "CZH200  ",
-                    1, new Helvetica());
-            AFPFont bf = new OutlineFont("Helvetica", cs);
-            this.fontInfo.addFontProperties("F" + num, "sans-serif", "normal", 400);
-            this.fontInfo.addMetrics("F" + num, bf);
-            num++;
-        }
-        if (this.fontInfo.fontLookup("serif", "normal", 400) == null) {
-            CharacterSet cs  = new FopCharacterSet("T1V10500", "Cp500", "CZN200  ",
-                    1, new TimesRoman());
-            AFPFont bf = new OutlineFont("Helvetica", cs);
-            this.fontInfo.addFontProperties("F" + num, "serif", "normal", 400);
-            this.fontInfo.addMetrics("F" + num, bf);
-            num++;
-        }
-        if (this.fontInfo.fontLookup("monospace", "normal", 400) == null) {
-            CharacterSet cs  = new FopCharacterSet("T1V10500", "Cp500", "CZ4200  ",
-                    1, new Courier());
-            AFPFont bf = new OutlineFont("Helvetica", cs);
-            this.fontInfo.addFontProperties("F" + num, "monospace", "normal", 400);
-            this.fontInfo.addMetrics("F" + num, bf);
-            num++;
-        }
-        if (this.fontInfo.fontLookup("any", "normal", 400) == null) {
-            FontTriplet ft = this.fontInfo.fontLookup("sans-serif", "normal", 400);
-            this.fontInfo.addFontProperties(
-                    this.fontInfo.getInternalFontKey(ft), "any", "normal", 400);
-        }
+        FontManager fontManager = userAgent.getFactory().getFontManager();
+        FontCollection[] fontCollections = new FontCollection[] {
+            new AFPFontCollection(userAgent.getEventBroadcaster(), getFontList())
+        };
+        fontManager.setup(getFontInfo(), fontCollections);
     }
 
     /**

Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java?rev=677651&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java Thu Jul 17 10:44:08 2008
@@ -0,0 +1,110 @@
+/*
+ * 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.afp.fonts;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.fop.events.EventBroadcaster;
+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.base14.Courier;
+import org.apache.fop.fonts.base14.Helvetica;
+import org.apache.fop.fonts.base14.TimesRoman;
+import org.apache.fop.render.afp.AFPEventProducer;
+
+/**
+ * A base collection of AFP fonts
+ */
+public class AFPFontCollection implements FontCollection {
+
+    private EventBroadcaster eventBroadcaster;
+    private List/*<EmbedFontInfo>*/ embedFontInfoList;
+    
+    /**
+     * Main constructor
+     * 
+     * @param eventBroadcaster the event broadcaster
+     * @param embedFontInfoList the embed font info list
+     */
+    public AFPFontCollection(EventBroadcaster eventBroadcaster, 
+            List/*<EmbedFontInfo>*/ embedFontInfoList) {
+        this.eventBroadcaster = eventBroadcaster;
+        this.embedFontInfoList = embedFontInfoList;
+    }
+    
+    /** {@inheritDoc} */
+    public int setup(int start, FontInfo fontInfo) {
+        int num = 1;
+        if (embedFontInfoList != null && embedFontInfoList.size() > 0) {
+            for (Iterator it = embedFontInfoList.iterator(); it.hasNext();) {
+                AFPFontInfo afi = (AFPFontInfo)it.next();
+                AFPFont bf = (AFPFont)afi.getAFPFont();
+                for (Iterator it2 = afi.getFontTriplets().iterator(); it2.hasNext();) {
+                    FontTriplet ft = (FontTriplet)it2.next();
+                    fontInfo.addFontProperties("F" + num, ft.getName()
+                                                    , ft.getStyle(), ft.getWeight());
+                    fontInfo.addMetrics("F" + num, bf);
+                    num++;
+                }
+            }
+        } else {
+            AFPEventProducer eventProducer = AFPEventProducer.Provider.get(eventBroadcaster);
+            eventProducer.warnDefaultFontSetup(this);
+        }
+        if (fontInfo.fontLookup("sans-serif", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL) == null) {
+            CharacterSet cs  = new FopCharacterSet("T1V10500", "Cp500", "CZH200  ",
+                    1, new Helvetica());
+            AFPFont bf = new OutlineFont("Helvetica", cs);
+            fontInfo.addFontProperties(
+                    "F" + num, "sans-serif", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+            fontInfo.addMetrics("F" + num, bf);
+            num++;
+        }
+        if (fontInfo.fontLookup("serif", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL) == null) {
+            CharacterSet cs  = new FopCharacterSet("T1V10500", "Cp500", "CZN200  ",
+                    1, new TimesRoman());
+            AFPFont bf = new OutlineFont("Helvetica", cs);
+            fontInfo.addFontProperties("F" + num, "serif", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+            fontInfo.addMetrics("F" + num, bf);
+            num++;
+        }
+        if (fontInfo.fontLookup("monospace", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL) == null) {
+            CharacterSet cs  = new FopCharacterSet("T1V10500", "Cp500", "CZ4200  ",
+                    1, new Courier());
+            AFPFont bf = new OutlineFont("Helvetica", cs);
+            fontInfo.addFontProperties(
+                    "F" + num, "monospace", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+            fontInfo.addMetrics("F" + num, bf);
+            num++;
+        }
+        if (fontInfo.fontLookup("any", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL) == null) {
+            FontTriplet ft = fontInfo.fontLookup(
+                    "sans-serif", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+            fontInfo.addFontProperties(
+                    fontInfo.getInternalFontKey(ft), "any", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+            num++;
+        }
+        return num;
+    }
+
+}

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java
------------------------------------------------------------------------------
    svn:keywords = Revision Id



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