[comp.lang.postscript] Underlining text

bann@virgin.UUCP (Roger Bannister) (06/17/89)

	Is there anybody on the net that has a postscript procedure that will
   underline a string no matter what font or size the string happens to be.
   I wrote my own procedure but it just didn't cut it.

			Roger

tompkins@ttidca.TTI.COM (Pete Tompkins) (06/21/89)

In article <2439@virgin.UUCP> bann@virgin.UUCP (Roger Bannister) writes:

> 
> 	Is there anybody on the net that has a postscript procedure that will
>    underline a string no matter what font or size the string happens to be.
>    I wrote my own procedure but it just didn't cut it.

			Roger
%!PS
% dy string  underline  -
% dy is the distance below the text for the underline (be careful
% if you start scaling things)
% 'underline' outputs the text and underlines it

/underline
{
gsave dup
stringwidth

% Throwaway dy (which is zero) and save dx (which is the length string)
pop
/dx exch def
show
grestore

%The requested distance for the line below the string is still on the stack
0  exch neg rmoveto
dx 0 rlineto
stroke
} def

/Times-Roman findfont 18 scalefont setfont
100 500 moveto
4 (Testing underlined text.) underline
showpage
-- 
*Pete Tompkins		(213) 452-9191 ext. 3000
*Citicorp/TTI
*Santa Monica, CA
*Path: tompkins@ttidca.tti.com