You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PCLRendererConfigurator.java 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.render.pcl;
  19. import java.util.List;
  20. import org.apache.fop.apps.FOPException;
  21. import org.apache.fop.apps.FOUserAgent;
  22. import org.apache.fop.apps.io.InternalResourceResolver;
  23. import org.apache.fop.fonts.EmbedFontInfo;
  24. import org.apache.fop.fonts.FontCollection;
  25. import org.apache.fop.render.PrintRendererConfigurator;
  26. import org.apache.fop.render.RendererConfig.RendererConfigParser;
  27. import org.apache.fop.render.intermediate.IFDocumentHandler;
  28. import org.apache.fop.render.java2d.Base14FontCollection;
  29. import org.apache.fop.render.java2d.ConfiguredFontCollection;
  30. import org.apache.fop.render.java2d.InstalledFontCollection;
  31. import org.apache.fop.render.java2d.Java2DFontMetrics;
  32. /**
  33. * PCL Renderer configurator
  34. */
  35. public class PCLRendererConfigurator extends PrintRendererConfigurator {
  36. /**
  37. * Default constructor
  38. * @param userAgent user agent
  39. */
  40. public PCLRendererConfigurator(FOUserAgent userAgent, RendererConfigParser rendererConfigParser) {
  41. super(userAgent, rendererConfigParser);
  42. }
  43. /** {@inheritDoc} */
  44. public void configure(IFDocumentHandler documentHandler) throws FOPException {
  45. PCLRendererConfig pdfConfig = (PCLRendererConfig) getRendererConfig(documentHandler);
  46. if (pdfConfig != null) {
  47. PCLDocumentHandler pclDocumentHandler = (PCLDocumentHandler) documentHandler;
  48. PCLRenderingUtil pclUtil = pclDocumentHandler.getPCLUtil();
  49. configure(pdfConfig, pclUtil);
  50. }
  51. }
  52. private void configure(PCLRendererConfig config, PCLRenderingUtil pclUtil) throws FOPException {
  53. if (config.getRenderingMode() != null) {
  54. pclUtil.setRenderingMode(config.getRenderingMode());
  55. }
  56. if (config.isDisablePjl() != null) {
  57. pclUtil.setPJLDisabled(config.isDisablePjl());
  58. }
  59. if (config.isTextRendering() != null) {
  60. pclUtil.setAllTextAsBitmaps(config.isTextRendering());
  61. }
  62. if (config.isColorEnabled() != null) {
  63. pclUtil.setColorEnabled(config.isColorEnabled());
  64. }
  65. }
  66. @Override
  67. protected List<FontCollection> getDefaultFontCollection() {
  68. final List<FontCollection> fontCollections = new java.util.ArrayList<FontCollection>();
  69. final Java2DFontMetrics java2DFontMetrics = new Java2DFontMetrics();
  70. fontCollections.add(new Base14FontCollection(java2DFontMetrics));
  71. fontCollections.add(new InstalledFontCollection(java2DFontMetrics));
  72. return fontCollections;
  73. }
  74. @Override
  75. protected FontCollection createCollectionFromFontList(InternalResourceResolver resourceResolver,
  76. List<EmbedFontInfo> fontList) {
  77. return new ConfiguredFontCollection(resourceResolver, fontList,
  78. userAgent.isComplexScriptFeaturesEnabled());
  79. }
  80. }