[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: printing superscript characters
- Subject: Re: printing superscript characters
- From: Ray Ontko <rayo@ONTKO.COM>
- Date: Fri, 17 Apr 1998 17:08:38 -0500
- In-reply-to: <35240006.6CEA@dbtinc.com> from Jeff Smith at "Apr 2, 98 03:15:50 pm"
Jeff,
> What is the best way to print characters in super-script in sqr. I'm
> thinking I probably need to do a print-direct with postscript commands
> or use printer codes. Does anyone know the proper postscript commands or
> HP printer codes ?
Here's an example that I've worked out for HP:
begin-program
do main
end-program
begin-procedure main
encode '<27>' into $escape
print 'Howdy' (1,1)
print 'Howdy' (2,1)
print-direct printer=hp $escape '&a200v720H' 'superscript'
print-direct printer=hp $escape '&a280v720H' 'subscript'
print 'Howdy' (3,1)
end-procedure
This would then be executed using -printer:hp.
Note that I have hard-coded the 200, 720 and 280. If you don't
hard-code them, you'll have to calculate them in your code. The
values which appear before the "v" are the vertical offset from
the top of the page, and the values which appear before the "H"
are the horizontal offset from the left edge of the page. The
actual values you use will depend on your LEFT-MARGIN, TOP-MARGIN,
CHAR-WIDTH, and LINE-HEIGHT. The units are "decipoints", i.e.,
720 per inch.
In this example, I have assumed that a superscript would be 1/3
of a line higher than the normal type, and that a subscript would
be 1/3 of a line lower. You could get much fancier by using alter
printer to reduce the type size, and place it higher or lower,
depending on your tastes.
Here's a more complicated approach:
begin-program
do main
end-program
begin-procedure main
encode '<27>' into $escape
print 'Howdy' (1,1)
print 'Howdy' (2,1)
print 'Howdy' (3,1)
do superscript('superscript',2,6)
do subscript('subscript',2,6)
print 'H' (5,1)
do subscript('2',0,0)
print 'O' ()
print 'U' (7,1)
do superscript('238',0,0)
print 'half-life' (,+1)
end-procedure
begin-procedure superscript( $str , #lin , #col )
if #lin = 0
move #_current-line to #lin
end-if
if #col = 0
move #_current-column to #col
end-if
encode '<27>' into $escape
alter-printer pitch=12
let $pos = '&a' || edit( #lin * 120 - 40 , '88888' ) || 'v' ||
edit( #col * 72 + 288 , '88888' ) || 'H'
print-direct printer=hp $escape $pos $str
alter-printer pitch=10
let #pos = ceil( #col + length( $str ) * 10.0 / 12.0 )
position (#lin,#pos)
end-procedure ! superscript
begin-procedure subscript( $str , #lin , #col )
if #lin = 0
move #_current-line to #lin
end-if
if #col = 0
move #_current-column to #col
end-if
encode '<27>' into $escape
alter-printer pitch=12
let $pos = '&a' || edit( #lin * 120 + 40 , '88888' ) || 'v' ||
edit( #col * 72 + 288 , '88888' ) || 'H'
print-direct printer=hp $escape $pos $str
alter-printer pitch=10
let #pos = ceil( #col + length( $str ) * 10.0 / 12.0 )
position (#lin,#pos)
end-procedure ! subscript
Hope this helps.
Ray
----------------------------------------------------------------------
Ray Ontko | Ray Ontko & Co | "Time for a new signature line."
rayo@ontko.com | Richmond, In | See us at http://www.ontko.com/