Skip to main content
Participant
January 22, 2020
Question

Postscript underline text

  • January 22, 2020
  • 1 reply
  • 654 views

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 has been closed for replies.

1 reply

Inspiring
March 3, 2020

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

 

Participant
March 6, 2020

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