diff options
Diffstat (limited to 'src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java')
-rw-r--r-- | src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java | 104 |
1 files changed, 31 insertions, 73 deletions
diff --git a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java index bc4cdc567..d103b4796 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java +++ b/src/java/org/apache/fop/render/pcl/PCLRendererConfigurator.java @@ -21,19 +21,13 @@ package org.apache.fop.render.pcl; import java.util.List; -import org.apache.avalon.framework.configuration.Configuration; - import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; +import org.apache.fop.apps.io.InternalResourceResolver; +import org.apache.fop.fonts.EmbedFontInfo; import org.apache.fop.fonts.FontCollection; -import org.apache.fop.fonts.FontEventAdapter; -import org.apache.fop.fonts.FontEventListener; -import org.apache.fop.fonts.FontInfo; -import org.apache.fop.fonts.FontManager; -import org.apache.fop.fonts.FontResolver; -import org.apache.fop.render.DefaultFontResolver; import org.apache.fop.render.PrintRendererConfigurator; -import org.apache.fop.render.Renderer; +import org.apache.fop.render.RendererConfig.RendererConfigParser; import org.apache.fop.render.intermediate.IFDocumentHandler; import org.apache.fop.render.intermediate.IFDocumentHandlerConfigurator; import org.apache.fop.render.java2d.Base14FontCollection; @@ -45,88 +39,52 @@ import org.apache.fop.render.java2d.Java2DFontMetrics; * PCL Renderer configurator */ public class PCLRendererConfigurator extends PrintRendererConfigurator - implements IFDocumentHandlerConfigurator { + implements IFDocumentHandlerConfigurator { /** * Default constructor * @param userAgent user agent */ - public PCLRendererConfigurator(FOUserAgent userAgent) { - super(userAgent); - } - - /** - * Throws an UnsupportedOperationException. - * - * @param renderer not used - */ - public void configure(Renderer renderer) { - throw new UnsupportedOperationException(); - } - - private void configure(Configuration cfg, PCLRenderingUtil pclUtil) throws FOPException { - String rendering = cfg.getChild("rendering").getValue(null); - if (rendering != null) { - try { - pclUtil.setRenderingMode(PCLRenderingMode.valueOf(rendering)); - } catch (IllegalArgumentException e) { - throw new FOPException( - "Valid values for 'rendering' are 'quality', 'speed' and 'bitmap'." - + " Value found: " + rendering); - } - } - - String textRendering = cfg.getChild("text-rendering").getValue(null); - if ("bitmap".equalsIgnoreCase(textRendering)) { - pclUtil.setAllTextAsBitmaps(true); - } else if ("auto".equalsIgnoreCase(textRendering)) { - pclUtil.setAllTextAsBitmaps(false); - } else if (textRendering != null) { - throw new FOPException( - "Valid values for 'text-rendering' are 'auto' and 'bitmap'. Value found: " - + textRendering); - } - - pclUtil.setPJLDisabled(cfg.getChild("disable-pjl").getValueAsBoolean(false)); + public PCLRendererConfigurator(FOUserAgent userAgent, RendererConfigParser rendererConfigParser) { + super(userAgent, rendererConfigParser); } - // ---=== IFDocumentHandler configuration ===--- - /** {@inheritDoc} */ public void configure(IFDocumentHandler documentHandler) throws FOPException { - Configuration cfg = super.getRendererConfig(documentHandler.getMimeType()); - if (cfg != null) { - PCLDocumentHandler pclDocumentHandler = (PCLDocumentHandler)documentHandler; + PCLRendererConfig pdfConfig = (PCLRendererConfig) getRendererConfig(documentHandler); + if (pdfConfig != null) { + PCLDocumentHandler pclDocumentHandler = (PCLDocumentHandler) documentHandler; PCLRenderingUtil pclUtil = pclDocumentHandler.getPCLUtil(); - configure(cfg, pclUtil); + configure(pdfConfig, pclUtil); } } - /** {@inheritDoc} */ - public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo) - throws FOPException { - FontManager fontManager = userAgent.getFactory().getFontManager(); + private void configure(PCLRendererConfig config, PCLRenderingUtil pclUtil) throws FOPException { + if (config.getRenderingMode() != null) { + pclUtil.setRenderingMode(config.getRenderingMode()); + } + if (config.isDisablePjl() != null) { + pclUtil.setPJLDisabled(config.isDisablePjl()); + } + if (config.isTextRendering() != null) { + pclUtil.setAllTextAsBitmaps(config.isTextRendering()); + } + } + @Override + protected List<FontCollection> getDefaultFontCollection() { + final List<FontCollection> fontCollections = new java.util.ArrayList<FontCollection>(); final Java2DFontMetrics java2DFontMetrics = new Java2DFontMetrics(); - final List fontCollections = new java.util.ArrayList(); fontCollections.add(new Base14FontCollection(java2DFontMetrics)); fontCollections.add(new InstalledFontCollection(java2DFontMetrics)); - - Configuration cfg = super.getRendererConfig(documentHandler.getMimeType()); - if (cfg != null) { - FontResolver fontResolver = new DefaultFontResolver(userAgent); - FontEventListener listener = new FontEventAdapter( - userAgent.getEventBroadcaster()); - List fontList = buildFontList(cfg, fontResolver, listener); - fontCollections.add(new ConfiguredFontCollection(fontResolver, fontList, - userAgent.isComplexScriptFeaturesEnabled())); - } - - fontManager.setup(fontInfo, - (FontCollection[])fontCollections.toArray( - new FontCollection[fontCollections.size()])); - documentHandler.setFontInfo(fontInfo); + return fontCollections; } + @Override + protected FontCollection createCollectionFromFontList(InternalResourceResolver resourceResolver, + List<EmbedFontInfo> fontList) { + return new ConfiguredFontCollection(resourceResolver, fontList, + userAgent.isComplexScriptFeaturesEnabled()); + } } |