source: trunk/SRC/Textoidl/showtex.pro @ 163

Last change on this file since 163 was 163, checked in by navarro, 18 years ago

header improvements : type of parameters and keywords, default values, spell checking + idldoc assistant (IDL online_help)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.8 KB
Line 
1;
2;+
3; NAME:
4;       SHOWTEX
5; PURPOSE:
6;       Display TeX sequence translation table on current graphics device.
7; CATEGORY:
8;       text/strings
9; CALLING SEQUENCE:
10;       showtex
11; INPUTS:
12; KEYWORD PARAMETERS:
13;       /HELP -- print out info on use of the function
14;                and exit.
15;       FONT  -- Set to 0 to use hardware font, -1 to use vector.
16;                Note that the only hardware font supported is
17;                Postscript
18; OUTPUTS:
19; COMMON BLOCKS:
20; SIDE EFFECTS:
21;       Plot is created.
22; NOTES:
23;       Hardware fonts are supported only for device PS (PostScript)
24; EXAMPLE:
25; MODIFICATION HISTORY:
26;       $Id$
27;       $Log: showtex.pro,v $
28;       Revision 1.4  2004/06/15 17:25:54  mcraig
29;       Fixed bug in regular expression, changed array notation to square brackets
30;
31;       Revision 1.3  1996/06/14 20:00:27  mcraig
32;       Updated Copyright info.
33;
34;       Revision 1.2  1996/05/09 00:22:17  mcraig
35;       Added error handling and updated built in help.
36;
37;       Revision 1.1  1996/02/08 18:55:12  mcraig
38;       Initial revision
39;
40; RELEASE:
41;       $Name: Rel_2_1_2 $
42;
43; COPYRIGHT:
44;  Copyright (C) 1996 The Regents of the University of California, All
45;  Rights Reserved.  Written by Matthew W. Craig.
46;  See the file COPYRIGHT for restrictions on distrubting this code.
47;  This code comes with absolutely NO warranty; see DISCLAIMER for details.
48;-
49;
50PRO showtex, FONT=fnt, HELP=help
51;
52  compile_opt idl2, strictarrsubs
53;
54
55; Return to caller on error.
56    On_error, 2
57
58; Print help if needed.
59    IF keyword_set(help) THEN BEGIN
60        print, '    Display TeX sequence translation table on current graphics device.'
61        print, '    showtex'
62        print, '    Keywords:'
63        print, '       /HELP       print this message and return'
64        print, '       FONT        set to 0 to use hardware fonts for current device,'
65        print, '                   -1 to use vector fonts (DEFAULT)'
66        print, '    NOTES:  - The only hardware font supported is PostScript.'
67        print, '            - The FONT keyword overrides the font selected in !p.font'
68        return
69    ENDIF
70   
71;  We begin by deciding on the font.  PostScript = 0 means use vector.
72    PostScript = 0
73    PlotTitle = 'Vector Fonts'
74    IF n_elements(fnt) EQ 0 THEN BEGIN ; get font from !p.font
75        IF !P.font NE -1 THEN BEGIN ; User wants hardware font.
76            PostScript = 1
77            PlotTitle = 'PostScript Fonts'
78        ENDIF
79    ENDIF ELSE BEGIN            ; get font from FONT keyword
80        IF fnt NE -1 THEN BEGIN
81            PostScript = 1
82            PlotTitle = 'PostScript Fonts'
83        ENDIF
84    ENDELSE
85   
86;  Bomb out if user wants hardware font for non-PostScript device.
87    IF (PostScript EQ 1) AND (strupcase(!D.name) NE 'PS') THEN BEGIN   
88                                              ; Device isn't postscript
89                                              ; and user wants hardware
90                                              ; font.  Not good.
91        print, 'Warning: No translation for device: ', !D.name
92        return
93    ENDIF
94   
95; Set !P.font to value indicated by FONT keyword, saving surrent
96; setting to reset at end.
97    OldPFont = !p.font
98    !p.font = PostScript - 1
99
100    erase
101    seq = textoidl(/tex)
102    DisplayString = seq + '  ' + textoidl(seq)
103
104    nseq = n_elements(seq)
105    nrows = nseq/5 + 1          ; Five sequences per row.
106    dx = .9/5.
107    dy = .9/nrows
108    y=.95
109    xyouts,.5,y,PlotTitle,align=.5,/norm,size=2.5
110    count=0
111    FOR i = 1L, nrows DO BEGIN
112        y= y - dy
113        x = .1
114        FOR j = 1, 5 DO BEGIN
115            IF (count LT nseq ) THEN xyouts, x, y, DisplayString[count], align = .5, /norm
116            count = count+1
117            x = x + dx
118        ENDFOR
119    ENDFOR
120
121; Restore old !P.font.
122    !p.font = OldPFont
123END
Note: See TracBrowser for help on using the repository browser.