]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
moved embed font info into the render.pdf package
authorKeiron Liddle <keiron@apache.org>
Wed, 31 Jul 2002 08:20:41 +0000 (08:20 +0000)
committerKeiron Liddle <keiron@apache.org>
Wed, 31 Jul 2002 08:20:41 +0000 (08:20 +0000)
reduced dependancy on Configuration

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195039 13f79535-47bb-0310-9956-ffa450edef68

14 files changed:
src/org/apache/fop/configuration/ConfigurationParser.java
src/org/apache/fop/configuration/FontInfo.java [deleted file]
src/org/apache/fop/configuration/FontTriplet.java [deleted file]
src/org/apache/fop/mif/MIFHandler.java
src/org/apache/fop/pdf/PDFDocument.java
src/org/apache/fop/render/PrintRenderer.java
src/org/apache/fop/render/pdf/EmbedFontInfo.java [new file with mode: 0644]
src/org/apache/fop/render/pdf/FontSetup.java
src/org/apache/fop/render/pdf/FontTriplet.java [new file with mode: 0644]
src/org/apache/fop/render/pdf/PDFRenderer.java
src/org/apache/fop/render/ps/PSRenderer.java
src/org/apache/fop/render/xml/XMLRenderer.java
src/org/apache/fop/svg/PDFDocumentGraphics2D.java
src/org/apache/fop/svg/PDFGraphics2D.java

index 39039dd8921df8b29bf612d8bb0416a28304edd4..9d60352acf80b1f4410b5dc70c3855cdcc17da4d 100644 (file)
@@ -8,6 +8,9 @@
 
 package org.apache.fop.configuration;
 
+import org.apache.fop.render.pdf.EmbedFontInfo;
+import org.apache.fop.render.pdf.FontTriplet;
+
 // sax
 import org.xml.sax.helpers.DefaultHandler;
 import org.xml.sax.Attributes;
@@ -74,7 +77,7 @@ public class ConfigurationParser extends DefaultHandler {
     private ArrayList fontList = null;
 
     // stores information on one font
-    private FontInfo fontInfo = null;
+    private EmbedFontInfo fontInfo = null;
 
     // stores information on a font triplet
     private FontTriplet fontTriplet = null;
@@ -195,7 +198,7 @@ public class ConfigurationParser extends DefaultHandler {
         } else if (localName.equals("fonts")) {
             this.store("standard", "fonts", fontList);
         } else if (localName.equals("font")) {
-            fontInfo = new FontInfo(fontName, metricsFile, kerning,
+            fontInfo = new EmbedFontInfo(fontName, metricsFile, kerning,
                                     fontTriplets, embedFile);
             fontList.add(fontInfo);
             fontTriplets = null;
diff --git a/src/org/apache/fop/configuration/FontInfo.java b/src/org/apache/fop/configuration/FontInfo.java
deleted file mode 100644 (file)
index db0c96c..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-
-package org.apache.fop.configuration;
-
-import java.util.ArrayList;
-
-/**
- * FontInfo contains meta information on fonts (where is the metrics file etc.)
- */
-
-public class FontInfo {
-    private String metricsFile, embedFile, name;
-    private boolean kerning;
-    private ArrayList fontTriplets;
-
-    public FontInfo(String name, String metricsFile, boolean kerning,
-                    ArrayList fontTriplets, String embedFile) {
-        this.name = name;
-        this.metricsFile = metricsFile;
-        this.embedFile = embedFile;
-        this.kerning = kerning;
-        this.fontTriplets = fontTriplets;
-    }
-
-    public String getMetricsFile() {
-        return metricsFile;
-    }
-
-    public String getEmbedFile() {
-        return embedFile;
-    }
-
-    public boolean getKerning() {
-        return kerning;
-    }
-
-    public ArrayList getFontTriplets() {
-        return fontTriplets;
-    }
-
-}
-
diff --git a/src/org/apache/fop/configuration/FontTriplet.java b/src/org/apache/fop/configuration/FontTriplet.java
deleted file mode 100644 (file)
index b39ab3e..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
- * For details on use and redistribution please refer to the
- * LICENSE file included with these sources.
- */
-
-
-package org.apache.fop.configuration;
-
-/**
- * FontTriplet contains information on name, weight, style of one font
- */
-
-
-public class FontTriplet {
-    private String name, weight, style;
-    public FontTriplet(String name, String weight, String style) {
-        this.name = name;
-        this.weight = weight;
-        this.style = style;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public String getWeight() {
-        return weight;
-    }
-
-    public String getStyle() {
-        return style;
-    }
-
-}
-
-
-
-
index 2cf6bff192c0e44757e8e65d4a988e5a3c13fb10..a71fa304efecd72029039316c1c2459bfb759d49 100644 (file)
@@ -42,7 +42,7 @@ public class MIFHandler extends StructureHandler {
     public MIFHandler(OutputStream os) {
         outStream = os;
         // use pdf fonts for now, this is only for resolving names
-        org.apache.fop.render.pdf.FontSetup.setup(fontInfo);
+        org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts());
     }
 
     public FontInfo getFontInfo() {
index 715e957427fd5c7b98d795a26e3abd3a95044955..1fcfdf69667b4912beb1852b3491c772a75fb045 100644 (file)
@@ -154,7 +154,7 @@ public class PDFDocument {
      * time to work out, and is so obvious now. Sigh.
      * mark-fop@inomial.com. Maybe I should do a PDF course.
      */
-    public PDFDocument() {
+    public PDFDocument(String prod) {
 
         /* create the /Root, /Info and /Resources objects */
         this.pages = makePages();
@@ -166,7 +166,7 @@ public class PDFDocument {
         this.resources = makeResources();
 
         // Make the /Info record
-        this.info = makeInfo();
+        this.info = makeInfo(prod);
     }
 
     /**
@@ -225,7 +225,7 @@ public class PDFDocument {
      * @param producer string indicating application producing the PDF
      * @return the created /Info object
      */
-    protected PDFInfo makeInfo() {
+    protected PDFInfo makeInfo(String prod) {
 
         /*
          * create a PDFInfo with the next object number and add to
@@ -233,7 +233,7 @@ public class PDFDocument {
          */
         PDFInfo pdfInfo = new PDFInfo(++this.objectcount);
         // set the default producer
-        pdfInfo.setProducer(org.apache.fop.apps.Version.getVersion());
+        pdfInfo.setProducer(prod);
         this.objects.add(pdfInfo);
         return pdfInfo;
     }
@@ -904,7 +904,7 @@ public class PDFDocument {
          * Create a PDFICCStream
          @see PDFXObject
          @see org.apache.fop.image.JpegImage
-         @see org.apache.fop.datatypes.ColorSpace
+         @see org.apache.fop.pdf.PDFColorSpace
         */
     public PDFICCStream makePDFICCStream() {
         PDFICCStream iccStream = new PDFICCStream(++this.objectcount);
index 95aa56d39ba569d74e7fde487aac700c397860ab..ca0c6238c203a58c16b6c701cac8a04afbbd10d0 100644 (file)
@@ -35,7 +35,7 @@ public abstract class PrintRenderer extends AbstractRenderer {
      */
     public void setupFontInfo(FontInfo fontInfo) {
         this.fontInfo = fontInfo;
-        FontSetup.setup(fontInfo);
+        FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts());
     }
 
     /**
diff --git a/src/org/apache/fop/render/pdf/EmbedFontInfo.java b/src/org/apache/fop/render/pdf/EmbedFontInfo.java
new file mode 100644 (file)
index 0000000..2704180
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
+package org.apache.fop.render.pdf;
+
+import java.util.ArrayList;
+
+/**
+ * FontInfo contains meta information on fonts (where is the metrics file etc.)
+ */
+public class EmbedFontInfo {
+    private String metricsFile, embedFile, name;
+    private boolean kerning;
+    private ArrayList fontTriplets;
+
+    public EmbedFontInfo(String name, String metricsFile, boolean kerning,
+                    ArrayList fontTriplets, String embedFile) {
+        this.name = name;
+        this.metricsFile = metricsFile;
+        this.embedFile = embedFile;
+        this.kerning = kerning;
+        this.fontTriplets = fontTriplets;
+    }
+
+    public String getMetricsFile() {
+        return metricsFile;
+    }
+
+    public String getEmbedFile() {
+        return embedFile;
+    }
+
+    public boolean getKerning() {
+        return kerning;
+    }
+
+    public ArrayList getFontTriplets() {
+        return fontTriplets;
+    }
+
+}
+
index 221020bbe9e601655d5df8a16c878cc4ca917849..21ae5ecedecc091f8905b796c39f430dbf22e039 100644 (file)
@@ -13,8 +13,6 @@ import org.apache.fop.layout.FontInfo;
 import org.apache.fop.layout.FontDescriptor;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFResources;
-import org.apache.fop.configuration.Configuration;
-import org.apache.fop.configuration.FontTriplet;
 
 // Java
 import java.util.HashMap;
@@ -37,7 +35,7 @@ public class FontSetup {
      *
      * @param fontInfo the font info object to set up
      */
-    public static void setup(FontInfo fontInfo) {
+    public static void setup(FontInfo fontInfo, ArrayList embedList) {
 
         fontInfo.addMetrics("F1", new Helvetica());
         fontInfo.addMetrics("F2", new HelveticaOblique());
@@ -129,27 +127,24 @@ public class FontSetup {
                                    "normal", FontInfo.NORMAL);
 
         /* Add configured fonts */
-        addConfiguredFonts(fontInfo, 15);
+        addConfiguredFonts(fontInfo, embedList, 15);
     }
 
     /**
      * Add fonts from configuration file starting with
      * internalnames F<num>
      */
-    public static void addConfiguredFonts(FontInfo fontInfo, int num) {
+    public static void addConfiguredFonts(FontInfo fontInfo, ArrayList fontInfos, int num) {
+        if (fontInfos == null)
+            return;
 
         String internalName = null;
         FontReader reader = null;
 
-        ArrayList fontInfos = Configuration.getFonts();
-        if (fontInfos == null)
-            return;
-
         for (int count = 0; count < fontInfos.size(); count++) {
-            org.apache.fop.configuration.FontInfo configFontInfo =
-                (org.apache.fop.configuration.FontInfo)fontInfos.get(count);
+            EmbedFontInfo configFontInfo =
+                (EmbedFontInfo)fontInfos.get(count);
 
-            try {
                 String metricsFile = configFontInfo.getMetricsFile();
                 if (metricsFile != null) {
                     internalName = "F" + num;
@@ -184,11 +179,6 @@ public class FontSetup {
                                                    weight);
                     }
                 }
-            } catch (Exception ex) {
-                //log.error("Failed to read font metrics file "
-                //                     + configFontInfo.getMetricsFile()
-                //                     + " : " + ex.getMessage());
-            }
         }
     }
 
@@ -212,5 +202,5 @@ public class FontSetup {
                                            font.encoding(), font, desc));
         }
     }
-
 }
+
diff --git a/src/org/apache/fop/render/pdf/FontTriplet.java b/src/org/apache/fop/render/pdf/FontTriplet.java
new file mode 100644 (file)
index 0000000..fda5ff0
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * $Id$
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
+ */
+
+package org.apache.fop.render.pdf;
+
+/**
+ * FontTriplet contains information on name, weight, style of one font
+ */
+public class FontTriplet {
+    private String name, weight, style;
+    public FontTriplet(String name, String weight, String style) {
+        this.name = name;
+        this.weight = weight;
+        this.style = style;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getWeight() {
+        return weight;
+    }
+
+    public String getStyle() {
+        return style;
+    }
+}
+
index db284112545df7e50dbfa44cae36c0d9ded9d05b..a288911c43e87c022ee543db0a014f6c0e9be31a 100644 (file)
@@ -14,6 +14,7 @@ import org.apache.fop.render.RendererContext;
 import org.apache.fop.fo.FOUserAgent;
 import org.apache.fop.image.*;
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.Version;
 import org.apache.fop.fo.properties.*;
 import org.apache.fop.datatypes.*;
 import org.apache.fop.pdf.*;
@@ -158,7 +159,7 @@ public class PDFRenderer extends PrintRenderer {
 
     public void startRenderer(OutputStream stream) throws IOException {
         ostream = stream;
-        this.pdfDoc = new PDFDocument();
+        this.pdfDoc = new PDFDocument(Version.getVersion());
         this.pdfDoc.setProducer(producer);
         pdfDoc.outputHeader(stream);
     }
index 67cdf8c4ec867f71aec3930a60afcc571dd98dec..c40af92b9f0249dd53f7fe64da7fb2474feada98 100644 (file)
@@ -229,7 +229,7 @@ public class PSRenderer extends AbstractRenderer {
      */
     public void setupFontInfo(FontInfo fontInfo) {
         /* use PDF's font setup to get PDF metrics */
-        org.apache.fop.render.pdf.FontSetup.setup(fontInfo);
+        org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts());
         this.fontInfo = fontInfo;
     }
 
index 8250ae4df7065068d1715618c2a9194089432518..8dfa8ee5fbc202d647cd3124858989cb126d1731 100644 (file)
@@ -148,7 +148,7 @@ public class XMLRenderer extends AbstractRenderer {
     public void setupFontInfo(FontInfo fontInfo) {
 
         /* use PDF's font setup to get PDF metrics */
-        org.apache.fop.render.pdf.FontSetup.setup(fontInfo);
+        org.apache.fop.render.pdf.FontSetup.setup(fontInfo, org.apache.fop.configuration.Configuration.getFonts());
     }
 
     private boolean isCoarseXml() {
index 2b67d0f8326ea3e310563590f75bc1ed9c522952..86f6ff20ab19ccdcc2af15460dceae48985dcfec 100644 (file)
@@ -59,14 +59,13 @@ public class PDFDocumentGraphics2D extends PDFGraphics2D {
     
         if(!textAsShapes) {
             fontInfo = new FontInfo();
-            FontSetup.setup(fontInfo);
+            FontSetup.setup(fontInfo, null);
             //FontState fontState = new FontState("Helvetica", "normal",
             //                          FontInfo.NORMAL, 12, 0);
         }
 
         standalone = true;
-        this.pdfDoc = new PDFDocument();
-        this.pdfDoc.setProducer("FOP SVG Renderer");
+        this.pdfDoc = new PDFDocument("FOP SVG Renderer");
 
         graphicsState = new PDFState();
 
index ec5bcb32718e88c119f7d40a2f4e11a231206b28..3093dedede9723bf5c41eb366d9b3725770013d6 100644 (file)
@@ -791,7 +791,7 @@ public class PDFGraphics2D extends AbstractGraphics2D {
             Rectangle2D rect = pp.getPatternRect();
 
             FontInfo fi = new FontInfo();
-            FontSetup.setup(fi);
+            FontSetup.setup(fi, null);
 
             PDFResources res = pdfDoc.makeResources();
             PDFResourceContext context = new PDFResourceContext(0, pdfDoc, res);