[net.unix-wizards] getting the wrong font in ti-troff

lee@rochester.UUCP (Lee Moore) (10/09/85)

I am having a problem with Typesetter Independent Troff.  It is set up
with a DESC file that describes 26 different fonts.  The problem comes
when I ask for font "B" and I get font "LB".  Looking at the intermediate
output of Troff, font "B" gets mapped into 18 which is the number for
"LB" rather than the correct number: 3.  When I ask for font 3 explicitly,
(like with a \f3) things work correctly.

Anybody have an clues?  Below is out DESC file:

# describe the 'newraven' press device
res 2540
hor 1
vert 1
unitwidth 5
paperwidth 21590
paperlength 27940
sizes  5 6 7 8 9 10 11 12 13 14 15 16 18 20 24 30 36 48 72 0
fonts 26  R I B X AR cR ER GR GI GB GX HR HI HB HX hR LR LB LO OE tR TR UR MR HP S
charset
 ff Fi Fl fi fl \- hy sl ua <- ap A: O: Ao a: o: ao u: c, um .. ri
 ga aa be ma ct po ps *! sc bu dg dd pp I! !! I? hc ud 14 12 *P is
 cs *S bc __ de if di an .= fm sr +- cm -+ tf a/ ci sq tr dm a+ a-
 ax ag ** rh lh bs bx <= != >= cf fa mo C# gr te sb !s ib sp !S ip
 cr nm !m es pt r2 R# ~~ bt cu lo == mu QE l< r> da -> al ~> co pd
 ~= io <> im :> h- || no mc st |- |= rg NE NW SW SE << >> ca -| 34
 r1 *A *B *C *D *E *F *G *Y *I *K *L *M *N *O *H *R *T *U *W *X *Q
 *Z *a *b *c *d *e *f *g *y *i ts *k *l *m *n *o *p *h *r *s *t *u
 *w *x *q *z ru ul br lt lb rt rb lk rk bv lf rf lc rc mi pl eq rn
 em or \| \^
-- 
TCP/IP:		lee@rochester.arpa
UUCP:		{seismo, allegra, decvax, cmcl2, topaz, harvard}!rochester!lee
XNS:		Lee Moore:CS:Univ Rochester
Phone:		+1 (716) 275-7747, -5671
Physical:	43 01' 40'' N, 77 37' 49'' W

-- 11 months 'till I drop off the face of the earth.

terry%owl@rand-unix.ARPA (Terry West) (10/14/85)

   I am having a problem with Typesetter Independent Troff.  It is set up
   with a DESC file that describes 26 different fonts.  The problem comes
   when I ask for font "B" and I get font "LB".  Looking at the intermediate
   output of Troff, font "B" gets mapped into 18 which is the number for
   "LB" rather than the correct number: 3.  When I ask for font 3 explicitly,
   (like with a \f3) things work correctly.

   Anybody have an clues?  Below is out DESC file:


The problem lies in findft() in t6.c.  Here's my fix:
-----------------------

#ifdef ORIGCODE
findft(i)
register int	i;
{
	register k;

	if ((k = i - '0') >= 0 && k <= nfonts && k < smnt)
		return(k);
	for (k = 0; fontlab[k] != i; k++)
		if (k > nfonts)
			return(-1);

	return(k);
}
#endif ORIGCODE

/*
 *  Old code has a problem if 'k' is a nondigit and is <= nfonts
 */

findft(i)
register int	i;
{
	register int k;
	register int b0, b1;

	/*
	 *  If ft name is digits, then set specified position; otherwise
	 *  lookup the "name".
	 */
	b0 = i&0177;
	b1 = i>>BYTE;

	if ((isdigit(b0) && isdigit(b1)) || (b1 == 0 && isdigit(b0))) {
		if (b1)
		    k = 10 * (b0 - '0') + b1 - '0';
		else
		    k = b0 - '0';
		if (k <= nfonts)
		    return(k);
		fprintf(stderr, "troff: bad font pos: %d\n", k);
		return(-1);
	}

	for (k = 0; fontlab[k] != i; k++) {
		if (k > nfonts)
			return(-1);
	}

	return(k);
}
------------------------

   Terry West
   <terry@rand-unix.ARPA>