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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* $Id$ */
  17. package org.apache.fop.pdf;
  18. import org.apache.fop.fonts.FontType;
  19. /**
  20. * Class representing a Type3 font.
  21. * <p>
  22. * <b>CAUTION: this is not yet fully implemented!!!!!!!</b>
  23. * the /CharProcs is still missing its <code>toPDF()</code> method.
  24. * <p>
  25. * Type3 fonts are specified on page 206 and onwards of the PDF 1.3 spec.
  26. */
  27. public class PDFFontType3 extends PDFFontNonBase14 {
  28. /**
  29. * font's required /FontBBox bounding box
  30. */
  31. protected PDFRectangle fontBBox;
  32. /**
  33. * font's required /FontMatrix array
  34. */
  35. protected PDFArray fontMatrix;
  36. /**
  37. * font's required /CharProcs dictionary
  38. */
  39. protected PDFCharProcs charProcs;
  40. /**
  41. * font's optional /Resources object
  42. */
  43. protected PDFResources resources;
  44. /**
  45. * Create the /Font object
  46. *
  47. * @param fontname the internal name for the font
  48. * @param basefont the base font name
  49. * @param encoding the character encoding schema used by the font
  50. */
  51. public PDFFontType3(String fontname,
  52. String basefont,
  53. Object encoding) {
  54. /* generic creation of PDF object */
  55. super(fontname, FontType.TYPE3, basefont, encoding /* , mapping */);
  56. this.fontBBox = null;
  57. this.fontMatrix = null;
  58. this.charProcs = null;
  59. }
  60. /**
  61. * Create the /Font object
  62. *
  63. * @param fontname the internal name for the font
  64. * @param basefont the base font name
  65. * @param encoding the character encoding schema used by the font
  66. * @param fontBBox the font's bounding box
  67. * @param fontMatrix the font's transformation matrix
  68. * @param charProcs the glyphs' definitions
  69. */
  70. public PDFFontType3(String fontname,
  71. String basefont,
  72. Object encoding,
  73. PDFRectangle fontBBox, PDFArray fontMatrix,
  74. PDFCharProcs charProcs) {
  75. /* generic creation of PDF object */
  76. super(fontname, FontType.TYPE3, basefont, encoding /* , mapping */);
  77. this.fontBBox = fontBBox;
  78. this.fontMatrix = fontMatrix;
  79. this.charProcs = charProcs;
  80. }
  81. /**
  82. * Set the font's bounding box
  83. *
  84. * @param bbox bounding box for the font
  85. */
  86. public void setFontBBox(PDFRectangle bbox) {
  87. this.fontBBox = bbox;
  88. }
  89. /**
  90. * Set the font's transformation matrix
  91. *
  92. * @param matrix the transformation matrix for the font
  93. */
  94. public void setFontMatrix(PDFArray matrix) {
  95. this.fontMatrix = matrix;
  96. }
  97. /**
  98. * Set the glyphs' definitions.
  99. * <p>
  100. * The /CharProcs object needs to be registered in the document's resources.
  101. *
  102. * @param chars the glyphs' dictionary
  103. */
  104. public void setCharProcs(PDFCharProcs chars) {
  105. this.charProcs = chars;
  106. }
  107. /**
  108. * @see org.apache.fop.pdf.PDFFont#fillInPDF(StringBuffer)
  109. */
  110. protected void fillInPDF(StringBuffer target) {
  111. if (fontBBox != null) {
  112. target.append("\n/FontBBox ");
  113. target.append(fontBBox.toPDF());
  114. }
  115. if (fontMatrix != null) {
  116. target.append("\n/FontMatrix ");
  117. target.append(fontMatrix.toPDF());
  118. }
  119. if (charProcs != null) {
  120. target.append("\n/CharProcs ");
  121. target.append(charProcs.referencePDF());
  122. }
  123. }
  124. }