1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 1989 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate 31*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate /* 34*7c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988 35*7c478bd9Sstevel@tonic-gate * The Regents of the University of California 36*7c478bd9Sstevel@tonic-gate * All Rights Reserved 37*7c478bd9Sstevel@tonic-gate * 38*7c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from 39*7c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its 40*7c478bd9Sstevel@tonic-gate * contributors. 41*7c478bd9Sstevel@tonic-gate */ 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate /* Note added 9/25/83 44*7c478bd9Sstevel@tonic-gate Setting the parameter biggestfont in the DESC file 45*7c478bd9Sstevel@tonic-gate to be at least as big as the number of characters 46*7c478bd9Sstevel@tonic-gate in the largest font for a particular device 47*7c478bd9Sstevel@tonic-gate eliminates the "font X too big for position Y" 48*7c478bd9Sstevel@tonic-gate message from troff. 49*7c478bd9Sstevel@tonic-gate Thanks to Dave Stephens, WECo. 50*7c478bd9Sstevel@tonic-gate */ 51*7c478bd9Sstevel@tonic-gate /* 52*7c478bd9Sstevel@tonic-gate makedev: 53*7c478bd9Sstevel@tonic-gate read text info about a particular device 54*7c478bd9Sstevel@tonic-gate (e.g., cat, 202, aps5) from file, convert 55*7c478bd9Sstevel@tonic-gate it into internal (binary) form suitable for 56*7c478bd9Sstevel@tonic-gate fast reading by troff initialization (ptinit()). 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate Usage: 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate makedev DESC [ F ... ] 61*7c478bd9Sstevel@tonic-gate uses DESC to create a description file 62*7c478bd9Sstevel@tonic-gate using the information therein. 63*7c478bd9Sstevel@tonic-gate It creates the file DESC.out. 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate makedev F ... 66*7c478bd9Sstevel@tonic-gate makes the font tables for fonts F only, 67*7c478bd9Sstevel@tonic-gate creates files F.out. 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate DESC.out contains: 70*7c478bd9Sstevel@tonic-gate dev structure with fundamental sizes 71*7c478bd9Sstevel@tonic-gate list of sizes (nsizes+1) terminated by 0, as short's 72*7c478bd9Sstevel@tonic-gate indices of char names (nchtab * sizeof(short)) 73*7c478bd9Sstevel@tonic-gate char names as hy\0em\0... (lchname) 74*7c478bd9Sstevel@tonic-gate nfonts occurrences of 75*7c478bd9Sstevel@tonic-gate widths (nwidth) 76*7c478bd9Sstevel@tonic-gate kerning (nwidth) [ascender+descender only so far] 77*7c478bd9Sstevel@tonic-gate codes (nwidth) to drive actual typesetter 78*7c478bd9Sstevel@tonic-gate fitab (nchtab+128-32) 79*7c478bd9Sstevel@tonic-gate each of these is an array of char. 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate dev.filesize contains the number of bytes 82*7c478bd9Sstevel@tonic-gate in the file, excluding the dev part itself. 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate F.out contains the font header, width, kern, codes, and fitab. 85*7c478bd9Sstevel@tonic-gate Width, kern and codes are parallel arrays. 86*7c478bd9Sstevel@tonic-gate (Which suggests that they ought to be together?) 87*7c478bd9Sstevel@tonic-gate Later, we might allow for codes which are actually 88*7c478bd9Sstevel@tonic-gate sequences of formatting info so characters can be drawn. 89*7c478bd9Sstevel@tonic-gate */ 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate #include "stdio.h" 92*7c478bd9Sstevel@tonic-gate #include "dev.h" 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate #define BYTEMASK 0377 95*7c478bd9Sstevel@tonic-gate #define skipline(f) while(getc(f) != '\n') 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate struct dev dev; 98*7c478bd9Sstevel@tonic-gate struct Font font; 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate #define NSIZE 100 /* maximum number of sizes */ 101*7c478bd9Sstevel@tonic-gate short size[NSIZE]; 102*7c478bd9Sstevel@tonic-gate #define NCH 256 /* max number of characters with funny names */ 103*7c478bd9Sstevel@tonic-gate char chname[5*NCH]; /* character names, including \0 for each */ 104*7c478bd9Sstevel@tonic-gate short chtab[NCH]; /* index of character in chname */ 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate #define NFITAB (NCH + 128-32) /* includes ascii chars, but not non-graphics */ 107*7c478bd9Sstevel@tonic-gate char fitab[NFITAB]; /* font index table: position of char i on this font. */ 108*7c478bd9Sstevel@tonic-gate /* zero if not there */ 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate #define FSIZE 256 /* size of a physical font (e.g., 102 for cat) */ 111*7c478bd9Sstevel@tonic-gate char width[FSIZE]; /* width table for a physical font */ 112*7c478bd9Sstevel@tonic-gate char kern[FSIZE]; /* ascender+descender info */ 113*7c478bd9Sstevel@tonic-gate char code[FSIZE]; /* actual device codes for a physical font */ 114*7c478bd9Sstevel@tonic-gate 115*7c478bd9Sstevel@tonic-gate #define NFONT 60 /* max number of default fonts */ 116*7c478bd9Sstevel@tonic-gate char fname[NFONT][10]; /* temp space to hold default font names */ 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate int fflag = 0; /* on if font table to be written */ 119*7c478bd9Sstevel@tonic-gate int fdout; /* output file descriptor */ 120*7c478bd9Sstevel@tonic-gate char *fout = "DESC.out"; 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate int main(int argc, char *argv[]) 123*7c478bd9Sstevel@tonic-gate { 124*7c478bd9Sstevel@tonic-gate FILE *fin; 125*7c478bd9Sstevel@tonic-gate char cmd[100], *p; 126*7c478bd9Sstevel@tonic-gate int i, totfont, v; 127*7c478bd9Sstevel@tonic-gate 128*7c478bd9Sstevel@tonic-gate if (argc < 2) { 129*7c478bd9Sstevel@tonic-gate fprintf(stderr, "Usage: makedev [DESC] [fonts]\n"); 130*7c478bd9Sstevel@tonic-gate exit(1); 131*7c478bd9Sstevel@tonic-gate } 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate if ((fin = fopen("DESC", "r")) == NULL) { 134*7c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: can't open %s\n", argv[1]); 135*7c478bd9Sstevel@tonic-gate exit(1); 136*7c478bd9Sstevel@tonic-gate } 137*7c478bd9Sstevel@tonic-gate while (fscanf(fin, "%s", cmd) != EOF) { 138*7c478bd9Sstevel@tonic-gate if (cmd[0] == '#') /* comment */ 139*7c478bd9Sstevel@tonic-gate skipline(fin); 140*7c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "res") == 0) { 141*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.res); 142*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "hor") == 0) { 143*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.hor); 144*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "vert") == 0) { 145*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.vert); 146*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "unitwidth") == 0) { 147*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.unitwidth); 148*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "sizescale") == 0) { 149*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.sizescale); 150*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "paperwidth") == 0) { 151*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.paperwidth); 152*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "paperlength") == 0) { 153*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.paperlength); 154*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "biggestfont") == 0) { 155*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.biggestfont); 156*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "spare2") == 0) { 157*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.spare2); 158*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "sizes") == 0) { 159*7c478bd9Sstevel@tonic-gate dev.nsizes = 0; 160*7c478bd9Sstevel@tonic-gate while (fscanf(fin, "%d", &v) != EOF && v != 0) 161*7c478bd9Sstevel@tonic-gate size[dev.nsizes++] = v; 162*7c478bd9Sstevel@tonic-gate size[dev.nsizes] = 0; /* need an extra 0 at the end */ 163*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "fonts") == 0) { 164*7c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.nfonts); 165*7c478bd9Sstevel@tonic-gate for (i = 0; i < dev.nfonts; i++) 166*7c478bd9Sstevel@tonic-gate fscanf(fin, "%s", fname[i]); 167*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "charset") == 0) { 168*7c478bd9Sstevel@tonic-gate p = chname; 169*7c478bd9Sstevel@tonic-gate dev.nchtab = 0; 170*7c478bd9Sstevel@tonic-gate while (fscanf(fin, "%s", p) != EOF) { 171*7c478bd9Sstevel@tonic-gate chtab[dev.nchtab++] = p - chname; 172*7c478bd9Sstevel@tonic-gate while (*p++) /* skip to end of name */ 173*7c478bd9Sstevel@tonic-gate ; 174*7c478bd9Sstevel@tonic-gate } 175*7c478bd9Sstevel@tonic-gate dev.lchname = p - chname; 176*7c478bd9Sstevel@tonic-gate chtab[dev.nchtab++] = 0; /* terminate properly */ 177*7c478bd9Sstevel@tonic-gate } else 178*7c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: unknown command %s\n", cmd); 179*7c478bd9Sstevel@tonic-gate } 180*7c478bd9Sstevel@tonic-gate if (argc > 0 && strcmp(argv[1], "DESC") == 0) { 181*7c478bd9Sstevel@tonic-gate fdout = creat(fout, 0666); 182*7c478bd9Sstevel@tonic-gate if (fdout < 0) { 183*7c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: can't open %s\n", fout); 184*7c478bd9Sstevel@tonic-gate exit(1); 185*7c478bd9Sstevel@tonic-gate } 186*7c478bd9Sstevel@tonic-gate write(fdout, &dev, sizeof(struct dev)); 187*7c478bd9Sstevel@tonic-gate write(fdout, size, (dev.nsizes+1) * sizeof(size[0])); /* we need a 0 on the end */ 188*7c478bd9Sstevel@tonic-gate write(fdout, chtab, dev.nchtab * sizeof(chtab[0])); 189*7c478bd9Sstevel@tonic-gate write(fdout, chname, dev.lchname); 190*7c478bd9Sstevel@tonic-gate totfont = 0; 191*7c478bd9Sstevel@tonic-gate for (i = 0; i < dev.nfonts; i++) { 192*7c478bd9Sstevel@tonic-gate totfont += dofont(fname[i]); 193*7c478bd9Sstevel@tonic-gate write(fdout, &font, sizeof(struct Font)); 194*7c478bd9Sstevel@tonic-gate write(fdout, width, font.nwfont & BYTEMASK); 195*7c478bd9Sstevel@tonic-gate write(fdout, kern, font.nwfont & BYTEMASK); 196*7c478bd9Sstevel@tonic-gate write(fdout, code, font.nwfont & BYTEMASK); 197*7c478bd9Sstevel@tonic-gate write(fdout, fitab, dev.nchtab+128-32); 198*7c478bd9Sstevel@tonic-gate } 199*7c478bd9Sstevel@tonic-gate lseek(fdout, 0L, 0); /* back to beginning to install proper size */ 200*7c478bd9Sstevel@tonic-gate dev.filesize = /* excluding dev struct itself */ 201*7c478bd9Sstevel@tonic-gate (dev.nsizes+1) * sizeof(size[0]) 202*7c478bd9Sstevel@tonic-gate + dev.nchtab * sizeof(chtab[0]) 203*7c478bd9Sstevel@tonic-gate + dev.lchname * sizeof(char) 204*7c478bd9Sstevel@tonic-gate + totfont * sizeof(char); 205*7c478bd9Sstevel@tonic-gate write(fdout, &dev, sizeof(struct dev)); 206*7c478bd9Sstevel@tonic-gate close(fdout); 207*7c478bd9Sstevel@tonic-gate argc--; 208*7c478bd9Sstevel@tonic-gate argv++; 209*7c478bd9Sstevel@tonic-gate } 210*7c478bd9Sstevel@tonic-gate for (i = 1; i < argc; i++) 211*7c478bd9Sstevel@tonic-gate dofont(argv[i]); 212*7c478bd9Sstevel@tonic-gate exit(0); 213*7c478bd9Sstevel@tonic-gate } 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate dofont(name) /* create fitab and width tab for font */ 216*7c478bd9Sstevel@tonic-gate char *name; 217*7c478bd9Sstevel@tonic-gate { 218*7c478bd9Sstevel@tonic-gate FILE *fin; 219*7c478bd9Sstevel@tonic-gate int fdout; 220*7c478bd9Sstevel@tonic-gate int i, nw, spacewidth, n, v; 221*7c478bd9Sstevel@tonic-gate char buf[100], ch[10], s1[10], s2[10], s3[10], cmd[30]; 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate if ((fin = fopen(name, "r")) == NULL) { 224*7c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: can't open font %s\n", name); 225*7c478bd9Sstevel@tonic-gate exit(2); 226*7c478bd9Sstevel@tonic-gate } 227*7c478bd9Sstevel@tonic-gate sprintf(cmd, "%s.out", name); 228*7c478bd9Sstevel@tonic-gate fdout = creat(cmd, 0666); 229*7c478bd9Sstevel@tonic-gate for (i = 0; i < NFITAB; i++) 230*7c478bd9Sstevel@tonic-gate fitab[i] = 0; 231*7c478bd9Sstevel@tonic-gate for (i = 0; i < FSIZE; i++) 232*7c478bd9Sstevel@tonic-gate width[i] = kern[i] = code[i] = 0; 233*7c478bd9Sstevel@tonic-gate font.specfont = font.ligfont = spacewidth = 0; 234*7c478bd9Sstevel@tonic-gate while (fscanf(fin, "%s", cmd) != EOF) { 235*7c478bd9Sstevel@tonic-gate if (cmd[0] == '#') 236*7c478bd9Sstevel@tonic-gate skipline(fin); 237*7c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "name") == 0) 238*7c478bd9Sstevel@tonic-gate fscanf(fin, "%s", font.namefont); 239*7c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "internalname") == 0) 240*7c478bd9Sstevel@tonic-gate fscanf(fin, "%s", font.intname); 241*7c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "special") == 0) 242*7c478bd9Sstevel@tonic-gate font.specfont = 1; 243*7c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "spare1") == 0) 244*7c478bd9Sstevel@tonic-gate fscanf(fin, "%1s", &font.spare1); 245*7c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "ligatures") == 0) { 246*7c478bd9Sstevel@tonic-gate font.ligfont = getlig(fin); 247*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "spacewidth") == 0) { 248*7c478bd9Sstevel@tonic-gate fscanf(fin, "%d", &spacewidth); 249*7c478bd9Sstevel@tonic-gate width[0] = spacewidth; /* width of space on this font */ 250*7c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "charset") == 0) { 251*7c478bd9Sstevel@tonic-gate skipline(fin); 252*7c478bd9Sstevel@tonic-gate nw = 0; 253*7c478bd9Sstevel@tonic-gate /* widths are origin 1 so fitab==0 can mean "not there" */ 254*7c478bd9Sstevel@tonic-gate while (fgets(buf, 100, fin) != NULL) { 255*7c478bd9Sstevel@tonic-gate sscanf(buf, "%s %s %s %s", ch, s1, s2, s3); 256*7c478bd9Sstevel@tonic-gate if (s1[0] != '"') { /* it's a genuine new character */ 257*7c478bd9Sstevel@tonic-gate nw++; 258*7c478bd9Sstevel@tonic-gate width[nw] = atoi(s1); 259*7c478bd9Sstevel@tonic-gate kern[nw] = atoi(s2); 260*7c478bd9Sstevel@tonic-gate /* temporarily, pick up one byte as code */ 261*7c478bd9Sstevel@tonic-gate if (s3[0] == '0') 262*7c478bd9Sstevel@tonic-gate sscanf(s3, "%o", &i); 263*7c478bd9Sstevel@tonic-gate else 264*7c478bd9Sstevel@tonic-gate sscanf(s3, "%d", &i); 265*7c478bd9Sstevel@tonic-gate code[nw] = i; 266*7c478bd9Sstevel@tonic-gate } 267*7c478bd9Sstevel@tonic-gate /* otherwise it's a synonym for previous character, 268*7c478bd9Sstevel@tonic-gate /* so leave previous values intact 269*7c478bd9Sstevel@tonic-gate */ 270*7c478bd9Sstevel@tonic-gate if (strlen(ch) == 1) /* it's ascii */ 271*7c478bd9Sstevel@tonic-gate fitab[ch[0] - 32] = nw; /* fitab origin omits non-graphics */ 272*7c478bd9Sstevel@tonic-gate else { /* it has a funny name */ 273*7c478bd9Sstevel@tonic-gate for (i = 0; i < dev.nchtab; i++) 274*7c478bd9Sstevel@tonic-gate if (strcmp(&chname[chtab[i]], ch) == 0) { 275*7c478bd9Sstevel@tonic-gate fitab[i + 128-32] = nw; /* starts after the ascii */ 276*7c478bd9Sstevel@tonic-gate break; 277*7c478bd9Sstevel@tonic-gate } 278*7c478bd9Sstevel@tonic-gate if (i >= dev.nchtab) 279*7c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: font %s: %s not in charset\n", name, ch); 280*7c478bd9Sstevel@tonic-gate } 281*7c478bd9Sstevel@tonic-gate } 282*7c478bd9Sstevel@tonic-gate nw++; 283*7c478bd9Sstevel@tonic-gate if (dev.biggestfont >= nw) 284*7c478bd9Sstevel@tonic-gate n = dev.biggestfont; 285*7c478bd9Sstevel@tonic-gate else { 286*7c478bd9Sstevel@tonic-gate if (dev.biggestfont > 0) 287*7c478bd9Sstevel@tonic-gate fprintf(stderr, "font %s too big\n", name); 288*7c478bd9Sstevel@tonic-gate n = nw; 289*7c478bd9Sstevel@tonic-gate } 290*7c478bd9Sstevel@tonic-gate font.nwfont = n; 291*7c478bd9Sstevel@tonic-gate } 292*7c478bd9Sstevel@tonic-gate } 293*7c478bd9Sstevel@tonic-gate if (spacewidth == 0) 294*7c478bd9Sstevel@tonic-gate width[0] = dev.res * dev.unitwidth / 72 / 3; 295*7c478bd9Sstevel@tonic-gate fclose(fin); 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate write(fdout, &font, sizeof(struct Font)); 298*7c478bd9Sstevel@tonic-gate write(fdout, width, font.nwfont & BYTEMASK); 299*7c478bd9Sstevel@tonic-gate write(fdout, kern, font.nwfont & BYTEMASK); 300*7c478bd9Sstevel@tonic-gate write(fdout, code, font.nwfont & BYTEMASK); 301*7c478bd9Sstevel@tonic-gate write(fdout, fitab, dev.nchtab+128-32); 302*7c478bd9Sstevel@tonic-gate close(fdout); 303*7c478bd9Sstevel@tonic-gate v = sizeof(struct Font) + 3 * n + dev.nchtab + 128-32; 304*7c478bd9Sstevel@tonic-gate fprintf(stderr, "%3s: %3d chars, width %3d, size %3d\n", 305*7c478bd9Sstevel@tonic-gate font.namefont, nw, width[0], v); 306*7c478bd9Sstevel@tonic-gate return v; 307*7c478bd9Sstevel@tonic-gate } 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate getlig(fin) /* pick up ligature list */ 310*7c478bd9Sstevel@tonic-gate FILE *fin; 311*7c478bd9Sstevel@tonic-gate { 312*7c478bd9Sstevel@tonic-gate int lig; 313*7c478bd9Sstevel@tonic-gate char temp[100]; 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate lig = 0; 316*7c478bd9Sstevel@tonic-gate while (fscanf(fin, "%s", temp) != EOF && strcmp(temp, "0") != 0) { 317*7c478bd9Sstevel@tonic-gate if (strcmp(temp, "fi") == 0) 318*7c478bd9Sstevel@tonic-gate lig |= LFI; 319*7c478bd9Sstevel@tonic-gate else if (strcmp(temp, "fl") == 0) 320*7c478bd9Sstevel@tonic-gate lig |= LFL; 321*7c478bd9Sstevel@tonic-gate else if (strcmp(temp, "ff") == 0) 322*7c478bd9Sstevel@tonic-gate lig |= LFF; 323*7c478bd9Sstevel@tonic-gate else if (strcmp(temp, "ffi") == 0) 324*7c478bd9Sstevel@tonic-gate lig |= LFFI; 325*7c478bd9Sstevel@tonic-gate else if (strcmp(temp, "ffl") == 0) 326*7c478bd9Sstevel@tonic-gate lig |= LFFL; 327*7c478bd9Sstevel@tonic-gate else 328*7c478bd9Sstevel@tonic-gate fprintf(stderr, "illegal ligature %s\n", temp); 329*7c478bd9Sstevel@tonic-gate } 330*7c478bd9Sstevel@tonic-gate skipline(fin); 331*7c478bd9Sstevel@tonic-gate return lig; 332*7c478bd9Sstevel@tonic-gate } 333