17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate * with the License.
87c478bd9Sstevel@tonic-gate *
97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate * and limitations under the License.
137c478bd9Sstevel@tonic-gate *
147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate *
207c478bd9Sstevel@tonic-gate * CDDL HEADER END
217c478bd9Sstevel@tonic-gate */
22*f928ce67Sceastha /*
23*f928ce67Sceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24*f928ce67Sceastha * Use is subject to license terms.
25*f928ce67Sceastha */
26*f928ce67Sceastha
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
287c478bd9Sstevel@tonic-gate /* All Rights Reserved */
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate * University Copyright- Copyright (c) 1982, 1986, 1988
327c478bd9Sstevel@tonic-gate * The Regents of the University of California
337c478bd9Sstevel@tonic-gate * All Rights Reserved
347c478bd9Sstevel@tonic-gate *
357c478bd9Sstevel@tonic-gate * University Acknowledgment- Portions of this document are derived from
367c478bd9Sstevel@tonic-gate * software developed by the University of California, Berkeley, and its
377c478bd9Sstevel@tonic-gate * contributors.
387c478bd9Sstevel@tonic-gate */
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate /* Note added 9/25/83
417c478bd9Sstevel@tonic-gate Setting the parameter biggestfont in the DESC file
427c478bd9Sstevel@tonic-gate to be at least as big as the number of characters
437c478bd9Sstevel@tonic-gate in the largest font for a particular device
447c478bd9Sstevel@tonic-gate eliminates the "font X too big for position Y"
457c478bd9Sstevel@tonic-gate message from troff.
467c478bd9Sstevel@tonic-gate Thanks to Dave Stephens, WECo.
477c478bd9Sstevel@tonic-gate */
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate makedev:
507c478bd9Sstevel@tonic-gate read text info about a particular device
517c478bd9Sstevel@tonic-gate (e.g., cat, 202, aps5) from file, convert
527c478bd9Sstevel@tonic-gate it into internal (binary) form suitable for
537c478bd9Sstevel@tonic-gate fast reading by troff initialization (ptinit()).
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate Usage:
567c478bd9Sstevel@tonic-gate
577c478bd9Sstevel@tonic-gate makedev DESC [ F ... ]
587c478bd9Sstevel@tonic-gate uses DESC to create a description file
597c478bd9Sstevel@tonic-gate using the information therein.
607c478bd9Sstevel@tonic-gate It creates the file DESC.out.
617c478bd9Sstevel@tonic-gate
627c478bd9Sstevel@tonic-gate makedev F ...
637c478bd9Sstevel@tonic-gate makes the font tables for fonts F only,
647c478bd9Sstevel@tonic-gate creates files F.out.
657c478bd9Sstevel@tonic-gate
667c478bd9Sstevel@tonic-gate DESC.out contains:
677c478bd9Sstevel@tonic-gate dev structure with fundamental sizes
687c478bd9Sstevel@tonic-gate list of sizes (nsizes+1) terminated by 0, as short's
697c478bd9Sstevel@tonic-gate indices of char names (nchtab * sizeof(short))
707c478bd9Sstevel@tonic-gate char names as hy\0em\0... (lchname)
717c478bd9Sstevel@tonic-gate nfonts occurrences of
727c478bd9Sstevel@tonic-gate widths (nwidth)
737c478bd9Sstevel@tonic-gate kerning (nwidth) [ascender+descender only so far]
747c478bd9Sstevel@tonic-gate codes (nwidth) to drive actual typesetter
757c478bd9Sstevel@tonic-gate fitab (nchtab+128-32)
767c478bd9Sstevel@tonic-gate each of these is an array of char.
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gate dev.filesize contains the number of bytes
797c478bd9Sstevel@tonic-gate in the file, excluding the dev part itself.
807c478bd9Sstevel@tonic-gate
817c478bd9Sstevel@tonic-gate F.out contains the font header, width, kern, codes, and fitab.
827c478bd9Sstevel@tonic-gate Width, kern and codes are parallel arrays.
837c478bd9Sstevel@tonic-gate (Which suggests that they ought to be together?)
847c478bd9Sstevel@tonic-gate Later, we might allow for codes which are actually
857c478bd9Sstevel@tonic-gate sequences of formatting info so characters can be drawn.
867c478bd9Sstevel@tonic-gate */
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gate #include "stdio.h"
897c478bd9Sstevel@tonic-gate #include "dev.h"
907c478bd9Sstevel@tonic-gate
917c478bd9Sstevel@tonic-gate #define BYTEMASK 0377
927c478bd9Sstevel@tonic-gate #define skipline(f) while(getc(f) != '\n')
937c478bd9Sstevel@tonic-gate
947c478bd9Sstevel@tonic-gate struct dev dev;
957c478bd9Sstevel@tonic-gate struct Font font;
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate #define NSIZE 100 /* maximum number of sizes */
987c478bd9Sstevel@tonic-gate short size[NSIZE];
997c478bd9Sstevel@tonic-gate #define NCH 256 /* max number of characters with funny names */
1007c478bd9Sstevel@tonic-gate char chname[5*NCH]; /* character names, including \0 for each */
1017c478bd9Sstevel@tonic-gate short chtab[NCH]; /* index of character in chname */
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate #define NFITAB (NCH + 128-32) /* includes ascii chars, but not non-graphics */
1047c478bd9Sstevel@tonic-gate char fitab[NFITAB]; /* font index table: position of char i on this font. */
1057c478bd9Sstevel@tonic-gate /* zero if not there */
1067c478bd9Sstevel@tonic-gate
1077c478bd9Sstevel@tonic-gate #define FSIZE 254 /* size of a physical font (e.g., 102 for cat) */
1087c478bd9Sstevel@tonic-gate char width[FSIZE]; /* width table for a physical font */
1097c478bd9Sstevel@tonic-gate char kern[FSIZE]; /* ascender+descender info */
1107c478bd9Sstevel@tonic-gate char code[FSIZE]; /* actual device codes for a physical font */
1117c478bd9Sstevel@tonic-gate #define BIGGESTFONT FSIZE /* biggest font if no size in DESC */
1127c478bd9Sstevel@tonic-gate /* MUST be < 256 */
1137c478bd9Sstevel@tonic-gate
1147c478bd9Sstevel@tonic-gate #define NFONT 50 /* max number of default fonts */
1157c478bd9Sstevel@tonic-gate char fname[NFONT][10]; /* temp space to hold default font names */
1167c478bd9Sstevel@tonic-gate
1177c478bd9Sstevel@tonic-gate int fflag = 0; /* on if font table to be written */
1187c478bd9Sstevel@tonic-gate int fdout; /* output file descriptor */
1197c478bd9Sstevel@tonic-gate char *fout = "DESC.out";
1207c478bd9Sstevel@tonic-gate
121*f928ce67Sceastha static int dofont(char *);
122*f928ce67Sceastha static int getlig(FILE *);
123*f928ce67Sceastha
124*f928ce67Sceastha int
main(int argc,char * argv[])125*f928ce67Sceastha main(int argc, char *argv[])
1267c478bd9Sstevel@tonic-gate {
1277c478bd9Sstevel@tonic-gate FILE *fin;
1287c478bd9Sstevel@tonic-gate char cmd[100], *p;
1297c478bd9Sstevel@tonic-gate int i, totfont, v;
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate if (argc < 2) {
1327c478bd9Sstevel@tonic-gate fprintf(stderr, "Usage: makedev [DESC] [fonts]\n");
1337c478bd9Sstevel@tonic-gate exit(1);
1347c478bd9Sstevel@tonic-gate }
1357c478bd9Sstevel@tonic-gate if ((fin = fopen("DESC", "r")) == NULL) {
1367c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: can't open DESC file\n");
1377c478bd9Sstevel@tonic-gate exit(1);
1387c478bd9Sstevel@tonic-gate }
1397c478bd9Sstevel@tonic-gate while (fscanf(fin, "%s", cmd) != EOF) {
1407c478bd9Sstevel@tonic-gate if (cmd[0] == '#') /* comment */
1417c478bd9Sstevel@tonic-gate skipline(fin);
1427c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "res") == 0) {
1437c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.res);
1447c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "hor") == 0) {
1457c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.hor);
1467c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "vert") == 0) {
1477c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.vert);
1487c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "unitwidth") == 0) {
1497c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.unitwidth);
1507c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "sizescale") == 0) {
1517c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.sizescale);
1527c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "paperwidth") == 0) {
1537c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.paperwidth);
1547c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "paperlength") == 0) {
1557c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.paperlength);
1567c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "biggestfont") == 0) {
1577c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.biggestfont);
1587c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "spare2") == 0) {
1597c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.spare2);
1607c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "sizes") == 0) {
1617c478bd9Sstevel@tonic-gate dev.nsizes = 0;
1627c478bd9Sstevel@tonic-gate while (fscanf(fin, "%d", &v) != EOF && v != 0)
1637c478bd9Sstevel@tonic-gate size[dev.nsizes++] = v;
1647c478bd9Sstevel@tonic-gate size[dev.nsizes] = 0; /* need an extra 0 at the end */
1657c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "fonts") == 0) {
1667c478bd9Sstevel@tonic-gate fscanf(fin, "%hd", &dev.nfonts);
1677c478bd9Sstevel@tonic-gate for (i = 0; i < dev.nfonts; i++)
1687c478bd9Sstevel@tonic-gate fscanf(fin, "%s", fname[i]);
1697c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "charset") == 0) {
1707c478bd9Sstevel@tonic-gate short pchname;
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gate p = chname;
1737c478bd9Sstevel@tonic-gate pchname = 0;
1747c478bd9Sstevel@tonic-gate dev.nchtab = 0;
1757c478bd9Sstevel@tonic-gate while (fscanf(fin, "%s", p) != EOF) {
1767c478bd9Sstevel@tonic-gate chtab[dev.nchtab++] = pchname;
1777c478bd9Sstevel@tonic-gate while (*p++) /* skip to end of name */
1787c478bd9Sstevel@tonic-gate pchname++;
1797c478bd9Sstevel@tonic-gate pchname++;
1807c478bd9Sstevel@tonic-gate }
1817c478bd9Sstevel@tonic-gate dev.lchname = pchname;
1827c478bd9Sstevel@tonic-gate chtab[dev.nchtab++] = 0; /* terminate properly */
1837c478bd9Sstevel@tonic-gate } else
1847c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: unknown command %s\n", cmd);
1857c478bd9Sstevel@tonic-gate }
1867c478bd9Sstevel@tonic-gate if (argc > 1 && strcmp(argv[1], "DESC") == 0) {
1877c478bd9Sstevel@tonic-gate fdout = creat(fout, 0666);
1887c478bd9Sstevel@tonic-gate if (fdout < 0) {
1897c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: can't open %s\n", fout);
1907c478bd9Sstevel@tonic-gate exit(1);
1917c478bd9Sstevel@tonic-gate }
1927c478bd9Sstevel@tonic-gate write(fdout, &dev, sizeof(struct dev));
1937c478bd9Sstevel@tonic-gate write(fdout, size, (dev.nsizes+1) * sizeof(size[0])); /* we need a 0 on the end */
1947c478bd9Sstevel@tonic-gate write(fdout, chtab, dev.nchtab * sizeof(chtab[0]));
1957c478bd9Sstevel@tonic-gate write(fdout, chname, dev.lchname);
1967c478bd9Sstevel@tonic-gate totfont = 0;
1977c478bd9Sstevel@tonic-gate for (i = 0; i < dev.nfonts; i++) {
1987c478bd9Sstevel@tonic-gate totfont += dofont(fname[i]);
1997c478bd9Sstevel@tonic-gate write(fdout, &font, sizeof(struct Font));
2007c478bd9Sstevel@tonic-gate write(fdout, width, font.nwfont & BYTEMASK);
2017c478bd9Sstevel@tonic-gate write(fdout, kern, font.nwfont & BYTEMASK);
2027c478bd9Sstevel@tonic-gate write(fdout, code, font.nwfont & BYTEMASK);
2037c478bd9Sstevel@tonic-gate write(fdout, fitab, dev.nchtab+128-32);
2047c478bd9Sstevel@tonic-gate }
2057c478bd9Sstevel@tonic-gate lseek(fdout, 0L, 0); /* back to beginning to install proper size */
2067c478bd9Sstevel@tonic-gate dev.filesize = /* excluding dev struct itself */
2077c478bd9Sstevel@tonic-gate (dev.nsizes+1) * sizeof(size[0])
2087c478bd9Sstevel@tonic-gate + dev.nchtab * sizeof(chtab[0])
2097c478bd9Sstevel@tonic-gate + dev.lchname * sizeof(char)
2107c478bd9Sstevel@tonic-gate + totfont * sizeof(char);
2117c478bd9Sstevel@tonic-gate write(fdout, &dev, sizeof(struct dev));
2127c478bd9Sstevel@tonic-gate close(fdout);
2137c478bd9Sstevel@tonic-gate argc--;
2147c478bd9Sstevel@tonic-gate argv++;
2157c478bd9Sstevel@tonic-gate }
2167c478bd9Sstevel@tonic-gate for (i = 1; i < argc; i++)
2177c478bd9Sstevel@tonic-gate dofont(argv[i]);
218*f928ce67Sceastha return (0);
2197c478bd9Sstevel@tonic-gate }
2207c478bd9Sstevel@tonic-gate
221*f928ce67Sceastha static int
dofont(char * name)222*f928ce67Sceastha dofont(char *name) /* create fitab and width tab for font */
2237c478bd9Sstevel@tonic-gate {
2247c478bd9Sstevel@tonic-gate FILE *fin;
2257c478bd9Sstevel@tonic-gate int fdout;
2267c478bd9Sstevel@tonic-gate int i, nw, spacewidth, n, v;
2277c478bd9Sstevel@tonic-gate char buf[100], ch[10], s1[10], s2[10], s3[10], cmd[30];
2287c478bd9Sstevel@tonic-gate
2297c478bd9Sstevel@tonic-gate if ((fin = fopen(name, "r")) == NULL) {
2307c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: can't open font %s\n", name);
2317c478bd9Sstevel@tonic-gate exit(2);
2327c478bd9Sstevel@tonic-gate }
2337c478bd9Sstevel@tonic-gate sprintf(cmd, "%s.out", name);
2347c478bd9Sstevel@tonic-gate fdout = creat(cmd, 0666);
2357c478bd9Sstevel@tonic-gate if (fdout < 0) {
2367c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: can't open %s\n", fout);
2377c478bd9Sstevel@tonic-gate exit(1);
2387c478bd9Sstevel@tonic-gate }
2397c478bd9Sstevel@tonic-gate for (i = 0; i < NFITAB; i++)
2407c478bd9Sstevel@tonic-gate fitab[i] = 0;
2417c478bd9Sstevel@tonic-gate for (i = 0; i < FSIZE; i++)
2427c478bd9Sstevel@tonic-gate width[i] = kern[i] = code[i] = 0;
2437c478bd9Sstevel@tonic-gate font.specfont = font.ligfont = spacewidth = 0;
2447c478bd9Sstevel@tonic-gate while (fscanf(fin, "%s", cmd) != EOF) {
2457c478bd9Sstevel@tonic-gate if (cmd[0] == '#')
2467c478bd9Sstevel@tonic-gate skipline(fin);
2477c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "name") == 0)
2487c478bd9Sstevel@tonic-gate fscanf(fin, "%s", font.namefont);
2497c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "internalname") == 0)
2507c478bd9Sstevel@tonic-gate fscanf(fin, "%s", font.intname);
2517c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "special") == 0)
2527c478bd9Sstevel@tonic-gate font.specfont = 1;
2537c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "spare1") == 0)
2547c478bd9Sstevel@tonic-gate fscanf(fin, "%1s", &font.spare1);
2557c478bd9Sstevel@tonic-gate else if (strcmp(cmd, "ligatures") == 0) {
2567c478bd9Sstevel@tonic-gate font.ligfont = getlig(fin);
2577c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "spacewidth") == 0) {
2587c478bd9Sstevel@tonic-gate fscanf(fin, "%d", &spacewidth);
2597c478bd9Sstevel@tonic-gate width[0] = spacewidth; /* width of space on this font */
2607c478bd9Sstevel@tonic-gate } else if (strcmp(cmd, "charset") == 0) {
2617c478bd9Sstevel@tonic-gate skipline(fin);
2627c478bd9Sstevel@tonic-gate nw = 0;
2637c478bd9Sstevel@tonic-gate /* widths are origin 1 so fitab==0 can mean "not there" */
2647c478bd9Sstevel@tonic-gate while (fgets(buf, 100, fin) != NULL) {
2657c478bd9Sstevel@tonic-gate sscanf(buf, "%s %s %s %s", ch, s1, s2, s3);
2667c478bd9Sstevel@tonic-gate if (s1[0] != '"') { /* it's a genuine new character */
2677c478bd9Sstevel@tonic-gate nw++;
2687c478bd9Sstevel@tonic-gate width[nw] = atoi(s1);
2697c478bd9Sstevel@tonic-gate kern[nw] = atoi(s2);
2707c478bd9Sstevel@tonic-gate /* temporarily, pick up one byte as code */
2717c478bd9Sstevel@tonic-gate if (s3[0] == '0')
2727c478bd9Sstevel@tonic-gate sscanf(s3, "%o", &i);
2737c478bd9Sstevel@tonic-gate else
2747c478bd9Sstevel@tonic-gate sscanf(s3, "%d", &i);
2757c478bd9Sstevel@tonic-gate code[nw] = i;
2767c478bd9Sstevel@tonic-gate }
2777c478bd9Sstevel@tonic-gate /* otherwise it's a synonym for previous character,
2787c478bd9Sstevel@tonic-gate * so leave previous values intact
2797c478bd9Sstevel@tonic-gate */
2807c478bd9Sstevel@tonic-gate if (strlen(ch) == 1) /* it's ascii */
2817c478bd9Sstevel@tonic-gate fitab[ch[0] - 32] = nw; /* fitab origin omits non-graphics */
2827c478bd9Sstevel@tonic-gate else if (strcmp(ch, "---") != 0) { /* it has a 2-char name */
2837c478bd9Sstevel@tonic-gate for (i = 0; i < dev.nchtab; i++)
2847c478bd9Sstevel@tonic-gate if (strcmp(&chname[chtab[i]], ch) == 0) {
2857c478bd9Sstevel@tonic-gate fitab[i + 128-32] = nw; /* starts after the ascii */
2867c478bd9Sstevel@tonic-gate break;
2877c478bd9Sstevel@tonic-gate }
2887c478bd9Sstevel@tonic-gate if (i >= dev.nchtab)
2897c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: font %s: %s not in charset\n", name, ch);
2907c478bd9Sstevel@tonic-gate }
2917c478bd9Sstevel@tonic-gate }
2927c478bd9Sstevel@tonic-gate nw++;
2937c478bd9Sstevel@tonic-gate if (dev.biggestfont > 0)
2947c478bd9Sstevel@tonic-gate n = dev.biggestfont + 1;
2957c478bd9Sstevel@tonic-gate else
2967c478bd9Sstevel@tonic-gate n = BIGGESTFONT;
2977c478bd9Sstevel@tonic-gate /*
2987c478bd9Sstevel@tonic-gate * Make files at least as big as biggestfont. Larger fonts
2997c478bd9Sstevel@tonic-gate * may only fit in postion 0.
3007c478bd9Sstevel@tonic-gate */
3017c478bd9Sstevel@tonic-gate if ( nw > n ) {
3027c478bd9Sstevel@tonic-gate n = nw;
3037c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: warning font %s may only fit in position 0\n", font.namefont);
3047c478bd9Sstevel@tonic-gate }
3057c478bd9Sstevel@tonic-gate if (n >= NCH) {
3067c478bd9Sstevel@tonic-gate fprintf(stderr, "makedev: font has %d characters, too big\n", n);
3077c478bd9Sstevel@tonic-gate exit(2);
3087c478bd9Sstevel@tonic-gate }
3097c478bd9Sstevel@tonic-gate font.nwfont = n;
3107c478bd9Sstevel@tonic-gate }
3117c478bd9Sstevel@tonic-gate }
3127c478bd9Sstevel@tonic-gate if (spacewidth == 0)
3137c478bd9Sstevel@tonic-gate width[0] = dev.res * dev.unitwidth / 72 / 3; /* should be rounded */
3147c478bd9Sstevel@tonic-gate fclose(fin);
3157c478bd9Sstevel@tonic-gate
3167c478bd9Sstevel@tonic-gate write(fdout, &font, sizeof(struct Font));
3177c478bd9Sstevel@tonic-gate write(fdout, width, font.nwfont & BYTEMASK);
3187c478bd9Sstevel@tonic-gate write(fdout, kern, font.nwfont & BYTEMASK);
3197c478bd9Sstevel@tonic-gate write(fdout, code, font.nwfont & BYTEMASK);
3207c478bd9Sstevel@tonic-gate write(fdout, fitab, dev.nchtab+128-32);
3217c478bd9Sstevel@tonic-gate close(fdout);
3227c478bd9Sstevel@tonic-gate v = sizeof(struct Font) + 3 * n + dev.nchtab + 128-32;
3237c478bd9Sstevel@tonic-gate fprintf(stderr, "%3s: %3d chars, width %3d, size %3d\n",
3247c478bd9Sstevel@tonic-gate font.namefont, nw, width[0], v);
325*f928ce67Sceastha return (v);
3267c478bd9Sstevel@tonic-gate }
3277c478bd9Sstevel@tonic-gate
328*f928ce67Sceastha static int
getlig(FILE * fin)329*f928ce67Sceastha getlig(FILE *fin) /* pick up ligature list */
3307c478bd9Sstevel@tonic-gate {
3317c478bd9Sstevel@tonic-gate int lig;
3327c478bd9Sstevel@tonic-gate char temp[100];
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate lig = 0;
3357c478bd9Sstevel@tonic-gate while (fscanf(fin, "%s", temp) != EOF && strcmp(temp, "0") != 0) {
3367c478bd9Sstevel@tonic-gate if (strcmp(temp, "fi") == 0)
3377c478bd9Sstevel@tonic-gate lig |= LFI;
3387c478bd9Sstevel@tonic-gate else if (strcmp(temp, "fl") == 0)
3397c478bd9Sstevel@tonic-gate lig |= LFL;
3407c478bd9Sstevel@tonic-gate else if (strcmp(temp, "ff") == 0)
3417c478bd9Sstevel@tonic-gate lig |= LFF;
3427c478bd9Sstevel@tonic-gate else if (strcmp(temp, "ffi") == 0)
3437c478bd9Sstevel@tonic-gate lig |= LFFI;
3447c478bd9Sstevel@tonic-gate else if (strcmp(temp, "ffl") == 0)
3457c478bd9Sstevel@tonic-gate lig |= LFFL;
3467c478bd9Sstevel@tonic-gate else
3477c478bd9Sstevel@tonic-gate fprintf(stderr, "illegal ligature %s\n", temp);
3487c478bd9Sstevel@tonic-gate }
3497c478bd9Sstevel@tonic-gate skipline(fin);
350*f928ce67Sceastha return (lig);
3517c478bd9Sstevel@tonic-gate }
352