001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.svggen.font.table;
020:
021: import java.io.IOException;
022: import java.io.RandomAccessFile;
023:
024: /**
025: *
026: * @author <a href="mailto:david@steadystate.co.uk">David Schweinsberg</a>
027: * @version $Id: PostTable.java 475685 2006-11-16 11:16:05Z cam $
028: */
029: public class PostTable implements Table {
030:
031: /**
032: * TODO: Mac Glyph names for 210 & 257
033: */
034: private static final String[] macGlyphName = { ".notdef", // 0
035: "null", // 1
036: "CR", // 2
037: "space", // 3
038: "exclam", // 4
039: "quotedbl", // 5
040: "numbersign", // 6
041: "dollar", // 7
042: "percent", // 8
043: "ampersand", // 9
044: "quotesingle", // 10
045: "parenleft", // 11
046: "parenright", // 12
047: "asterisk", // 13
048: "plus", // 14
049: "comma", // 15
050: "hyphen", // 16
051: "period", // 17
052: "slash", // 18
053: "zero", // 19
054: "one", // 20
055: "two", // 21
056: "three", // 22
057: "four", // 23
058: "five", // 24
059: "six", // 25
060: "seven", // 26
061: "eight", // 27
062: "nine", // 28
063: "colon", // 29
064: "semicolon", // 30
065: "less", // 31
066: "equal", // 32
067: "greater", // 33
068: "question", // 34
069: "at", // 35
070: "A", // 36
071: "B", // 37
072: "C", // 38
073: "D", // 39
074: "E", // 40
075: "F", // 41
076: "G", // 42
077: "H", // 43
078: "I", // 44
079: "J", // 45
080: "K", // 46
081: "L", // 47
082: "M", // 48
083: "N", // 49
084: "O", // 50
085: "P", // 51
086: "Q", // 52
087: "R", // 53
088: "S", // 54
089: "T", // 55
090: "U", // 56
091: "V", // 57
092: "W", // 58
093: "X", // 59
094: "Y", // 60
095: "Z", // 61
096: "bracketleft", // 62
097: "backslash", // 63
098: "bracketright", // 64
099: "asciicircum", // 65
100: "underscore", // 66
101: "grave", // 67
102: "a", // 68
103: "b", // 69
104: "c", // 70
105: "d", // 71
106: "e", // 72
107: "f", // 73
108: "g", // 74
109: "h", // 75
110: "i", // 76
111: "j", // 77
112: "k", // 78
113: "l", // 79
114: "m", // 80
115: "n", // 81
116: "o", // 82
117: "p", // 83
118: "q", // 84
119: "r", // 85
120: "s", // 86
121: "t", // 87
122: "u", // 88
123: "v", // 89
124: "w", // 90
125: "x", // 91
126: "y", // 92
127: "z", // 93
128: "braceleft", // 94
129: "bar", // 95
130: "braceright", // 96
131: "asciitilde", // 97
132: "Adieresis", // 98
133: "Aring", // 99
134: "Ccedilla", // 100
135: "Eacute", // 101
136: "Ntilde", // 102
137: "Odieresis", // 103
138: "Udieresis", // 104
139: "aacute", // 105
140: "agrave", // 106
141: "acircumflex", // 107
142: "adieresis", // 108
143: "atilde", // 109
144: "aring", // 110
145: "ccedilla", // 111
146: "eacute", // 112
147: "egrave", // 113
148: "ecircumflex", // 114
149: "edieresis", // 115
150: "iacute", // 116
151: "igrave", // 117
152: "icircumflex", // 118
153: "idieresis", // 119
154: "ntilde", // 120
155: "oacute", // 121
156: "ograve", // 122
157: "ocircumflex", // 123
158: "odieresis", // 124
159: "otilde", // 125
160: "uacute", // 126
161: "ugrave", // 127
162: "ucircumflex", // 128
163: "udieresis", // 129
164: "dagger", // 130
165: "degree", // 131
166: "cent", // 132
167: "sterling", // 133
168: "section", // 134
169: "bullet", // 135
170: "paragraph", // 136
171: "germandbls", // 137
172: "registered", // 138
173: "copyright", // 139
174: "trademark", // 140
175: "acute", // 141
176: "dieresis", // 142
177: "notequal", // 143
178: "AE", // 144
179: "Oslash", // 145
180: "infinity", // 146
181: "plusminus", // 147
182: "lessequal", // 148
183: "greaterequal", // 149
184: "yen", // 150
185: "mu", // 151
186: "partialdiff", // 152
187: "summation", // 153
188: "product", // 154
189: "pi", // 155
190: "integral'", // 156
191: "ordfeminine", // 157
192: "ordmasculine", // 158
193: "Omega", // 159
194: "ae", // 160
195: "oslash", // 161
196: "questiondown", // 162
197: "exclamdown", // 163
198: "logicalnot", // 164
199: "radical", // 165
200: "florin", // 166
201: "approxequal", // 167
202: "increment", // 168
203: "guillemotleft",// 169
204: "guillemotright",//170
205: "ellipsis", // 171
206: "nbspace", // 172
207: "Agrave", // 173
208: "Atilde", // 174
209: "Otilde", // 175
210: "OE", // 176
211: "oe", // 177
212: "endash", // 178
213: "emdash", // 179
214: "quotedblleft", // 180
215: "quotedblright",// 181
216: "quoteleft", // 182
217: "quoteright", // 183
218: "divide", // 184
219: "lozenge", // 185
220: "ydieresis", // 186
221: "Ydieresis", // 187
222: "fraction", // 188
223: "currency", // 189
224: "guilsinglleft",// 190
225: "guilsinglright",//191
226: "fi", // 192
227: "fl", // 193
228: "daggerdbl", // 194
229: "middot", // 195
230: "quotesinglbase",//196
231: "quotedblbase", // 197
232: "perthousand", // 198
233: "Acircumflex", // 199
234: "Ecircumflex", // 200
235: "Aacute", // 201
236: "Edieresis", // 202
237: "Egrave", // 203
238: "Iacute", // 204
239: "Icircumflex", // 205
240: "Idieresis", // 206
241: "Igrave", // 207
242: "Oacute", // 208
243: "Ocircumflex", // 209
244: "", // 210
245: "Ograve", // 211
246: "Uacute", // 212
247: "Ucircumflex", // 213
248: "Ugrave", // 214
249: "dotlessi", // 215
250: "circumflex", // 216
251: "tilde", // 217
252: "overscore", // 218
253: "breve", // 219
254: "dotaccent", // 220
255: "ring", // 221
256: "cedilla", // 222
257: "hungarumlaut", // 223
258: "ogonek", // 224
259: "caron", // 225
260: "Lslash", // 226
261: "lslash", // 227
262: "Scaron", // 228
263: "scaron", // 229
264: "Zcaron", // 230
265: "zcaron", // 231
266: "brokenbar", // 232
267: "Eth", // 233
268: "eth", // 234
269: "Yacute", // 235
270: "yacute", // 236
271: "Thorn", // 237
272: "thorn", // 238
273: "minus", // 239
274: "multiply", // 240
275: "onesuperior", // 241
276: "twosuperior", // 242
277: "threesuperior",// 243
278: "onehalf", // 244
279: "onequarter", // 245
280: "threequarters",// 246
281: "franc", // 247
282: "Gbreve", // 248
283: "gbreve", // 249
284: "Idot", // 250
285: "Scedilla", // 251
286: "scedilla", // 252
287: "Cacute", // 253
288: "cacute", // 254
289: "Ccaron", // 255
290: "ccaron", // 256
291: "" // 257
292: };
293:
294: private int version;
295: private int italicAngle;
296: private short underlinePosition;
297: private short underlineThickness;
298: private int isFixedPitch;
299: private int minMemType42;
300: private int maxMemType42;
301: private int minMemType1;
302: private int maxMemType1;
303:
304: // v2
305: private int numGlyphs;
306: private int[] glyphNameIndex;
307: private String[] psGlyphName;
308:
309: /** Creates new PostTable */
310: protected PostTable(DirectoryEntry de, RandomAccessFile raf)
311: throws IOException {
312: raf.seek(de.getOffset());
313: version = raf.readInt();
314: italicAngle = raf.readInt();
315: underlinePosition = raf.readShort();
316: underlineThickness = raf.readShort();
317: isFixedPitch = raf.readInt();
318: minMemType42 = raf.readInt();
319: maxMemType42 = raf.readInt();
320: minMemType1 = raf.readInt();
321: maxMemType1 = raf.readInt();
322:
323: if (version == 0x00020000) {
324: numGlyphs = raf.readUnsignedShort();
325: glyphNameIndex = new int[numGlyphs];
326: for (int i = 0; i < numGlyphs; i++) {
327: glyphNameIndex[i] = raf.readUnsignedShort();
328: }
329: int h = highestGlyphNameIndex();
330: if (h > 257) {
331: h -= 257;
332: psGlyphName = new String[h];
333: for (int i = 0; i < h; i++) {
334: int len = raf.readUnsignedByte();
335: byte[] buf = new byte[len];
336: raf.readFully(buf);
337: psGlyphName[i] = new String(buf);
338: }
339: }
340: } else if (version == 0x00020005) {
341: }
342: }
343:
344: private int highestGlyphNameIndex() {
345: int high = 0;
346: for (int i = 0; i < numGlyphs; i++) {
347: if (high < glyphNameIndex[i]) {
348: high = glyphNameIndex[i];
349: }
350: }
351: return high;
352: }
353:
354: public String getGlyphName(int i) {
355: if (version == 0x00020000) {
356: return (glyphNameIndex[i] > 257) ? psGlyphName[glyphNameIndex[i] - 258]
357: : macGlyphName[glyphNameIndex[i]];
358: } else {
359: return null;
360: }
361: }
362:
363: /** Get the table type, as a table directory value.
364: * @return The table type
365: */
366: public int getType() {
367: return post;
368: }
369:
370: }
|