aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/afp
diff options
context:
space:
mode:
authorAdrian Cumiskey <acumiskey@apache.org>2008-07-17 18:14:01 +0000
committerAdrian Cumiskey <acumiskey@apache.org>2008-07-17 18:14:01 +0000
commit96b06ff833f8c1059c3a5ae5a3bc023812e38a14 (patch)
tree1c333b49039e0c9bd89ee34259929a3b053a8e5d /src/java/org/apache/fop/render/afp
parent74567e49f4caf648926ab2ba7a034ae84c30b2e9 (diff)
downloadxmlgraphics-fop-96b06ff833f8c1059c3a5ae5a3bc023812e38a14.tar.gz
xmlgraphics-fop-96b06ff833f8c1059c3a5ae5a3bc023812e38a14.zip
Merged revisions 676161,676297,676307,676397,676608,677404-677405,677543,677648-677652 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r676161 | jeremias | 2008-07-12 13:19:40 +0100 (Sat, 12 Jul 2008) | 1 line Attempt to fix a potential build problem. ........ r676297 | adelmelle | 2008-07-13 11:26:48 +0100 (Sun, 13 Jul 2008) | 2 lines Replace occurrences of File.toURL() by File.toURI().toURL() (recommended as of Java 6, where File.toURL() is deprecated) ........ r676307 | jeremias | 2008-07-13 13:11:17 +0100 (Sun, 13 Jul 2008) | 1 line null is not correct here, an empty String needs to be used for the default namespace. Saxon 9 fails with a NullPointerException otherwise. Xalan is more tolerant. ........ r676397 | adelmelle | 2008-07-13 19:31:30 +0100 (Sun, 13 Jul 2008) | 1 line Another attempt at avoiding build issues (?) ........ r676608 | cbowditch | 2008-07-14 15:44:53 +0100 (Mon, 14 Jul 2008) | 1 line A nit: clarify message so its more meaningful to end user ........ r677404 | jeremias | 2008-07-16 21:16:51 +0100 (Wed, 16 Jul 2008) | 1 line Worked around a bug in Xalan 2.4.0 (bundled with Sun Java 1.4.2_xx) where file URLs like file:/C:/.... got converted to file:\C:\.... on Windows causing a FileNotFoundException. ........ r677405 | jeremias | 2008-07-16 21:22:17 +0100 (Wed, 16 Jul 2008) | 1 line Removed stray System.out. ........ r677543 | jeremias | 2008-07-17 10:11:09 +0100 (Thu, 17 Jul 2008) | 1 line fonts package must not depend on the render package. Refactored to restore that rule. ........ r677648 | acumiskey | 2008-07-17 18:39:14 +0100 (Thu, 17 Jul 2008) | 2 lines ZapfDingbats and Symbol is not always available on the AFPRenderer so we can't have these as default font family properties unfortunately. ........ r677649 | acumiskey | 2008-07-17 18:40:12 +0100 (Thu, 17 Jul 2008) | 2 lines A minor optimization. ........ r677650 | acumiskey | 2008-07-17 18:41:27 +0100 (Thu, 17 Jul 2008) | 2 lines An optimization and improved readability of fontLookup() call. ........ r677651 | acumiskey | 2008-07-17 18:44:08 +0100 (Thu, 17 Jul 2008) | 2 lines Moved font setup stuff from setupFontInfo() in AFPRenderer and delegated this stuff to an AFPFontCollection class. ........ r677652 | acumiskey | 2008-07-17 18:47:04 +0100 (Thu, 17 Jul 2008) | 2 lines Unused imports. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@677664 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/afp')
-rw-r--r--src/java/org/apache/fop/render/afp/AFPRenderer.java67
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java110
-rw-r--r--src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java8
3 files changed, 122 insertions, 63 deletions
diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java
index 70dd3f458..98d2440c1 100644
--- a/src/java/org/apache/fop/render/afp/AFPRenderer.java
+++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java
@@ -65,11 +65,9 @@ import org.apache.fop.datatypes.URISpecification;
import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionAttachment;
+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.fonts.FontManager;
import org.apache.fop.render.AbstractPathOrientedRenderer;
import org.apache.fop.render.AbstractState;
import org.apache.fop.render.Graphics2DAdapter;
@@ -77,10 +75,7 @@ import org.apache.fop.render.RendererContext;
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.AFPFontInfo;
-import org.apache.fop.render.afp.fonts.CharacterSet;
-import org.apache.fop.render.afp.fonts.FopCharacterSet;
-import org.apache.fop.render.afp.fonts.OutlineFont;
+import org.apache.fop.render.afp.fonts.AFPFontCollection;
import org.apache.fop.render.afp.modca.AFPConstants;
import org.apache.fop.render.afp.modca.AFPDataStream;
import org.apache.fop.render.afp.modca.PageObject;
@@ -183,57 +178,11 @@ public class AFPRenderer extends AbstractPathOrientedRenderer {
/** {@inheritDoc} */
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);
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java
new file mode 100644
index 000000000..55953daf0
--- /dev/null
+++ b/src/java/org/apache/fop/render/afp/fonts/AFPFontCollection.java
@@ -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;
+ }
+
+}
diff --git a/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java b/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
index 77792267c..7951be26c 100644
--- a/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
+++ b/src/java/org/apache/fop/render/afp/fonts/AFPFontReader.java
@@ -157,7 +157,7 @@ public final class AFPFontReader {
if (url == null) {
try {
File file = new File(path);
- url = file.toURL();
+ url = file.toURI().toURL();
if (url == null) {
String msg = "CharacterSet file not found for "
+ characterset + " in classpath: " + path;
@@ -194,7 +194,7 @@ public final class AFPFontReader {
log.warn(msg);
}
- inputStream = csfont[0].toURL().openStream();
+ inputStream = csfont[0].toURI().toURL().openStream();
if (inputStream == null) {
String msg = "Failed to open character set resource "
+ characterset;
@@ -258,7 +258,7 @@ public final class AFPFontReader {
if (url == null) {
try {
File file = new File(path);
- url = file.toURL();
+ url = file.toURI().toURL();
if (url == null) {
String msg = "CodePage file not found for " + codePage
+ " in classpath: " + path;
@@ -300,7 +300,7 @@ public final class AFPFontReader {
log.warn(msg);
}
- InputStream is = codepage[0].toURL().openStream();
+ InputStream is = codepage[0].toURI().toURL().openStream();
if (is == null) {
String msg = "AFPFontReader:: loadCodePage(String):: code page file not found for "