KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > fonts > truetype > TTFDirTabEntry


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
18 /* $Id: TTFDirTabEntry.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.fonts.truetype;
21
22 import java.io.IOException JavaDoc;
23 import java.io.UnsupportedEncodingException JavaDoc;
24
25
26 /**
27  * This class represents an entry to a TrueType font's Dir Tab.
28  */

29 class TTFDirTabEntry {
30
31     private byte[] tag = new byte[4];
32     private int checksum;
33     private long offset;
34     private long length;
35
36     /**
37      * Read Dir Tab, return tag name
38      */

39     public String JavaDoc read(FontFileReader in) throws IOException JavaDoc {
40         tag[0] = in.readTTFByte();
41         tag[1] = in.readTTFByte();
42         tag[2] = in.readTTFByte();
43         tag[3] = in.readTTFByte();
44
45         in.skip(4); // Skip checksum
46

47         offset = in.readTTFULong();
48         length = in.readTTFULong();
49         String JavaDoc tagStr = new String JavaDoc(tag, "ISO-8859-1");
50
51         return tagStr;
52     }
53
54
55     public String JavaDoc toString() {
56         return "Read dir tab ["
57             + tag[0] + " " + tag[1] + " " + tag[2] + " " + tag[3] + "]"
58             + " offset: " + offset
59             + " length: " + length
60             + " name: " + tag;
61     }
62
63     /**
64      * Returns the checksum.
65      * @return int
66      */

67     public int getChecksum() {
68         return checksum;
69     }
70
71     /**
72      * Returns the length.
73      * @return long
74      */

75     public long getLength() {
76         return length;
77     }
78
79     /**
80      * Returns the offset.
81      * @return long
82      */

83     public long getOffset() {
84         return offset;
85     }
86
87     /**
88      * Returns the tag bytes.
89      * @return byte[]
90      */

91     public byte[] getTag() {
92         return tag;
93     }
94
95     /**
96      * Returns the tag bytes.
97      * @return byte[]
98      */

99     public String JavaDoc getTagString() {
100         try {
101             return new String JavaDoc(tag, "ISO-8859-1");
102         } catch (UnsupportedEncodingException JavaDoc e) {
103             return this.toString(); // Should never happen.
104
}
105     }
106
107 }
108
Popular Tags