📄 scanfont.c
字号:
/* $TOG: scanfont.c /main/11 1997/06/09 13:27:16 barstow $ *//* Copyright International Business Machines,Corp. 1991 * All Rights Reserved * * License to use, copy, modify, and distribute this software * and its documentation for any purpose and without fee is * hereby granted, provided that the above copyright notice * appear in all copies and that both that copyright notice and * this permission notice appear in supporting documentation, * and that the name of IBM not be used in advertising or * publicity pertaining to distribution of the software without * specific, written prior permission. * * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. *//* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */ #include <string.h>#include "t1stdio.h"#include "util.h"#include "token.h"#include "fontfcn.h"#include "blues.h" static int rc;static boolean InPrivateDict;static boolean WantFontInfo;static boolean TwoSubrs;static psobj inputFile;static psobj filterFile;static psobj *inputP; /**********************************************************************//* Init_BuiltInEncoding() *//* *//* Initializes the StandardEncoding and ISOLatin1Encoding vector. *//* *//**********************************************************************/typedef struct /* Builtin Standard Encoding */{ int index; char *name;} EncodingTable;static EncodingTable StdEnc[] = { 040 , "space", 041 , "exclam", 042 , "quotedbl", 043 , "numbersign", 044 , "dollar", 045 , "percent", 046 , "ampersand", 047 , "quoteright", 050 , "parenleft", 051 , "parenright", 052 , "asterisk", 053 , "plus", 054 , "comma", 055 , "hyphen", 056 , "period", 057 , "slash", 060 , "zero", 061 , "one", 062 , "two", 063 , "three", 064 , "four", 065 , "five", 066 , "six", 067 , "seven", 070 , "eight", 071 , "nine", 072 , "colon", 073 , "semicolon", 074 , "less", 075 , "equal", 076 , "greater", 077 , "question", 0100 , "at", 0101 , "A", 0102 , "B", 0103 , "C", 0104 , "D", 0105 , "E", 0106 , "F", 0107 , "G", 0110 , "H", 0111 , "I", 0112 , "J", 0113 , "K", 0114 , "L", 0115 , "M", 0116 , "N", 0117 , "O", 0120 , "P", 0121 , "Q", 0122 , "R", 0123 , "S", 0124 , "T", 0125 , "U", 0126 , "V", 0127 , "W", 0130 , "X", 0131 , "Y", 0132 , "Z", 0133 , "bracketleft", 0134 , "backslash", 0135 , "bracketright", 0136 , "asciicircum", 0137 , "underscore", 0140 , "quoteleft", 0141 , "a", 0142 , "b", 0143 , "c", 0144 , "d", 0145 , "e", 0146 , "f", 0147 , "g", 0150 , "h", 0151 , "i", 0152 , "j", 0153 , "k", 0154 , "l", 0155 , "m", 0156 , "n", 0157 , "o", 0160 , "p", 0161 , "q", 0162 , "r", 0163 , "s", 0164 , "t", 0165 , "u", 0166 , "v", 0167 , "w", 0170 , "x", 0171 , "y", 0172 , "z", 0173 , "braceleft", 0174 , "bar", 0175 , "braceright", 0176 , "asciitilde", 0241 , "exclamdown", 0242 , "cent", 0243 , "sterling", 0244 , "fraction", 0245 , "yen", 0246 , "florin", 0247 , "section", 0250 , "currency", 0251 , "quotesingle", 0252 , "quotedblleft", 0253 , "guillemotleft", 0254 , "guilsinglleft", 0255 , "guilsinglright", 0256 , "fi", 0257 , "fl", 0261 , "endash", 0262 , "dagger", 0263 , "daggerdbl", 0264 , "periodcentered", 0266 , "paragraph", 0267 , "bullet", 0270 , "quotesinglbase", 0271 , "quotedblbase", 0272 , "quotedblright", 0273 , "guillemotright", 0274 , "ellipsis", 0275 , "perthousand", 0277 , "questiondown", 0301 , "grave", 0302 , "acute", 0303 , "circumflex", 0304 , "tilde", 0305 , "macron", 0306 , "breve", 0307 , "dotaccent", 0310 , "dieresis", 0312 , "ring", 0313 , "cedilla", 0315 , "hungarumlaut", 0316 , "ogonek", 0317 , "caron", 0320 , "emdash", 0341 , "AE", 0343 , "ordfeminine", 0350 , "Lslash", 0351 , "Oslash", 0352 , "OE", 0353 , "ordmasculine", 0361 , "ae", 0365 , "dotlessi", 0370 , "lslash", 0371 , "oslash", 0372 , "oe", 0373 , "germandbls", 0, 0};static EncodingTable ISO8859Enc[] = { 32, "space", 33, "exclam", 34, "quotedbl", 35, "numbersign", 36, "dollar", 37, "percent", 38, "ampersand", 39, "quoteright", 40, "parenleft", 41, "parenright", 42, "asterisk", 43, "plus", 44, "comma", 45, "minus", 46, "period", 47, "slash", 48, "zero", 49, "one", 50, "two", 51, "three", 52, "four", 53, "five", 54, "six", 55, "seven", 56, "eight", 57, "nine", 58, "colon", 59, "semicolon", 60, "less", 61, "equal", 62, "greater", 63, "question", 64, "at", 65, "A", 66, "B", 67, "C", 68, "D", 69, "E", 70, "F", 71, "G", 72, "H", 73, "I", 74, "J", 75, "K", 76, "L", 77, "M", 78, "N", 79, "O", 80, "P", 81, "Q", 82, "R", 83, "S", 84, "T", 85, "U", 86, "V", 87, "W", 88, "X", 89, "Y", 90, "Z", 91, "bracketleft", 92, "backslash", 93, "bracketright", 94, "asciicircum", 95, "underscore", 96, "quoteleft", 97, "a", 98, "b", 99, "c", 100, "d", 101, "e", 102, "f", 103, "g", 104, "h", 105, "i", 106, "j", 107, "k", 108, "l", 109, "m", 110, "n", 111, "o", 112, "p", 113, "q", 114, "r", 115, "s", 116, "t", 117, "u", 118, "v", 119, "w", 120, "x", 121, "y", 122, "z", 123, "braceleft", 124, "bar", 125, "braceright", 126, "asciitilde", 161, "exclamdown", 162, "cent", 163, "sterling", 164, "currency", 165, "yen", 166, "brokenbar", 167, "section", 168, "dieresis", 169, "copyright", 170, "ordfeminine", 171, "guillemotleft", 172, "logicalnot", 173, "hyphen", 174, "registered", 175, "macron", 176, "degree", 177, "plusminus", 178, "twosuperior", 179, "threesuperior", 180, "acute", 181, "mu", 182, "paragraph", 183, "periodcentered", 184, "cedilla", 185, "onesuperior", 186, "ordmasculine", 187, "guillemotright", 188, "onequarter", 189, "onehalf", 190, "threequarters", 191, "questiondown", 192, "Agrave", 193, "Aacute", 194, "Acircumflex", 195, "Atilde", 196, "Adieresis", 197, "Aring", 198, "AE", 199, "Ccedilla", 200, "Egrave", 201, "Eacute", 202, "Ecircumflex", 203, "Edieresis", 204, "Igrave", 205, "Iacute", 206, "Icircumflex", 207, "Idieresis", 208, "Eth", 209, "Ntilde", 210, "Ograve", 211, "Oacute", 212, "Ocircumflex", 213, "Otilde", 214, "Odieresis", 215, "multiply", 216, "Oslash", 217, "Ugrave", 218, "Uacute", 219, "Ucircumflex", 220, "Udieresis", 221, "Yacute", 222, "Thorn", 223, "germandbls", 224, "agrave", 225, "aacute", 226, "acircumflex", 227, "atilde", 228, "adieresis", 229, "aring", 230, "ae", 231, "ccedilla", 232, "egrave", 233, "eacute", 234, "ecircumflex", 235, "edieresis", 236, "igrave", 237, "iacute", 238, "icircumflex", 239, "idieresis", 240, "eth", 241, "ntilde", 242, "ograve", 243, "oacute", 244, "ocircumflex", 245, "otilde", 246, "odieresis", 247, "divide", 248, "oslash", 249, "ugrave", 250, "uacute", 251, "ucircumflex", 252, "udieresis", 253, "yacute", 254, "thorn", 255, "ydieresis", 0, 0};static psobj *StdEncArrayP = NULL;psobj *ISOLatin1EncArrayP = NULL; static psobj *MakeEncodingArrayP(encodingTable) EncodingTable *encodingTable;{ int i; psobj *encodingArrayP; encodingArrayP = (psobj *)vm_alloc(256*(sizeof(psobj))); if (!encodingArrayP) return NULL; /* initialize everything to .notdef */ for (i=0; i<256;i++) objFormatName(&(encodingArrayP[i]),7, ".notdef"); for (i=0; encodingTable[i].name; i++) { objFormatName(&(encodingArrayP[encodingTable[i].index]), strlen(encodingTable[i].name), encodingTable[i].name); } return(encodingArrayP);} boolean Init_BuiltInEncoding(){ StdEncArrayP = MakeEncodingArrayP(StdEnc); ISOLatin1EncArrayP = MakeEncodingArrayP(ISO8859Enc); return (StdEncArrayP && ISOLatin1EncArrayP);} /********************************************************************//***================================================================***/static int getNextValue(valueType) int valueType;{ scan_token(inputP); if (tokenType != valueType) { return(SCAN_ERROR); } return(SCAN_OK); }/***================================================================***//* This routine will set the global rc if there is an error *//***================================================================***/static int getInt(){ scan_token(inputP); if (tokenType != TOKEN_INTEGER) { rc = SCAN_ERROR; return(0); } else { return( tokenValue.integer); } }/***================================================================***//* * See Sec 10.3 of ``Adobe Type 1 Font Format'' v1.1, * for parsing Encoding. */static int getEncoding(arrayP) psobj *arrayP;{ scan_token(inputP); if ((tokenType == TOKEN_NAME) && (((tokenLength==16) && (!strncmp(tokenStartP,"StandardEncoding",16))) || (((tokenLength==17) && (!strncmp(tokenStartP,"ISOLatin1Encoding",17)))))) { /* Adobe Standard Encoding */ if (tokenLength == 16) arrayP->data.valueP = (char *) StdEncArrayP; else arrayP->data.valueP = (char *) ISOLatin1EncArrayP; arrayP->len = 256; return(SCAN_OK); } else if ( (tokenType == TOKEN_LEFT_BRACE) || (tokenType == TOKEN_LEFT_BRACKET) ) { /* Array of literal names */ psobj *objP; int i; objP = (psobj *)vm_alloc(256*(sizeof(psobj))); if (!(objP)) return(SCAN_OUT_OF_MEMORY);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -