makedev.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
/*
* This is a special version of makedev, tailored for the font disk
* of the APS-5 in the MH Computing Center. It is not to be used
* to set up font description files for other devices.
*
* makedev:
* read text info about a particular device
* (e.g., cat, 202, aps5) from file, convert
* it into internal (binary) form suitable for
* fast reading by troff initialization (ptinit()).
*
* Usage:
*
* makedev DESC [ F ... ]
* uses DESC to create a description file
* using the information therein.
* It creates the file DESC.out.
*
* makedev F ...
* makes the font tables for fonts F only,
* creates files F.out.
*
* DESC.out contains:
* dev structure with fundamental sizes
* list of sizes (nsizes+1) terminated by 0, as short's
* indices of char names (nchtab * sizeof (short))
* char names as hy\0em\0... (lchname)
* nfonts occurrences of
* widths (nwidth)
* kerning (nwidth) [ascender+descender only so far]
* codes (nwidth) to drive actual typesetter
* fitab (nchtab+128-32)
* each of these is an array of char.
*
* dev.filesize contains the number of bytes
* in the file, excluding the dev part itself.
*
* F.out contains the font header, width, kern, codes, and fitab.
* Width, kern and codes are parallel arrays.
* (Which suggests that they ought to be together?)
* Later, we might allow for codes which are actually
* sequences of formatting info so characters can be drawn.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include "dev.h"
#define BYTEMASK 0377
/* zero if not there */
int dbg = 0; /* debug flag */
int fflag = 0; /* on if font table to be written */
int fdout; /* output file descriptor */
char *fout = "DESC.out";
void dump_font(void);
int
{
char cmd[100], *p;
int i, totfont, v;
if (argc < 2) {
exit(1);
}
exit(1);
}
dbg++;
p = chname;
while (*p++) /* skip to end of name */
;
}
} else
}
if (fdout < 0) {
exit(1);
}
/* we need a 0 on the end */
totfont = 0;
}
/* back to beginning to install proper size */
+ totfont * sizeof (char);
argc--;
argv++;
}
for (i = 1; i < argc; i++)
exit(0);
}
int
/* string containing name of font */
{
int fdout; /* output file descriptor */
int i, nw, spacewidth, n, v;
int count; /* value returned from sscanf() */
int dflt_range; /* default maximum range for font */
int dflt_slant; /* default slant for this font */
/*
* This routine is responsible for making the '.out' file for
* the font specified by the parameter name. It also sets up some
* of the data structures needed to make the DESC.out file in the
* main routine. In addition I have changed this routine so that
* we can add some typesetter dependent parameters to the font
* files and have this information dumped out to a 'add' file
* for this font, which can be read as needed by the aps driver.
*/
exit(2);
} /* End if */
spacewidth = 0; /* really useful for CW font */
dflt_slant = 0; /* no slant for this font yet */
for (i = 0; i < NFITAB; i++) /* initialize font index table */
fitab[i] = 0;
for (i = 0; i < FSIZE; i++) { /* initialize font index table */
alt_font[i] = 0;
alt_code[i] = 0;
} /* End for */
if (cmd[0] == '#')
/* width of space on this font */
width[0] = spacewidth;
nw = 0;
/* widths are origin 1 so fitab==0 can mean */
/* "not there" */
if (s1[0] != '"') {
/* it's a genuine new character */
nw++;
/* temporarily, pick up one byte as */
/* code */
if (s3[0] == '0')
else
} /* End if */
/* otherwise it's a synonym for previous */
/* character, so leave previous values intact */
/* fitab origin omits non-graphics */
else { /* it has a funny name */
ch) == 0) {
/* starts after the */
/* ascii */
break;
} /* End if */
"makedev: font %s: %s not "
} /* End else */
} /* End while */
nw++;
n = dev.biggestfont;
else {
if (dev.biggestfont > 0)
name);
n = nw;
}
/* clear two slant val bits */
/* set font slant bit */
/* read the default slant value */
if (dflt_slant > 0) /* encode it as 01 */
else if (dflt_slant < 0) /* encode it as 10 */
/* set range bit in spare1 */
/* read default font slant */
"makedev: illegal default range %d\n",
exit(1);
} /* End if */
dbg++;
} /* End while */
if (spacewidth == 0)
if (dbg)
dump_font();
return (v);
} /* End of dofont */
/* pick up ligature list */
int
{
int lig;
char temp[100];
lig = 0;
else
}
return (lig);
} /* End of getlg */
void
char *buf, /* last input line */
int nw) /* data for next char goes here */
{
char s[3][20]; /* used for special char commands */
char v[3][20]; /* and their values */
int count; /* number of extra commands */
int range; /* largest allowed master range */
int angle; /* slant the character by this much */
int i; /* loop index */
/*
*
* Called from dofont() to interpret any extra fields in the current input
* line. The additional stuff can include one or more of the following
*
* slant n
* max_range n
* font n
*
* separated by white space and in any order. In all the above n is an
* integer. Comments will really screw things up so leave them out of the
* charset part in the APS-5 font files.
*
*/
s[0], v[0], s[1], v[1], s[2], v[2]);
exit(1);
} /* End if */
for (i = 0; i < count/2; i++) {
if (strcmp(s[i], "font") == 0) {
/* get char from another font */
/* daps checks this bit */
} else if (strcmp(s[i], "max_range") == 0) {
exit(1);
} /* End if */
} else if (strcmp(s[i], "slant") == 0) {
if (angle > 0) /* again daps understands these */
else if (angle < 0)
} else {
exit(1);
} /* End else */
} /* End for */
exit(1);
} /* End if */
} /* End of finish_line */
void
{
int fdout; /* output file descriptor */
int k; /* number of width entries */
/*
*
* If there were any special requests made in the current font file we'll
* want to save the real data (for daps) in a binary file that ends with
* the suffix ".add". When daps tries to print a character and finds that
* it's character code bigger than 129 it knows it will need to get more
* real data from the appropriate .add file.
*
*/
} /* End of add_font */
void
dump_font(void)
{
int pos; /* position in character tables */
int j; /* for loop index */
int code_val; /* number in code table */
/*
*
* Just a debugging routine that's really not important anymore. It's
* called from dofont() after everything's been built for the current
* font file. Need to include the string "debug" in the font file that
* we want to check.
*
*/
printf(" font structure data:\n");
printf(" CHAR WIDTH KERN CODE INDEX\n");
if (j >= 96)
printf("%10d", j);
if (code_val > 128) {
printf(" slant %d",
printf(" range %d",
} /* End if */
printf("\n");
} /* End if */
} /* End for */
printf("\n\n");
} /* End of dump_font */