Skip to main content
Participant
Jan 22, 2020 4:07 PM UTC
Question

Postscript underline text

Hi 

I have this postscript script the will underline some of the text

/UnderlineThickness
/UnderlinePosition
/ulshow % string on stack
{
/fontheight { currentfont /FontMatrix get 3 get } bind def
/lineheight { fontheight 1.2 mul } bind def
currentpoint /y exch def /x exch def
dup
show
stringwidth pop dup neg 0 rlineto stroke
x add y moveto
} def
72 720 moveto
/Courier 18 selectfont
(Hello ) show (World ) ulshow (GoodNight ) show (Moon.) ulshow
showpage

I want to put the underline to be in the middle of the text so it looks like it is struck through.

Can you help please? 

 

Thanks in advance

Rob

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

Inspiring
Mar 3, 2020 10:37 AM UTC

It might be late!

But in case you still need it  here it is


  /ulshow % string on stack
{
/fontheight { currentfont /FontMatrix get 3 get } bind def
/lineheight { fontheight 1.2 mul } bind def
/strikeheight 5 def
/H-SPACE 5 def
currentpoint /y exch def /x exch def
dup
show H-SPACE 0 rmoveto gsave
x y strikeheight add moveto
stringwidth pop 0 rlineto stroke
grestore

} def
72 720 moveto
  /Courier 18 selectfont
 (Hello ) show (World) ulshow (GoodNight ) show (Moon.) ulshow
showpage

 

I added two variables , you might change them as you want  strikeheight & H-SPACE 

Cheers

Adam

 

Translate
Participant
Mar 6, 2020 10:09 AM UTC

Hi,

 

Thank you for this.

I did evebtually work it out. 

Below is my solution.

Regards

Rob

 

/Strike {
dup
show
currentpoint
4 2 roll
stringwidth pop neg
exch 0.2 mul
0 exch rmoveto
0 rlineto
stroke
moveto
} def

/Times-Roman 40 selectfont
50 600 moveto
(An ) show
40 (Strike Through Words) Strike
( word.) show
showpage

Translate