1 51 package org.apache.fop.fonts.type1; 52 53 import java.io.IOException ; 54 import java.io.InputStream ; 55 import java.io.InputStreamReader ; 56 import java.io.DataInputStream ; 57 58 62 public class PFMInputStream extends java.io.FilterInputStream { 63 64 DataInputStream inStream; 65 66 71 public PFMInputStream(InputStream in) { 72 super(in); 73 inStream = new DataInputStream (in); 74 } 75 76 81 public short readByte() throws IOException { 82 short s = inStream.readByte(); 83 int s1 = (((s & 0xF0) >>> 4) << 4) + (s & 0x0F); 85 return (short)s1; 86 } 87 88 93 public int readShort() throws IOException { 94 int i = inStream.readShort(); 95 96 int high = (i & 0xFF00) >>> 8; 98 int low = (i & 0x00FF) << 8; 99 return low + high; 100 } 101 102 107 public long readInt() throws IOException { 108 int i = inStream.readInt(); 109 110 int i1 = (i & 0xFF000000) >>> 24; 112 int i2 = (i & 0x00FF0000) >>> 8; 113 int i3 = (i & 0x0000FF00) << 8; 114 int i4 = (i & 0x000000FF) << 24; 115 return i1 + i2 + i3 + i4; 116 } 117 118 123 public String readString() throws IOException { 124 InputStreamReader reader = new InputStreamReader (in, "ISO-8859-1"); 125 StringBuffer buf = new StringBuffer (); 126 int ch = reader.read(); 127 while (ch != 0) { 128 buf.append((char)ch); 129 ch = reader.read(); 130 } 131 return buf.toString(); 132 } 133 134 } 135 | Popular Tags |