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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.intermediate.IFDocumentHandlerConfigurator;
  29. import org.apache.fop.render.java2d.Base14FontCollection;
  30. import org.apache.fop.render.java2d.ConfiguredFontCollection;
  31. import org.apache.fop.render.java2d.InstalledFontCollection;
  32. import org.apache.fop.render.java2d.Java2DFontMetrics;
  33. /**
  34. * PCL Renderer configurator
  35. */
  36. public class PCLRendererConfigurator extends PrintRendererConfigurator
  37. implements IFDocumentHandlerConfigurator {
  38. /**
  39. * Default constructor
  40. * @param userAgent user agent
  41. */
  42. public PCLRendererConfigurator(FOUserAgent userAgent, RendererConfigParser rendererConfigParser) {
  43. super(userAgent, rendererConfigParser);
  44. }
  45. /** {@inheritDoc} */
  46. public void configure(IFDocumentHandler documentHandler) throws FOPException {
  47. PCLRendererConfig pdfConfig = (PCLRendererConfig) getRendererConfig(documentHandler);
  48. if (pdfConfig != null) {
  49. PCLDocumentHandler pclDocumentHandler = (PCLDocumentHandler) documentHandler;
  50. PCLRenderingUtil pclUtil = pclDocumentHandler.getPCLUtil();
  51. configure(pdfConfig, pclUtil);
  52. }
  53. }
  54. private void configure(PCLRendererConfig config, PCLRenderingUtil pclUtil) throws FOPException {
  55. if (config.getRenderingMode() != null) {
  56. pclUtil.setRenderingMode(config.getRenderingMode());
  57. }
  58. if (config.isDisablePjl() != null) {
  59. pclUtil.setPJLDisabled(config.isDisablePjl());
  60. }
  61. if (config.isTextRendering() != null) {
  62. pclUtil.setAllTextAsBitmaps(config.isTextRendering());
  63. }
  64. }
  65. @Override
  66. protected List<FontCollection> getDefaultFontCollection() {
  67. final List<FontCollection> fontCollections = new java.util.ArrayList<FontCollection>();
  68. final Java2DFontMetrics java2DFontMetrics = new Java2DFontMetrics();
  69. fontCollections.add(new Base14FontCollection(java2DFontMetrics));
  70. fontCollections.add(new InstalledFontCollection(java2DFontMetrics));
  71. return fontCollections;
  72. }
  73. @Override
  74. protected FontCollection createCollectionFromFontList(InternalResourceResolver resourceResolver,
  75. List<EmbedFontInfo> fontList) {
  76. return new ConfiguredFontCollection(resourceResolver, fontList,
  77. userAgent.isComplexScriptFeaturesEnabled());
  78. }
  79. }