1 51 package org.apache.fop.fonts.type1; 52 53 import java.io.OutputStream ; 54 import java.io.IOException ; 55 56 61 public class PFBData { 62 63 66 public static final int PFB_RAW = 0; 67 68 71 public static final int PFB_PC = 1; 72 73 76 public static final int PFB_MAC = 2; 77 78 private int pfbFormat; private byte[] headerSegment; 80 private byte[] encryptedSegment; 81 private byte[] trailerSegment; 82 83 84 88 public void setPFBFormat(int format) { 89 switch (format) { 90 case PFB_RAW: 91 case PFB_PC: 92 this.pfbFormat = format; 93 break; 94 case PFB_MAC: 95 throw new UnsupportedOperationException ("Mac format is not yet implemented"); 96 default: 97 throw new IllegalArgumentException ("Invalid value for PFB format: " + format); 98 } 99 } 100 101 102 106 public int getPFBFormat() { 107 return this.pfbFormat; 108 } 109 110 114 public void setHeaderSegment(byte[] headerSeg) { 115 this.headerSegment = headerSeg; 116 } 117 118 122 public void setEncryptedSegment(byte[] encryptedSeg) { 123 this.encryptedSegment = encryptedSeg; 124 } 125 126 130 public void setTrailerSegment(byte[] trailerSeg) { 131 this.trailerSegment = trailerSeg; 132 } 133 134 138 public int getLength() { 139 return getLength1() + getLength2() + getLength3(); 140 } 141 142 143 147 public int getLength1() { 148 return this.headerSegment.length; 149 } 150 151 152 156 public int getLength2() { 157 return this.encryptedSegment.length; 158 } 159 160 161 165 public int getLength3() { 166 return this.trailerSegment.length; 167 } 168 169 170 175 public void outputAllParts(OutputStream out) throws IOException { 176 out.write(this.headerSegment); 177 out.write(this.encryptedSegment); 178 out.write(this.trailerSegment); 179 } 180 181 182 185 public String toString() { 186 return "PFB: format=" + getPFBFormat() 187 + " len1=" + getLength1() 188 + " len2=" + getLength2() 189 + " len3=" + getLength3(); 190 } 191 192 } | Popular Tags |