getting the wrong font in ti-troff

Terry West terry%owl at rand-unix.ARPA
Mon Oct 14 19:08:45 AEST 1985


   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 at rand-unix.ARPA>



More information about the Comp.unix.wizards mailing list