aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/ps
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2007-05-28 14:31:24 +0000
committerJeremias Maerki <jeremias@apache.org>2007-05-28 14:31:24 +0000
commit8c1aba3f976127d33ec50b67d760f56364c08487 (patch)
treeadfdca730f41c1b9029324bf53535aa25bf16d27 /src/java/org/apache/fop/render/ps
parent7ada0a06fe2b9ce0e1867d2c9c47f71ea47a43b2 (diff)
downloadxmlgraphics-fop-8c1aba3f976127d33ec50b67d760f56364c08487.tar.gz
xmlgraphics-fop-8c1aba3f976127d33ec50b67d760f56364c08487.zip
Bugzilla #41831:
- Add support font auto-detection (easier font configuration) including a font cache to speed up the auto-detection process. - Refactoring of the configuration code: All Avalon configuration stuff is extracted into separate "Configurator" classes. - Refactoring of the FOURIResolver. Submitted by: Adrian Cumiskey <fop-dev.at.cumiskey.com> Changes to the patch by jeremias during the review: - Font cache simplified (Java object serialization instead of XML), functionality fixed and moved to the fonts.package. - Relocated default cache file location to user directory. - Fixed the font configuration for PDFDocumentGraphics2D/PDFTranscoder that got lost with the patch. - Fixed a problem with having a non-file URL as font base URL. - Simplified RendererContextInfo stuff to make it easier to understand. - Fixed handling of Type 1 fonts in auto-detection. - Reduced verbosity of font-related log output. - Updated Jakarta Commons IO to version 1.3.1 (the patch depends on it) - Various javadocs improvements git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@542237 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/render/ps')
-rw-r--r--src/java/org/apache/fop/render/ps/NativeTextHandler.java2
-rw-r--r--src/java/org/apache/fop/render/ps/PSRenderer.java21
-rw-r--r--src/java/org/apache/fop/render/ps/PSRendererConfigurator.java56
-rw-r--r--src/java/org/apache/fop/render/ps/PSRendererMaker.java12
-rw-r--r--src/java/org/apache/fop/render/ps/PSTextPainter.java8
5 files changed, 69 insertions, 30 deletions
diff --git a/src/java/org/apache/fop/render/ps/NativeTextHandler.java b/src/java/org/apache/fop/render/ps/NativeTextHandler.java
index 47f7fb0b8..5cda145b9 100644
--- a/src/java/org/apache/fop/render/ps/NativeTextHandler.java
+++ b/src/java/org/apache/fop/render/ps/NativeTextHandler.java
@@ -159,7 +159,7 @@ public class NativeTextHandler implements TextHandler {
}
int fontSize = 1000 * f.getSize();
String style = f.isItalic() ? "italic" : "normal";
- int weight = f.isBold() ? Font.BOLD : Font.NORMAL;
+ int weight = f.isBold() ? Font.WEIGHT_BOLD : Font.WEIGHT_NORMAL;
FontTriplet triplet = fontInfo.findAdjustWeight(fontFamily, style, weight);
if (triplet == null) {
diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java
index 68c6cc86c..ad5b0b3ce 100644
--- a/src/java/org/apache/fop/render/ps/PSRenderer.java
+++ b/src/java/org/apache/fop/render/ps/PSRenderer.java
@@ -35,8 +35,6 @@ import java.util.Map;
import javax.xml.transform.Source;
// FOP
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -61,7 +59,6 @@ import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExtensionAttachment;
import org.apache.fop.fonts.Font;
-import org.apache.fop.fonts.FontSetup;
import org.apache.fop.fonts.LazyFont;
import org.apache.fop.fonts.Typeface;
import org.apache.fop.image.EPSImage;
@@ -146,24 +143,6 @@ public class PSRenderer extends AbstractPathOrientedRenderer implements ImageAda
private Map formResources;
/**
- * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
- */
- public void configure(Configuration cfg) throws ConfigurationException {
- super.configure(cfg);
- this.autoRotateLandscape = cfg.getChild(AUTO_ROTATE_LANDSCAPE).getValueAsBoolean(false);
- this.languageLevel = cfg.getChild(LANGUAGE_LEVEL).getValueAsInteger(this.languageLevel);
- this.twoPassGeneration = cfg.getChild(OPTIMIZE_RESOURCES).getValueAsBoolean(false);
-
- //Font configuration
- List cfgFonts = FontSetup.buildFontListFromConfiguration(cfg, this);
- if (this.fontList == null) {
- this.fontList = cfgFonts;
- } else {
- this.fontList.addAll(cfgFonts);
- }
- }
-
- /**
* @see org.apache.fop.render.Renderer#setUserAgent(FOUserAgent)
*/
public void setUserAgent(FOUserAgent agent) {
diff --git a/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
new file mode 100644
index 000000000..c7b5a025b
--- /dev/null
+++ b/src/java/org/apache/fop/render/ps/PSRendererConfigurator.java
@@ -0,0 +1,56 @@
+/*
+ * 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.ps;
+
+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;
+import org.apache.fop.render.Renderer;
+
+/**
+ * Postscript renderer config
+ */
+public class PSRendererConfigurator extends PrintRendererConfigurator {
+
+ /**
+ * Default constructor
+ * @param userAgent user agent
+ */
+ public PSRendererConfigurator(FOUserAgent userAgent) {
+ super(userAgent);
+ }
+
+ /**
+ * Configure the PS renderer.
+ * @param renderer postscript renderer
+ * @throws FOPException fop exception
+ */
+ public void configure(Renderer renderer) throws FOPException {
+ Configuration cfg = super.getRendererConfig(renderer);
+ if (cfg != null) {
+ super.configure(renderer);
+
+ PSRenderer psRenderer = (PSRenderer)renderer;
+ psRenderer.setAutoRotateLandscape(
+ cfg.getChild("auto-rotate-landscape").getValueAsBoolean(false));
+ }
+ }
+}
diff --git a/src/java/org/apache/fop/render/ps/PSRendererMaker.java b/src/java/org/apache/fop/render/ps/PSRendererMaker.java
index 45f7663aa..0db4281d0 100644
--- a/src/java/org/apache/fop/render/ps/PSRendererMaker.java
+++ b/src/java/org/apache/fop/render/ps/PSRendererMaker.java
@@ -23,6 +23,7 @@ import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.MimeConstants;
import org.apache.fop.render.AbstractRendererMaker;
import org.apache.fop.render.Renderer;
+import org.apache.fop.render.RendererConfigurator;
/**
* RendererMaker for the PostScript Renderer.
@@ -31,12 +32,16 @@ public class PSRendererMaker extends AbstractRendererMaker {
private static final String[] MIMES = new String[] {MimeConstants.MIME_POSTSCRIPT};
-
- /** @see org.apache.fop.render.AbstractRendererMaker */
- public Renderer makeRenderer(FOUserAgent ua) {
+ /** @see org.apache.fop.render.AbstractRendererMaker#makeRenderer(FOUserAgent) */
+ public Renderer makeRenderer(FOUserAgent userAgent) {
return new PSRenderer();
}
+ /** @see org.apache.fop.render.AbstractRendererMaker#getConfigurator(FOUserAgent) */
+ public RendererConfigurator getConfigurator(FOUserAgent userAgent) {
+ return new PSRendererConfigurator(userAgent);
+ }
+
/** @see org.apache.fop.render.AbstractRendererMaker#needsOutputStream() */
public boolean needsOutputStream() {
return true;
@@ -46,5 +51,4 @@ public class PSRendererMaker extends AbstractRendererMaker {
public String[] getSupportedMimeTypes() {
return MIMES;
}
-
}
diff --git a/src/java/org/apache/fop/render/ps/PSTextPainter.java b/src/java/org/apache/fop/render/ps/PSTextPainter.java
index 78efd56b9..f4796fd2b 100644
--- a/src/java/org/apache/fop/render/ps/PSTextPainter.java
+++ b/src/java/org/apache/fop/render/ps/PSTextPainter.java
@@ -367,8 +367,8 @@ public class PSTextPainter implements TextPainter {
private int getWeight(AttributedCharacterIterator aci) {
Float taWeight = (Float)aci.getAttribute(TextAttribute.WEIGHT);
return ((taWeight != null) && (taWeight.floatValue() > 1.0))
- ? Font.BOLD
- : Font.NORMAL;
+ ? Font.WEIGHT_BOLD
+ : Font.WEIGHT_NORMAL;
}
private Font makeFont(AttributedCharacterIterator aci) {
@@ -402,7 +402,7 @@ public class PSTextPainter implements TextPainter {
}
}
}
- FontTriplet triplet = fontInfo.fontLookup("any", style, Font.NORMAL);
+ FontTriplet triplet = fontInfo.fontLookup("any", style, Font.WEIGHT_NORMAL);
int fsize = (int)(fontSize.floatValue() * 1000);
return fontInfo.getFontInstance(triplet, fsize);
}
@@ -411,7 +411,7 @@ public class PSTextPainter implements TextPainter {
final String style = getStyle(aci);
final int weight = getWeight(aci);
int fStyle = java.awt.Font.PLAIN;
- if (weight == Font.BOLD) {
+ if (weight == Font.WEIGHT_BOLD) {
fStyle |= java.awt.Font.BOLD;
}
if ("italic".equals(style)) {