1C*GRSY00 -- initialize font definition
2C+
3      SUBROUTINE GRSY00
4C
5C This routine must be called once in order to initialize the tables
6C defining the symbol numbers to be used for ASCII characters in each
7C font, and to read the character digitization from a file.
8C
9C Arguments: none.
10C
11C Implicit input:
12C  The file with name specified in environment variable PGPLOT_FONT
13C  is read, if it is available.
14C  This is a binary file containing two arrays INDEX and BUFFER.
15C  The digitization of each symbol occupies a number of words in
16C  the INTEGER*2 array BUFFER; the start of the digitization
17C  for symbol number N is in BUFFER(INDEX(N)), where INDEX is an
18C  integer array of 3000 elements. Not all symbols 1...3000 have
19C  a representation; if INDEX(N) = 0, the symbol is undefined.
20C
21*  PGPLOT uses the Hershey symbols for two `primitive' operations:
22*  graph markers and text.  The Hershey symbol set includes several
23*  hundred different symbols in a digitized form that allows them to
24*  be drawn with a series of vectors (polylines).
25*
26*  The digital representation of all the symbols is stored in common
27*  block /GRSYMB/.  This is read from a disk file at run time. The
28*  name of the disk file is specified in environment variable
29*  PGPLOT_FONT.
30*
31* Modules:
32*
33* GRSY00 -- initialize font definition
34* GRSYDS -- decode character string into list of symbol numbers
35* GRSYMK -- convert marker number into symbol number
36* GRSYXD -- obtain the polyline representation of a given symbol
37*
38* PGPLOT calls these routines as follows:
39*
40* Routine          Called by
41*
42* GRSY00          GROPEN
43* GRSYDS          GRTEXT, GRLEN
44* GRSYMK          GRMKER,
45* GRSYXD          GRTEXT, GRLEN, GRMKER
46***********************************************************************
47C--
48C (2-Jan-1984)
49C 22-Jul-1984 - revise to use DATA statements [TJP].
50C  5-Jan-1985 - make missing font file non-fatal [TJP].
51C  9-Feb-1988 - change default file name to Unix name; overridden
52C               by environment variable PGPLOT_FONT [TJP].
53C 29-Nov-1990 - move font assignment to GRSYMK.
54C  7-Nov-1994 - look for font file in PGPLOT_DIR if PGPLOT_FONT is
55C               undefined [TJP].
56C-----------------------------------------------------------------------
57      CHARACTER*(*) DEFNAM
58      PARAMETER  (DEFNAM='grfont.dat')
59      INTEGER*2  BUFFER(27000)
60      INTEGER    FNTFIL, IER, INDEX(3000), NC1, NC2, NC3
61      INTEGER    L, GRTRIM
62      COMMON     /GRSYMB/ NC1, NC2, INDEX, BUFFER
63      CHARACTER*128 FF
64C
65C Read the font file. If an I/O error occurs, it is ignored; the
66C effect will be that all symbols will be undefined (treated as
67C blank spaces).
68C
69      CALL GRGFIL('FONT', FF)
70      L = GRTRIM(FF)
71      IF (L.LT.1) L = 1
72      CALL GRGLUN(FNTFIL)
73      OPEN (UNIT=FNTFIL, FILE=FF(1:L), FORM='UNFORMATTED',
74     2      STATUS='OLD', IOSTAT=IER)
75      IF (IER.EQ.0) READ (UNIT=FNTFIL, IOSTAT=IER)
76     1            NC1,NC2,NC3,INDEX,BUFFER
77      IF (IER.EQ.0) CLOSE (UNIT=FNTFIL, IOSTAT=IER)
78      CALL GRFLUN(FNTFIL)
79      IF (IER.NE.0) THEN
80          CALL GRWARN('Unable to read font file: '//FF(:L))
81          CALL GRWARN('Use environment variable PGPLOT_FONT to specify '
82     :          //'the location of the PGPLOT grfont.dat file.')
83      END IF
84      RETURN
85      END
86