t6.c revision e5190c108bde19ca4d7c03b1d1eab7b00bd3a1ed
/*
* 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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* t6.c
*
* width functions, sizes and fonts
*/
#include "tdef.h"
#include "dev.h"
#include <ctype.h>
#include "ext.h"
/* fitab[f][c] is 0 if c is not on font f */
/* if it's non-zero, c is in fontab[f] at position
* fitab[f][c].
*/
extern int nchtab;
short *pstab;
int sbold = 0;
int
width(j)
tchar j;
{
int i, k;
if (iszbit(j))
return(0);
if (isvmot(j))
return(0);
k = absmot(j);
if (isnmot(j))
k = -k;
return(k);
}
i = cbits(j);
if (i < ' ') {
if (i == '\b')
return(-widthp);
if (i == PRESC)
i = eschar;
else if (iscontrol(i))
return(0);
}
if (i==ohc)
return(0);
i = trtab[i];
if (i < 32)
return(0);
} else
xbits(j, 0);
else {
k = getcw(i-32);
if (bd)
if (cs)
k = cs;
}
widthp = k;
return(k);
}
/*
* clear width cache-- s means just space
*/
int
zapwcache(s)
{
int i;
if (s) {
return (0);
}
for (i=0; i<NWIDCACHE; i++)
return (0);
}
int
getcw(i)
int i;
{
int k;
char *p;
int x, j;
int nocache = 0;
bd = 0;
goto g0;
}
if (i == 0) { /* a blank */
/* this nonsense because .ss cmd uses 1/36 em as its units */
/* and default is 12 */
goto g1;
}
/* search through search list of xfont
* to see what font it ought to be on.
* searches S, then remaining fonts in wraparound order.
*/
nocache = 1;
if (smnt) {
if (j != 0) {
k = *(p + j);
if (setwdf)
goto g1;
}
}
}
goto g1;
}
g0:
if (setwdf)
k = *(p + j);
g1:
if (!bd)
nocache = 1;
x = ccs;
else
x = xpts;
}
else {
}
return(k);
* Units is the fundamental digitization
* of the character set widths, and
* Point is the number of goobies in a point
* e.g., for cat, Units=36, Point=6, so Unitwidth=36/6=6
* In effect, it's the size at which the widths
* translate directly into units.
*/
}
int
abscw(n) /* return index of abs char n in fontab[], etc. */
{ int i, ncf;
for (i = 0; i < ncf; i++)
return i;
return 0;
}
int
tchar i;
{
int k;
k = sbits(i);
if (k) {
return (0);
}
switch (bitf) {
case 0:
break;
case 1:
break;
case 2:
}
return (0);
}
{
int j;
char temp[10];
char *s;
extern char *chname;
extern short *chtab;
extern int nchtab;
s = temp;
return(0);
*s = '\0';
for (j = 0; j < nchtab; j++)
return(j + 128 | chbits);
return(0);
}
{
int i, n, nf;
extern int nchtab;
getch();
n = 0;
n = inumb(&n);
getch();
if (nonumb)
return 0;
return n + nchtab + 128;
}
int
findft(i)
int i;
{
int k;
return(k);
for (k = 0; fontlab[k] != i; k++)
if (k > nfonts)
return(-1);
return(k);
}
int
caseps()
{
int i;
if (skip())
i = apts1;
else {
noscale++;
noscale = 0;
if (nonumb)
return (0);
}
casps1(i);
return (0);
}
int
casps1(i)
int i;
{
/*
* in olden times, it used to ignore changes to 0 or negative.
* this is meant to allow the requested size to be anything,
* in particular so eqn can generate lots of \s-3's and still
* get back by matching \s+3's.
if (i <= 0)
return (0);
*/
apts = i;
mchbits();
return (0);
}
int
findps(i)
int i;
{
int j, k;
for (j=k=0 ; pstab[j] != 0 ; j++)
k = j;
return(pstab[k]);
}
int
mchbits()
{
int i, j, k;
i = pts;
for (j = 0; i > (k = pstab[j]); j++)
if (!k) {
k = pstab[--j];
break;
}
chbits = 0;
zapwcache(1);
return (0);
}
int
setps()
{
int i, j;
i -= '0';
if (i == 0) /* \s0 */
j = apts1;
isdigit(j)) { /* \sdd */
j = 10 * i + j - '0';
ch = 0;
} else /* \sd */
j = i;
} else if (i == '(') { /* \s(dd */
if (j == 0) /* \s(00 */
j = apts1;
} else if (i == '+' || i == '-') { /* \s+, \s- */
j -= '0';
} else if (j == '(') { /* \s+(dd, \s-(dd */
}
if (i == '-')
j = -j;
j += apts;
}
casps1(j);
return (0);
}
{
int n;
tchar c;
getch();
getch();
if (n == 0 || nonumb)
n = apts; /* does this work? */
c = CHARHT;
c |= ZBIT;
setsbits(c, n);
return(c);
}
{
int n;
tchar c;
getch();
n = 0;
n = inumb(&n);
getch();
if (nonumb)
n = 0;
c = SLANT;
c |= ZBIT;
setsfbits(c, n+180);
return(c);
}
int
caseft()
{
skip();
setfont(1);
return (0);
}
int
setfont(a)
int a;
{
int i, j;
if (a)
i = getrq();
else
i = getsn();
if (!i || i == 'P') {
j = font1;
goto s0;
}
if (i == 'S' || i == '0')
return (0);
if ((j = findft(i)) == -1)
return (0);
s0:
font = j;
mchbits();
return (0);
}
int
setwd()
{
tchar i;
return (0);
setwdf++;
k = width(i);
wid += k;
if (!ismot(i)) {
} else if (isvmot(i)) {
k = absmot(i);
if (isnmot(i))
k = -k;
base -= k;
emsz = 0;
} else
continue;
}
mchbits();
setwdf = 0;
return (0);
}
{
vflag++;
return(mot());
}
{
return(mot());
}
{
int j, n;
tchar i;
j = HOR;
getch(); /*eat delim*/
if (n = atoi()) {
if (vflag)
j = VERT;
} else
i = 0;
getch();
vflag = 0;
dfact = 1;
return(i);
}
int k;
{
int j;
tchar i;
j = EM / 2;
if (k == 'u')
j = -j;
else if (k == 'r')
j = -2 * j;
vflag++;
i = makem(j);
vflag = 0;
return(i);
}
int i;
{
tchar j;
if ((j = i) < 0)
j = -j;
j |= MOT;
if (i < 0)
j |= NMOT;
if (vflag)
j |= VMOT;
return(j);
}
tchar i;
{
tchar j, k;
int lf;
return(i);
j = getch0();
j = LIG_FI;
j = LIG_FL;
k = getch0();
j = LIG_FFI;
j = LIG_FFL;
else {
*pbp++ = k;
j = LIG_FF;
}
} else
j = LIG_FF;
} else {
*pbp++ = j;
j = i;
}
return(i & SFMASK | j);
}
int
caselg()
{
lg = 1;
if (skip())
return (0);
return (0);
}
int
casefp()
{
int i, j;
char *s;
skip();
setfp(i, j, 0);
else /* 3rd argument = filename */
return (0);
}
int
int pos, f;
char *truename;
{
int k;
int n;
extern int nchtab;
zapwcache(0);
if (truename)
else {
}
return(-1);
}
/* have to reset the fitab pointer because the width may be different */
pos);
return(-1);
}
close(k);
smnt = 0;
sbold = 0;
}
/* if there is a directory, no place to store its name. */
/* if position isn't zero, no place to store its value. */
/* only time a FONTPOS is pushed back is if it's a */
/* standard font on position 0 (i.e., mounted implicitly. */
/* there's a bug here: if there are several input lines */
/* that look like .ft XX in short successtion, the output */
/* will all be in the last one because the "x font ..." */
/* comes out too soon. pushing back FONTPOS doesn't work */
/* with .ft commands because input is flushed after .xx cmds */
if (pos == 0)
return(pos);
}
int
casecs()
{
int i, j;
noscale++;
skip();
goto rtn;
skip();
skip();
j = atoi();
if (nonumb)
ccstab[i] = 0;
else
rtn:
zapwcache(0);
noscale = 0;
return (0);
}
int
casebd()
{
int i, j, k;
zapwcache(0);
k = 0;
bd0:
if (k)
goto bd1;
else
return (0);
}
if (j == smnt) {
k = smnt;
goto bd0;
}
if (k) {
sbold = j;
j = k;
}
bd1:
skip();
noscale++;
noscale = 0;
return (0);
}
int
casevs()
{
int i;
skip();
vflag++;
dfactd = 72;
if (nonumb)
i = lss1;
if (i < VERT)
i = VERT;
lss = i;
return (0);
}
int
casess()
{
int i;
noscale++;
skip();
if (i = atoi()) {
spacesz = i & 0177;
zapwcache(0);
}
noscale = 0;
return (0);
}
{
/* stores \x'...' into
* two successive tchars.
* the first contains HX, the second the value,
* encoded as a vertical motion.
* decoding is done in n2.c by pchar().
*/
int i;
getch();
dfact = 1;
getch();
if (i >= 0)
else
return(HX);
}