[comp.lang.postscript] Postscript Underlining

wam6186@tahoma.UUCP (Warren A. Murray) (08/18/88)

Is there anyone out there who knows how to do underlining in
Postscript?  I need an algorithm that will work with any of
the Apple LaserWriter Plus fonts at any size.

Thanks in advance for your help.



Mike Haldeman 		      Voice: (206) 237-2577
Boeing Commercial Airplanes   UUCP: ..!uw-beaver!ssc-vax!shuksan!tahoma!wam6186
P.O. Box 3707, M/S 66-04
Seattle, WA  98124-2207

ted@mitre-bedford.ARPA (Edward J. Ede) (08/22/88)

In article <259@tahoma.UUCP> wam6186@tahoma.UUCP (Warren A. Murray) writes:
>Is there anyone out there who knows how to do underlining in
>Postscript?  I need an algorithm that will work with any of
>the Apple LaserWriter Plus fonts at any size.
>
>Mike Haldeman 		      Voice: (206) 237-2577

In all of Adobe's font dictionaries, there exists another dictionary
named FontInfo.  Within FontInfo there are two numbers:
UnderlinePosition and UnderlineThickness.  They are both in the
Character Coordinate System (to use them, divide by 1000 and multiply
by the current point size).  For example, the numbers for Courier are
-82 and 40, so in 12 point, move -.98 points (-82/1000*12) from the
baseline and stroke a line .48 points (40/1000*12) thick.  You can use
the stringwidth operator to get the proper length.

For a more detailed explanation, look in section 5.3 of the red bood,
"Font Dictionaries".  I'd write a procedure for you, but my
PostScript, as of late, is a bit rusty :-(

In a bind, just use italics :-)

Ted Ede -- ted@mitre-bedford.arpa -- The MITRE Corporation -- Burlington Road  
| linus!mbunix!ted -- Bedford MA, 01730 -- Mail Stop B015 -- (617) 271-2524 |
|                   - this line intentionally left blank -                  |
+---------------------------------------------------------------------------+

jos@idca.tds.PHILIPS.nl (Jos Vos) (08/25/88)

In article <259@tahoma.UUCP> wam6186@tahoma.UUCP (Warren A. Murray) writes:
>Is there anyone out there who knows how to do underlining in
>Postscript?  I need an algorithm that will work with any of
>the Apple LaserWriter Plus fonts at any size.

Here's the algorithm, which can be used as show, but it shows the
string including underlining.
I made it a while ago, and I still don't find the result very satisfying
(lines are too thick and too close on the characters themselves...),
but it is according the specifications in the Red Book, I think.

/showu {
	dup show gsave
	currentfont dup /FontMatrix get 3 get exch
	/FontInfo get dup /UnderlineThickness get 2 index
	mul setlinewidth /UnderlinePosition get mul
	0 exch rmoveto stringwidth pop neg 0 rlineto stroke
	grestore
} def

I hope this is what you asked for...

-- 
#  Jos Vos                             #  Internet  jos@idca.tds.philips.nl  #
#  Philips TDS, Dept SSP               #                                     #
#  P.O. Box 245                        #  UUCP        ...!mcvax!philapd!jos  #
#  7300 AE Apeldoorn, The Netherlands  #  Phone               +31 55 433181  #