w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

scanfont.c
Go to the documentation of this file.
1 /* $XConsortium: scanfont.c,v 1.9 92/07/07 17:14:56 gildea Exp $ */
2 /* Copyright International Business Machines,Corp. 1991
3  * All Rights Reserved
4  *
5  * License to use, copy, modify, and distribute this software
6  * and its documentation for any purpose and without fee is
7  * hereby granted, provided that the above copyright notice
8  * appear in all copies and that both that copyright notice and
9  * this permission notice appear in supporting documentation,
10  * and that the name of IBM not be used in advertising or
11  * publicity pertaining to distribution of the software without
12  * specific, written prior permission.
13  *
14  * IBM PROVIDES THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES
15  * OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT
16  * LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT OF
18  * THIRD PARTY RIGHTS. THE ENTIRE RISK AS TO THE QUALITY AND
19  * PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
20  * OR MAINTAIN, BELONGS TO THE LICENSEE. SHOULD ANY PORTION OF
21  * THE SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM) ASSUMES
22  * THE ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION. IN
23  * NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
25  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
26  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
27  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
28  * SOFTWARE.
29  */
30 /* Author: Katherine A. Hitchcock IBM Almaden Research Laboratory */
31 
32 #include "types.h"
33 #include <string.h>
34 
35 #include "t1stdio.h"
36 #include "util.h"
37 #include "token.h"
38 #include "objects.h"
39 #include "spaces.h"
40 #include "fontmisc.h"
41 #include "ffilest.h"
42 #include "fontfcn.h"
43 #include "blues.h"
44 
45 
46 static int rc;
47 static boolean InPrivateDict;
48 static boolean WantFontInfo;
49 static boolean TwoSubrs;
52 static psobj *inputP;
53 
54 
55 /**********************************************************************/
56 /* Init_BuiltInEncoding() */
57 /* */
58 /* Initializes the StandardEncoding and ISOLatin1Encoding vector. */
59 /* */
60 /**********************************************************************/
61 typedef struct /* Builtin Standard Encoding */
62 {
63  int index;
64  const char *name;
66 
67 static EncodingTable StdEnc[] = {
68  { 040 , "space" },
69  { 041 , "exclam" },
70  { 042 , "quotedbl" },
71  { 043 , "numbersign" },
72  { 044 , "dollar" },
73  { 045 , "percent" },
74  { 046 , "ampersand" },
75  { 047 , "quoteright" },
76  { 050 , "parenleft" },
77  { 051 , "parenright" },
78  { 052 , "asterisk" },
79  { 053 , "plus" },
80  { 054 , "comma" },
81  { 055 , "hyphen" },
82  { 056 , "period" },
83  { 057 , "slash" },
84  { 060 , "zero" },
85  { 061 , "one" },
86  { 062 , "two" },
87  { 063 , "three" },
88  { 064 , "four" },
89  { 065 , "five" },
90  { 066 , "six" },
91  { 067 , "seven" },
92  { 070 , "eight" },
93  { 071 , "nine" },
94  { 072 , "colon" },
95  { 073 , "semicolon" },
96  { 074 , "less" },
97  { 075 , "equal" },
98  { 076 , "greater" },
99  { 077 , "question" },
100  { 0100 , "at" },
101  { 0101 , "A" },
102  { 0102 , "B" },
103  { 0103 , "C" },
104  { 0104 , "D" },
105  { 0105 , "E" },
106  { 0106 , "F" },
107  { 0107 , "G" },
108  { 0110 , "H" },
109  { 0111 , "I" },
110  { 0112 , "J" },
111  { 0113 , "K" },
112  { 0114 , "L" },
113  { 0115 , "M" },
114  { 0116 , "N" },
115  { 0117 , "O" },
116  { 0120 , "P" },
117  { 0121 , "Q" },
118  { 0122 , "R" },
119  { 0123 , "S" },
120  { 0124 , "T" },
121  { 0125 , "U" },
122  { 0126 , "V" },
123  { 0127 , "W" },
124  { 0130 , "X" },
125  { 0131 , "Y" },
126  { 0132 , "Z" },
127  { 0133 , "bracketleft" },
128  { 0134 , "backslash" },
129  { 0135 , "bracketright" },
130  { 0136 , "asciicircum" },
131  { 0137 , "underscore" },
132  { 0140 , "quoteleft" },
133  { 0141 , "a" },
134  { 0142 , "b" },
135  { 0143 , "c" },
136  { 0144 , "d" },
137  { 0145 , "e" },
138  { 0146 , "f" },
139  { 0147 , "g" },
140  { 0150 , "h" },
141  { 0151 , "i" },
142  { 0152 , "j" },
143  { 0153 , "k" },
144  { 0154 , "l" },
145  { 0155 , "m" },
146  { 0156 , "n" },
147  { 0157 , "o" },
148  { 0160 , "p" },
149  { 0161 , "q" },
150  { 0162 , "r" },
151  { 0163 , "s" },
152  { 0164 , "t" },
153  { 0165 , "u" },
154  { 0166 , "v" },
155  { 0167 , "w" },
156  { 0170 , "x" },
157  { 0171 , "y" },
158  { 0172 , "z" },
159  { 0173 , "braceleft" },
160  { 0174 , "bar" },
161  { 0175 , "braceright" },
162  { 0176 , "asciitilde" },
163  { 0241 , "exclamdown" },
164  { 0242 , "cent" },
165  { 0243 , "sterling" },
166  { 0244 , "fraction" },
167  { 0245 , "yen" },
168  { 0246 , "florin" },
169  { 0247 , "section" },
170  { 0250 , "currency" },
171  { 0251 , "quotesingle" },
172  { 0252 , "quotedblleft" },
173  { 0253 , "guillemotleft" },
174  { 0254 , "guilsinglleft" },
175  { 0255 , "guilsinglright" },
176  { 0256 , "fi" },
177  { 0257 , "fl" },
178  { 0261 , "endash" },
179  { 0262 , "dagger" },
180  { 0263 , "daggerdbl" },
181  { 0264 , "periodcentered" },
182  { 0266 , "paragraph" },
183  { 0267 , "bullet" },
184  { 0270 , "quotesinglbase" },
185  { 0271 , "quotedblbase" },
186  { 0272 , "quotedblright" },
187  { 0273 , "guillemotright" },
188  { 0274 , "ellipsis" },
189  { 0275 , "perthousand" },
190  { 0277 , "questiondown" },
191  { 0301 , "grave" },
192  { 0302 , "acute" },
193  { 0303 , "circumflex" },
194  { 0304 , "tilde" },
195  { 0305 , "macron" },
196  { 0306 , "breve" },
197  { 0307 , "dotaccent" },
198  { 0310 , "dieresis" },
199  { 0312 , "ring" },
200  { 0313 , "cedilla" },
201  { 0315 , "hungarumlaut" },
202  { 0316 , "ogonek" },
203  { 0317 , "caron" },
204  { 0320 , "emdash" },
205  { 0341 , "AE" },
206  { 0343 , "ordfeminine" },
207  { 0350 , "Lslash" },
208  { 0351 , "Oslash" },
209  { 0352 , "OE" },
210  { 0353 , "ordmasculine" },
211  { 0361 , "ae" },
212  { 0365 , "dotlessi" },
213  { 0370 , "lslash" },
214  { 0371 , "oslash" },
215  { 0372 , "oe" },
216  { 0373 , "germandbls" },
217  { 0, 0 }
218 };
219 
221  { 32, "space" },
222  { 33, "exclam" },
223  { 34, "quotedbl" },
224  { 35, "numbersign" },
225  { 36, "dollar" },
226  { 37, "percent" },
227  { 38, "ampersand" },
228  { 39, "quoteright" },
229  { 40, "parenleft" },
230  { 41, "parenright" },
231  { 42, "asterisk" },
232  { 43, "plus" },
233  { 44, "comma" },
234  { 45, "minus" },
235  { 46, "period" },
236  { 47, "slash" },
237  { 48, "zero" },
238  { 49, "one" },
239  { 50, "two" },
240  { 51, "three" },
241  { 52, "four" },
242  { 53, "five" },
243  { 54, "six" },
244  { 55, "seven" },
245  { 56, "eight" },
246  { 57, "nine" },
247  { 58, "colon" },
248  { 59, "semicolon" },
249  { 60, "less" },
250  { 61, "equal" },
251  { 62, "greater" },
252  { 63, "question" },
253  { 64, "at" },
254  { 65, "A" },
255  { 66, "B" },
256  { 67, "C" },
257  { 68, "D" },
258  { 69, "E" },
259  { 70, "F" },
260  { 71, "G" },
261  { 72, "H" },
262  { 73, "I" },
263  { 74, "J" },
264  { 75, "K" },
265  { 76, "L" },
266  { 77, "M" },
267  { 78, "N" },
268  { 79, "O" },
269  { 80, "P" },
270  { 81, "Q" },
271  { 82, "R" },
272  { 83, "S" },
273  { 84, "T" },
274  { 85, "U" },
275  { 86, "V" },
276  { 87, "W" },
277  { 88, "X" },
278  { 89, "Y" },
279  { 90, "Z" },
280  { 91, "bracketleft" },
281  { 92, "backslash" },
282  { 93, "bracketright" },
283  { 94, "asciicircum" },
284  { 95, "underscore" },
285  { 96, "quoteleft" },
286  { 97, "a" },
287  { 98, "b" },
288  { 99, "c" },
289  { 100, "d" },
290  { 101, "e" },
291  { 102, "f" },
292  { 103, "g" },
293  { 104, "h" },
294  { 105, "i" },
295  { 106, "j" },
296  { 107, "k" },
297  { 108, "l" },
298  { 109, "m" },
299  { 110, "n" },
300  { 111, "o" },
301  { 112, "p" },
302  { 113, "q" },
303  { 114, "r" },
304  { 115, "s" },
305  { 116, "t" },
306  { 117, "u" },
307  { 118, "v" },
308  { 119, "w" },
309  { 120, "x" },
310  { 121, "y" },
311  { 122, "z" },
312  { 123, "braceleft" },
313  { 124, "bar" },
314  { 125, "braceright" },
315  { 126, "asciitilde" },
316  { 161, "exclamdown" },
317  { 162, "cent" },
318  { 163, "sterling" },
319  { 164, "currency" },
320  { 165, "yen" },
321  { 166, "brokenbar" },
322  { 167, "section" },
323  { 168, "dieresis" },
324  { 169, "copyright" },
325  { 170, "ordfeminine" },
326  { 171, "guillemotleft" },
327  { 172, "logicalnot" },
328  { 173, "hyphen" },
329  { 174, "registered" },
330  { 175, "macron" },
331  { 176, "degree" },
332  { 177, "plusminus" },
333  { 178, "twosuperior" },
334  { 179, "threesuperior" },
335  { 180, "acute" },
336  { 181, "mu" },
337  { 182, "paragraph" },
338  { 183, "periodcentered" },
339  { 184, "cedilla" },
340  { 185, "onesuperior" },
341  { 186, "ordmasculine" },
342  { 187, "guillemotright" },
343  { 188, "onequarter" },
344  { 189, "onehalf" },
345  { 190, "threequarters" },
346  { 191, "questiondown" },
347  { 192, "Agrave" },
348  { 193, "Aacute" },
349  { 194, "Acircumflex" },
350  { 195, "Atilde" },
351  { 196, "Adieresis" },
352  { 197, "Aring" },
353  { 198, "AE" },
354  { 199, "Ccedilla" },
355  { 200, "Egrave" },
356  { 201, "Eacute" },
357  { 202, "Ecircumflex" },
358  { 203, "Edieresis" },
359  { 204, "Igrave" },
360  { 205, "Iacute" },
361  { 206, "Icircumflex" },
362  { 207, "Idieresis" },
363  { 208, "Eth" },
364  { 209, "Ntilde" },
365  { 210, "Ograve" },
366  { 211, "Oacute" },
367  { 212, "Ocircumflex" },
368  { 213, "Otilde" },
369  { 214, "Odieresis" },
370  { 215, "multiply" },
371  { 216, "Oslash" },
372  { 217, "Ugrave" },
373  { 218, "Uacute" },
374  { 219, "Ucircumflex" },
375  { 220, "Udieresis" },
376  { 221, "Yacute" },
377  { 222, "Thorn" },
378  { 223, "germandbls" },
379  { 224, "agrave" },
380  { 225, "aacute" },
381  { 226, "acircumflex" },
382  { 227, "atilde" },
383  { 228, "adieresis" },
384  { 229, "aring" },
385  { 230, "ae" },
386  { 231, "ccedilla" },
387  { 232, "egrave" },
388  { 233, "eacute" },
389  { 234, "ecircumflex" },
390  { 235, "edieresis" },
391  { 236, "igrave" },
392  { 237, "iacute" },
393  { 238, "icircumflex" },
394  { 239, "idieresis" },
395  { 240, "eth" },
396  { 241, "ntilde" },
397  { 242, "ograve" },
398  { 243, "oacute" },
399  { 244, "ocircumflex" },
400  { 245, "otilde" },
401  { 246, "odieresis" },
402  { 247, "divide" },
403  { 248, "oslash" },
404  { 249, "ugrave" },
405  { 250, "uacute" },
406  { 251, "ucircumflex" },
407  { 252, "udieresis" },
408  { 253, "yacute" },
409  { 254, "thorn" },
410  { 255, "ydieresis" },
411  { 0, 0 }
412 };
413 
416 
417 static psobj *MakeEncodingArrayP(EncodingTable *encodingTable)
418 {
419  int i;
420  psobj *encodingArrayP;
421 
422  encodingArrayP = (psobj *)vm_alloc(256*(sizeof(psobj)));
423  if (!encodingArrayP)
424  return NULL;
425 
426  /* initialize everything to .notdef */
427  for (i=0; i<256;i++)
428  objFormatName(&(encodingArrayP[i]),7, ".notdef");
429 
430  for (i=0; encodingTable[i].name; i++)
431  {
432  objFormatName(&(encodingArrayP[encodingTable[i].index]),
433  strlen(encodingTable[i].name),
434  encodingTable[i].name);
435  }
436 
437  return(encodingArrayP);
438 }
439 
440 boolean Init_BuiltInEncoding(void)
441 {
444  return (StdEncArrayP && ISOLatin1EncArrayP);
445 }
446 
447 /********************************************************************/
448 /***================================================================***/
449 static int getNextValue(int valueType)
450 {
452  if (tokenType != valueType) {
453  return(SCAN_ERROR);
454  }
455  return(SCAN_OK);
456 
457 }
458 /***================================================================***/
459 /* This routine will set the global rc if there is an error */
460 /***================================================================***/
461 static int getInt(void)
462 {
464  if (tokenType != TOKEN_INTEGER) {
465  rc = SCAN_ERROR;
466  return(0);
467  }
468  else {
469  return( tokenValue.integer);
470  }
471 
472 }
473 /***================================================================***/
474 /*
475  * See Sec 10.3 of ``Adobe Type 1 Font Format'' v1.1,
476  * for parsing Encoding.
477  */
478 static int getEncoding(psobj *arrayP)
479 {
480 
482  if ((tokenType == TOKEN_NAME)
483  &&
484  (((tokenLength==16) && (!strncmp(tokenStartP,"StandardEncoding",16))) ||
485  (((tokenLength==17) && (!strncmp(tokenStartP,"ISOLatin1Encoding",17))))))
486  {
487  /* Adobe Standard Encoding */
488 
489  if (tokenLength == 16)
490  arrayP->data.valueP = (char *) StdEncArrayP;
491  else
492  arrayP->data.valueP = (char *) ISOLatin1EncArrayP;
493 
494  arrayP->len = 256;
495  return(SCAN_OK);
496  }
497  else if ( (tokenType == TOKEN_LEFT_BRACE) ||
499  {
500  /* Array of literal names */
501 
502  psobj *objP;
503  int i;
504 
505  objP = (psobj *)vm_alloc(256*(sizeof(psobj)));
506  if (!(objP)) return(SCAN_OUT_OF_MEMORY);
507 
508  arrayP->data.valueP = (char *) objP;
509  arrayP->len = 256;
510 
511  for (i=0; i<256; i++, objP++)
512  {
514 
516  return(SCAN_ERROR);
517 
518  if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
520  }
521 
523  if ( (tokenType == TOKEN_RIGHT_BRACE) ||
525  return(SCAN_OK);
526  }
527  else
528  {
529  /* Must be sequences of ``dup <index> <charactername> put" */
530 
531  psobj *objP;
532  int i;
533 
534  objP = (psobj *)vm_alloc(256*(sizeof(psobj)));
535  if (!(objP)) return(SCAN_OUT_OF_MEMORY);
536 
537  arrayP->data.valueP = (char *) objP;
538  arrayP->len = 256;
539 
540  for (i=0; i<256; i++)
541  objFormatName(objP + i, 7, ".notdef");
542 
543  while (TRUE)
544  {
546 
547  switch (tokenType)
548  {
549  case TOKEN_NAME:
550  if (tokenLength == 3)
551  {
552  if (strncmp(tokenStartP,"dup",3) == 0)
553  {
554  /* get <index> */
556  if (tokenType != TOKEN_INTEGER ||
557  tokenValue.integer < 0 ||
558  tokenValue.integer > 255)
559  return (SCAN_ERROR);
560  i = tokenValue.integer;
561 
562  /* get <characer_name> */
565  return(SCAN_ERROR);
566 
567  if (!(vm_alloc(tokenLength)) )
568  return(SCAN_OUT_OF_MEMORY);
570 
571  /* get "put" */
573  if (tokenType != TOKEN_NAME)
574  return(SCAN_ERROR);
575  }
576  else if (strncmp(tokenStartP,"def",3) == 0)
577  return (SCAN_OK);
578  }
579  break;
580  case TOKEN_EOF:
581  case TOKEN_NONE:
582  case TOKEN_INVALID:
583  return (SCAN_ERROR);
584  }
585  }
586  }
587 
588  return (SCAN_ERROR);
589 }
590 /***================================================================***/
591 static int getArray(psobj *arrayP)
592 {
593  int N; /* count the items in the array */
594  psobj *objP;
595 
596 
598  if ( (tokenType != TOKEN_LEFT_BRACE) &&
600  return(SCAN_ERROR);
601  }
602  /* format the array in memory, save pointer to the beginning */
603  arrayP->data.valueP = tokenStartP;
604  /* loop, picking up next object, until right BRACE or BRACKET */
605  N = 0;
606  do {
608  if ( (tokenType == TOKEN_RIGHT_BRACE) ||
610  /* save then number of items in the array */
611  arrayP->len = N;
612  return(SCAN_OK);
613  }
614  /* allocate the space for the object */
615  objP = (psobj *)vm_alloc(sizeof(psobj));
616  if (!(objP)) return(SCAN_OUT_OF_MEMORY);
617 
618  /* array is an array of numbers, (real or integer) */
619  if (tokenType == TOKEN_REAL) {
621  }
622  else
623  if (tokenType == TOKEN_INTEGER) {
625  }
626  else return(SCAN_ERROR);
627  N++;
628  } while ( 1>0 );
629  /* NOTREACHED*/
630 }
631 /***================================================================***/
632 static int getName(const char *nameP)
633 {
634  do {
636  if (tokenType <= TOKEN_NONE) {
637  if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
638  return(SCAN_ERROR);
639  }
640  } while ((tokenType != TOKEN_NAME) ||
641  (0 != strncmp(tokenStartP,nameP,strlen(nameP))) );
642  /* found */
643  return(SCAN_OK);
644 }
645 /***================================================================***/
646 static int getNbytes(int N)
647 {
648  int I;
649 
650  if (N > vm_free_bytes()) {
651  if (!vm_init()) return(SCAN_OUT_OF_MEMORY);
652  }
655  if ( I != N ) return(SCAN_FILE_EOF);
656  return(SCAN_OK);
657 }
658 
659 /***================================================================***/
660 /* getLiteralName(nameObjP) */
661 /* scan for next literal. */
662 /* if we encounter the name 'end' then terminate and say ok. */
663 /* It means that the CharStrings does not have as many characters */
664 /* as the dictionary said it would and that is ok. */
665 /***================================================================***/
666 static int getLiteralName(psobj *nameObjP)
667 {
668  do {
670  if (tokenType <= TOKEN_NONE) {
671  if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
672  return(SCAN_ERROR);
673  }
674  if (tokenType == TOKEN_NAME) {
675  if (0 == strncmp(tokenStartP,"end",3) ) {
676  return(SCAN_END);
677  }
678  }
679  } while (tokenType != TOKEN_LITERAL_NAME) ;
680  nameObjP->len = tokenLength;
681  /* allocate all the names in the CharStrings Structure */
682  if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
683  nameObjP->data.valueP = tokenStartP;
684  /* found */
685  return(SCAN_OK);
686 }
687 
688 /***================================================================***/
689 /*
690  * BuildSubrs routine
691  */
692 /***================================================================***/
693 
694 static int BuildSubrs(psfont *FontP)
695 {
696  int N; /* number of values in Subrs */
697  int I; /* index into Subrs */
698  int i; /* loop thru Subrs */
699  int J; /* length of Subrs entry */
700  psobj *arrayP;
701 
702  /* next token should be a positive int */
703  /* note: rc is set by getInt. */
704  N = getInt();
705  if (rc) return(rc);
706  if (N < 0 ) return(SCAN_ERROR);
707  /* if we already have a Subrs, then skip the second one */
708  /* The second one is for hiresolution devices. */
709  if (FontP->Subrs.data.arrayP != NULL) {
710  TwoSubrs = TRUE;
711  /* process all the Subrs, but do not update anything */
712  /* can not just skip them because of the binary data */
713  for (i=0;i<N;i++) {
714  /* look for dup */
715  rc = getName("dup");
716  if (rc) return(rc);
717  /* get 2 integers */
718  I = getInt();
719  if (rc) return(rc);
720  J = getInt();
721  if (rc) return(rc);
722  if ( (I < 0) || (J < 0 ) ) return (SCAN_ERROR);
723  /* get the next token, it should be RD or -|, either is ok */
725  if ( rc != SCAN_OK ) return(rc);
726  rc = getNbytes(J);
727  if (rc) return(rc);
728  }
729  return(SCAN_OK);
730  }
731 
732  arrayP = (psobj *)vm_alloc(N*sizeof(psobj));
733  if (!(arrayP) ) return(SCAN_OUT_OF_MEMORY);
734  FontP->Subrs.len = N;
735  FontP->Subrs.data.arrayP = arrayP;
736  /* get N values for Subrs */
737  for (i=0;i<N;i++) {
738  /* look for dup */
739  rc = getName("dup");
740  if (rc) return(rc);
741  /* get 2 integers */
742  I = getInt();
743  if (rc) return(rc);
744  J = getInt();
745  if (rc) return(rc);
746  if ( (I < 0) || (J < 0 ) ) return (SCAN_ERROR);
747  arrayP[I].len = J;
748  /* get the next token, it should be RD or -|, either is ok */
750  if ( rc != SCAN_OK ) return(rc);
751  rc = getNbytes(J);
752  if (rc == SCAN_OK) {
753  arrayP[I].data.valueP = tokenStartP;
754  if ( !(vm_alloc(J)) ) return(SCAN_OUT_OF_MEMORY);
755  }
756  else return(rc);
757  }
758  return(SCAN_OK);
759 
760 }
761 /***================================================================***/
762 /***================================================================***/
763 /*
764  * BuildCharStrings routine
765  */
766 /***================================================================***/
767 
769 {
770  int N; /* number of values in CharStrings */
771  int i; /* loop thru Subrs */
772  int J; /* length of Subrs entry */
773  psdict *dictP;
774 
775  /* next token should be a positive int */
776  N = getInt();
777  if (rc) {
778  /* check if file had TwoSubrs, hi resolution stuff is in file*/
779  if (TwoSubrs) {
780  do {
782  if (tokenType <= TOKEN_NONE) {
783  if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
784  return(SCAN_ERROR);
785  }
786  } while (tokenType != TOKEN_INTEGER);
787  N = tokenValue.integer;
788  }
789  else return(rc); /* if next token was not an Int */
790  }
791  if (N<=0) return(SCAN_ERROR);
792  /* save number of entries in the dictionary */
793 
794  dictP = (psdict *)vm_alloc((N+1)*sizeof(psdict));
795  if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
796  FontP->CharStringsP = dictP;
797  dictP[0].key.len = N;
798  /* get N values for CharStrings */
799  for (i=1;i<=N;i++) {
800  /* look for next literal name */
801  rc = getLiteralName(&(dictP[i].key));
802  if (rc) return(rc);
803  /* get 1 integer */
804  J = getInt();
805  if (rc) return(rc); /* if next token was not an Int */
806  if (J<0) return (SCAN_ERROR);
807  dictP[i].value.len = J;
808  /* get the next token, it should be RD or -|, either is ok */
810  if ( rc != SCAN_OK ) return(rc);
811  rc = getNbytes(J);
812  if (rc == SCAN_OK) {
813  dictP[i].value.data.valueP = tokenStartP;
814  if ( !(vm_alloc(J)) ) return(SCAN_OUT_OF_MEMORY);
815  }
816  else return(rc);
817  }
818  return(SCAN_OK);
819 
820 }
821 /***================================================================***/
822 /***================================================================***/
823 /*
824  * BuildFontInfo Dictionary
825  */
826 /***================================================================***/
827 static int BuildFontInfo(psfont *fontP)
828 {
829  psdict *dictP;
830 
831  /* allocate the private dictionary */
832  dictP = (psdict *)vm_alloc(20*sizeof(psdict));
833  if (!(dictP)) return(SCAN_OUT_OF_MEMORY);
834 
835  fontP->fontInfoP = dictP;
836  fontP->fontInfoP[0].key.len = 17; /* number of actual entries */
837  objFormatName(&(dictP[FONTNAME].key),8,"FontName");
838  objFormatName(&(dictP[FONTNAME].value),0,NULL);
839  objFormatName(&(dictP[PAINTTYPE].key),9,"PaintType");
840  objFormatInteger(&(dictP[PAINTTYPE].value),0);
841  objFormatName(&(dictP[FONTTYPENUM].key),8,"FontType");
842  objFormatInteger(&(dictP[FONTTYPENUM].value),0);
843  objFormatName(&(dictP[FONTMATRIX].key),10,"FontMatrix");
844  objFormatArray(&(dictP[FONTMATRIX].value),0,NULL);
845  objFormatName(&(dictP[FONTBBOX].key),8,"FontBBox");
846  objFormatArray(&(dictP[FONTBBOX].value),0,NULL);
847  objFormatName(&(dictP[ENCODING].key),8,"Encoding");
848  objFormatEncoding(&(dictP[ENCODING].value),0,NULL);
849  objFormatName(&(dictP[UNIQUEID].key),8,"UniqueID");
850  objFormatInteger(&(dictP[UNIQUEID].value),0);
851  objFormatName(&(dictP[STROKEWIDTH].key),11,"StrokeWidth");
852  objFormatReal(&(dictP[STROKEWIDTH].value),0.0);
853  objFormatName(&(dictP[VERSION].key),7,"version");
854  objFormatString(&(dictP[VERSION].value),0,NULL);
855  objFormatName(&(dictP[NOTICE].key),6,"Notice");
856  objFormatString(&(dictP[NOTICE].value),0,NULL);
857  objFormatName(&(dictP[FULLNAME].key),8,"FullName");
858  objFormatString(&(dictP[FULLNAME].value),0,NULL);
859  objFormatName(&(dictP[FAMILYNAME].key),10,"FamilyName");
860  objFormatString(&(dictP[FAMILYNAME].value),0,NULL);
861  objFormatName(&(dictP[WEIGHT].key),6,"Weight");
862  objFormatString(&(dictP[WEIGHT].value),0,NULL);
863  objFormatName(&(dictP[ITALICANGLE].key),11,"ItalicAngle");
864  objFormatReal(&(dictP[ITALICANGLE].value),0.0);
865  objFormatName(&(dictP[ISFIXEDPITCH].key),12,"isFixedPitch");
867  objFormatName(&(dictP[UNDERLINEPOSITION].key),17,"UnderlinePosition");
868  objFormatReal(&(dictP[UNDERLINEPOSITION].value),0.0);
869  objFormatName(&(dictP[UNDERLINETHICKNESS].key),18,"UnderlineThickness");
870  objFormatReal(&(dictP[UNDERLINETHICKNESS].value),0.0);
871  return(SCAN_OK);
872 }
873 /***================================================================***/
874 /*
875  * BuildPrivate Dictionary
876  */
877 /***================================================================***/
878 static int BuildPrivate(psfont *fontP)
879 {
880  psdict *Private;
881 
882  /* allocate the private dictionary */
883  Private = (psdict *)vm_alloc(20*sizeof(psdict));
884 
885  if (!(Private)) return(SCAN_OUT_OF_MEMORY);
886 
887  fontP->Private = Private;
888  fontP->Private[0].key.len = 16; /* number of actual entries */
889 
890  objFormatName(&(Private[BLUEVALUES].key),10,"BlueValues");
891  objFormatArray(&(Private[BLUEVALUES].value),0,NULL);
892  objFormatName(&(Private[OTHERBLUES].key),10,"OtherBlues");
893  objFormatArray(&(Private[OTHERBLUES].value),0,NULL);
894  objFormatName(&(Private[FAMILYBLUES].key),11,"FamilyBlues");
895  objFormatArray(&(Private[FAMILYBLUES].value),0,NULL);
896  objFormatName(&(Private[FAMILYOTHERBLUES].key),16,"FamilyOtherBlues");
897  objFormatArray(&(Private[FAMILYOTHERBLUES].value),0,NULL);
898  objFormatName(&(Private[BLUESCALE].key),9,"BlueScale");
900  objFormatName(&(Private[BLUESHIFT].key),9,"BlueShift");
902  objFormatName(&(Private[BLUEFUZZ].key),8,"BlueFuzz");
904  objFormatName(&(Private[STDHW].key),5,"StdHW");
905  objFormatArray(&(Private[STDHW].value),0,NULL);
906  objFormatName(&(Private[STDVW].key),5,"StdVW");
907  objFormatArray(&(Private[STDVW].value),0,NULL);
908  objFormatName(&(Private[STEMSNAPH].key),9,"StemSnapH");
909  objFormatArray(&(Private[STEMSNAPH].value),0,NULL);
910  objFormatName(&(Private[STEMSNAPV].key),9,"StemSnapV");
911  objFormatArray(&(Private[STEMSNAPV].value),0,NULL);
912  objFormatName(&(Private[FORCEBOLD].key),9,"ForceBold");
914  objFormatName(&(Private[LANGUAGEGROUP].key),13,"LanguageGroup");
916  objFormatName(&(Private[LENIV].key),5,"LenIV");
918  objFormatName(&(Private[RNDSTEMUP].key),9,"RndStemUp");
920  objFormatName(&(Private[EXPANSIONFACTOR].key),9,"ExpansionFactor");
921  objFormatReal(&(Private[EXPANSIONFACTOR].value),
923  return(SCAN_OK);
924 }
925 /***================================================================***/
926 /**********************************************************************/
927 /* GetType1Blues(fontP) */
928 /* */
929 /* Routine to support font-level hints. */
930 /* */
931 /* Gets all the Blues information from the Private dictionary */
932 /* for the font. */
933 /* */
934 /* */
935 /**********************************************************************/
936 static int GetType1Blues(psfont *fontP)
937 {
938  psdict *PrivateDictP; /* the Private dict relating to hints */
939  struct blues_struct *blues; /* ptr for the blues struct we will allocate */
940  int i;
941  psobj *HintEntryP;
942 
943 
944 
945  /* get the Private dictionary pointer */
946  PrivateDictP = fontP->Private;
947 
948  /* allocate the memory for the blues structure */
949  blues = (struct blues_struct *) vm_alloc(sizeof(struct blues_struct));
950 
951  if (!blues) return(SCAN_OUT_OF_MEMORY);
952 
953  /* Make fontP's blues ptr point to this newly allocated structure. */
954  fontP->BluesP = blues;
955 
956  /* fill in the BlueValues array */
957  HintEntryP = &(PrivateDictP[BLUEVALUES].value);
958  /* check to see if the entry exists and if it's an array */
959  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
960  blues->numBlueValues = 0;
961  else {
962  /* get the number of values in the array */
963  if (HintEntryP->len > NUMBLUEVALUES) {
965  } else
966  blues->numBlueValues = HintEntryP->len;
967  for (i = 0; i<= blues->numBlueValues-1; ++i) {
968  if (objPIsInteger(&HintEntryP->data.arrayP[i]))
969  blues->BlueValues[i] =
970  HintEntryP->data.arrayP[i].data.integer;
971  else if (objPIsReal(&HintEntryP->data.arrayP[i]))
972  blues->BlueValues[i] =
973  HintEntryP->data.arrayP[i].data.real;
974  else
975  blues->BlueValues[i] = 0;
976  }
977  }
978 
979  /* fill in the OtherBlues array */
980  HintEntryP = &(PrivateDictP[OTHERBLUES].value);
981  /* check to see if the entry exists and if it's an array */
982  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
983  blues->numOtherBlues = 0;
984  else {
985  /* get the number of values in the array */
986  if (HintEntryP->len > NUMOTHERBLUES) {
988  } else
989  blues->numOtherBlues = HintEntryP->len;
990  for (i = 0; i<= blues->numOtherBlues-1; ++i) {
991  if (objPIsInteger(&HintEntryP->data.arrayP[i]))
992  blues->OtherBlues[i] =
993  HintEntryP->data.arrayP[i].data.integer;
994  else if (objPIsReal(&HintEntryP->data.arrayP[i]))
995  blues->OtherBlues[i] =
996  HintEntryP->data.arrayP[i].data.real;
997  else
998  blues->OtherBlues[i] = 0;
999  }
1000  }
1001 
1002  /* fill in the FamilyBlues array */
1003  HintEntryP = &(PrivateDictP[FAMILYBLUES].value);
1004  /* check to see if the entry exists and if it's an array */
1005  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
1006  blues->numFamilyBlues = 0;
1007  else {
1008  /* get the number of values in the array */
1009  if (HintEntryP->len > NUMFAMILYBLUES) {
1011  } else
1012  blues->numFamilyBlues = HintEntryP->len;
1013  for (i = 0; i<= blues->numFamilyBlues-1; ++i) {
1014  if (objPIsInteger(&HintEntryP->data.arrayP[i]))
1015  blues->FamilyBlues[i] =
1016  HintEntryP->data.arrayP[i].data.integer;
1017  else if (objPIsReal(&HintEntryP->data.arrayP[i]))
1018  blues->FamilyBlues[i] =
1019  HintEntryP->data.arrayP[i].data.real;
1020  else
1021  blues->FamilyBlues[i] = 0;
1022  }
1023  }
1024 
1025  /* fill in the FamilyOtherBlues array */
1026  HintEntryP = &(PrivateDictP[FAMILYOTHERBLUES].value);
1027  /* check to see if the entry exists and if it's an array */
1028  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
1030  else {
1031  /* get the number of values in the array */
1032  if (HintEntryP->len > NUMFAMILYOTHERBLUES) {
1034  } else
1035  blues->numFamilyOtherBlues = HintEntryP->len;
1036  for (i = 0; i<= blues->numFamilyOtherBlues-1; ++i) {
1037  if (objPIsInteger(&HintEntryP->data.arrayP[i]))
1039  HintEntryP->data.arrayP[i].data.integer;
1040  else if (objPIsReal(&HintEntryP->data.arrayP[i]))
1042  HintEntryP->data.arrayP[i].data.real;
1043  else
1044  blues->FamilyOtherBlues[i] = 0;
1045  }
1046  }
1047 
1048  /* fill in the StemSnapH array */
1049  HintEntryP = &(PrivateDictP[STEMSNAPH].value);
1050  /* check to see if the entry exists and if it's an array */
1051  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
1052  blues->numStemSnapH = 0;
1053  else {
1054  /* get the number of values in the array */
1055  if (HintEntryP->len > NUMSTEMSNAPH) {
1057  } else
1058  blues->numStemSnapH = HintEntryP->len;
1059  for (i = 0; i<= blues->numStemSnapH-1; ++i) {
1060  if (objPIsInteger(&HintEntryP->data.arrayP[i]))
1061  blues->StemSnapH[i] =
1062  HintEntryP->data.arrayP[i].data.integer;
1063  else if (objPIsReal(&HintEntryP->data.arrayP[i]))
1064  blues->StemSnapH[i] =
1065  HintEntryP->data.arrayP[i].data.real;
1066  else
1067  blues->StemSnapH[i] = 0;
1068  }
1069  }
1070 
1071  /* fill in the StemSnapV array */
1072  HintEntryP = &(PrivateDictP[STEMSNAPV].value);
1073  /* check to see if the entry exists and if it's an array */
1074  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
1075  blues->numStemSnapV = 0;
1076  else {
1077  /* get the number of values in the array */
1078  if (HintEntryP->len > NUMSTEMSNAPV) {
1080  } else
1081  blues->numStemSnapV = HintEntryP->len;
1082  for (i = 0; i<= blues->numStemSnapV-1; ++i) {
1083  if (objPIsInteger(&HintEntryP->data.arrayP[i]))
1084  blues->StemSnapV[i] =
1085  HintEntryP->data.arrayP[i].data.integer;
1086  else if (objPIsReal(&HintEntryP->data.arrayP[i]))
1087  blues->StemSnapV[i] =
1088  HintEntryP->data.arrayP[i].data.real;
1089  else
1090  blues->StemSnapV[i] = 0;
1091  }
1092  }
1093 
1094  /* fill in the StdVW array */
1095  HintEntryP = &(PrivateDictP[STDVW].value);
1096  /* check to see if the entry exists and if it's an array */
1097  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
1098  /* a value of zero signifies no entry */
1099  blues->StdVW = 0;
1100  else {
1101  if (HintEntryP->len > NUMSTDVW) {
1102  }
1103  if (objPIsInteger(&HintEntryP->data.arrayP[0]))
1104  blues->StdVW = HintEntryP->data.arrayP[0].data.integer;
1105  else if (objPIsReal(&HintEntryP->data.arrayP[0]))
1106  blues->StdVW = HintEntryP->data.arrayP[0].data.real;
1107  else
1108  blues->StdVW = 0;
1109  }
1110 
1111  /* fill in the StdHW array */
1112  HintEntryP = &(PrivateDictP[STDHW].value);
1113  /* check to see if the entry exists and if it's an array */
1114  if ( !objPIsArray(HintEntryP) || (HintEntryP->len == 0 ))
1115  /* a value of zero signifies no entry */
1116  blues->StdHW = 0;
1117  else {
1118  if (HintEntryP->len > NUMSTDHW) {
1119  }
1120  if (objPIsInteger(&HintEntryP->data.arrayP[0]))
1121  blues->StdHW = HintEntryP->data.arrayP[0].data.integer;
1122  else if (objPIsReal(&HintEntryP->data.arrayP[0]))
1123  blues->StdHW = HintEntryP->data.arrayP[0].data.real;
1124  else
1125  blues->StdHW = 0;
1126  }
1127 
1128 
1129  /* get the ptr to the BlueScale entry */
1130  HintEntryP = &(PrivateDictP[BLUESCALE].value);
1131  /* put the BlueScale in the blues structure */
1132  if (objPIsInteger(HintEntryP)) /* Must be integer! */
1133  blues->BlueScale = HintEntryP->data.integer;
1134  else if (objPIsReal(HintEntryP)) /* Error? */
1135  blues->BlueScale = HintEntryP->data.real;
1136  else
1138 
1139  /* get the ptr to the BlueShift entry */
1140  HintEntryP = &(PrivateDictP[BLUESHIFT].value);
1141  if (objPIsInteger(HintEntryP)) /* Must be integer! */
1142  blues->BlueShift = HintEntryP->data.integer;
1143  else if (objPIsReal(HintEntryP)) /* Error? */
1144  blues->BlueShift = HintEntryP->data.real;
1145  else
1147 
1148  /* get the ptr to the BlueFuzz entry */
1149  HintEntryP = &(PrivateDictP[BLUEFUZZ].value);
1150  if (objPIsInteger(HintEntryP)) /* Must be integer! */
1151  blues->BlueFuzz = HintEntryP->data.integer;
1152  else if (objPIsReal(HintEntryP)) /* Error? */
1153  blues->BlueFuzz = HintEntryP->data.real;
1154  else
1156 
1157  /* get the ptr to the ForceBold entry */
1158  HintEntryP = &(PrivateDictP[FORCEBOLD].value);
1159  if (objPIsBoolean(HintEntryP)) /* Must be integer! */
1160  blues->ForceBold = HintEntryP->data.boolean;
1161  else
1163 
1164  /* get the ptr to the LanguageGroup entry */
1165  HintEntryP = &(PrivateDictP[LANGUAGEGROUP].value);
1166  if (objPIsInteger(HintEntryP)) /* Must be integer! */
1167  blues->LanguageGroup = HintEntryP->data.integer;
1168  else
1170 
1171  /* get the ptr to the RndStemUp entry */
1172  HintEntryP = &(PrivateDictP[RNDSTEMUP].value);
1173  if (objPIsBoolean(HintEntryP)) /* Must be integer! */
1174  blues->RndStemUp = HintEntryP->data.boolean;
1175  else
1177 
1178  /* get the ptr to the lenIV entry */
1179  HintEntryP = &(PrivateDictP[LENIV].value);
1180  if (objPIsInteger(HintEntryP)) /* Must be integer! */
1181  blues->lenIV = HintEntryP->data.integer;
1182  else
1184 
1185  /* get the ptr to the ExpansionFactor entry */
1186  HintEntryP = &(PrivateDictP[EXPANSIONFACTOR].value);
1187  if (objPIsInteger(HintEntryP))
1188  blues->ExpansionFactor = HintEntryP->data.integer;
1189  else if (objPIsReal(HintEntryP))
1190  blues->ExpansionFactor = HintEntryP->data.real;
1191  else
1193  return(SCAN_OK);
1194 }
1195 /**********************************************************************/
1196 /* GetType1CharString(fontP,code) */
1197 /* */
1198 /* Look up code in the standard encoding vector and return */
1199 /* the charstring associated with the character name. */
1200 /* */
1201 /* fontP is the psfont structure. */
1202 /* */
1203 /* Returns a psobj (string) */
1204 /**********************************************************************/
1205 psobj *GetType1CharString(psfont *fontP, unsigned char code)
1206 {
1207  int N; /* the 'Nth' entry in the CharStrings */
1208  psobj *charnameP; /* points to psobj that is name of character*/
1209 
1210  psdict *CharStringsDictP; /* dictionary with char strings */
1211  psobj *theStringP; /* the definition for the code */
1212 
1213 
1214 
1215  if (StdEncArrayP == NULL) {
1216  return(NULL);
1217  }
1218  /* use the code to index into the standard encoding vector */
1219  charnameP = &(StdEncArrayP[code]);
1220 
1221  /* test if the encoding array points to a name */
1222  if (!(objPIsName(charnameP)) ) {
1223  return(NULL);
1224  }
1225 
1226  /* Now that we have the character name out of the standardencoding */
1227  /* get the character definition out of the current font */
1228  CharStringsDictP = fontP->CharStringsP;
1229 
1230  /* search the chars string for this charname as key */
1231  N = SearchDictName(CharStringsDictP,charnameP);
1232  if (N<=0) {
1233  return(NULL);
1234  }
1235  /* OK, the nth item is the psobj that is the string for this char */
1236  theStringP = &(CharStringsDictP[N].value);
1237 
1238  return(theStringP);
1239 }
1240 
1241 /***================================================================***/
1242 /*
1243  * FindDictValue
1244  */
1245 /***================================================================***/
1246 
1247 static int FindDictValue(psdict *dictP)
1248 {
1249  psobj LitName;
1250  int N;
1251  int V;
1252 
1253  /* we have just scanned a token and it is a literal name */
1254  /* need to check if that name is in Private dictionary */
1256  /* is it in the dictP */
1257  N = SearchDictName(dictP,&LitName);
1258  /* if found */
1259  if ( N > 0 ) {
1260  /* what type */
1261  switch (dictP[N].value.type) {
1262  case OBJ_ENCODING:
1263  V = getEncoding(&(dictP[N].value));
1264  if ( V != SCAN_OK ) return(V);
1265  break;
1266  case OBJ_ARRAY:
1267  V = getArray(&(dictP[N].value));
1268  if ( V != SCAN_OK ) return(V);
1269  break;
1270  case OBJ_INTEGER:
1271  /* next value in integer */
1272  dictP[N].value.data.integer = getInt();
1273  if (rc) return(rc); /* if next token was not an Int */
1274  break;
1275  case OBJ_REAL:
1276  /* next value must be real or int, store as a real */
1277  scan_token(inputP);
1278  if (tokenType == TOKEN_REAL) {
1279  dictP[N].value.data.real = tokenValue.real;
1280  }
1281  else
1282  if (tokenType == TOKEN_INTEGER) {
1283  dictP[N].value.data.real = tokenValue.integer;
1284  }
1285  else return(SCAN_ERROR);
1286  break;
1287  case OBJ_NAME:
1289  if ( V != SCAN_OK ) return(V);
1290  if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
1292  break;
1293  case OBJ_STRING:
1295  if ( V != SCAN_OK ) return(V);
1296  if (!(vm_alloc(tokenLength)) ) return(SCAN_OUT_OF_MEMORY);
1298  break;
1299  case OBJ_BOOLEAN:
1300  scan_token(inputP);
1301  if (tokenType != TOKEN_NAME) {
1302  return(SCAN_ERROR);
1303  }
1304  if (0 == strncmp(tokenStartP,"true",4) ) {
1305  dictP[N].value.data.boolean =TRUE;
1306  }
1307  else
1308  if (0 == strncmp(tokenStartP,"false",5) ) {
1309  dictP[N].value.data.boolean =FALSE;
1310  }
1311  else return(SCAN_ERROR);
1312  break;
1313 
1314  default:
1315  return(SCAN_ERROR);
1316  break;
1317  }
1318  }
1319  /* Name is not in dictionary. That is ok. */
1320  return(SCAN_OK);
1321 
1322 }
1323 /***================================================================***/
1324 
1325 /*
1326  * -------------------------------------------------------------------
1327  * Scan the next token and convert it into an object
1328  * Result is placed on the Operand Stack as next object
1329  * -------------------------------------------------------------------
1330  */
1332 {
1333 
1334 
1335  char filename[128];
1336  char filetype[3];
1337  FILE *fileP;
1338  const char *nameP;
1339  int namelen;
1340  int V;
1341  int i;
1342  boolean starthex80;
1343 
1344  starthex80 = FALSE;
1345  filetype[0] = 'r';
1346  filetype[1] = 'b';
1347  filetype[2] = '\0';
1348  /* copy the filename and remove leading or trailing blanks */
1349  /* point to name and search for leading blanks */
1350  nameP= FontP->FontFileName.data.nameP;
1351  namelen = FontP->FontFileName.len;
1352  while (nameP[0] == ' ') {
1353  nameP++;
1354  namelen--;
1355  }
1356  /* now remove any trailing blanks */
1357  while ((namelen>0) && ( nameP[namelen-1] == ' ')) {
1358  namelen--;
1359  }
1360  strncpy(filename,nameP,namelen);
1361  filename[namelen] = '\0';
1362  /* file name is now constructed */
1365 
1366  inputP = &inputFile;
1367  if ((fileP = fopen(filename,filetype))) {
1368  /* get the first byte of file */
1369  V = getc(fileP);
1370  /* if file starts with x'80' then skip next 5 bytes */
1371  if ( V == 0X80 ) {
1372  for (i=0;i<5;i++) V = getc(fileP);
1373  starthex80 = TRUE;
1374  }
1375  else ungetc(V,fileP);
1376  objFormatFile(inputP,fileP);
1377  }
1378  else {
1379  return(SCAN_FILE_OPEN_ERROR);
1380  };
1381 
1382  WantFontInfo = TRUE;
1383  InPrivateDict = FALSE;
1384  TwoSubrs = FALSE;
1385  rc = BuildFontInfo(FontP);
1386  if (rc != 0) return(rc);
1387 
1388  /* Assume everything will be OK */
1389  rc = 0;
1390 
1391  /* Loop until complete font is read */
1392  do {
1393  /* Scan the next token */
1394  scan_token(inputP);
1395 
1396  /* ==> tokenLength, tokenTooLong, tokenType, and tokenValue are */
1397  /* now set */
1398 
1399  switch (tokenType) {
1400  case TOKEN_EOF:
1401  case TOKEN_NONE:
1402  case TOKEN_INVALID:
1403  /* in this case we are done */
1404  if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
1405  rc = SCAN_ERROR;
1406  break;
1407  case TOKEN_LITERAL_NAME:
1408  /* Look up the name */
1409  tokenStartP[tokenLength] = '\0';
1410  if (InPrivateDict ) {
1411  if (0== strncmp(tokenStartP,"Subrs",5) ) {
1412  rc = BuildSubrs(FontP);
1413  break;
1414  }
1415  if (0== strncmp(tokenStartP,"CharStrings",11) ) {
1417  if ( (rc == SCAN_OK) ||(rc == SCAN_END) ) {
1418  fclose(inputP->data.fileP);
1419  /* Build the Blues Structure */
1420  rc = GetType1Blues(FontP);
1421  /* whatever the return code, return it */
1422  /* all the work is done. This is the normal exit.*/
1423  return(rc);
1424  }
1425  break;
1426  }
1428  /* we are not going to report errors */
1429  /* Sometimes the font file may test a value such as */
1430  /* testing to see if the font is alreadly loaded with */
1431  /* same UniqueID. We would faile on /UniqueID get */
1432  /* because we are expecting a int to follow UniqueID*/
1433  /* If the correct object type does not follow a Name*/
1434  /* then we will skip over it without reporting error*/
1435  rc = SCAN_OK;
1436  break;
1437  } /* end of reading Private dictionary */
1438  else
1439  if (0== strncmp(tokenStartP,"Private",7) ) {
1440  InPrivateDict = TRUE;
1441  rc = BuildPrivate(FontP);
1442  break;
1443  }
1444  else
1445  if (WantFontInfo) {
1447  /* we are not going to report errors */
1448  rc = SCAN_OK;
1449  break;
1450  }
1451  break;
1452  case TOKEN_NAME:
1453  if (0 == strncmp(tokenStartP,"eexec",5) ) {
1454  /* if file started with x'80', check next 5 bytes */
1455  if (starthex80) {
1456  V = getc(fileP);
1457  if ( V == 0X80 ) {
1458  for (i=0;i<5;i++) V = getc(fileP);
1459  }
1460  else ungetc(V,fileP);
1461  }
1463  if (filterFile.data.fileP == NULL) {
1465  return(SCAN_FILE_OPEN_ERROR);
1466  }
1467  inputP = &filterFile;
1468 
1469  WantFontInfo = FALSE;
1470  }
1471  break;
1472  }
1473 
1474  }
1475  while (rc ==0);
1476  fclose(inputP->data.fileP);
1477  if (tokenTooLong) return(SCAN_OUT_OF_MEMORY);
1478  return(rc);
1479 }
1480 
int code
Definition: aftopl.c:52
#define name
#define DEFAULTLANGUAGEGROUP
Definition: blues.h:55
#define NUMOTHERBLUES
Definition: blues.h:38
#define DEFAULTLENIV
Definition: blues.h:57
#define DEFAULTFORCEBOLD
Definition: blues.h:54
#define NUMFAMILYBLUES
Definition: blues.h:39
#define DEFAULTBLUESCALE
Definition: blues.h:49
#define NUMBLUEVALUES
Definition: blues.h:37
#define NUMFAMILYOTHERBLUES
Definition: blues.h:40
#define DEFAULTBLUESHIFT
Definition: blues.h:50
#define NUMSTEMSNAPH
Definition: blues.h:41
#define DEFAULTEXPANSIONFACTOR
Definition: blues.h:58
#define NUMSTDHW
Definition: blues.h:43
#define DEFAULTRNDSTEMUP
Definition: blues.h:56
#define NUMSTDVW
Definition: blues.h:44
#define NUMSTEMSNAPV
Definition: blues.h:42
#define DEFAULTBLUEFUZZ
Definition: blues.h:51
@ FALSE
Definition: dd.h:101
@ TRUE
Definition: dd.h:102
#define fopen
Definition: xxstdio.h:21
#define fread
Definition: xxstdio.h:25
char * strncpy()
int SearchDictName(psdict *dictP, psobj *keyP)
Definition: fontfcn.c:66
psfont * FontP
Definition: fontfcn.c:56
#define FAMILYBLUES
Definition: fontfcn.h:108
#define SCAN_OUT_OF_MEMORY
Definition: fontfcn.h:76
#define STDHW
Definition: fontfcn.h:113
#define UNDERLINETHICKNESS
Definition: fontfcn.h:101
#define STEMSNAPV
Definition: fontfcn.h:116
#define FAMILYNAME
Definition: fontfcn.h:96
#define ISFIXEDPITCH
Definition: fontfcn.h:99
#define STROKEWIDTH
Definition: fontfcn.h:92
#define RNDSTEMUP
Definition: fontfcn.h:120
#define FONTTYPENUM
Definition: fontfcn.h:88
#define FONTBBOX
Definition: fontfcn.h:90
#define SCAN_OK
Definition: fontfcn.h:73
void objFormatName(psobj *, int, const char *)
Definition: util.c:158
#define SCAN_ERROR
Definition: fontfcn.h:75
#define BLUESHIFT
Definition: fontfcn.h:111
#define BLUEFUZZ
Definition: fontfcn.h:112
#define SCAN_FILE_EOF
Definition: fontfcn.h:74
#define OTHERBLUES
Definition: fontfcn.h:107
#define BLUEVALUES
Definition: fontfcn.h:106
#define LANGUAGEGROUP
Definition: fontfcn.h:118
#define ITALICANGLE
Definition: fontfcn.h:98
#define STDVW
Definition: fontfcn.h:114
#define FONTMATRIX
Definition: fontfcn.h:89
#define EXPANSIONFACTOR
Definition: fontfcn.h:121
#define PAINTTYPE
Definition: fontfcn.h:87
#define SCAN_END
Definition: fontfcn.h:80
#define UNDERLINEPOSITION
Definition: fontfcn.h:100
#define WEIGHT
Definition: fontfcn.h:97
#define UNIQUEID
Definition: fontfcn.h:91
#define NOTICE
Definition: fontfcn.h:94
#define STEMSNAPH
Definition: fontfcn.h:115
#define FAMILYOTHERBLUES
Definition: fontfcn.h:109
#define BLUESCALE
Definition: fontfcn.h:110
#define FULLNAME
Definition: fontfcn.h:95
#define SCAN_FILE_OPEN_ERROR
Definition: fontfcn.h:77
@ VERSION
Definition: genrb.cpp:69
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
#define I(x, y, z)
Definition: md5.c:55
#define FORCEBOLD
Definition: tt_aux.c:129
#define fclose
Definition: debug.h:100
#define getc
Definition: line.c:39
static struct blues_struct * blues
Definition: type1.c:217
#define objPIsBoolean(o)
Definition: util.h:162
#define OBJ_INTEGER
Definition: util.h:93
#define vm_next_byte()
Definition: util.h:84
#define OBJ_ARRAY
Definition: util.h:96
#define OBJ_NAME
Definition: util.h:98
#define OBJ_STRING
Definition: util.h:97
#define vm_free_bytes()
Definition: util.h:85
#define OBJ_REAL
Definition: util.h:94
#define objPIsReal(o)
Definition: util.h:161
struct ps_dict psdict
#define objPIsArray(o)
Definition: util.h:163
#define objPIsName(o)
Definition: util.h:165
#define objPIsInteger(o)
Definition: util.h:160
#define OBJ_BOOLEAN
Definition: util.h:95
#define OBJ_ENCODING
Definition: util.h:100
int strncmp()
char * filename[256]
Definition: pbmtopk.c:46
#define V
Definition: pgmcrater.c:68
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
@ FONTNAME
Definition: pl-parser.h:78
tokenType
void objFormatEncoding(struct ps_obj *objP, int length, struct ps_obj *valueP)
Definition: util.c:121
void objFormatReal(struct ps_obj *objP, double value)
char * vm_alloc(unsigned int bytes)
Definition: util.c:60
void objFormatFile(struct ps_obj *objP, struct _iobuf *valueP)
void objFormatInteger(struct ps_obj *objP, int value)
Definition: util.c:85
void objFormatBoolean(struct ps_obj *objP, int value)
void objFormatArray(struct ps_obj *objP, int length, struct ps_obj *valueP)
Definition: util.c:133
void objFormatString(struct ps_obj *objP, int length, char *valueP)
Definition: util.c:146
util c int vm_init(void)
Definition: util.c:46
struct F_FILE * T1eexec(struct F_FILE *f)
Definition: t1io.c:175
void scan_token(struct ps_obj *inputP)
Definition: token.c:1120
static int getEncoding(psobj *arrayP)
Definition: scanfont.c:478
static int BuildCharStrings(psfont *FontP)
Definition: scanfont.c:768
static psobj inputFile
Definition: scanfont.c:50
static int BuildSubrs(psfont *FontP)
Definition: scanfont.c:694
static psobj filterFile
Definition: scanfont.c:51
static psobj * MakeEncodingArrayP(EncodingTable *encodingTable)
Definition: scanfont.c:417
static int BuildFontInfo(psfont *fontP)
Definition: scanfont.c:827
static int FindDictValue(psdict *dictP)
Definition: scanfont.c:1247
psobj * ISOLatin1EncArrayP
Definition: scanfont.c:415
static int GetType1Blues(psfont *fontP)
Definition: scanfont.c:936
static int getNextValue(int valueType)
Definition: scanfont.c:449
static int BuildPrivate(psfont *fontP)
Definition: scanfont.c:878
static int getName(const char *nameP)
Definition: scanfont.c:632
static EncodingTable ISO8859Enc[]
Definition: scanfont.c:220
psobj * GetType1CharString(psfont *fontP, unsigned char code)
Definition: scanfont.c:1205
static psobj * StdEncArrayP
Definition: scanfont.c:414
boolean Init_BuiltInEncoding(void)
Definition: scanfont.c:440
static int getNbytes(int N)
Definition: scanfont.c:646
static EncodingTable StdEnc[]
Definition: scanfont.c:67
static psobj * inputP
Definition: scanfont.c:52
static int getLiteralName(psobj *nameObjP)
Definition: scanfont.c:666
static boolean InPrivateDict
Definition: scanfont.c:47
static int rc
Definition: scanfont.c:46
static boolean WantFontInfo
Definition: scanfont.c:48
static boolean TwoSubrs
Definition: scanfont.c:49
int scan_font(psfont *FontP)
Definition: scanfont.c:1331
static int getInt(void)
Definition: scanfont.c:461
static int getArray(psobj *arrayP)
Definition: scanfont.c:591
const char * name
Definition: scanfont.c:64
int FamilyOtherBlues[10]
Definition: blues.h:71
DOUBLE StdVW
Definition: blues.h:76
DOUBLE StemSnapH[12]
Definition: blues.h:78
int BlueShift
Definition: blues.h:73
int OtherBlues[10]
Definition: blues.h:67
DOUBLE ExpansionFactor
Definition: blues.h:85
int numBlueValues
Definition: blues.h:64
int numFamilyOtherBlues
Definition: blues.h:70
int numStemSnapV
Definition: blues.h:79
DOUBLE StdHW
Definition: blues.h:75
DOUBLE BlueScale
Definition: blues.h:72
int BlueValues[14]
Definition: blues.h:65
int numStemSnapH
Definition: blues.h:77
int numOtherBlues
Definition: blues.h:66
int BlueFuzz
Definition: blues.h:74
int ForceBold
Definition: blues.h:81
int RndStemUp
Definition: blues.h:83
int LanguageGroup
Definition: blues.h:82
int lenIV
Definition: blues.h:84
DOUBLE StemSnapV[12]
Definition: blues.h:80
int FamilyBlues[14]
Definition: blues.h:69
int numFamilyBlues
Definition: blues.h:68
Definition: inftrees.h:24
Definition: mendex.h:20
psdict * CharStringsP
Definition: fontfcn.h:35
psobj Subrs
Definition: fontfcn.h:34
psdict * fontInfoP
Definition: fontfcn.h:37
psdict * Private
Definition: fontfcn.h:36
struct blues_struct * BluesP
Definition: fontfcn.h:38
psobj FontFileName
Definition: fontfcn.h:33
Definition: util.h:120
union ps_value data
Definition: util.h:124
unsigned short len
Definition: util.h:123
#define LENIV
Definition: t1part.c:126
#define FILE
Definition: t1stdio.h:34
#define ungetc(c, f)
Definition: t1stdio.h:106
*job_name strlen((char *) job_name) - 4)
#define key
Definition: tex2xindy.c:753
long unsigned N
Definition: tex4ht.c:2765
psvalue tokenValue
Definition: token.c:52
int tokenLength
Definition: token.c:49
boolean tokenTooLong
Definition: token.c:50
char * tokenStartP
Definition: token.c:45
#define TOKEN_INTEGER
Definition: token.h:51
#define TOKEN_NAME
Definition: token.h:49
#define TOKEN_REAL
Definition: token.h:52
#define TOKEN_STRING
Definition: token.h:55
#define TOKEN_INVALID
Definition: token.h:37
#define TOKEN_LEFT_BRACKET
Definition: token.h:47
#define TOKEN_RIGHT_BRACKET
Definition: token.h:48
#define TOKEN_LEFT_BRACE
Definition: token.h:45
#define TOKEN_NONE
Definition: token.h:40
#define TOKEN_RIGHT_BRACE
Definition: token.h:46
#define TOKEN_EOF
Definition: token.h:39
#define TOKEN_LITERAL_NAME
Definition: token.h:50
const char * nameP
Definition: util.h:113
int boolean
Definition: util.h:110
FILE * fileP
Definition: util.h:114
char * valueP
Definition: util.h:106
struct ps_obj * arrayP
Definition: util.h:111
float real
Definition: util.h:109
int integer
Definition: util.h:108
Definition: obx.h:51