comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: QUESTION: special characters in postscript output
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: QUESTION: special characters in postscript output [message #927] Sat, 13 March 1993 22:12
sterne is currently offline  sterne
Messages: 15
Registered: March 1992
Junior Member
In article <1993Mar13.015020.29487@bnlux1.bnl.gov> rivers@bnlux1.bnl.gov (mark rivers) writes:

> ; This program section defines some strings which contain both English
> ; and Greek characters. It treats PostScript and all other devices
> ; differently. The strings are "K (alpha)", "K (beta)", etc. These are
> ; symbols for x-ray emission lines. This works in IDL 3.0. I am not sure
> ; about PV-WAVE.
>

This does not work in PV-WAVE, at least at version 3.10. The !9, !X and
!D are not converted in any way and are printed out as literal
characters. I don't know if the more recent releases of WAVE have
implemented this badly needed feature. If they have, I'd be interested
in hearing about it, as it might change my mind about buying into their
maintenance program.

In the meantime, it is possible to get some of the same capability in
PV-WAVE by modifying the postscript prolog file. A while back, Robert
Boughner sent me a modified postscript prolog file he had made for IDL
which converted characters within < > to greek. I made the trivial
modifications for PV-WAVE. Here is the patch. Apply it to the
wave_prolog.ps file which is in the WAVE_DIR directory, usually
something like /usr/local/pvi/wave on a U**x box. Somebody who speaks
postscript well enough might like to make it more compatible with the
current IDL behavior. Please post if you do!

*** wave_prolog.ps.orig Sat Mar 13 22:58:39 1993
--- wave_prolog.ps Sat Mar 13 23:02:04 1993
***************
*** 30,36 ****
% x y string size orientation alignment T
%
% Define our dictionary:
! /$T_DICT 20 dict def
%
% Define the procedure
%
--- 30,36 ----
% x y string size orientation alignment T
%
% Define our dictionary:
! /$T_DICT 26 dict def
%
% Define the procedure
%
***************
*** 38,43 ****
--- 38,46 ----
% The character with an octal code of 330 starts superscripting,
% 331 starts subscripting, and 332 reverts to normal.
%
+ % Modified by REB on December 3, 1991 to handle switching to Greek
+ % characters which are indicated by enclosing them in < > characters
+ %
$T_DICT begin % Use this dictionary
/align exch def % Get parameters
/orien exch def
***************
*** 53,84 ****
/SUBS 8#331 def % Escape code for subscript
/NORM 8#332 def % Escape code for normal text
/SCRIPTWID 0.7 def % Size of super & subscripts
! /OFFSET 0.6 def % Offset from baseline of sub & super scripts
%
orien rotate % Rotate for text orientation
size dup scale % Set global scale factor
%
/orien false def % Will be true if there are subs/super scripts

! thestring { % Loop for each character
! /charcode exch def % Save code
! charcode SUPER eq charcode SUBS eq or
! { /chsize SCRIPTWID def % if super | subs, make smaller
! /orien true def } % Set flag indicating scripts
! { charcode NORM eq % Back to normal
! { /chsize 1.0 def
! /orien true def }
! { ( ) dup 0 charcode put % Make a 1 character string for the char
! stringwidth pop chsize mul xsize add % Get width & accum
! /xsize exch def % Save back in xsize
! } ifelse }
! ifelse
! } forall
xsize align mul neg 0 rmoveto % Do the adjustment for alignment
%
orien % Need to do font stuff?
{
- /regularfont currentfont def % save current font
/fractionfont currentfont [ SCRIPTWID 0 0 SCRIPTWID 0 0 ]
makefont def % Make a new font for subscripts & superscripts
gsave % Get height of numeral 1 in current font
--- 56,116 ----
/SUBS 8#331 def % Escape code for subscript
/NORM 8#332 def % Escape code for normal text
/SCRIPTWID 0.7 def % Size of super & subscripts
! /SYMST (<) 0 get def % Start of symbol fonts
! /SYMEND (>) 0 get def % End of symbol fonts
! /SKPNXT (/) 0 get def % Escape character
! % "FntSize" determines size of currentfont and leaves it on stack
! /FntSize
! { currentfont /FontMatrix get 0 get 0.001 div } def
%
orien rotate % Rotate for text orientation
size dup scale % Set global scale factor
%
/orien false def % Will be true if there are subs/super scripts
+ /regularfont currentfont def % save current font
+ /symfont /Symbol findfont FntSize scalefont def %symbol fonts
+ /NOSKIP true def
+ /size {
+ ( ) dup 0 charcode put % Make a 1 character string for the char
+ stringwidth pop chsize mul xsize add % Get width & accum
+ /xsize exch def % Save back in xsize
+ } def
+ /TestForSkp { % char on stack, on return, leave a Boolean
+ /chr exch def
+ chr SKPNXT eq chr SYMST eq or chr SYMEND eq or not } def
+ /StrLen { thestring length 1 sub } def

!
! 0 1 StrLen { % Loop for each character
! /indx exch def
! /charcode thestring indx get def %Get charcode
! charcode SKPNXT eq NOSKIP and % Chk if escape character
! % if yes, don't treat the next character in a special manner
! % if last character is "/", then just return " "
! {/NOSKIP thestring indx 1 add dup StrLen gt
! {pop pop ( ) 0}if get TestForSkp def
! NOSKIP {size}if }
! {charcode SYMST eq NOSKIP and % go into symbol fonts?
! {symfont setfont}
! {charcode SYMEND eq NOSKIP and % end symbol fonts?
! {regularfont setfont}
! {charcode SUPER eq charcode SUBS eq or
! { /chsize SCRIPTWID def % if super | subs, make smaller
! /orien true def } % Set flag indicating scripts
! {charcode NORM eq % Back to normal
! { /chsize 1.0 def
! /orien true def }
! { size /NOSKIP true def
! } ifelse
! } ifelse
! } ifelse
! } ifelse
! } ifelse
! } for
xsize align mul neg 0 rmoveto % Do the adjustment for alignment
%
orien % Need to do font stuff?
{
/fractionfont currentfont [ SCRIPTWID 0 0 SCRIPTWID 0 0 ]
makefont def % Make a new font for subscripts & superscripts
gsave % Get height of numeral 1 in current font
***************
*** 87,109 ****
grestore
} if
%
/xsize 0 def % Starting out a 0 baseline
! thestring { % Now draw each character
! /charcode exch def % char code
charcode SUPER eq
! { 0 OFFSET height mul dup /xsize exch def % Up for superscripts
! rmoveto fractionfont setfont } % Set this font
! { charcode SUBS eq % Down for subscripts
! { 0 OFFSET height mul neg dup /xsize exch def rmoveto
! fractionfont setfont }
! { charcode NORM eq
! { 0 xsize neg rmoveto % Back to normal
! regularfont setfont } % Baseline & size
! { ( ) dup 0 charcode put show } % Otherwise show it
! ifelse }
! ifelse }
! ifelse }
! forall
grestore % Restore original context
end % Restore original dictionary
} bdef
--- 119,164 ----
grestore
} if
%
+ /orien false def
/xsize 0 def % Starting out a 0 baseline
! /savfont currentfont def
! /NOSKIP true def
! /PrntIt {
! orien {fractionfont}{regularfont}ifelse setfont
! ( ) dup 0 charcode put show % Otherwise show it
! } def
!
! 0 1 StrLen { % Now draw each character
! /indx exch def %get index value
! /charcode thestring indx get def % and the char code
charcode SUPER eq
! { 0 0.6 height mul dup /xsize exch def rmoveto % Up for superscripts
! /orien true def }
! {charcode SUBS eq % Down for subscripts
! { 0 0.3 height mul neg dup /xsize exch def rmoveto
! /orien true def }
! {charcode SKPNXT eq NOSKIP and
! {/NOSKIP thestring indx 1 add dup StrLen gt
! {pop pop ( ) 0}if get TestForSkp def
! NOSKIP {PrntIt}if }
! {charcode SYMST eq NOSKIP and
! {symfont setfont /regularfont currentfont def
! orien {/fractionfont currentfont [ SCRIPTWID 0 0 SCRIPTWID 0 0 ]
! makefont def }if }
! {charcode SYMEND eq NOSKIP and
! {/regularfont savfont def
! orien{/fractionfont savfont [ SCRIPTWID 0 0 SCRIPTWID 0 0 ]
! makefont def} if }
! {charcode NORM eq
! { 0 xsize neg rmoveto /orien false def } % Back to normal
! { PrntIt /NOSKIP true def
! } ifelse
! } ifelse
! } ifelse
! } ifelse
! } ifelse
! } ifelse
! } for
grestore % Restore original context
end % Restore original dictionary
} bdef





Enjoy,
Phil

------------------------------------------------------------ ------------
--
Philip Sterne | sterne@dublin.llnl.gov
Lawrence Livermore National Laboratory | Phone (510) 422-2510
Livermore, CA 94550 | Fax (510) 422-7300
Re: QUESTION: special characters in postscript output [message #928 is a reply to message #927] Fri, 12 March 1993 17:50 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
; This program section defines some strings which contain both English
; and Greek characters. It treats PostScript and all other devices
; differently. The strings are "K (alpha)", "K (beta)", etc. These are
; symbols for x-ray emission lines. This works in IDL 3.0. I am not sure
; about PV-WAVE.
if !d.name eq 'PS' then begin
!p.font = 0
!p.thick = 5
!p.charsize=1.5
chsize=1.5
device, xsize=10, ysize=7, /inch, /land
ka = 'K!9a!X'
kb = 'K!9b!X'
la1 = 'L!9a!X!D1'
lb1 = 'L!9b!X!D1'
lb2 = 'L!9b!X!D2'
lb3 = 'L!9b!X!D3'
lg1 = 'L!9g!X!D1'
endif else begin
!p.font=-1
!p.thick = 1
!p.charsize=1.0
chsize=1.0
ka = 'K!7a!X'
kb = 'K!7b!X'
la1 = 'L!7a!X!D1'
lb1 = 'L!7b!X!D1'
lb2 = 'L!7b!X!D2'
lb3 = 'L!7b!X!D3'
lg1 = 'L!7c!X!D1'
endelse

xyouts, 6.842, 30, 'Eu '+lb2, orien=90, size=chsize
xyouts, 6.571, 20, 'Eu '+lb3, orien=90, size=chsize


end
--
Mark Rivers (516) 282-7708 or 5626
Building 815 rivers@bnlx26.nsls.bnl.gov (Internet)
Brookhaven National Laboratory rivers@bnl (Bitnet)
Upton, NY 11973 BNLX26::RIVERS (Physnet)
Re: QUESTION: special characters in postscript output [message #934 is a reply to message #928] Thu, 11 March 1993 11:32 Go to previous message
xm9 is currently offline  xm9
Messages: 2
Registered: March 1993
Junior Member
In article <1nldk4$3p5@mozz.unh.edu= jrl1@kepler.unh.edu (John R Labonte) writes:
=When using the postscript graphics device with hardware fonts (!P.FONT=0),
=is there any way to display special characters (like greek and math symbols)
=and normal characters at the SAME time. The manual only mentions super/sub
=scripting (via !E etc.) and the bullet character (via !MX) but no mention of
=other special characters.
=
=Please reply via email

I'd be grateful for a reply in this newsgroup!
Re: QUESTION: special characters in postscript output [message #935 is a reply to message #934] Thu, 11 March 1993 05:45 Go to previous message
zawodny is currently offline  zawodny
Messages: 121
Registered: August 1992
Senior Member
In a somewhat related vain:

Here is a little routine I wrote up that creates a PostScript plot
displaying the characters in a font and how theey map to the keyboard and
their byte values. A sample usage of this might be:

IDL> !p.multi=[0,2,2,0,0]
IDL> for k=3,20 do DRAWFONT,k

This will draw all the available fonts (3 through 20) as they are cuurently
defined 4 fonts to a page.

There is also a .signature file at end of this message.
-----cut here-----------cut here-----------cut here-----------cut here------
;+
; NAME:
; DRAWFONT
; PURPOSE:
; Make a postscript file containing a display of the font
; CATEGORY:
; Unknown
; CALLING SEQUENCE:
; DRAWFONT,num
; INPUTS:
; num Font number (see the HELP,/DEVICE command)
; OUTPUTS:
; None
; COMMON BLOCKS:
; None
; SIDE EFFECTS:
; Make a postscript file
; RESTRICTIONS:
; None
; PROCEDURE:
; STRAIGHTFORWARD (seems to be the default value of this field).
; MODIFICATION HISTORY:
; Written Dec, 1991 by J. M. Zawodny
; zawodny@arbd0.larc.nasa.gov
;-

pro DRAWFONT,num

if (!d.name ne 'PS') then begin
set_graph,/ps
device,xoff=.5,xsize=7.5,yoff=1.,ysize=9.,/inch
!p.font=0
endif

!p.thick = 5
!x.range = [0,10]
!x.margin = [.12,.12]
!x.style = 5
!y.range = [0,10]
!y.margin = [.1,.1]
!y.style = 5
plot,[0,0,10,6,6,0],[0,10,10,10,9,9],/noclip
if(total(!p.multi) ne 0) then scale=.5 else scale=1.

font = '!'+strtrim(fix(num),2)
rfnt = '!3'
titl = 'PS Font !'+font
xyouts,3,9.15,titl,size=4*scale,align=.5
for r=0,9 do begin
y = 9.17-r
for c=0,9 do begin
if (r eq 0) and (c le 5) then goto,skip
x = c+.5
char = string(27B+byte(c+10*r))
if (char eq '!') then char = '!!'
numb = strtrim(27+c+10*r,2)
xyouts,x ,y ,font+char,align=.5,size=3*scale
xyouts,x-.40,y+.63,rfnt+char,align=0.,size=1.25*scale
xyouts,x+.40,y+.63,numb ,align=1.,size=1.25*scale
oplot,[0,1,1]+c,10-r-[1,1,0],/noclip
skip:
endfor
endfor
return
end
-----cut here-----------cut here-----------cut here-----------cut here------


--
Joseph M. Zawodny (KO4LW) NASA Langley Research Center
Internet: zawodny@arbd0.larc.nasa.gov MS-475, Hampton VA, 23681-0001
Packet: ko4lw@wb0tax.va.usa
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Q: How to scroll image quickly in IDL 2.4.0?
Next Topic: Looking for DECODE_GIF

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:06:42 PDT 2025

Total time taken to generate the page: 0.15746 seconds