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.

PDFCIDSystemInfo.java 2.8KB

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.pdf;
  19. import java.io.ByteArrayOutputStream;
  20. import java.io.IOException;
  21. // based on work by Takayuki Takeuchi
  22. /**
  23. * class representing system information for "character identifier" fonts.
  24. *
  25. * this small object is used in the CID fonts and in the CMaps.
  26. */
  27. public class PDFCIDSystemInfo extends PDFObject {
  28. private String registry;
  29. private String ordering;
  30. private int supplement;
  31. /**
  32. * Create a CID system info.
  33. *
  34. * @param registry the registry value
  35. * @param ordering the ordering value
  36. * @param supplement the supplement value
  37. */
  38. public PDFCIDSystemInfo(String registry, String ordering,
  39. int supplement) {
  40. this.registry = registry;
  41. this.ordering = ordering;
  42. this.supplement = supplement;
  43. }
  44. /**
  45. * Create a string for the CIDSystemInfo dictionary.
  46. * The entries are placed as an inline dictionary.
  47. *
  48. * @return the string for the CIDSystemInfo entry with the inline dictionary
  49. */
  50. public String toPDFString() {
  51. StringBuffer p = new StringBuffer(64);
  52. p.setLength(0);
  53. p.append("/CIDSystemInfo << /Registry (");
  54. p.append(registry);
  55. p.append(") /Ordering (");
  56. p.append(ordering);
  57. p.append(") /Supplement ");
  58. p.append(supplement);
  59. p.append(" >>");
  60. return p.toString();
  61. }
  62. /**
  63. * {@inheritDoc}
  64. */
  65. public byte[] toPDF() {
  66. ByteArrayOutputStream bout = new ByteArrayOutputStream(128);
  67. try {
  68. bout.write(encode("<< /Registry "));
  69. bout.write(encodeText(registry));
  70. bout.write(encode(" /Ordering "));
  71. bout.write(encodeText(ordering));
  72. bout.write(encode(" /Supplement "));
  73. bout.write(encode(Integer.toString(supplement)));
  74. bout.write(encode(" >>"));
  75. } catch (IOException ioe) {
  76. log.error("Ignored I/O exception", ioe);
  77. }
  78. return bout.toByteArray();
  79. }
  80. }