1: /*
   2:  * Copyright (c) 1984, 1985 Xerox Corp.
   3:  *
   4:  *  create TeX font files
   5:  *
   6:  * HISTORY
   7:  *	Dec, 1985	Lee Moore, Xerox Webster Research Center
   8:  *		Created.
   9:  *
  10:  */
  11: 
  12: #include <stdio.h>
  13: #include <math.h>
  14: #include "stack.h"
  15: #include "token.h"
  16: #include "config.h"
  17: #include "ipmetrics.h"
  18: #include "tex.h"
  19: 
  20: #define TRUE    1
  21: #define FALSE   0
  22: 
  23: #define public
  24: #define private static
  25: 
  26: public char *malloc();
  27: 
  28: public char *DeviceName,
  29:         *LibraryDirectory;
  30: 
  31: public
  32: CleanUpTeX(configChain)
  33:     struct FontConfig *configChain; {
  34:     struct FontConfig *p;
  35: 
  36:     WriteTeXInstallFile(configChain);
  37:     WriteTeXCleanUpFile(configChain);
  38: 
  39:     for( p = configChain; p != NULL; p = p->Next )
  40:         if( !p->SeenFlag )
  41:             printf("couldn't find: %s/%s/%s\n",
  42:                 p->FontPt1, p->FontPt2, p->FontPt3);
  43: }
  44: 
  45: 
  46: private
  47: WriteTeXInstallFile(configChain)
  48:     struct FontConfig *configChain; {
  49:     int i;
  50:     FILE *installFile;
  51:     struct FontConfig *p;
  52: 
  53:     if( (installFile = fopen(INSTALLNAME, "w")) == NULL ) {
  54:         fprintf(stderr, "can't open the file 'install' for writing\n");
  55:         return; }
  56: 
  57:     fprintf(installFile, "#! /bin/sh\n");
  58:     fprintf(installFile, "if test ! -d %s/fonts/%s\n", LibraryDirectory, DeviceName);
  59:     fprintf(installFile, "  then\n");
  60:     fprintf(installFile, "    mkdir %s/fonts/%s\n", LibraryDirectory, DeviceName);
  61:     fprintf(installFile, "  fi\n");
  62:     fprintf(installFile, "if test ! -d %s/fonts/%s/tex\n", LibraryDirectory, DeviceName);
  63:     fprintf(installFile, "  then\n");
  64:     fprintf(installFile, "    mkdir %s/fonts/%s/tex\n", LibraryDirectory, DeviceName);
  65:     fprintf(installFile, "  fi\n");
  66: 
  67: 
  68:     for( p = configChain; p != NULL; p = p->Next )
  69:         if( p->SeenFlag ) {
  70:                 fprintf(installFile, "cp %s.pl %s/fonts/%s/tex\n",
  71:                 p->TroffName, LibraryDirectory, DeviceName);
  72:             fprintf(installFile, "pltotf %s.pl %s.tfm\n",
  73:                 p->TroffName, p->TroffName); }
  74: 
  75:     fprintf(installFile, "cd %s/fonts/%s/tex\n", LibraryDirectory,
  76:             DeviceName);
  77:     fclose(installFile);
  78:     chmod(INSTALLNAME, 0755); }
  79: 
  80: 
  81: /*
  82:  * write a file that rm's all the files created by this program
  83:  */
  84: 
  85: private
  86: WriteTeXCleanUpFile(configChain)
  87:     struct FontConfig *configChain; {
  88:     int i;
  89:     FILE *cleanupFile;
  90:     struct FontConfig *p;
  91: 
  92:     if( (cleanupFile = fopen(CLEANUPNAME, "w")) == NULL ) {
  93:         fprintf(stderr, "can't open the file 'cleanup' for writing\n");
  94:         return; }
  95: 
  96:     fprintf(cleanupFile, "#! /bin/sh\n");
  97: 
  98:     for( p = configChain; p != NULL; p = p->Next )
  99:         if( p->SeenFlag )
 100:                 fprintf(cleanupFile, "rm %s.pl\n", p->TroffName);
 101: 
 102:     fprintf(cleanupFile, "rm %s\n", CLEANUPNAME);
 103:     fprintf(cleanupFile, "rm %s\n", INSTALLNAME);
 104:     fclose(cleanupFile);
 105:     chmod(CLEANUPNAME, 0755); }
 106: 
 107: 
 108: PerTeXFont(configChain, fontDescVec)
 109: struct FontConfig *configChain;
 110: unsigned char *fontDescVec; {
 111:     unsigned char *charMetricsProperty,
 112:               *metricsProperty,
 113:               *width,
 114:               *charMetric;
 115:     char iSender[MAXTOKENSIZE],
 116:          iCharName[MAXTOKENSIZE],
 117:          fileType[MAXTOKENSIZE],
 118:         *fontName[40],
 119:          metricFileName[40],
 120:          iCharSet[MAXTOKENSIZE],
 121:          iCharCode[MAXTOKENSIZE];
 122:     FILE *descFile,
 123:          *modelFile;
 124:     struct FontConfig *p;
 125:     struct TokenState *ts;
 126:     int charSet,
 127:         charNumber,
 128:         charIndex;
 129:     double xWidth;
 130: 
 131:     if( !GetFontNameProperty(fontDescVec, fontName) ) {
 132:         fprintf(stderr, "ipmetrics: can't get font name\n");
 133:         return;
 134:     }
 135: 
 136:     if( (charMetricsProperty = GetStringProp("characterMetrics", fontDescVec))
 137:             == NULL ) {
 138:         printf("ipmetrics: can't find 'characterMetrics' property\n");
 139:         return; }
 140: 
 141:     for( p = configChain; p != NULL; p = p->Next ) {
 142:         if( !(strcmp(p->FontPt1,  fontName[0]) == 0 &&
 143:                 strcmp(p->FontPt2,  fontName[1]) == 0 &&
 144:                 strcmp(p->FontPt3,  fontName[2]) == 0) )
 145:             continue;
 146: 
 147:         sprintf(metricFileName, "%s.pl", p->TroffName);
 148: 
 149:         if( (descFile = fopen(metricFileName, "w")) == NULL ) {
 150:             printf("ipmetrics: can't open %s for writing\n", metricFileName);
 151:             return;}
 152: 
 153:         if( (modelFile = fopen(p->MapFile, "r")) == NULL ) {
 154:             printf("ipmetrics: can't open %s for reading\n", p->MapFile);
 155:             return;}
 156: 
 157:         p->SeenFlag = TRUE;
 158: /*		(void) strcpy(malloc((unsigned) 40), p->TroffName);	*/
 159: 
 160:         ts = InitTokenStream(modelFile);
 161: 
 162:         fprintf(descFile, "(COMMENT %s/%s/%s for Interpress device %s\n", p->FontPt1, p->FontPt2, p->FontPt3, DeviceName);
 163: 
 164:         fprintf(descFile, " for interpress device '%s')\n", DeviceName);
 165:         fprintf(descFile, "(FAMILY %s)\n", p->TroffName);
 166:         fprintf(descFile, "(DESIGNSIZE D 10)\n");
 167:         fprintf(descFile, "(DESIGNUNITS D 1)\n");
 168: 
 169:         GetToken(ts, fileType, MAXTOKENSIZE);
 170:         /* file type doesn't mean much in this case... */
 171: 
 172:         while( !EndOfFile(ts) ) {
 173:             GetToken(ts, iCharSet, MAXTOKENSIZE);
 174:             sscanf(iCharSet, "%o", &charSet);
 175:             GetToken(ts, iCharCode, MAXTOKENSIZE);
 176:             sscanf(iCharCode, "%o", &charNumber);
 177:             GetToken(ts, iSender, MAXTOKENSIZE); /* ignored... */
 178:             GetToken(ts, iCharName, MAXTOKENSIZE);
 179:             charIndex = Make16BitChar(charSet, charNumber);
 180: 
 181:             /* skip the rest of this loop if it's not in this font */
 182:             if( (charMetric =
 183:                 GetIntegerProp(charIndex, charMetricsProperty)) == NULL )
 184:                 continue;
 185: 
 186:             if( (width = GetStringProp("widthX", charMetric)) == NULL ){
 187:                 printf("ipmetrics: can't find widthX property of %d\n",
 188:                     charIndex);
 189:                 continue;}
 190: 
 191:             if( gettype(width) != type_number ) {
 192:                 printf("ipmetrics: width not of type number for %d\n",
 193:                     charIndex);
 194:                 continue;}
 195: 
 196:             if( getsubtype(width) != subtype_rational ) {
 197:                 printf("ipmetrics: width not of subtype number for %d\n",
 198:                     charIndex);
 199:                 continue;}
 200: 
 201:             xWidth = ((float) getnumerator(width)) / ((float) getdenominator(width));
 202: 
 203:             fprintf(descFile, "(CHARACTER O %3o", charNumber);
 204:             fprintf(descFile, " (CHARWD R %6.4f))", xWidth);
 205: 
 206:             if( charSet == 0 )
 207:                 fprintf(descFile, "\n");
 208:             else
 209:                 fprintf(descFile, "\t(COMMENT in charset 0%o)\n", charSet);
 210: 
 211:             while( !EndOfLine(ts) ) {
 212:                 GetToken(ts, iCharName, MAXTOKENSIZE);} }
 213: 
 214:         CloseTokenStream(ts);
 215:         fclose(descFile);
 216:         fclose(modelFile); }
 217: }

Defined functions

WriteTeXCleanUpFile defined in line 85; used 1 times
  • in line 37
WriteTeXInstallFile defined in line 46; used 1 times
  • in line 36

Defined variables

DeviceName defined in line 28; used 8 times
LibraryDirectory defined in line 29; used 6 times

Defined macros

FALSE defined in line 21; never used
TRUE defined in line 20; used 1 times
private defined in line 24; used 2 times
public defined in line 23; used 3 times
Last modified: 1986-01-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1252
Valid CSS Valid XHTML 1.0 Strict