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.

FOPProcSet.java 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.ps;
  19. import java.io.IOException;
  20. import org.apache.xmlgraphics.ps.DSCConstants;
  21. import org.apache.xmlgraphics.ps.PSGenerator;
  22. import org.apache.xmlgraphics.ps.PSProcSet;
  23. /**
  24. * Proc Set with FOP-specific procs.
  25. */
  26. public final class FOPProcSet extends PSProcSet {
  27. /** Singleton instance of the FOP procset */
  28. public static final FOPProcSet INSTANCE = new FOPProcSet();
  29. private FOPProcSet() {
  30. super("Apache FOP Std ProcSet", 1.0f, 0);
  31. }
  32. /**
  33. * Writes the procset to the PostScript file.
  34. * @param gen the PS generator
  35. * @throws IOException if an I/O error occurs
  36. */
  37. public void writeTo(PSGenerator gen) throws IOException {
  38. gen.writeDSCComment(DSCConstants.BEGIN_RESOURCE,
  39. new Object[] {TYPE_PROCSET, getName(),
  40. Float.toString(getVersion()), Integer.toString(getRevision())});
  41. gen.writeDSCComment(DSCConstants.VERSION,
  42. new Object[] {Float.toString(getVersion()), Integer.toString(getRevision())});
  43. gen.writeDSCComment(DSCConstants.COPYRIGHT, "Copyright 2009 "
  44. + "The Apache Software Foundation. "
  45. + "License terms: http://www.apache.org/licenses/LICENSE-2.0");
  46. gen.writeDSCComment(DSCConstants.TITLE,
  47. "Basic set of procedures used by Apache FOP");
  48. gen.writeln("/TJ { % Similar but not equal to PDF's TJ operator");
  49. gen.writeln(" {");
  50. gen.writeln(" dup type /stringtype eq");
  51. gen.writeln(" { show }"); //normal text show
  52. gen.writeln(" {");
  53. gen.writeln(" dup type /arraytype eq");
  54. gen.writeln(" { aload pop neg 1000 div exch 1000 div rmoveto }");
  55. gen.writeln(" { neg 1000 div 0 rmoveto }");
  56. gen.writeln(" ifelse");
  57. gen.writeln(" }");
  58. gen.writeln(" ifelse");
  59. gen.writeln(" } forall");
  60. gen.writeln("} bd");
  61. gen.writeln("/ATJ { % As TJ but adds letter-spacing");
  62. gen.writeln(" /ATJls exch def");
  63. gen.writeln(" {");
  64. gen.writeln(" dup type /stringtype eq");
  65. gen.writeln(" { ATJls 0 3 2 roll ashow }"); //normal text show
  66. gen.writeln(" { neg 1000 div 0 rmoveto }"); //negative X movement
  67. gen.writeln(" ifelse");
  68. gen.writeln(" } forall");
  69. gen.writeln("} bd");
  70. gen.writeDSCComment(DSCConstants.END_RESOURCE);
  71. gen.getResourceTracker().registerSuppliedResource(this);
  72. }
  73. }