reduced dependancy on Configuration git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195039 13f79535-47bb-0310-9956-ffa450edef68pull/30/head
@@ -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; |
@@ -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() { |
@@ -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); |
@@ -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()); | |||
} | |||
/** |
@@ -5,21 +5,19 @@ | |||
* LICENSE file included with these sources. | |||
*/ | |||
package org.apache.fop.configuration; | |||
package org.apache.fop.render.pdf; | |||
import java.util.ArrayList; | |||
/** | |||
* FontInfo contains meta information on fonts (where is the metrics file etc.) | |||
*/ | |||
public class FontInfo { | |||
public class EmbedFontInfo { | |||
private String metricsFile, embedFile, name; | |||
private boolean kerning; | |||
private ArrayList fontTriplets; | |||
public FontInfo(String name, String metricsFile, boolean kerning, | |||
public EmbedFontInfo(String name, String metricsFile, boolean kerning, | |||
ArrayList fontTriplets, String embedFile) { | |||
this.name = name; | |||
this.metricsFile = metricsFile; |
@@ -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)); | |||
} | |||
} | |||
} | |||
@@ -5,14 +5,11 @@ | |||
* LICENSE file included with these sources. | |||
*/ | |||
package org.apache.fop.configuration; | |||
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) { | |||
@@ -32,9 +29,5 @@ public class FontTriplet { | |||
public String getStyle() { | |||
return style; | |||
} | |||
} | |||
@@ -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); | |||
} |
@@ -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; | |||
} | |||
@@ -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() { |
@@ -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(); | |||
@@ -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); |