001: /*
002: * $Id: FontSupport.java,v 1.2 2007/12/20 18:33:32 rbair Exp $
003: *
004: * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005: * Santa Clara, California 95054, U.S.A. All rights reserved.
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this library; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
020: */
021:
022: package com.sun.pdfview.font;
023:
024: /**
025: * some constants and utility functions for font support.
026: * @author Mike Wessler
027: */
028: public class FontSupport {
029: /**
030: * names for glyphs in the standard Adobe order. This is the ordering
031: * of the glyphs in a font, not the mapping of character number to
032: * character.
033: */
034: public static final String stdNames[] = { ".notdef", "space",
035: "exclam", "quotedbl", "numbersign", "dollar", "percent",
036: "ampersand", "quoteright", "parenleft", "parenright",
037: "asterisk", "plus", "comma", "hyphen", "period", "slash",
038: "zero", "one", "two", "three", "four", "five", "six",
039: "seven", "eight", "nine", "colon", "semicolon", "less",
040: "equal", "greater", "question", "at", "A", "B", "C", "D",
041: "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
042: "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
043: "bracketleft", "backslash", "bracketright", "asciicircum",
044: "underscore", "quoteleft", "a", "b", "c", "d", "e", "f",
045: "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r",
046: "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar",
047: "braceright", "asciitilde", "exclamdown", "cent",
048: "sterling", "fraction", "yen", "florin", "section",
049: "currency", "quotesingle", "quotedblleft", "guillemotleft",
050: "guilsinglleft", "guilsinglright", "fi", "fl", "endash",
051: "dagger", "daggerdbl", "periodcentered", "paragraph",
052: "bullet", "quotesinglbase", "quotedblbase",
053: "quotedblright", "guillemotright", "ellipsis",
054: "perthousand", "questiondown", "grave", "acute",
055: "circumflex", "tilde", "macron", "breve", "dotaccent",
056: "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek",
057: "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash",
058: "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash",
059: "oe", "germandbls", "onesuperior", "logicalnot", "mu",
060: "trademark", "Eth", "onehalf", "plusminus", "Thorn",
061: "onequarter", "divide", "brokenbar", "degree", "thorn",
062: "threequarters", "twosuperior", "registered", "minus",
063: "eth", "multiply", "threesuperior", "copyright", "Aacute",
064: "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde",
065: "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave",
066: "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde",
067: "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde",
068: "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave",
069: "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex",
070: "adieresis", "agrave", "aring", "atilde", "ccedilla",
071: "eacute", "ecircumflex", "edieresis", "egrave", "iacute",
072: "icircumflex", "idieresis", "igrave", "ntilde", "oacute",
073: "ocircumflex", "odieresis", "ograve", "otilde", "scaron",
074: "uacute", "ucircumflex", "udieresis", "ugrave", "yacute",
075: "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall",
076: "dollaroldstyle", "dollarsuperior", "ampersandsmall",
077: "Acutesmall", "parenleftsuperior", "parenrightsuperior",
078: "twodotenleader", "onedotenleader", "zerooldstyle",
079: "oneoldstyle", "twooldstyle", "threeoldstyle",
080: "fouroldstyle", "fiveoldstyle", "sixoldstyle",
081: "sevenoldstyle", "eightoldstyle", "nineoldstyle",
082: "commasuperior", "threequartersemdash", "periodsuperior",
083: "questionsmall", "asuperior", "bsuperior", "centsuperior",
084: "dsuperior", "esuperior", "isuperior", "lsuperior",
085: "msuperior", "nsuperior", "osuperior", "rsuperior",
086: "ssuperior", "tsuperior", "ff", "ffi", "ffl",
087: "parenleftinferior", "parenrightinferior",
088: "Circumflexsmall", "hyphensuperior", "Gravesmall",
089: "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall",
090: "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall",
091: "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall",
092: "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall",
093: "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah",
094: "Tildesmall", "exclamdownsmall", "centoldstyle",
095: "Lslashsmall", "Scaronsmall", "Zcaronsmall",
096: "Dieresissmall", "Brevesmall", "Caronsmall",
097: "Dotaccentsmall", "Macronsmall", "figuredash",
098: "hypheninferior", "Ogoneksmall", "Ringsmall",
099: "Cedillasmall", "questiondownsmall", "oneeighth",
100: "threeeighths", "fiveeighths", "seveneighths", "onethird",
101: "twothirds", "zerosuperior", "foursuperior",
102: "fivesuperior", "sixsuperior", "sevensuperior",
103: "eightsuperior", "ninesuperior", "zeroinferior",
104: "oneinferior", "twoinferior", "threeinferior",
105: "fourinferior", "fiveinferior", "sixinferior",
106: "seveninferior", "eightinferior", "nineinferior",
107: "centinferior", "dollarinferior", "periodinferior",
108: "commainferior", "Agravesmall", "Aacutesmall",
109: "Acircumflexsmall", "Atildesmall", "Adieresissmall",
110: "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall",
111: "Eacutesmall", "Ecircumflexsmall", "Edieresissmall",
112: "Igravesmall", "Iacutesmall", "Icircumflexsmall",
113: "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall",
114: "Oacutesmall", "Ocircumflexsmall", "Otildesmall",
115: "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall",
116: "Uacutesmall", "Ucircumflexsmall", "Udieresissmall",
117: "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000",
118: "001.001", "001.002", "001.003", "Black", "Bold", "Book",
119: "Light", "Medium", "Regular", "Roman", "Semibold" };
120:
121: /**
122: * characters for glyphs in the standard order. These are string "values"
123: * to go with the names in stdNames. Not all glyphs have been translated
124: * to their unicode values. In many cases, the name of the glyph has
125: * been appended to an ASCII approximation of the glyph. Strings longer
126: * than 3 characters have this characteristic. To get the character,
127: * use the string if it contains 3 or fewer characters; otherwise,
128: * grab the first character off the string and use that.
129: */
130: static final String stdValues[] = { "", " ", "!", "\"", "#", "$",
131: "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0",
132: "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<",
133: "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H",
134: "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
135: "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_",
136: "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
137: "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
138: "x", "y", "z", "{", "|", "}", "~", "\u00a1", "\u00a2",
139: "\u00a3", "/fraction", "\u00a5", "Fflorin", "\u00a7",
140: "\u00a4", "\u00b4quotesingle", "\u201c", "?guillemotleft",
141: "\u2039", "\u203a", "fi", "fl", "--", "\u2020", "\u2021",
142: "\u00b7", "\u00b6", "\u2022", "'quotesinglbase",
143: "\"quotedblbase", "\"quotedblright", "?guillemotright",
144: "...ellipsis", "%perthousand", "?questiondown", "`grave",
145: "'acute", "^circumflex", "~tilde", "-macron", "?breve",
146: "?dotaccent", "?dieresis", "oring", "ccedilla",
147: ":hungarumlaut", "?ogonek", ",caron", "---emdash", "AE",
148: "aordfeminine", "LLslash", "OOslash", "OE",
149: "oordmasculine", "ae", "idotlessi", "llslash", "ooslash",
150: "oe", "Bgermandbls", "1onesuperior", "~logicalnot", "?mu",
151: "(TM)trademark", "?Eth", "1/2", "+/-", "?Thorn", "1/4",
152: "/divide", "|brokenbar", "*degree", "?thorn", "3/4",
153: "2twosuperior", "(R)", "-minus", "?eth", "*multiply",
154: "3threesuperior", "(C)", "AAacute", "AAcircumflex",
155: "AAdieresis", "AAgrave", "AAring", "AAtilde", "CCcedilla",
156: "EEacute", "EEcircumflex", "EEdieresis", "EEgrave",
157: "IIacute", "IIcircumflex", "IIdieresis", "IIgrave",
158: "NNtilde", "OOacute", "OOcircumflex", "OOdieresis",
159: "OOgrave", "OOtilde", "SScaron", "UUacute", "UUcircumflex",
160: "UUdieresis", "UUgrave", "YYacute", "YYdieresis",
161: "ZZcaron", "aaacute", "aacircumflex", "aadieresis",
162: "aagrave", "aaring", "aatilde", "cccedilla", "eeacute",
163: "eecircumflex", "eedieresis", "eegrave", "iiacute",
164: "iicircumflex", "iidieresis", "iigrave", "nntilde",
165: "ooacute", "oocircumflex", "oodieresis", "oograve",
166: "ootilde", "sscaron", "uuacute", "uucircumflex",
167: "uudieresis", "uugrave", "yyacute", "yydieresis",
168: "zzcaron", "!exclamsmall", "?Hungarumlautsmall",
169: "$dollaroldstyle", "$dollarsuperior", "&ersandsmall",
170: "'Acutesmall", "/parenleftsuperior",
171: "\\parenrightsuperior", "?twodotenleader",
172: "?onedotenleader", "0zerooldstyle", "1oneoldstyle",
173: "2twooldstyle", "3threeoldstyle", "4fouroldstyle",
174: "5fiveoldstyle", "6sixoldstyle", "7sevenoldstyle",
175: "8eightoldstyle", "9nineoldstyle", "'commasuperior",
176: "--threequartersemdash", ".periodsuperior",
177: "?questionsmall", "aasuperior", "bbsuperior",
178: "ccentsuperior", "ddsuperior", "eesuperior", "iisuperior",
179: "llsuperior", "mmsuperior", "nnsuperior", "oosuperior",
180: "rrsuperior", "sssuperior", "ttsuperior", "ff", "ffi",
181: "ffl", "\\parenleftinferior", "/parenrightinferior",
182: "^Circumflexsmall", "-hyphensuperior", "`Gravesmall",
183: "AAsmall", "BBsmall", "CCsmall", "DDsmall", "EEsmall",
184: "FFsmall", "GGsmall", "HHsmall", "IIsmall", "JJsmall",
185: "KKsmall", "LLsmall", "MMsmall", "NNsmall", "OOsmall",
186: "PPsmall", "QQsmall", "RRsmall", "SSsmall", "TTsmall",
187: "UUsmall", "VVsmall", "WWsmall", "XXsmall", "YYsmall",
188: "ZZsmall", ":colonmonetary", "1onefitted", "?rupiah",
189: "~Tildesmall", "!exclamdownsmall", "ccentoldstyle",
190: "LLslashsmall", "SScaronsmall", "ZZcaronsmall",
191: "?Dieresissmall", "?Brevesmall", "^Caronsmall",
192: "?Dotaccentsmall", "?Macronsmall", "--figuredash",
193: "-hypheninferior", "?Ogoneksmall", "oRingsmall",
194: ",Cedillasmall", "?questiondownsmall", "1/8oneeighth",
195: "3/8threeeighths", "5/8fiveeighths", "7/8seveneighths",
196: "1/3onethird", "2/3twothirds", "0zerosuperior",
197: "4foursuperior", "5fivesuperior", "6sixsuperior",
198: "7sevensuperior", "8eightsuperior", "9ninesuperior",
199: "0zeroinferior", "1oneinferior", "2twoinferior",
200: "3threeinferior", "4fourinferior", "5fiveinferior",
201: "6sixinferior", "7seveninferior", "8eightinferior",
202: "9nineinferior", "ccentinferior", "$dollarinferior",
203: ".periodinferior", ",commainferior", "AAgravesmall",
204: "AAacutesmall", "AAcircumflexsmall", "AAtildesmall",
205: "AAdieresissmall", "AAringsmall", "AEAEsmall",
206: "CCcedillasmall", "EEgravesmall", "EEacutesmall",
207: "EEcircumflexsmall", "EEdieresissmall", "IIgravesmall",
208: "IIacutesmall", "IIcircumflexsmall", "IIdieresissmall",
209: "EthEthsmall", "NNtildesmall", "OOgravesmall",
210: "OOacutesmall", "OOcircumflexsmall", "OOtildesmall",
211: "OOdieresissmall", "OEOEsmall", "OOslashsmall",
212: "UUgravesmall", "UUacutesmall", "UUcircumflexsmall",
213: "UUdieresissmall", "YYacutesmall", "?Thornsmall",
214: "YYdieresissmall", "?001.000", "?001.001", "?001.002",
215: "?001.003", " Black", " Bold", " Book", " Light",
216: " Medium", " Regular", " Roman", " Semibold",
217: /* extra mac stuff */
218: "?NUL", "?HT", " LF", " CR", "?DLE", "?DC1", "?DC2",
219: "?DC3", "?DC4", "?RS", "?US", "!=", "?DEL", "?infinity",
220: "<=", ">=", "?partialdiff", "?summation", "xproduct",
221: "?pi", "?integral", "?Omega", "?radical", "~=", "?Delta",
222: " nbspace", "?lozenge", "?apple" };
223:
224: /**
225: * glyph order of the glyphs for the Type1C Expert character set. These
226: * are indices into the glyph name array.
227: */
228: public static final int type1CExpertCharset[] = { 1, 229, 230, 231,
229: 232, 233, 234, 235, 236, 237, 238, 13, 14, 15, 99, 239,
230: 240, 241, 242, 243, 244, 245, 246, 247, 248, 27, 28, 249,
231: 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261,
232: 262, 263, 264, 265, 266, 109, 110, 267, 268, 269, 270, 271,
233: 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283,
234: 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295,
235: 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307,
236: 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 158,
237: 155, 163, 319, 320, 321, 322, 323, 324, 325, 326, 150, 164,
238: 169, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337,
239: 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349,
240: 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361,
241: 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373,
242: 374, 375, 376, 377, 378 };
243:
244: /**
245: * glyph order of the glyphs for the Type1C Expert Sub character set.
246: * These are indices into the glyph name array.
247: */
248: public static final int type1CExpertSubCharset[] = { 1, 231, 232,
249: 235, 236, 237, 238, 13, 14, 15, 99, 239, 240, 241, 242,
250: 243, 244, 245, 246, 247, 248, 27, 28, 249, 250, 251, 253,
251: 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
252: 266, 109, 110, 267, 268, 269, 270, 272, 300, 301, 302, 305,
253: 314, 315, 158, 155, 163, 320, 321, 322, 323, 324, 325, 326,
254: 150, 164, 169, 327, 328, 329, 330, 331, 332, 333, 334, 335,
255: 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346 };
256:
257: /**
258: * extra names for the Macintosh glyph set. This array should be
259: * considered to be appended to the stdNames array. The stdValues array
260: * already contains values for this set.
261: */
262: public static final String macExtras[] = { // index starts at 391=NUL
263: "NUL", "HT", "LF", "CR", "DLE", "DC1", "DC2", "DC3", "DC4", "RS",
264: "US", "notequal", "DEL", "infinity", "lessequal",
265: "greaterequal", "partialdiff", "summation", "product",
266: "pi", "integral", "Omega", "radical", "approxequal",
267: "Delta", "nbspace", "lozenge", "apple" };
268:
269: /**
270: * character mapping from values to glyphs for the Macintosh MacRoman
271: * encoding
272: */
273: public static final int macRomanEncoding[] = { 391, 154, 167, 140,
274: 146, 192, 221, 197, 226, 392, 393, 157, 162, 394, 199, 228,
275: 395, 396, 397, 398, 399, 155, 158, 150, 163, 169, 164, 160,
276: 166, 168, 400, 401, 1, 2, 3, 4, 5, 6, 7, 104, 9, 10, 11,
277: 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
278: 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
279: 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
280: 57, 58, 59, 60, 61, 62, 63, 64, 124, 66, 67, 68, 69, 70,
281: 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
282: 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 403, 173, 175, 177,
283: 178, 186, 189, 195, 200, 203, 201, 202, 205, 204, 206, 207,
284: 210, 208, 209, 211, 214, 212, 213, 215, 216, 219, 217, 218,
285: 220, 222, 225, 223, 224, 112, 161, 97, 98, 102, 116, 115,
286: 149, 165, 170, 153, 125, 131, 402, 138, 141, 404, 156, 405,
287: 406, 100, 152, 407, 408, 409, 410, 411, 139, 143, 412, 144,
288: 147, 123, 96, 151, 413, 101, 414, 415, 106, 120, 121, 416,
289: 174, 176, 191, 142, 148, 111, 137, 105, 119, 65, 8, 159,
290: 417, 227, 198, 99, 103, 107, 108, 109, 110, 113, 114, 117,
291: 118, 122, 172, 179, 171, 180, 181, 182, 183, 184, 185, 187,
292: 188, 418, 190, 193, 194, 196, 145, 126, 127, 128, 129, 130,
293: 132, 133, 134, 135, 136 };
294:
295: /**
296: * character mapping from values to glyphs for the isoLatin1Encoding
297: */
298: public static final int isoLatin1Encoding[] = { 0, 0, 0, 0, 0, 0,
299: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
300: 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
301: 13, 166, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
302: 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
303: 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
304: 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71,
305: 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
306: 87, 88, 89, 90, 91, 92, 93, 94, 95, 0, 0, 0, 0, 0, 0, 0, 0,
307: 0, 0, 0, 0, 0, 0, 0, 0, 0, 145, 124, 125, 126, 127, 128,
308: 129, 130, 131, 0, 132, 133, 0, 134, 135, 136, 1, 96, 97,
309: 98, 103, 100, 160, 102, 131, 170, 139, 106, 151, 14, 165,
310: 128, 161, 156, 164, 169, 125, 152, 115, 114, 133, 150, 143,
311: 120, 158, 155, 163, 123, 174, 171, 172, 176, 173, 175, 138,
312: 177, 181, 178, 179, 180, 185, 182, 183, 184, 154, 186, 190,
313: 187, 188, 191, 189, 168, 141, 196, 193, 194, 195, 197, 157,
314: 149, 203, 200, 201, 205, 202, 204, 144, 206, 210, 207, 208,
315: 209, 214, 211, 212, 213, 167, 215, 219, 216, 217, 220, 218,
316: 159, 147, 225, 222, 223, 224, 226, 162, 227 };
317:
318: /**
319: * character mapping from values to glyphs for the Windows winAnsi
320: * character encoding
321: */
322: public static final int winAnsiEncoding[] = { 124, 125, 126, 127,
323: 128, 129, 130, 131, 132, 133, 134, 135, 136, 145, 0, 0, 0,
324: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5,
325: 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
326: 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
327: 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
328: 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
329: 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
330: 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 0,
331: 0, 0, 117, 101, 118, 121, 112, 113, 0, 122, 192, 107, 142,
332: 0, 0, 0, 0, 65, 8, 105, 119, 116, 111, 137, 0, 153, 221,
333: 108, 148, 0, 0, 198, 1, 96, 97, 98, 103, 100, 160, 102,
334: 131, 170, 139, 106, 151, 14, 165, 128, 161, 156, 164, 169,
335: 125, 152, 115, 114, 133, 150, 143, 120, 158, 155, 163, 123,
336: 174, 171, 172, 176, 173, 175, 138, 177, 181, 178, 179, 180,
337: 185, 182, 183, 184, 154, 186, 190, 187, 188, 191, 189, 168,
338: 141, 196, 193, 194, 195, 197, 157, 149, 203, 200, 201, 205,
339: 202, 204, 144, 206, 210, 207, 208, 209, 214, 211, 212, 213,
340: 167, 215, 219, 216, 217, 220, 218, 159, 147, 225, 222, 223,
341: 224, 226, 162, 227 };
342:
343: /**
344: * character mapping from values to glyphs for Adobe's standard
345: * character encoding
346: */
347: public static final int standardEncoding[] = { 0, 0, 0, 0, 0, 0, 0,
348: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
349: 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
350: 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
351: 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
352: 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58,
353: 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
354: 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
355: 89, 90, 91, 92, 93, 94, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
356: 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
357: 0, 0, 0, 0, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
358: 106, 107, 108, 109, 110, 0, 111, 112, 113, 114, 0, 115,
359: 116, 117, 118, 119, 120, 121, 122, 0, 123, 0, 124, 125,
360: 126, 127, 128, 129, 130, 131, 0, 132, 133, 0, 134, 135,
361: 136, 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
362: 138, 0, 139, 0, 0, 0, 0, 140, 141, 142, 143, 0, 0, 0, 0, 0,
363: 144, 0, 0, 0, 145, 0, 0, 146, 147, 148, 149, 0, 0, 0, 0 };
364:
365: /**
366: * get the name of a glyph from its encoding value (NOT the character
367: * value), using the standard encoding.
368: */
369: public static String getName(int i) {
370: if (i < stdNames.length) {
371: return stdNames[i];
372: } else {
373: i -= stdNames.length;
374: if (i < macExtras.length) {
375: return macExtras[i];
376: }
377: }
378: return ".notdef";
379: }
380:
381: /**
382: * get the encoding value a glyph given its name and a name table.
383: * @param name the name of the glyph
384: * @param table the charset as an array of names
385: * @return the index of the name in the table, or -1 if the name
386: * cannot be found in the table
387: */
388: public static int findName(String name, String[] table) {
389: for (int i = 0; i < table.length; i++) {
390: if (name.equals(table[i])) {
391: return i;
392: }
393: }
394: return -1;
395: }
396:
397: /**
398: * get the encoding value of a glyph given its name and a charset.
399: * @param name the name of the glyph
400: * @param table the charset table
401: * @return the index of the name in the charset.
402: */
403: public static int findName(String name, int[] table) {
404: for (int i = 0; i < table.length; i++) {
405: if (name.equals(getName(table[i]))) {
406: return i;
407: }
408: }
409: return -1;
410: }
411:
412: /**
413: * get the encoding value of a glyph given its name, in the standard
414: * charset. This is equivalent to findName(name, FontSupport.stdNames).
415: * @param name the name of the glyph
416: * @return the index of the name in stdNames, or -1 if the name doesn't
417: * appear in stdNames.
418: */
419: public static int getStrIndex(String name) {
420: for (int i = 0; i < stdNames.length; i++) {
421: if (name.equals(stdNames[i])) {
422: return i;
423: }
424: }
425: return -1;
426: }
427: }
|