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 */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 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 40*e5190c10Smuffin #pragma ident "%Z%%M% %I% %E% SMI" 41*e5190c10Smuffin 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * t6.c 447c478bd9Sstevel@tonic-gate * 457c478bd9Sstevel@tonic-gate * width functions, sizes and fonts 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate #include "tdef.h" 497c478bd9Sstevel@tonic-gate #include "dev.h" 507c478bd9Sstevel@tonic-gate #include <ctype.h> 517c478bd9Sstevel@tonic-gate #include "ext.h" 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* fitab[f][c] is 0 if c is not on font f */ 547c478bd9Sstevel@tonic-gate /* if it's non-zero, c is in fontab[f] at position 557c478bd9Sstevel@tonic-gate * fitab[f][c]. 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate extern struct Font *fontbase[NFONT+1]; 587c478bd9Sstevel@tonic-gate extern char *codetab[NFONT+1]; 597c478bd9Sstevel@tonic-gate extern int nchtab; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate int fontlab[NFONT+1]; 627c478bd9Sstevel@tonic-gate short *pstab; 637c478bd9Sstevel@tonic-gate int cstab[NFONT+1]; 647c478bd9Sstevel@tonic-gate int ccstab[NFONT+1]; 657c478bd9Sstevel@tonic-gate int bdtab[NFONT+1]; 667c478bd9Sstevel@tonic-gate int sbold = 0; 677c478bd9Sstevel@tonic-gate 68*e5190c10Smuffin int 697c478bd9Sstevel@tonic-gate width(j) 70*e5190c10Smuffin tchar j; 717c478bd9Sstevel@tonic-gate { 72*e5190c10Smuffin int i, k; 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate if (j & (ZBIT|MOT)) { 757c478bd9Sstevel@tonic-gate if (iszbit(j)) 767c478bd9Sstevel@tonic-gate return(0); 777c478bd9Sstevel@tonic-gate if (isvmot(j)) 787c478bd9Sstevel@tonic-gate return(0); 797c478bd9Sstevel@tonic-gate k = absmot(j); 807c478bd9Sstevel@tonic-gate if (isnmot(j)) 817c478bd9Sstevel@tonic-gate k = -k; 827c478bd9Sstevel@tonic-gate return(k); 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate i = cbits(j); 857c478bd9Sstevel@tonic-gate if (i < ' ') { 867c478bd9Sstevel@tonic-gate if (i == '\b') 877c478bd9Sstevel@tonic-gate return(-widthp); 887c478bd9Sstevel@tonic-gate if (i == PRESC) 897c478bd9Sstevel@tonic-gate i = eschar; 907c478bd9Sstevel@tonic-gate else if (iscontrol(i)) 917c478bd9Sstevel@tonic-gate return(0); 927c478bd9Sstevel@tonic-gate } 937c478bd9Sstevel@tonic-gate if (i==ohc) 947c478bd9Sstevel@tonic-gate return(0); 957c478bd9Sstevel@tonic-gate i = trtab[i]; 967c478bd9Sstevel@tonic-gate if (i < 32) 977c478bd9Sstevel@tonic-gate return(0); 987c478bd9Sstevel@tonic-gate if (sfbits(j) == oldbits) { 997c478bd9Sstevel@tonic-gate xfont = pfont; 1007c478bd9Sstevel@tonic-gate xpts = ppts; 1017c478bd9Sstevel@tonic-gate } else 1027c478bd9Sstevel@tonic-gate xbits(j, 0); 1037c478bd9Sstevel@tonic-gate if (widcache[i-32].fontpts == (xfont<<8) + xpts && !setwdf) 1047c478bd9Sstevel@tonic-gate k = widcache[i-32].width; 1057c478bd9Sstevel@tonic-gate else { 1067c478bd9Sstevel@tonic-gate k = getcw(i-32); 1077c478bd9Sstevel@tonic-gate if (bd) 1087c478bd9Sstevel@tonic-gate k += (bd - 1) * HOR; 1097c478bd9Sstevel@tonic-gate if (cs) 1107c478bd9Sstevel@tonic-gate k = cs; 1117c478bd9Sstevel@tonic-gate } 1127c478bd9Sstevel@tonic-gate widthp = k; 1137c478bd9Sstevel@tonic-gate return(k); 1147c478bd9Sstevel@tonic-gate } 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate /* 1177c478bd9Sstevel@tonic-gate * clear width cache-- s means just space 1187c478bd9Sstevel@tonic-gate */ 119*e5190c10Smuffin int 1207c478bd9Sstevel@tonic-gate zapwcache(s) 1217c478bd9Sstevel@tonic-gate { 122*e5190c10Smuffin int i; 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate if (s) { 1257c478bd9Sstevel@tonic-gate widcache[0].fontpts = 0; 126*e5190c10Smuffin return (0); 1277c478bd9Sstevel@tonic-gate } 1287c478bd9Sstevel@tonic-gate for (i=0; i<NWIDCACHE; i++) 1297c478bd9Sstevel@tonic-gate widcache[i].fontpts = 0; 130*e5190c10Smuffin 131*e5190c10Smuffin return (0); 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate 134*e5190c10Smuffin int 1357c478bd9Sstevel@tonic-gate getcw(i) 136*e5190c10Smuffin int i; 1377c478bd9Sstevel@tonic-gate { 138*e5190c10Smuffin int k; 139*e5190c10Smuffin char *p; 140*e5190c10Smuffin int x, j; 1417c478bd9Sstevel@tonic-gate int nocache = 0; 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate bd = 0; 1447c478bd9Sstevel@tonic-gate if (i >= nchtab + 128-32) { 1457c478bd9Sstevel@tonic-gate j = abscw(i + 32 - (nchtab+128)); 1467c478bd9Sstevel@tonic-gate goto g0; 1477c478bd9Sstevel@tonic-gate } 1487c478bd9Sstevel@tonic-gate if (i == 0) { /* a blank */ 1497c478bd9Sstevel@tonic-gate k = (fontab[xfont][0] * spacesz + 6) / 12; 1507c478bd9Sstevel@tonic-gate /* this nonsense because .ss cmd uses 1/36 em as its units */ 1517c478bd9Sstevel@tonic-gate /* and default is 12 */ 1527c478bd9Sstevel@tonic-gate goto g1; 1537c478bd9Sstevel@tonic-gate } 1547c478bd9Sstevel@tonic-gate if ((j = fitab[xfont][i] & BYTEMASK) == 0) { /* it's not on current font */ 1557c478bd9Sstevel@tonic-gate /* search through search list of xfont 1567c478bd9Sstevel@tonic-gate * to see what font it ought to be on. 1577c478bd9Sstevel@tonic-gate * searches S, then remaining fonts in wraparound order. 1587c478bd9Sstevel@tonic-gate */ 1597c478bd9Sstevel@tonic-gate nocache = 1; 1607c478bd9Sstevel@tonic-gate if (smnt) { 1617c478bd9Sstevel@tonic-gate int ii, jj; 1627c478bd9Sstevel@tonic-gate for (ii=smnt, jj=0; jj < nfonts; jj++, ii=ii % nfonts + 1) { 1637c478bd9Sstevel@tonic-gate j = fitab[ii][i] & BYTEMASK; 1647c478bd9Sstevel@tonic-gate if (j != 0) { 1657c478bd9Sstevel@tonic-gate p = fontab[ii]; 1667c478bd9Sstevel@tonic-gate k = *(p + j); 1677c478bd9Sstevel@tonic-gate if (xfont == sbold) 1687c478bd9Sstevel@tonic-gate bd = bdtab[ii]; 1697c478bd9Sstevel@tonic-gate if (setwdf) 1707c478bd9Sstevel@tonic-gate numtab[CT].val |= kerntab[ii][j]; 1717c478bd9Sstevel@tonic-gate goto g1; 1727c478bd9Sstevel@tonic-gate } 1737c478bd9Sstevel@tonic-gate } 1747c478bd9Sstevel@tonic-gate } 1757c478bd9Sstevel@tonic-gate k = fontab[xfont][0]; /* leave a space-size space */ 1767c478bd9Sstevel@tonic-gate goto g1; 1777c478bd9Sstevel@tonic-gate } 1787c478bd9Sstevel@tonic-gate g0: 1797c478bd9Sstevel@tonic-gate p = fontab[xfont]; 1807c478bd9Sstevel@tonic-gate if (setwdf) 1817c478bd9Sstevel@tonic-gate numtab[CT].val |= kerntab[xfont][j]; 1827c478bd9Sstevel@tonic-gate k = *(p + j); 1837c478bd9Sstevel@tonic-gate g1: 1847c478bd9Sstevel@tonic-gate if (!bd) 1857c478bd9Sstevel@tonic-gate bd = bdtab[xfont]; 1867c478bd9Sstevel@tonic-gate if (cs = cstab[xfont]) { 1877c478bd9Sstevel@tonic-gate nocache = 1; 1887c478bd9Sstevel@tonic-gate if (ccs = ccstab[xfont]) 1897c478bd9Sstevel@tonic-gate x = ccs; 1907c478bd9Sstevel@tonic-gate else 1917c478bd9Sstevel@tonic-gate x = xpts; 1927c478bd9Sstevel@tonic-gate cs = (cs * EMPTS(x)) / 36; 1937c478bd9Sstevel@tonic-gate } 1947c478bd9Sstevel@tonic-gate k = ((k&BYTEMASK) * xpts + (Unitwidth / 2)) / Unitwidth; 1957c478bd9Sstevel@tonic-gate if (nocache|bd) 1967c478bd9Sstevel@tonic-gate widcache[i].fontpts = 0; 1977c478bd9Sstevel@tonic-gate else { 1987c478bd9Sstevel@tonic-gate widcache[i].fontpts = (xfont<<8) + xpts; 1997c478bd9Sstevel@tonic-gate widcache[i].width = k; 2007c478bd9Sstevel@tonic-gate } 2017c478bd9Sstevel@tonic-gate return(k); 2027c478bd9Sstevel@tonic-gate /* Unitwidth is Units/Point, where 2037c478bd9Sstevel@tonic-gate * Units is the fundamental digitization 2047c478bd9Sstevel@tonic-gate * of the character set widths, and 2057c478bd9Sstevel@tonic-gate * Point is the number of goobies in a point 2067c478bd9Sstevel@tonic-gate * e.g., for cat, Units=36, Point=6, so Unitwidth=36/6=6 2077c478bd9Sstevel@tonic-gate * In effect, it's the size at which the widths 2087c478bd9Sstevel@tonic-gate * translate directly into units. 2097c478bd9Sstevel@tonic-gate */ 2107c478bd9Sstevel@tonic-gate } 2117c478bd9Sstevel@tonic-gate 212*e5190c10Smuffin int 2137c478bd9Sstevel@tonic-gate abscw(n) /* return index of abs char n in fontab[], etc. */ 214*e5190c10Smuffin { int i, ncf; 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate ncf = fontbase[xfont]->nwfont & BYTEMASK; 2177c478bd9Sstevel@tonic-gate for (i = 0; i < ncf; i++) 2187c478bd9Sstevel@tonic-gate if (codetab[xfont][i] == n) 2197c478bd9Sstevel@tonic-gate return i; 2207c478bd9Sstevel@tonic-gate return 0; 2217c478bd9Sstevel@tonic-gate } 2227c478bd9Sstevel@tonic-gate 223*e5190c10Smuffin int 2247c478bd9Sstevel@tonic-gate xbits(i, bitf) 225*e5190c10Smuffin tchar i; 2267c478bd9Sstevel@tonic-gate { 227*e5190c10Smuffin int k; 2287c478bd9Sstevel@tonic-gate 2297c478bd9Sstevel@tonic-gate xfont = fbits(i); 2307c478bd9Sstevel@tonic-gate k = sbits(i); 2317c478bd9Sstevel@tonic-gate if (k) { 2327c478bd9Sstevel@tonic-gate xpts = pstab[--k]; 2337c478bd9Sstevel@tonic-gate oldbits = sfbits(i); 2347c478bd9Sstevel@tonic-gate pfont = xfont; 2357c478bd9Sstevel@tonic-gate ppts = xpts; 236*e5190c10Smuffin return (0); 2377c478bd9Sstevel@tonic-gate } 2387c478bd9Sstevel@tonic-gate switch (bitf) { 2397c478bd9Sstevel@tonic-gate case 0: 2407c478bd9Sstevel@tonic-gate xfont = font; 2417c478bd9Sstevel@tonic-gate xpts = pts; 2427c478bd9Sstevel@tonic-gate break; 2437c478bd9Sstevel@tonic-gate case 1: 2447c478bd9Sstevel@tonic-gate xfont = pfont; 2457c478bd9Sstevel@tonic-gate xpts = ppts; 2467c478bd9Sstevel@tonic-gate break; 2477c478bd9Sstevel@tonic-gate case 2: 2487c478bd9Sstevel@tonic-gate xfont = mfont; 2497c478bd9Sstevel@tonic-gate xpts = mpts; 2507c478bd9Sstevel@tonic-gate } 251*e5190c10Smuffin 252*e5190c10Smuffin return (0); 2537c478bd9Sstevel@tonic-gate } 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate tchar setch() 2577c478bd9Sstevel@tonic-gate { 258*e5190c10Smuffin int j; 2597c478bd9Sstevel@tonic-gate char temp[10]; 260*e5190c10Smuffin char *s; 2617c478bd9Sstevel@tonic-gate extern char *chname; 2627c478bd9Sstevel@tonic-gate extern short *chtab; 2637c478bd9Sstevel@tonic-gate extern int nchtab; 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate s = temp; 2667c478bd9Sstevel@tonic-gate if ((*s++ = getach()) == 0 || (*s++ = getach()) == 0) 2677c478bd9Sstevel@tonic-gate return(0); 2687c478bd9Sstevel@tonic-gate *s = '\0'; 2697c478bd9Sstevel@tonic-gate for (j = 0; j < nchtab; j++) 2707c478bd9Sstevel@tonic-gate if (strcmp(&chname[chtab[j]], temp) == 0) 2717c478bd9Sstevel@tonic-gate return(j + 128 | chbits); 2727c478bd9Sstevel@tonic-gate return(0); 2737c478bd9Sstevel@tonic-gate } 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate tchar setabs() /* set absolute char from \C'...' */ 2767c478bd9Sstevel@tonic-gate { 2777c478bd9Sstevel@tonic-gate int i, n, nf; 2787c478bd9Sstevel@tonic-gate extern int nchtab; 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate getch(); 2817c478bd9Sstevel@tonic-gate n = 0; 2827c478bd9Sstevel@tonic-gate n = inumb(&n); 2837c478bd9Sstevel@tonic-gate getch(); 2847c478bd9Sstevel@tonic-gate if (nonumb) 2857c478bd9Sstevel@tonic-gate return 0; 2867c478bd9Sstevel@tonic-gate return n + nchtab + 128; 2877c478bd9Sstevel@tonic-gate } 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate 2907c478bd9Sstevel@tonic-gate 291*e5190c10Smuffin int 2927c478bd9Sstevel@tonic-gate findft(i) 293*e5190c10Smuffin int i; 2947c478bd9Sstevel@tonic-gate { 295*e5190c10Smuffin int k; 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate if ((k = i - '0') >= 0 && k <= nfonts && k < smnt) 2987c478bd9Sstevel@tonic-gate return(k); 2997c478bd9Sstevel@tonic-gate for (k = 0; fontlab[k] != i; k++) 3007c478bd9Sstevel@tonic-gate if (k > nfonts) 3017c478bd9Sstevel@tonic-gate return(-1); 3027c478bd9Sstevel@tonic-gate return(k); 3037c478bd9Sstevel@tonic-gate } 3047c478bd9Sstevel@tonic-gate 3057c478bd9Sstevel@tonic-gate 306*e5190c10Smuffin int 3077c478bd9Sstevel@tonic-gate caseps() 3087c478bd9Sstevel@tonic-gate { 309*e5190c10Smuffin int i; 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate if (skip()) 3127c478bd9Sstevel@tonic-gate i = apts1; 3137c478bd9Sstevel@tonic-gate else { 3147c478bd9Sstevel@tonic-gate noscale++; 3157c478bd9Sstevel@tonic-gate i = inumb(&apts); /* this is a disaster for fractional point sizes */ 3167c478bd9Sstevel@tonic-gate noscale = 0; 3177c478bd9Sstevel@tonic-gate if (nonumb) 318*e5190c10Smuffin return (0); 3197c478bd9Sstevel@tonic-gate } 3207c478bd9Sstevel@tonic-gate casps1(i); 321*e5190c10Smuffin 322*e5190c10Smuffin return (0); 3237c478bd9Sstevel@tonic-gate } 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate 326*e5190c10Smuffin int 3277c478bd9Sstevel@tonic-gate casps1(i) 328*e5190c10Smuffin int i; 3297c478bd9Sstevel@tonic-gate { 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate /* 3327c478bd9Sstevel@tonic-gate * in olden times, it used to ignore changes to 0 or negative. 3337c478bd9Sstevel@tonic-gate * this is meant to allow the requested size to be anything, 3347c478bd9Sstevel@tonic-gate * in particular so eqn can generate lots of \s-3's and still 3357c478bd9Sstevel@tonic-gate * get back by matching \s+3's. 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate if (i <= 0) 338*e5190c10Smuffin return (0); 3397c478bd9Sstevel@tonic-gate */ 3407c478bd9Sstevel@tonic-gate apts1 = apts; 3417c478bd9Sstevel@tonic-gate apts = i; 3427c478bd9Sstevel@tonic-gate pts1 = pts; 3437c478bd9Sstevel@tonic-gate pts = findps(i); 3447c478bd9Sstevel@tonic-gate mchbits(); 345*e5190c10Smuffin 346*e5190c10Smuffin return (0); 3477c478bd9Sstevel@tonic-gate } 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate 350*e5190c10Smuffin int 3517c478bd9Sstevel@tonic-gate findps(i) 352*e5190c10Smuffin int i; 3537c478bd9Sstevel@tonic-gate { 354*e5190c10Smuffin int j, k; 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate for (j=k=0 ; pstab[j] != 0 ; j++) 3577c478bd9Sstevel@tonic-gate if (abs(pstab[j]-i) < abs(pstab[k]-i)) 3587c478bd9Sstevel@tonic-gate k = j; 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate return(pstab[k]); 3617c478bd9Sstevel@tonic-gate } 3627c478bd9Sstevel@tonic-gate 3637c478bd9Sstevel@tonic-gate 364*e5190c10Smuffin int 3657c478bd9Sstevel@tonic-gate mchbits() 3667c478bd9Sstevel@tonic-gate { 367*e5190c10Smuffin int i, j, k; 3687c478bd9Sstevel@tonic-gate 3697c478bd9Sstevel@tonic-gate i = pts; 3707c478bd9Sstevel@tonic-gate for (j = 0; i > (k = pstab[j]); j++) 3717c478bd9Sstevel@tonic-gate if (!k) { 3727c478bd9Sstevel@tonic-gate k = pstab[--j]; 3737c478bd9Sstevel@tonic-gate break; 3747c478bd9Sstevel@tonic-gate } 3757c478bd9Sstevel@tonic-gate chbits = 0; 3767c478bd9Sstevel@tonic-gate setsbits(chbits, ++j); 3777c478bd9Sstevel@tonic-gate setfbits(chbits, font); 3787c478bd9Sstevel@tonic-gate sps = width(' ' | chbits); 3797c478bd9Sstevel@tonic-gate zapwcache(1); 380*e5190c10Smuffin 381*e5190c10Smuffin return (0); 3827c478bd9Sstevel@tonic-gate } 3837c478bd9Sstevel@tonic-gate 384*e5190c10Smuffin int 3857c478bd9Sstevel@tonic-gate setps() 3867c478bd9Sstevel@tonic-gate { 387*e5190c10Smuffin int i, j; 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate i = cbits(getch()); 3907c478bd9Sstevel@tonic-gate if (ischar(i) && isdigit(i)) { /* \sd or \sdd */ 3917c478bd9Sstevel@tonic-gate i -= '0'; 3927c478bd9Sstevel@tonic-gate if (i == 0) /* \s0 */ 3937c478bd9Sstevel@tonic-gate j = apts1; 3947c478bd9Sstevel@tonic-gate else if (i <= 3 && ischar(j = cbits(ch = getch())) && 3957c478bd9Sstevel@tonic-gate isdigit(j)) { /* \sdd */ 3967c478bd9Sstevel@tonic-gate j = 10 * i + j - '0'; 3977c478bd9Sstevel@tonic-gate ch = 0; 3987c478bd9Sstevel@tonic-gate } else /* \sd */ 3997c478bd9Sstevel@tonic-gate j = i; 4007c478bd9Sstevel@tonic-gate } else if (i == '(') { /* \s(dd */ 4017c478bd9Sstevel@tonic-gate j = cbits(getch()) - '0'; 4027c478bd9Sstevel@tonic-gate j = 10 * j + cbits(getch()) - '0'; 4037c478bd9Sstevel@tonic-gate if (j == 0) /* \s(00 */ 4047c478bd9Sstevel@tonic-gate j = apts1; 4057c478bd9Sstevel@tonic-gate } else if (i == '+' || i == '-') { /* \s+, \s- */ 4067c478bd9Sstevel@tonic-gate j = cbits(getch()); 4077c478bd9Sstevel@tonic-gate if (ischar(j) && isdigit(j)) { /* \s+d, \s-d */ 4087c478bd9Sstevel@tonic-gate j -= '0'; 4097c478bd9Sstevel@tonic-gate } else if (j == '(') { /* \s+(dd, \s-(dd */ 4107c478bd9Sstevel@tonic-gate j = cbits(getch()) - '0'; 4117c478bd9Sstevel@tonic-gate j = 10 * j + cbits(getch()) - '0'; 4127c478bd9Sstevel@tonic-gate } 4137c478bd9Sstevel@tonic-gate if (i == '-') 4147c478bd9Sstevel@tonic-gate j = -j; 4157c478bd9Sstevel@tonic-gate j += apts; 4167c478bd9Sstevel@tonic-gate } 4177c478bd9Sstevel@tonic-gate casps1(j); 418*e5190c10Smuffin 419*e5190c10Smuffin return (0); 4207c478bd9Sstevel@tonic-gate } 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate tchar setht() /* set character height from \H'...' */ 4247c478bd9Sstevel@tonic-gate { 4257c478bd9Sstevel@tonic-gate int n; 4267c478bd9Sstevel@tonic-gate tchar c; 4277c478bd9Sstevel@tonic-gate 4287c478bd9Sstevel@tonic-gate getch(); 4297c478bd9Sstevel@tonic-gate n = inumb(&apts); 4307c478bd9Sstevel@tonic-gate getch(); 4317c478bd9Sstevel@tonic-gate if (n == 0 || nonumb) 4327c478bd9Sstevel@tonic-gate n = apts; /* does this work? */ 4337c478bd9Sstevel@tonic-gate c = CHARHT; 4347c478bd9Sstevel@tonic-gate c |= ZBIT; 4357c478bd9Sstevel@tonic-gate setsbits(c, n); 4367c478bd9Sstevel@tonic-gate return(c); 4377c478bd9Sstevel@tonic-gate } 4387c478bd9Sstevel@tonic-gate 4397c478bd9Sstevel@tonic-gate tchar setslant() /* set slant from \S'...' */ 4407c478bd9Sstevel@tonic-gate { 4417c478bd9Sstevel@tonic-gate int n; 4427c478bd9Sstevel@tonic-gate tchar c; 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate getch(); 4457c478bd9Sstevel@tonic-gate n = 0; 4467c478bd9Sstevel@tonic-gate n = inumb(&n); 4477c478bd9Sstevel@tonic-gate getch(); 4487c478bd9Sstevel@tonic-gate if (nonumb) 4497c478bd9Sstevel@tonic-gate n = 0; 4507c478bd9Sstevel@tonic-gate c = SLANT; 4517c478bd9Sstevel@tonic-gate c |= ZBIT; 4527c478bd9Sstevel@tonic-gate setsfbits(c, n+180); 4537c478bd9Sstevel@tonic-gate return(c); 4547c478bd9Sstevel@tonic-gate } 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate 457*e5190c10Smuffin int 4587c478bd9Sstevel@tonic-gate caseft() 4597c478bd9Sstevel@tonic-gate { 4607c478bd9Sstevel@tonic-gate skip(); 4617c478bd9Sstevel@tonic-gate setfont(1); 462*e5190c10Smuffin 463*e5190c10Smuffin return (0); 4647c478bd9Sstevel@tonic-gate } 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate 467*e5190c10Smuffin int 4687c478bd9Sstevel@tonic-gate setfont(a) 4697c478bd9Sstevel@tonic-gate int a; 4707c478bd9Sstevel@tonic-gate { 471*e5190c10Smuffin int i, j; 4727c478bd9Sstevel@tonic-gate 4737c478bd9Sstevel@tonic-gate if (a) 4747c478bd9Sstevel@tonic-gate i = getrq(); 4757c478bd9Sstevel@tonic-gate else 4767c478bd9Sstevel@tonic-gate i = getsn(); 4777c478bd9Sstevel@tonic-gate if (!i || i == 'P') { 4787c478bd9Sstevel@tonic-gate j = font1; 4797c478bd9Sstevel@tonic-gate goto s0; 4807c478bd9Sstevel@tonic-gate } 4817c478bd9Sstevel@tonic-gate if (i == 'S' || i == '0') 482*e5190c10Smuffin return (0); 4837c478bd9Sstevel@tonic-gate if ((j = findft(i)) == -1) 4847c478bd9Sstevel@tonic-gate if ((j = setfp(0, i, 0)) == -1) /* try to put it in position 0 */ 485*e5190c10Smuffin return (0); 4867c478bd9Sstevel@tonic-gate s0: 4877c478bd9Sstevel@tonic-gate font1 = font; 4887c478bd9Sstevel@tonic-gate font = j; 4897c478bd9Sstevel@tonic-gate mchbits(); 490*e5190c10Smuffin 491*e5190c10Smuffin return (0); 4927c478bd9Sstevel@tonic-gate } 4937c478bd9Sstevel@tonic-gate 4947c478bd9Sstevel@tonic-gate 495*e5190c10Smuffin int 4967c478bd9Sstevel@tonic-gate setwd() 4977c478bd9Sstevel@tonic-gate { 498*e5190c10Smuffin int base, wid; 499*e5190c10Smuffin tchar i; 5007c478bd9Sstevel@tonic-gate int delim, emsz, k; 5017c478bd9Sstevel@tonic-gate int savhp, savapts, savapts1, savfont, savfont1, savpts, savpts1; 5027c478bd9Sstevel@tonic-gate 5037c478bd9Sstevel@tonic-gate base = numtab[ST].val = numtab[ST].val = wid = numtab[CT].val = 0; 5047c478bd9Sstevel@tonic-gate if (ismot(i = getch())) 505*e5190c10Smuffin return (0); 5067c478bd9Sstevel@tonic-gate delim = cbits(i); 5077c478bd9Sstevel@tonic-gate savhp = numtab[HP].val; 5087c478bd9Sstevel@tonic-gate numtab[HP].val = 0; 5097c478bd9Sstevel@tonic-gate savapts = apts; 5107c478bd9Sstevel@tonic-gate savapts1 = apts1; 5117c478bd9Sstevel@tonic-gate savfont = font; 5127c478bd9Sstevel@tonic-gate savfont1 = font1; 5137c478bd9Sstevel@tonic-gate savpts = pts; 5147c478bd9Sstevel@tonic-gate savpts1 = pts1; 5157c478bd9Sstevel@tonic-gate setwdf++; 5167c478bd9Sstevel@tonic-gate while (cbits(i = getch()) != delim && !nlflg) { 5177c478bd9Sstevel@tonic-gate k = width(i); 5187c478bd9Sstevel@tonic-gate wid += k; 5197c478bd9Sstevel@tonic-gate numtab[HP].val += k; 5207c478bd9Sstevel@tonic-gate if (!ismot(i)) { 5217c478bd9Sstevel@tonic-gate emsz = POINT * xpts; 5227c478bd9Sstevel@tonic-gate } else if (isvmot(i)) { 5237c478bd9Sstevel@tonic-gate k = absmot(i); 5247c478bd9Sstevel@tonic-gate if (isnmot(i)) 5257c478bd9Sstevel@tonic-gate k = -k; 5267c478bd9Sstevel@tonic-gate base -= k; 5277c478bd9Sstevel@tonic-gate emsz = 0; 5287c478bd9Sstevel@tonic-gate } else 5297c478bd9Sstevel@tonic-gate continue; 5307c478bd9Sstevel@tonic-gate if (base < numtab[SB].val) 5317c478bd9Sstevel@tonic-gate numtab[SB].val = base; 5327c478bd9Sstevel@tonic-gate if ((k = base + emsz) > numtab[ST].val) 5337c478bd9Sstevel@tonic-gate numtab[ST].val = k; 5347c478bd9Sstevel@tonic-gate } 5357c478bd9Sstevel@tonic-gate setn1(wid, 0, (tchar) 0); 5367c478bd9Sstevel@tonic-gate numtab[HP].val = savhp; 5377c478bd9Sstevel@tonic-gate apts = savapts; 5387c478bd9Sstevel@tonic-gate apts1 = savapts1; 5397c478bd9Sstevel@tonic-gate font = savfont; 5407c478bd9Sstevel@tonic-gate font1 = savfont1; 5417c478bd9Sstevel@tonic-gate pts = savpts; 5427c478bd9Sstevel@tonic-gate pts1 = savpts1; 5437c478bd9Sstevel@tonic-gate mchbits(); 5447c478bd9Sstevel@tonic-gate setwdf = 0; 545*e5190c10Smuffin 546*e5190c10Smuffin return (0); 5477c478bd9Sstevel@tonic-gate } 5487c478bd9Sstevel@tonic-gate 5497c478bd9Sstevel@tonic-gate 5507c478bd9Sstevel@tonic-gate tchar vmot() 5517c478bd9Sstevel@tonic-gate { 5527c478bd9Sstevel@tonic-gate dfact = lss; 5537c478bd9Sstevel@tonic-gate vflag++; 5547c478bd9Sstevel@tonic-gate return(mot()); 5557c478bd9Sstevel@tonic-gate } 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate 5587c478bd9Sstevel@tonic-gate tchar hmot() 5597c478bd9Sstevel@tonic-gate { 5607c478bd9Sstevel@tonic-gate dfact = EM; 5617c478bd9Sstevel@tonic-gate return(mot()); 5627c478bd9Sstevel@tonic-gate } 5637c478bd9Sstevel@tonic-gate 5647c478bd9Sstevel@tonic-gate 5657c478bd9Sstevel@tonic-gate tchar mot() 5667c478bd9Sstevel@tonic-gate { 567*e5190c10Smuffin int j, n; 568*e5190c10Smuffin tchar i; 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate j = HOR; 5717c478bd9Sstevel@tonic-gate getch(); /*eat delim*/ 5727c478bd9Sstevel@tonic-gate if (n = atoi()) { 5737c478bd9Sstevel@tonic-gate if (vflag) 5747c478bd9Sstevel@tonic-gate j = VERT; 5757c478bd9Sstevel@tonic-gate i = makem(quant(n, j)); 5767c478bd9Sstevel@tonic-gate } else 5777c478bd9Sstevel@tonic-gate i = 0; 5787c478bd9Sstevel@tonic-gate getch(); 5797c478bd9Sstevel@tonic-gate vflag = 0; 5807c478bd9Sstevel@tonic-gate dfact = 1; 5817c478bd9Sstevel@tonic-gate return(i); 5827c478bd9Sstevel@tonic-gate } 5837c478bd9Sstevel@tonic-gate 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate tchar sethl(k) 5867c478bd9Sstevel@tonic-gate int k; 5877c478bd9Sstevel@tonic-gate { 588*e5190c10Smuffin int j; 5897c478bd9Sstevel@tonic-gate tchar i; 5907c478bd9Sstevel@tonic-gate 5917c478bd9Sstevel@tonic-gate j = EM / 2; 5927c478bd9Sstevel@tonic-gate if (k == 'u') 5937c478bd9Sstevel@tonic-gate j = -j; 5947c478bd9Sstevel@tonic-gate else if (k == 'r') 5957c478bd9Sstevel@tonic-gate j = -2 * j; 5967c478bd9Sstevel@tonic-gate vflag++; 5977c478bd9Sstevel@tonic-gate i = makem(j); 5987c478bd9Sstevel@tonic-gate vflag = 0; 5997c478bd9Sstevel@tonic-gate return(i); 6007c478bd9Sstevel@tonic-gate } 6017c478bd9Sstevel@tonic-gate 6027c478bd9Sstevel@tonic-gate 6037c478bd9Sstevel@tonic-gate tchar makem(i) 604*e5190c10Smuffin int i; 6057c478bd9Sstevel@tonic-gate { 606*e5190c10Smuffin tchar j; 6077c478bd9Sstevel@tonic-gate 6087c478bd9Sstevel@tonic-gate if ((j = i) < 0) 6097c478bd9Sstevel@tonic-gate j = -j; 6107c478bd9Sstevel@tonic-gate j |= MOT; 6117c478bd9Sstevel@tonic-gate if (i < 0) 6127c478bd9Sstevel@tonic-gate j |= NMOT; 6137c478bd9Sstevel@tonic-gate if (vflag) 6147c478bd9Sstevel@tonic-gate j |= VMOT; 6157c478bd9Sstevel@tonic-gate return(j); 6167c478bd9Sstevel@tonic-gate } 6177c478bd9Sstevel@tonic-gate 6187c478bd9Sstevel@tonic-gate 6197c478bd9Sstevel@tonic-gate tchar getlg(i) 6207c478bd9Sstevel@tonic-gate tchar i; 6217c478bd9Sstevel@tonic-gate { 6227c478bd9Sstevel@tonic-gate tchar j, k; 623*e5190c10Smuffin int lf; 6247c478bd9Sstevel@tonic-gate 6257c478bd9Sstevel@tonic-gate if ((lf = fontbase[fbits(i)]->ligfont) == 0) /* font lacks ligatures */ 6267c478bd9Sstevel@tonic-gate return(i); 6277c478bd9Sstevel@tonic-gate j = getch0(); 6287c478bd9Sstevel@tonic-gate if (cbits(j) == 'i' && (lf & LFI)) 6297c478bd9Sstevel@tonic-gate j = LIG_FI; 6307c478bd9Sstevel@tonic-gate else if (cbits(j) == 'l' && (lf & LFL)) 6317c478bd9Sstevel@tonic-gate j = LIG_FL; 6327c478bd9Sstevel@tonic-gate else if (cbits(j) == 'f' && (lf & LFF)) { 6337c478bd9Sstevel@tonic-gate if ((lf & (LFFI|LFFL)) && lg != 2) { 6347c478bd9Sstevel@tonic-gate k = getch0(); 6357c478bd9Sstevel@tonic-gate if (cbits(k)=='i' && (lf&LFFI)) 6367c478bd9Sstevel@tonic-gate j = LIG_FFI; 6377c478bd9Sstevel@tonic-gate else if (cbits(k)=='l' && (lf&LFFL)) 6387c478bd9Sstevel@tonic-gate j = LIG_FFL; 6397c478bd9Sstevel@tonic-gate else { 6407c478bd9Sstevel@tonic-gate *pbp++ = k; 6417c478bd9Sstevel@tonic-gate j = LIG_FF; 6427c478bd9Sstevel@tonic-gate } 6437c478bd9Sstevel@tonic-gate } else 6447c478bd9Sstevel@tonic-gate j = LIG_FF; 6457c478bd9Sstevel@tonic-gate } else { 6467c478bd9Sstevel@tonic-gate *pbp++ = j; 6477c478bd9Sstevel@tonic-gate j = i; 6487c478bd9Sstevel@tonic-gate } 6497c478bd9Sstevel@tonic-gate return(i & SFMASK | j); 6507c478bd9Sstevel@tonic-gate } 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate 653*e5190c10Smuffin int 6547c478bd9Sstevel@tonic-gate caselg() 6557c478bd9Sstevel@tonic-gate { 6567c478bd9Sstevel@tonic-gate 6577c478bd9Sstevel@tonic-gate lg = 1; 6587c478bd9Sstevel@tonic-gate if (skip()) 659*e5190c10Smuffin return (0); 6607c478bd9Sstevel@tonic-gate lg = atoi(); 661*e5190c10Smuffin 662*e5190c10Smuffin return (0); 6637c478bd9Sstevel@tonic-gate } 6647c478bd9Sstevel@tonic-gate 6657c478bd9Sstevel@tonic-gate 666*e5190c10Smuffin int 6677c478bd9Sstevel@tonic-gate casefp() 6687c478bd9Sstevel@tonic-gate { 669*e5190c10Smuffin int i, j; 670*e5190c10Smuffin char *s; 6717c478bd9Sstevel@tonic-gate 6727c478bd9Sstevel@tonic-gate skip(); 6737c478bd9Sstevel@tonic-gate if ((i = cbits(getch()) - '0') <= 0 || i > nfonts) 6747c478bd9Sstevel@tonic-gate errprint(gettext("fp: bad font position %d"), i); 6757c478bd9Sstevel@tonic-gate else if (skip() || !(j = getrq())) 6767c478bd9Sstevel@tonic-gate errprint(gettext("fp: no font name")); 6777c478bd9Sstevel@tonic-gate else if (skip() || !getname()) 6787c478bd9Sstevel@tonic-gate setfp(i, j, 0); 6797c478bd9Sstevel@tonic-gate else /* 3rd argument = filename */ 6807c478bd9Sstevel@tonic-gate setfp(i, j, nextf); 681*e5190c10Smuffin 682*e5190c10Smuffin return (0); 6837c478bd9Sstevel@tonic-gate } 6847c478bd9Sstevel@tonic-gate 685*e5190c10Smuffin int 6867c478bd9Sstevel@tonic-gate setfp(pos, f, truename) /* mount font f at position pos[0...nfonts] */ 6877c478bd9Sstevel@tonic-gate int pos, f; 6887c478bd9Sstevel@tonic-gate char *truename; 6897c478bd9Sstevel@tonic-gate { 690*e5190c10Smuffin int k; 6917c478bd9Sstevel@tonic-gate int n; 6927c478bd9Sstevel@tonic-gate char longname[NS], shortname[20]; 6937c478bd9Sstevel@tonic-gate extern int nchtab; 6947c478bd9Sstevel@tonic-gate 6957c478bd9Sstevel@tonic-gate zapwcache(0); 6967c478bd9Sstevel@tonic-gate if (truename) 6977c478bd9Sstevel@tonic-gate strcpy(shortname, truename); 6987c478bd9Sstevel@tonic-gate else { 6997c478bd9Sstevel@tonic-gate shortname[0] = f & BYTEMASK; 7007c478bd9Sstevel@tonic-gate shortname[1] = f >> BYTE; 7017c478bd9Sstevel@tonic-gate shortname[2] = '\0'; 7027c478bd9Sstevel@tonic-gate } 7037c478bd9Sstevel@tonic-gate sprintf(longname, "%s/dev%s/%s.out", fontfile, devname, shortname); 7047c478bd9Sstevel@tonic-gate if ((k = open(longname, 0)) < 0) { 7057c478bd9Sstevel@tonic-gate errprint(gettext("Can't open %s"), longname); 7067c478bd9Sstevel@tonic-gate return(-1); 7077c478bd9Sstevel@tonic-gate } 7087c478bd9Sstevel@tonic-gate n = fontbase[pos]->nwfont & BYTEMASK; 7097c478bd9Sstevel@tonic-gate read(k, (char *) fontbase[pos], 3*n + nchtab + 128 - 32 + sizeof(struct Font)); 7107c478bd9Sstevel@tonic-gate kerntab[pos] = (char *) fontab[pos] + (fontbase[pos]->nwfont & BYTEMASK); 7117c478bd9Sstevel@tonic-gate /* have to reset the fitab pointer because the width may be different */ 7127c478bd9Sstevel@tonic-gate fitab[pos] = (char *) fontab[pos] + 3 * (fontbase[pos]->nwfont & BYTEMASK); 7137c478bd9Sstevel@tonic-gate if ((fontbase[pos]->nwfont & BYTEMASK) > n) { 7147c478bd9Sstevel@tonic-gate errprint(gettext("Font %s too big for position %d"), shortname, 7157c478bd9Sstevel@tonic-gate pos); 7167c478bd9Sstevel@tonic-gate return(-1); 7177c478bd9Sstevel@tonic-gate } 7187c478bd9Sstevel@tonic-gate fontbase[pos]->nwfont = n; /* so can load a larger one again later */ 7197c478bd9Sstevel@tonic-gate close(k); 7207c478bd9Sstevel@tonic-gate if (pos == smnt) { 7217c478bd9Sstevel@tonic-gate smnt = 0; 7227c478bd9Sstevel@tonic-gate sbold = 0; 7237c478bd9Sstevel@tonic-gate } 7247c478bd9Sstevel@tonic-gate if ((fontlab[pos] = f) == 'S') 7257c478bd9Sstevel@tonic-gate smnt = pos; 7267c478bd9Sstevel@tonic-gate bdtab[pos] = cstab[pos] = ccstab[pos] = 0; 7277c478bd9Sstevel@tonic-gate /* if there is a directory, no place to store its name. */ 7287c478bd9Sstevel@tonic-gate /* if position isn't zero, no place to store its value. */ 7297c478bd9Sstevel@tonic-gate /* only time a FONTPOS is pushed back is if it's a */ 7307c478bd9Sstevel@tonic-gate /* standard font on position 0 (i.e., mounted implicitly. */ 7317c478bd9Sstevel@tonic-gate /* there's a bug here: if there are several input lines */ 7327c478bd9Sstevel@tonic-gate /* that look like .ft XX in short successtion, the output */ 7337c478bd9Sstevel@tonic-gate /* will all be in the last one because the "x font ..." */ 7347c478bd9Sstevel@tonic-gate /* comes out too soon. pushing back FONTPOS doesn't work */ 7357c478bd9Sstevel@tonic-gate /* with .ft commands because input is flushed after .xx cmds */ 7367c478bd9Sstevel@tonic-gate ptfpcmd(pos, shortname); 7377c478bd9Sstevel@tonic-gate if (pos == 0) 7387c478bd9Sstevel@tonic-gate ch = (tchar) FONTPOS | (tchar) f << 16; 7397c478bd9Sstevel@tonic-gate return(pos); 7407c478bd9Sstevel@tonic-gate } 7417c478bd9Sstevel@tonic-gate 7427c478bd9Sstevel@tonic-gate 743*e5190c10Smuffin int 7447c478bd9Sstevel@tonic-gate casecs() 7457c478bd9Sstevel@tonic-gate { 746*e5190c10Smuffin int i, j; 7477c478bd9Sstevel@tonic-gate 7487c478bd9Sstevel@tonic-gate noscale++; 7497c478bd9Sstevel@tonic-gate skip(); 7507c478bd9Sstevel@tonic-gate if (!(i = getrq()) || (i = findft(i)) < 0) 7517c478bd9Sstevel@tonic-gate goto rtn; 7527c478bd9Sstevel@tonic-gate skip(); 7537c478bd9Sstevel@tonic-gate cstab[i] = atoi(); 7547c478bd9Sstevel@tonic-gate skip(); 7557c478bd9Sstevel@tonic-gate j = atoi(); 7567c478bd9Sstevel@tonic-gate if (nonumb) 7577c478bd9Sstevel@tonic-gate ccstab[i] = 0; 7587c478bd9Sstevel@tonic-gate else 7597c478bd9Sstevel@tonic-gate ccstab[i] = findps(j); 7607c478bd9Sstevel@tonic-gate rtn: 7617c478bd9Sstevel@tonic-gate zapwcache(0); 7627c478bd9Sstevel@tonic-gate noscale = 0; 763*e5190c10Smuffin 764*e5190c10Smuffin return (0); 7657c478bd9Sstevel@tonic-gate } 7667c478bd9Sstevel@tonic-gate 7677c478bd9Sstevel@tonic-gate 768*e5190c10Smuffin int 7697c478bd9Sstevel@tonic-gate casebd() 7707c478bd9Sstevel@tonic-gate { 771*e5190c10Smuffin int i, j, k; 7727c478bd9Sstevel@tonic-gate 7737c478bd9Sstevel@tonic-gate zapwcache(0); 7747c478bd9Sstevel@tonic-gate k = 0; 7757c478bd9Sstevel@tonic-gate bd0: 7767c478bd9Sstevel@tonic-gate if (skip() || !(i = getrq()) || (j = findft(i)) == -1) { 7777c478bd9Sstevel@tonic-gate if (k) 7787c478bd9Sstevel@tonic-gate goto bd1; 7797c478bd9Sstevel@tonic-gate else 780*e5190c10Smuffin return (0); 7817c478bd9Sstevel@tonic-gate } 7827c478bd9Sstevel@tonic-gate if (j == smnt) { 7837c478bd9Sstevel@tonic-gate k = smnt; 7847c478bd9Sstevel@tonic-gate goto bd0; 7857c478bd9Sstevel@tonic-gate } 7867c478bd9Sstevel@tonic-gate if (k) { 7877c478bd9Sstevel@tonic-gate sbold = j; 7887c478bd9Sstevel@tonic-gate j = k; 7897c478bd9Sstevel@tonic-gate } 7907c478bd9Sstevel@tonic-gate bd1: 7917c478bd9Sstevel@tonic-gate skip(); 7927c478bd9Sstevel@tonic-gate noscale++; 7937c478bd9Sstevel@tonic-gate bdtab[j] = atoi(); 7947c478bd9Sstevel@tonic-gate noscale = 0; 795*e5190c10Smuffin 796*e5190c10Smuffin return (0); 7977c478bd9Sstevel@tonic-gate } 7987c478bd9Sstevel@tonic-gate 7997c478bd9Sstevel@tonic-gate 800*e5190c10Smuffin int 8017c478bd9Sstevel@tonic-gate casevs() 8027c478bd9Sstevel@tonic-gate { 803*e5190c10Smuffin int i; 8047c478bd9Sstevel@tonic-gate 8057c478bd9Sstevel@tonic-gate skip(); 8067c478bd9Sstevel@tonic-gate vflag++; 8077c478bd9Sstevel@tonic-gate dfact = INCH; /* default scaling is points! */ 8087c478bd9Sstevel@tonic-gate dfactd = 72; 8097c478bd9Sstevel@tonic-gate res = VERT; 8107c478bd9Sstevel@tonic-gate i = inumb(&lss); 8117c478bd9Sstevel@tonic-gate if (nonumb) 8127c478bd9Sstevel@tonic-gate i = lss1; 8137c478bd9Sstevel@tonic-gate if (i < VERT) 8147c478bd9Sstevel@tonic-gate i = VERT; 8157c478bd9Sstevel@tonic-gate lss1 = lss; 8167c478bd9Sstevel@tonic-gate lss = i; 817*e5190c10Smuffin 818*e5190c10Smuffin return (0); 8197c478bd9Sstevel@tonic-gate } 8207c478bd9Sstevel@tonic-gate 8217c478bd9Sstevel@tonic-gate 822*e5190c10Smuffin int 8237c478bd9Sstevel@tonic-gate casess() 8247c478bd9Sstevel@tonic-gate { 825*e5190c10Smuffin int i; 8267c478bd9Sstevel@tonic-gate 8277c478bd9Sstevel@tonic-gate noscale++; 8287c478bd9Sstevel@tonic-gate skip(); 8297c478bd9Sstevel@tonic-gate if (i = atoi()) { 8307c478bd9Sstevel@tonic-gate spacesz = i & 0177; 8317c478bd9Sstevel@tonic-gate zapwcache(0); 8327c478bd9Sstevel@tonic-gate sps = width(' ' | chbits); 8337c478bd9Sstevel@tonic-gate } 8347c478bd9Sstevel@tonic-gate noscale = 0; 835*e5190c10Smuffin 836*e5190c10Smuffin return (0); 8377c478bd9Sstevel@tonic-gate } 8387c478bd9Sstevel@tonic-gate 8397c478bd9Sstevel@tonic-gate 8407c478bd9Sstevel@tonic-gate tchar xlss() 8417c478bd9Sstevel@tonic-gate { 8427c478bd9Sstevel@tonic-gate /* stores \x'...' into 8437c478bd9Sstevel@tonic-gate * two successive tchars. 8447c478bd9Sstevel@tonic-gate * the first contains HX, the second the value, 8457c478bd9Sstevel@tonic-gate * encoded as a vertical motion. 8467c478bd9Sstevel@tonic-gate * decoding is done in n2.c by pchar(). 8477c478bd9Sstevel@tonic-gate */ 8487c478bd9Sstevel@tonic-gate int i; 8497c478bd9Sstevel@tonic-gate 8507c478bd9Sstevel@tonic-gate getch(); 8517c478bd9Sstevel@tonic-gate dfact = lss; 8527c478bd9Sstevel@tonic-gate i = quant(atoi(), VERT); 8537c478bd9Sstevel@tonic-gate dfact = 1; 8547c478bd9Sstevel@tonic-gate getch(); 8557c478bd9Sstevel@tonic-gate if (i >= 0) 8567c478bd9Sstevel@tonic-gate *pbp++ = MOT | VMOT | i; 8577c478bd9Sstevel@tonic-gate else 8587c478bd9Sstevel@tonic-gate *pbp++ = MOT | VMOT | NMOT | -i; 8597c478bd9Sstevel@tonic-gate return(HX); 8607c478bd9Sstevel@tonic-gate } 861