1 18 package org.apache.batik.svggen.font.table; 19 20 import java.io.IOException ; 21 import java.io.RandomAccessFile ; 22 23 28 public class PostTable implements Table { 29 30 33 private static final String [] macGlyphName = { 34 ".notdef", "null", "CR", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "Adieresis", "Aring", "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex", "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling", "section", "bullet", "paragraph", "germandbls", "registered", "copyright", "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity", "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff", "summation", "product", "pi", "integral'", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot", "radical", "florin", "approxequal", "increment", "guillemotleft", "guillemotright", "ellipsis", "nbspace", "Agrave", "Atilde", "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright", "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis", "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl", "daggerdbl", "middot", "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex", "", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi", "circumflex", "tilde", "overscore", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron", "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn", "thorn", "minus", "multiply", "onesuperior", "twosuperior", "threesuperior", "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve", "Idot", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron", "" }; 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 private int numGlyphs; 306 private int[] glyphNameIndex; 307 private String [] psGlyphName; 308 309 310 protected PostTable(DirectoryEntry de, RandomAccessFile raf) throws IOException { 311 raf.seek(de.getOffset()); 312 version = raf.readInt(); 313 italicAngle = raf.readInt(); 314 underlinePosition = raf.readShort(); 315 underlineThickness = raf.readShort(); 316 isFixedPitch = raf.readInt(); 317 minMemType42 = raf.readInt(); 318 maxMemType42 = raf.readInt(); 319 minMemType1 = raf.readInt(); 320 maxMemType1 = raf.readInt(); 321 322 if (version == 0x00020000) { 323 numGlyphs = raf.readUnsignedShort(); 324 glyphNameIndex = new int[numGlyphs]; 325 for (int i = 0; i < numGlyphs; i++) { 326 glyphNameIndex[i] = raf.readUnsignedShort(); 327 } 328 int h = highestGlyphNameIndex(); 329 if (h > 257) { 330 h -= 257; 331 psGlyphName = new String [h]; 332 for (int i = 0; i < h; i++) { 333 int len = raf.readUnsignedByte(); 334 byte[] buf = new byte[len]; 335 raf.readFully(buf); 336 psGlyphName[i] = new String (buf); 337 } 338 } 339 } else if (version == 0x00020005) { 340 } 341 } 342 343 private int highestGlyphNameIndex() { 344 int high = 0; 345 for (int i = 0; i < numGlyphs; i++) { 346 if (high < glyphNameIndex[i]) { 347 high = glyphNameIndex[i]; 348 } 349 } 350 return high; 351 } 352 353 public String getGlyphName(int i) { 354 if (version == 0x00020000) { 355 return (glyphNameIndex[i] > 257) 356 ? psGlyphName[glyphNameIndex[i] - 258] 357 : macGlyphName[glyphNameIndex[i]]; 358 } else { 359 return null; 360 } 361 } 362 363 366 public int getType() { 367 return post; 368 } 369 370 } 371 | Popular Tags |