|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1984, 1985, 1986 Xerox Corp. ! 3: * ! 4: * create Generic font files ! 5: * ! 6: * HISTORY ! 7: * 03-Sep-86 Lee Moore (lee) at Xerox Webster Research Center ! 8: * Created from tex.c . ! 9: * ! 10: * 11-Feb-86 Lee Moore (lee) at Xerox Webster Research Center ! 11: * Added the creation of an extra text file which contains information ! 12: * on how to access characters in other character-sets than zero (0). ! 13: * ! 14: * 15-Dec-85 Lee Moore (lee) at Xerox Webster Research Center ! 15: * Created. ! 16: * ! 17: */ ! 18: ! 19: #include <stdio.h> ! 20: #include <math.h> ! 21: #include "stack.h" ! 22: #include "token.h" ! 23: #include "config.h" ! 24: #include "ipmetrics.h" ! 25: #include "generic.h" ! 26: ! 27: #define TRUE 1 ! 28: #define FALSE 0 ! 29: ! 30: #define public ! 31: #define private static ! 32: ! 33: extern unsigned char **getvector(); ! 34: ! 35: public char *malloc(); ! 36: ! 37: public char *DeviceName, ! 38: *LibraryDirectory; ! 39: ! 40: public ! 41: CleanUpGeneric(configChain) ! 42: struct FontConfig *configChain; { ! 43: struct FontConfig *p; ! 44: ! 45: WriteGenericInstallFile(configChain); ! 46: WriteGenericCleanUpFile(configChain); ! 47: ! 48: for( p = configChain; p != NULL; p = p->Next ) ! 49: if( !p->SeenFlag ) ! 50: printf("couldn't find: %s/%s/%s\n", ! 51: p->FontPt1, p->FontPt2, p->FontPt3); ! 52: } ! 53: ! 54: ! 55: private ! 56: WriteGenericInstallFile(configChain) ! 57: struct FontConfig *configChain; { ! 58: FILE *installFile; ! 59: struct FontConfig *p; ! 60: ! 61: if( (installFile = fopen(INSTALLNAME, "w")) == NULL ) { ! 62: fprintf(stderr, "can't open the file 'install' for writing\n"); ! 63: return; } ! 64: ! 65: fprintf(installFile, "#! /bin/sh\n"); ! 66: fprintf(installFile, "if test ! -d %s/fonts/%s\n", LibraryDirectory, DeviceName); ! 67: fprintf(installFile, " then\n"); ! 68: fprintf(installFile, " mkdir %s/fonts/%s\n", LibraryDirectory, DeviceName); ! 69: fprintf(installFile, " fi\n"); ! 70: fprintf(installFile, "if test ! -d %s/fonts/%s/generic\n", LibraryDirectory, DeviceName); ! 71: fprintf(installFile, " then\n"); ! 72: fprintf(installFile, " mkdir %s/fonts/%s/generic\n", LibraryDirectory, DeviceName); ! 73: fprintf(installFile, " fi\n"); ! 74: ! 75: ! 76: for( p = configChain; p != NULL; p = p->Next ) ! 77: if( p->SeenFlag ) ! 78: fprintf(installFile, "cp %s.generic %s/fonts/%s/generic\n", ! 79: p->TargetName, LibraryDirectory, DeviceName); ! 80: ! 81: fprintf(installFile, "cd %s/fonts/%s/generic\n", LibraryDirectory, ! 82: DeviceName); ! 83: (void) fclose(installFile); ! 84: (void) chmod(INSTALLNAME, 0755); } ! 85: ! 86: ! 87: /* ! 88: * write a file that rm's all the files created by this program ! 89: */ ! 90: ! 91: private ! 92: WriteGenericCleanUpFile(configChain) ! 93: struct FontConfig *configChain; { ! 94: FILE *cleanupFile; ! 95: struct FontConfig *p; ! 96: ! 97: if( (cleanupFile = fopen(CLEANUPNAME, "w")) == NULL ) { ! 98: fprintf(stderr, "can't open the file 'cleanup' for writing\n"); ! 99: return; } ! 100: ! 101: fprintf(cleanupFile, "#! /bin/sh\n"); ! 102: ! 103: for( p = configChain; p != NULL; p = p->Next ) ! 104: if( p->SeenFlag ) ! 105: fprintf(cleanupFile, "rm %s.generic\n", p->TargetName); ! 106: ! 107: fprintf(cleanupFile, "rm %s\n", CLEANUPNAME); ! 108: fprintf(cleanupFile, "rm %s\n", INSTALLNAME); ! 109: (void) fclose(cleanupFile); ! 110: (void) chmod(CLEANUPNAME, 0755); } ! 111: ! 112: ! 113: PerGenericFont(configChain, fontDescVec) ! 114: struct FontConfig *configChain; ! 115: unsigned char *fontDescVec; { ! 116: unsigned char *charMetricsProperty, ! 117: *width, ! 118: **array; ! 119: char *fontName[40], ! 120: metricFileName[40]; ! 121: FILE *descFile; ! 122: struct FontConfig *p; ! 123: int n, ! 124: depth; ! 125: double xWidth; ! 126: ! 127: if( !GetFontNameProperty(fontDescVec, fontName) ) { ! 128: fprintf(stderr, "ipmetrics: can't get font name\n"); ! 129: return; ! 130: } ! 131: ! 132: if( (charMetricsProperty = GetStringProp("characterMetrics", fontDescVec)) ! 133: == NULL ) { ! 134: printf("ipmetrics: can't find 'characterMetrics' property\n"); ! 135: return; } ! 136: ! 137: for( p = configChain; p != NULL; p = p->Next ) { ! 138: if( !(strcmp(p->FontPt1, fontName[0]) == 0 && ! 139: strcmp(p->FontPt2, fontName[1]) == 0 && ! 140: strcmp(p->FontPt3, fontName[2]) == 0) ) ! 141: continue; ! 142: ! 143: (void) sprintf(metricFileName, "%s.generic", p->TargetName); ! 144: ! 145: if( (descFile = fopen(metricFileName, "w")) == NULL ) { ! 146: printf("ipmetrics: can't open %s for writing\n", metricFileName); ! 147: return;} ! 148: ! 149: p->SeenFlag = TRUE; ! 150: ! 151: fprintf(descFile, "# %s/%s/%s for Interpress device %s\n", p->FontPt1, p->FontPt2, p->FontPt3, DeviceName); ! 152: ! 153: fprintf(descFile, "# for interpress device '%s'\n", DeviceName); ! 154: fprintf(descFile, "#\n"); ! 155: fprintf(descFile, "# character\n"); ! 156: fprintf(descFile, "# index\twidth\n"); ! 157: fprintf(descFile, "# (decimal)\t(ems)\n"); ! 158: ! 159: if( gettype(charMetricsProperty) != type_vector ) { ! 160: printf("ipmetrics: characterMetrics not a vector\n"); ! 161: return;} ! 162: ! 163: if( getsubtype(charMetricsProperty) != subtype_general ) { ! 164: printf("ipmetrics: characterMetrics subtype != general\n"); ! 165: return;} ! 166: ! 167: if( (depth = getdepth(charMetricsProperty)) & 01 ) { ! 168: printf("ipmetrics: characterMetrics vector is odd length\n"); ! 169: return;} ! 170: ! 171: array = getvector(charMetricsProperty); ! 172: ! 173: for (n = 0; n < depth; n += 2 ) { ! 174: if( ! checktype(array[n], type_number, subtype_integer)) { ! 175: printf("ipmetrics: property of incorrect type\n"); ! 176: return;} ! 177: ! 178: if( (width = GetStringProp("widthX", array[n+1])) == NULL ){ ! 179: printf("ipmetrics: can't find widthX property"); ! 180: continue;} ! 181: ! 182: if( gettype(width) != type_number ) { ! 183: printf("width not of type number\n"); ! 184: continue;} ! 185: ! 186: if( getsubtype(width) != subtype_rational ) { ! 187: printf("ipmetrics: width not of type rational\n"); ! 188: continue;} ! 189: ! 190: xWidth = ((float) getnumerator(width)) / ((float) getdenominator(width)); ! 191: fprintf(descFile, "%8d\t%7.5f\n", getint(array[n]), xWidth); ! 192: } ! 193: ! 194: free((char *) array); ! 195: ! 196: ! 197: (void) fclose(descFile); } ! 198: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.