OTWO-1213 Works around lost encoding in Ruby/C binding layer
[ohcount] / test / src_dir / idl_pvwave.pro
1 ;+
2 ; NAME: 
3 ;      SHOWFONT
4 ;
5 ; PURPOSE: 
6 ;          Uses current graphics device to draw a map of characters
7 ;          available in the font specified in argument
8 ;
9 ; CATEGORY: 
10 ;          General 
11 ;
12 ; CALLING SEQUENCE:
13 ;          showfont, num, 'title' ; table of font num entitled 'title'
14 ;
15 ; KEYWORD PARAMETERS: 
16 ;          /encapsulated                ; ignored (just for compatibility)
17 ;          /tt_font                     ; ignored (just for compatibility)
18 ;          base = 16                    ; number of columns in the table 
19 ;          beg = 32                     ; first character
20 ;          fin = num eq 3 ? 255 : 127   ; last character
21 ;
22 ; OUTPUTS:
23 ;          None.
24 ;
25 ; OPTIONAL OUTPUTS:
26 ;          None.
27 ;
28 ; COMMON BLOCKS:
29 ;          None.
30 ;
31 ; SIDE EFFECTS:
32 ;          Draws a font table on the current graphic device.
33 ;
34 ; RESTRICTIONS:
35 ;          None.
36 ;
37 ; PROCEDURE:
38 ;
39 ; EXAMPLE:
40 ;          showfont, 9, 'GDL math symbols'   ; show mappings for font 9
41 ;
42 ; MODIFICATION HISTORY:
43 ;       Written by: Sylwester Arabas (2008/12/28)
44 ;-
45 ; LICENCE:
46 ; Copyright (C) 2008,
47 ; This program is free software; you can redistribute it and/or modify  
48 ; it under the terms of the GNU General Public License as published by  
49 ; the Free Software Foundation; either version 2 of the License, or     
50 ; (at your option) any later version.                                   
51 ;-
52
53 pro showfont, num, name, encapsulated=eps, tt_font=tt, base=base, beg=beg, fin=fin
54   
55   ; handling default keyword values
56   if not keyword_set(base) then base = 16
57   if not keyword_set(beg) then beg = 32
58   if not keyword_set(fin) then fin = num eq 3 ? 255 : 127
59   if not keyword_set(name) then name = ''
60
61   ; constructing horizontal and vertical grid lines
62   n_hor = (fin + 1 - beg) / base + 1
63   h_x = (double(rebin(base * byte(128 * indgen(2 * (n_hor))) / 128, 4 * n_hor, /sample)))[1:4 * n_hor - 1] - .5
64   h_y = (double(rebin(beg + indgen(n_hor) * base, 4 * n_hor, /sample)))[0:4 * n_hor - 2] - base/2.
65   v_x = base - indgen(4 * base - 1) / 4 - .5
66   v_y = (double(rebin(byte(128 * indgen(2 * (base))) / 128, 4 * base, /sample)))[1:4 * base - 1] $
67     * base * ((fin + 1 - beg) / base) + beg - base / 2.
68
69   ; ploting grid and title
70   plot,  [h_x, v_x], [h_y, v_y], $
71      title='Font ' + strtrim(string(num), 2) + ', ' + name, $
72      xrange=[-1, base], $
73      yrange=[base * ((fin + 1) / base), beg - base], $
74      yticks=n_hor, $
75      xticks=base+1, $
76      xtitle='char mod ' + strtrim(string(base), 2), $
77      ytitle=strtrim(string(base), 2) + ' * (char / ' + strtrim(string(base), 2) + ')'
78      
79   ; ploting characters
80   for c = beg, fin do $
81     xyouts, (c mod base), base * (c / base), '!' + strtrim(string(num), 2) + string(byte(c))
82
83 end