#include <dos.h>
#include <exec/types.h>
#include <intuition/gadgetclass.h>
#include <intuition/intuitionbase.h>
#include <libraries/gadtools.h>
#include <libraries/reqtools.h>
#include <proto/diskfont.h>
#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/reqtools.h>
#include <stdlib.h>
#include <string.h>


#define  NUMLINES  8                             //  8 Lines of InfoText.  

#define  MSG  "Usage: Shelley <[FullPath:]DiskFontName/DiskFontSize>/S\n"



UBYTE *ScrTitle = { "Shelley V1.00 © 1997 by Jenny Vromans" };

UBYTE *Version  = { "$VER: Shelley 1.00 (25.08.97)" };


struct InfoWin
{
  UWORD Left;
  UWORD Top;
  UWORD Width;
  UWORD Height;

} IW;


struct TextAttr Topaz80 =
{
  "topaz.font",
  TOPAZ_EIGHTY,
  FS_NORMAL,
  FPF_ROMFONT
};


UBYTE InfoText[ NUMLINES ][ 20 ] =
{
  { "Font height  :  " },
  { "Nominal width:  " },
  { "Baseline     :  " },
  { "BoldSmear    :  " },
  { "LoChar       :  " },
  { "HiChar       :  " },
  { "Modulo       :  " },
  { "Type = "          }
};


struct IntuiText InfoIText[ NUMLINES ] =
{
  { 1, 0, JAM1, 15, 0, &Topaz80, InfoText[ 0 ], NULL },
  { 1, 0, JAM1, 15, 0, &Topaz80, InfoText[ 1 ], &InfoIText[ 0 ] },
  { 1, 0, JAM1, 15, 0, &Topaz80, InfoText[ 2 ], &InfoIText[ 1 ] },
  { 1, 0, JAM1, 15, 0, &Topaz80, InfoText[ 3 ], &InfoIText[ 2 ] },
  { 1, 0, JAM1, 15, 0, &Topaz80, InfoText[ 4 ], &InfoIText[ 3 ] },
  { 1, 0, JAM1, 15, 0, &Topaz80, InfoText[ 5 ], &InfoIText[ 4 ] },
  { 1, 0, JAM1, 15, 0, &Topaz80, InfoText[ 6 ], &InfoIText[ 5 ] },
  { 1, 0, JAM1, 15, 0, &Topaz80, InfoText[ 7 ], &InfoIText[ 6 ] },
};


struct TextAttr TxtAttr =                    //  Used for requested font. 
{
  "topaz.font", 8, FS_NORMAL, FPF_DISKFONT | FPF_DESIGNED
};


LONG Pen;                                           //  Pencolor of text. 

struct rtFileRequester *FileReq;

struct TextFont *TxtFont;                     //  Our requested diskfont. 

struct Window *InfoWin, *Win;

struct Screen *Scr;

UBYTE FRBuffer[ 108 ];                            //  Buffer for FileReq. 

UBYTE File[ 256 ];                   //  Used with rtFileRequest().       

UWORD TopOffset;             //  Space between text and top window border.

UWORD WBorTop;               //  Scr->WBorTop + Scr->Font->ta_YSize + 1.  
                             //  = YSize of top window border.            
UBYTE *SongText[ 24 ] = 
{
  { "Samantha Jones - My Way" },
  { "And now the end is near and so I face the final curtain," },
  { "My friend, I'll say it clear, I'll state my case, of which I'm certain." },
  { "I've lived a life that's full, I've travelled each and every highway," },
  { "And more, much more than this, I did it my way." },
  
  { "Regrets I've had a few but then again too few to mention," },
  { "I did what I had to do, and saw it through without exemption." },
  { "I planned each chartered course, each careful step along the by-way," },
  { "And more, much more than this, I did it my way." },
  
  { "Yes there were times I'm sure you knew," },
  { "When I bit off more than I could chew." },
  { "But through it all, when there was doubt, I ate it up and spit it out," },
  { "I faced it all and I stood tall, and did it my way." },
  
  { "I've loved I've laughed and cried I've had my fill my share of losing," },
  { "And now as tears subside, I find it all so amusing." },
  { "To think I did it all that and may I say, not in a shy way," },
  { "Oh no, oh no not me, I did it my way." },
  
  { "For what is a woman, what has she got, if not herself, then she has not," },
  { "To say the things she'd truly feel and not the words of one who kneels." },
  { "The record shows I took the blows and did it my way." },
  
  { "English text »  Paul Anka" },
  { "French text »  Gilles Thibault" },
  { "Music »  Jacques Revaux / Claude François" },
  { "© Copyright 1967 by Barclay Morris S.A. - Paris" }
};

WORD SongTextLen[]  = { 23, 56, 71, 69, 47, 57, 61, 68, 47, 39, 38, 70,
                        51, 70, 51, 59, 37, 72, 71, 52, 25, 30, 41, 47 };



void CloseAll( void );
void ConvertTxtFontData( UWORD, UBYTE );
void ReadFont( UBYTE *, UBYTE );
void Setup( int );
void ShowText( UBYTE );
void UpdateInfoWin( void );



/*************************************************************************
 *                                                                       *
 *  Function:  void main( int argc, char *argv[] );                      *
 *                                                                       *
 *  Comment :  The main function, handles all input.                     *
 *                                                                       *
 *             This program has two modes. Workbench mode ( argc == 0 )  *
 *             and CLI mode ( argc != 0 ). Typing Shelley at the CLI     *
 *             prompt with no argument also triggers Workbench mode.     *
 *                                                                       *
 *             In Workbench mode pressing RMB will bring up the File-    *
 *             requester for selecting another font. In CLI mode pres-   *
 *             sing the RMB terminates the program. There is no way to   *
 *             open another font in CLI mode.                            *
 *                                                                       *
 *************************************************************************/


void main( int argc, char *argv[] )
{
  BOOL loop = TRUE, ok = NULL, refresh = TRUE, torc = 1;
  struct IntuiMessage *msg;
  ULONG _class;                              // ^-- Read T or C.          
  UWORD bits, code, style = FS_NORMAL;
  
  
  if ( argc != 0 )                                  //  Started from CLI. 
    {
      if ( argv[ 1 ][ 0 ] == '?' )               //  User requested help. 
        {
          if ( DOSBase = ( struct DosLibrary * )
                                         OpenLibrary( "dos.library", 39L ))
            {
              Write( Output(), MSG, strlen( MSG ));
              
              CloseLibrary( ( struct Library * ) DOSBase );
            }
            
          exit( 1 );
        }
      
      
      if ( !argv[ 1 ] )            //  Started from CLI with no argument. 
        argc = 0;                  //  Pretend if started from Workbench. 
    }
  
  
  Setup( argc );                        //  Setup automatically opens the 
                                        //  FileRequester when argc == 0. 
  
  if ( argc == 0 )
    ReadFont( File, torc );           //  The torc argument is used to    
  else                                //  toggle between text and chars.  
    ReadFont( argv[ 1 ], torc );      //  torc == 1 is text, 2 is chars.  
  
  
  while ( loop )
    {
      Wait( 1L << Win->UserPort->mp_SigBit );
      
      
      while ( msg = ( struct IntuiMessage * ) GetMsg( Win->UserPort ))
        {
          _class = msg->Class;
          code   = msg->Code;
          
          ReplyMsg( ( struct Message * ) msg );
          
          
          switch ( _class )
            {
              case IDCMP_CLOSEWINDOW:
                
                loop = FALSE;
                
                break;
              
              
              case IDCMP_MOUSEBUTTONS:
                
                if ( code == MENUDOWN )
                  ok = 2;                                  //  See below. 
                
                break;
              
              
              case IDCMP_RAWKEY:
              
                if ( code == 80 || code == 89 )            //  F1 or F10. 
                  {
                    if ( !InfoWin )
                      {
                        if ( InfoWin = OpenWindowTags( NULL,
                          
                           WA_Left,      IW.Left, WA_Top,           IW.Top,
                           WA_Width,    IW.Width, WA_Height,     IW.Height,
                           WA_DragBar,      TRUE, WA_ScreenTitle, ScrTitle,
                           WA_DepthGadget,  TRUE, WA_PubScreen,        Scr,
                           WA_RMBTrap,      TRUE, WA_SmartRefresh,    TRUE,
                           
                           WA_Title,                        "Font info...",
                           
                           WA_IDCMP,      IDCMP_REFRESHWINDOW,   TAG_END ))
                       
                          UpdateInfoWin();
                      }
                    else if ( InfoWin )
                      {
                        CloseWindow( InfoWin );
                        
                        InfoWin = NULL;
                     }
                  }
                else if ( code == 95 )                          //  HELP. 
                  {
                    rtEZRequestTags(
                       
                        "F1/F10    Open/Close Font info window\n"
                        "ESC       Quit Shelley\n"
                        "L/O       Load/Open new font\n"
                        "RMB       Load new font or Quit\n\n"
                        
                        "B         Toggle Bold on/off\n"
                        "I         Toggle Italic on/off\n"
                        "U         Toggle Underlined on/off\n"
                        "N/P       Switch to normal/plain text\n\n"
                        
                        "C/T       Toggle between chars and text",
                        
                        "OK", NULL, NULL,
                                   
                                      RTEZ_ReqTitle,  "Shelley Help...",
                                      RT_ReqPos,         REQPOS_POINTER,
                                      RT_Window,                    Win,
                                     
                                                                TAG_DONE );
                  }
                
                break;
              
                                           //  Win would be updated twice 
              case IDCMP_REFRESHWINDOW:    //  when a FileRequester is    
                                           //  closed, because this would 
                if ( refresh == TRUE )     //  also cause a call to this  
                  {                        //  refresh function. The      
                    BeginRefresh( Win );   //  boolean 'refresh' prevents 
                                           //  this. [ See also below at  
                      ShowText( torc );    //  if ( ok == 2 ) ].          
                                           
                    EndRefresh( Win, TRUE );
                  }
                else
                  refresh = TRUE;
                
                break;
              
              
              case IDCMP_VANILLAKEY:
                
                switch ( code )
                  { 
                    case 27:                                      // ESC. 
                      
                      loop = FALSE;
                      
                      break;
                    
                    
                    case 66:                                       //  B. 
                    case 98:                                       //  b. 
                      
                      if ( style & FSF_BOLD )
                        style &= ~FSF_BOLD;
                      else
                        style |= FSF_BOLD;
                      
                      ok = 1;
                      
                      break;
                    
                    
                    case  73:                                      //  I. 
                    case 105:                                      //  i. 
                    
                      if ( style & FSF_ITALIC )
                        style &= ~FSF_ITALIC;
                      else
                        style |= FSF_ITALIC;
                      
                      ok = 1;
                    
                      break;
                    
                    
                    case  85:                                      //  U. 
                    case 117:                                      //  u. 
                    
                      if ( style & FSF_UNDERLINED )
                        style &= ~FSF_UNDERLINED;
                      else
                        style |= FSF_UNDERLINED;
                      
                      ok = 1;
                    
                      break;
                    
                    
                    case  78:                                      //  N. 
                    case 110:                                      //  n. 
                    case  80:                                      //  P. 
                    case 112:                                      //  p. 
                    
                      style = FS_NORMAL;
                      
                      ok = 1;
                    
                      break;
                    
                    
                    case  76:     //  L.     Pressing one of these keys   
                    case 108:     //  l.     would cause Shelley to quit  
                    case  79:     //  O.     if in CLI mode. This if-line 
                    case 111:     //  o.     prevents that.               
                    
                      if ( argc == 0 )       //  <-- Only act in WB mode. 
                        ok = 2;
                                          
                      break;
                    
                    
                    case  67:                                      //  C. 
                    case  99:                                      //  c. 
                    case  84:                                      //  T. 
                    case 116:                                      //  t. 
                    
                      torc = ( torc == 1 ) ? 2 : 1;    //  Toggle between 
                                                       //  text ( 1 ) and 
                      ShowText( torc );                //  chars ( 2 ).   
                      
                      break;
                  }
                                            //  Here's where we actually, 
                                            //  set or unset Plain, Bold, 
              if ( ok == 1 )                //  Italic and Underline.     
                {
                  bits = AskSoftStyle( Win->RPort );
                  
                  SetSoftStyle( Win->RPort, style, bits );
                  
                  ShowText( torc );
                  
                  ok = NULL;
                }
              
              break;
            }
          
          
          if ( ok == 2 )  //  Open the FileRequester or Quit the program. 
            {
              if ( rtFileRequest(  FileReq, FRBuffer,
                              "Select font...", RT_Screen, Scr, TAG_DONE ))
                {
                  strcpy( File, FileReq->Dir );
                  
                  if ( AddPart( File, FRBuffer, sizeof( File )) )
                    {
                      style = FS_NORMAL;
                      
                      ReadFont( File, torc );
                      
                      refresh = FALSE;       //  See IDCMP_REFRESHWINDOW. 
                    }
                }
              else if ( argc != 0 )
              
                CloseAll();  // ^-- Started from CLI with an argument.    
              
              
              ok = NULL;
            }
        }
    }
  
  
  CloseAll();
}



/*************************************************************************
 *                                                                       *
 *  Function:  void CloseAll( void );                                    *
 *                                                                       *
 *  Comment :  Clean up all that was opened and allocated by Setup().    *
 *                                                                       *
 *************************************************************************/


void CloseAll( void )
{
  if ( InfoWin )
    CloseWindow( InfoWin );
  
  
  if ( TxtFont )
    CloseFont( TxtFont );
  
  
  if ( Win )
    {
      CloseWindow( ( struct Window * ) Win );
      
      ReleasePen( Win->WScreen->ViewPort.ColorMap, Pen );
    }
  
  
  if ( FileReq )
    rtFreeRequest( FileReq );
  
  
  if ( Scr )
    UnlockPubScreen( NULL, Scr );
  
  
  if ( ReqToolsBase )
    CloseLibrary( ( struct Library * ) ReqToolsBase );
  
  
  if ( IntuitionBase )
    CloseLibrary( ( struct Library * ) IntuitionBase );
  
  
  if ( GfxBase )
    CloseLibrary( ( struct Library * ) GfxBase );
  
  
  if ( DiskfontBase )
    CloseLibrary( ( struct Library * ) DiskfontBase );
  
  
  exit( 1 );
}



/*************************************************************************
 *                                                                       *
 *  Function:  void ConvertTxtFontData( UWORD, UBYTE );                  *
 *                                                                       *
 *  Comment :  This function converts some TxtFont UWORD'S ans UBYTE's   *
 *             to decimal strings for use in the Info window. If the     *
 *             length of the string is less than 3 chars ( represented   *
 *             by x ), we will first insert some white spaces.           *
 *                                                                       *
 *************************************************************************/


void ConvertTxtFontData( UWORD data, UBYTE nr )
{
  int x;
  UBYTE buffer[ 7 ];
  
  
  x = stci_d( buffer, data );
  
  while ( x++ < 3 )
    strcat( InfoText[ nr ], " " );
  
  strcat( InfoText[ nr ], buffer );
}



/*************************************************************************
 *                                                                       *
 *  Function:  void ReadFont( UBYTE *, UBYTE );                          *
 *                                                                       *
 *  Comment :  Open the requested diskfont.                              *
 *                                                                       *
 *             Close the opened font when entering this function again   *
 *             or in CloseAll(). This is because we still need some      *
 *             data from TxtFont after leaving this function.            *
 *                                                                       *
 *************************************************************************/


void ReadFont( UBYTE *font, UBYTE torc )           //  torc: Read T or C. 
{
  UBYTE *ptr;
  UBYTE fontname[ 256 ], fontsize;
    
  
  if ( TxtFont )                 //  Set to zero by OpenDiskFont() below  
    CloseFont( TxtFont );        //  if the desired font cannot be found. 
  
  
  fontsize = atoi( FilePart( font ));   //  font could be something like  
                                        //  Courier/15 or Times/11 etc.   
  
  strcpy( fontname, font );
  
  ptr = PathPart( fontname );
  
  *ptr = '\0';                                     //  Cut off font size. 
  
  strcat( fontname, ".font" );
  
  
  TxtAttr.ta_Name  = fontname;
  
  TxtAttr.ta_YSize = fontsize;
  
  if ( TxtFont = ( struct TextFont * ) OpenDiskFont( &TxtAttr ))
    {
      SetFont( Win->RPort, TxtFont );
      
      SetWindowTitles( Win,
                     TxtFont->tf_Message.mn_Node.ln_Name, ( UBYTE * ) ~0 );
      
      ShowText( torc );                  //  If the font could be opened, 
                                         //  refresh the output window.   
      
      if ( InfoWin )                     //  If the Info window is opened 
        UpdateInfoWin();                 //  then also update it.         
    }
}




/*************************************************************************
 *                                                                       *
 *  Function:  void Setup( int );                                        *
 *                                                                       *
 *  Comment :  Self explaining.                                          *
 *                                                                       *
 *************************************************************************/

void Setup( int argc )
{
  struct List *psList;
  struct PubScreenNode *psNode;
  struct Screen *aScr;
  ULONG lock;
  UWORD height;
  UWORD register x;

  
  if (! ( DiskfontBase = ( struct Library * )
                                  OpenLibrary( "diskfont.library", 39L )) )
    CloseAll();
  
  
  if (! ( GfxBase = ( struct GfxBase * )
                                  OpenLibrary( "graphics.library", 39L )) )
    CloseAll();
  
  
  if (! ( IntuitionBase = ( struct IntuitionBase * )
                                 OpenLibrary( "intuition.library", 39L )) )
    CloseAll();
  
  
  if (! ( ReqToolsBase = ( struct ReqToolsBase * )
                                  OpenLibrary( "reqtools.library", 38L )) )
    CloseAll();
  
  
  lock = LockIBase( NULL );                  //  Find the screen on which 
                                             //  Shelley was started.     
    aScr = IntuitionBase->ActiveScreen;
  
  UnlockIBase( lock );
                                   //  Find the name of the public screen 
                                   //  on which Shelley was started, so   
  psList = LockPubScreenList();    //  we can open our window on it.      
  
  psNode = ( struct PubScreenNode * ) psList->lh_Head;
  
  while ( psNode )
    {
      if ( aScr == psNode->psn_Screen )
        {
          Scr = LockPubScreen( psNode->psn_Node.ln_Name );
          
          break;   //  ^-- Scr will be unlocked in CloseAll().            
        }
      
      psNode = ( struct PubScreenNode * ) psNode->psn_Node.ln_Succ;
    }
  
  UnlockPubScreenList();
  
  
  if ( Scr == NULL )                      //  <-- Not a public screen ??? 
    Scr = LockPubScreen( NULL );
  
  WBorTop = Scr->WBorTop + Scr->Font->ta_YSize + 1;    //  YSize of top   
                                                       //  window border. 
  height = Scr->Height - 11 - WBorTop;
  
  
  if ( argc == 0 )             // Workbench mode, open the FileRequester. 
    {
      if (! ( FileReq = rtAllocRequest( RT_FILEREQ, NULL )) )
        CloseAll();
      
      rtChangeReqAttr( FileReq, RTFI_Dir,         "Fonts:",
                            RTFI_OkText,             "_OK",
                            RT_Underscore,             '_',
                            RT_ReqPos,      REQPOS_POINTER,     TAG_DONE );
      
      
      if ( rtFileRequest( FileReq, FRBuffer,
                              "Select font...", RT_Screen, Scr, TAG_DONE ))
        {
          strcpy( File, FileReq->Dir );
          
          if (! ( AddPart( File, FRBuffer, sizeof( File ))) )
            CloseAll();
        }
      else
        CloseAll();
     }
  
  
  if (! ( Win = OpenWindowTags( NULL,
  
                WA_Left,                19, WA_Top,                11,
                WA_Width,              598, WA_Height,         height,
                WA_CloseGadget,       TRUE, WA_DragBar,          TRUE,
                WA_DepthGadget,       TRUE, WA_Activate,         TRUE,
                WA_PubScreen,          Scr, WA_RMBTrap,          TRUE,
                WA_RptQueue,          NULL, WA_SimpleRefresh,    TRUE,
                WA_ScreenTitle,   ScrTitle,
                
                WA_IDCMP,    IDCMP_REFRESHWINDOW | IDCMP_CLOSEWINDOW |
                             IDCMP_MOUSEBUTTONS  | IDCMP_VANILLAKEY  |
                             IDCMP_RAWKEY,
                                                               TAG_END )) )
    CloseAll();
  
  
  TopOffset = ( Scr->ViewPort.Modes & LACE ) ? 20 : 15;
    
  Pen = ObtainBestPen( Win->WScreen->ViewPort.ColorMap, 0x00 << 24,
          0x00 << 24, 0x00 << 24, OBP_Precision, PRECISION_GUI, TAG_DONE );
  
  SetDrMd( Win->RPort, JAM1 );             // ^-- Released in CloseAll(). 
  
  
  IW.Height = TopOffset + ( ( 8 * NUMLINES ) - 4 ) + WBorTop;
  IW.Width  = 180;            
                          //  ^-- 8 = height of Topaz80.                  

  IW.Left   = ( Win->LeftEdge + Win->Width ) - IW.Width - 8;
  IW.Top    = ( TopOffset == 20 ) ? Win->TopEdge + WBorTop + 4 :
                                                Win->TopEdge + WBorTop + 2;
  
  for ( x = 0; x < NUMLINES; ++x )
    {
      InfoIText[ x ].FrontPen = Pen;
      InfoIText[ x ].TopEdge  = TopOffset + ( x * 8 );
    }
}



/*************************************************************************
 *                                                                       *
 *  Function:  void ShowText( void );                                    *
 *                                                                       *
 *  Comment :  Show the text of 'My Way' ( torc == 1 ) or all characters *
 *             ( torc == 2 ) in the choosen font.                        *
 *                                                                       *
 *************************************************************************/


void ShowText( UBYTE torc )
{
  UWORD max, xOffset = 20, yOffset, ySize = TxtFont->tf_YSize;
    
  
  SetAPen( Win->RPort, 0 );
  
  RectFill( Win->RPort, 4, WBorTop, Win->Width - 5, Win->Height - 3 );
    
  SetAPen( Win->RPort, Pen );     //  ^-- Erase previous text ( if any ). 
  
  
  if ( torc == 1 )
    {                  //  24 lines of songtext & their vertical offsets. 
      WORD len[ 24 ];
      UWORD register x;
      WORD line[] = {  1,  3,  4,  5,  6,  8,  9, 10, 11, 13, 14, 15, 16,
                              18, 19, 20, 21, 23, 24, 25, 28, 29, 30, 31 };
      
      max = Win->Width - ( 2 * xOffset );
      
      for ( x = 0; x < 24; ++x )  
        { 
          len[ x ] = SongTextLen[ x ];
          
          while ( TextLength( Win->RPort, SongText[ x ], len[ x ] ) > max )
            --len[ x ];
        }             //  Cut off that part of the text that would exceed 
                      //  the right window border character by character. 
      
      max = Win->Height - WBorTop - TopOffset;
      
                                   //  Print the text as long as we won't 
      for ( x = 0; x < 24; ++x )   //  exceed the bottom window border.   
        {
          if ( ( yOffset = line[ x ] * ySize + TopOffset ) > max )
            break;
          
          Move( Win->RPort, xOffset, yOffset );
          
          Text( Win->RPort, SongText[ x ], len[ x ] );
        }
    }
  else                   //  Show the complete character set of the font. 
    {
      UBYTE buf[ 256 ], i = 1, c, x;
      UWORD ymax = Win->Height - WBorTop - TopOffset;
      
      
      max = Win->Width - 2 * xOffset;
      x = c = 33;                          //  33 is our first character. 

      
      while ( TRUE )
        {
          buf[ c - x ] = c;     //  c is character, x is position in buf. 
          
          if ( ( yOffset = i * ySize + TopOffset ) > ymax )
            break;
                      //  ^-- i represents the line number.               
          
          if ( TextLength( Win->RPort, buf, c - x + 1 ) > max )
            {
              Move( Win->RPort, xOffset, yOffset );    //  + 1 is because 
                                                       //  the computer   
              Text( Win->RPort, buf, --c - x + 1 );    //  starts at 0.   
              
              x = c + 1;           //  When buf[] is full print the text, 
                                   //  and go 1 line down ( ++i ).        
              ++i;
            }
          
          
          if ( c == 255 )              //  Print the last line and break. 
            {
              Move( Win->RPort, xOffset, yOffset );
              
              Text( Win->RPort, buf, c - x + 1 );
              
              break;
            }
          
          
          if ( c == 126 )         // Skip non printable chars 126 to 160. 
            {
              c += 34;
              x += 34;
            }
          
          ++c;
        }
    }
}



/*************************************************************************
 *                                                                       *
 *  Function:  void UpdateInfoWin( void );                               *
 *                                                                       *
 *  Comment :  Update the text in the info window if a new font is       *
 *             loaded.                                                   *
 *                                                                       *
 *************************************************************************/


void UpdateInfoWin( void )
{
  int x;
  
  
  for ( x = 0; x < NUMLINES - 1; ++x )              //  Cut off previous  
    InfoText[ x ][ 16 ] = '\0';                     //  strcpy()'ed data. 
  
  
  SetAPen( InfoWin->RPort, 0 );      //  Erase all text in window; needed 
                                     //  if function is called again.     
  RectFill( InfoWin->RPort, 4,
                              WBorTop, IW.Width - 5, InfoWin->Height - 3 );
  
  SetAPen( InfoWin->RPort, Pen );
  
  
  ConvertTxtFontData( TxtFont->tf_YSize, 0 );            //  Font height. 
  
  ConvertTxtFontData( TxtFont->tf_XSize, 1 );            //  Font width.  
  
  ConvertTxtFontData( TxtFont->tf_Baseline, 2 );
  
  ConvertTxtFontData( TxtFont->tf_BoldSmear, 3 );
  
  ConvertTxtFontData( TxtFont->tf_LoChar, 4 );
  
  ConvertTxtFontData( TxtFont->tf_HiChar, 5 );
  
  ConvertTxtFontData( TxtFont->tf_Modulo, 6 );
  
  
  if ( TxtFont->tf_Flags & FPF_PROPORTIONAL )              //  Font type. 
    strcpy( &InfoText[ 7 ][ 7 ], "PROPORTIONAL" );
  else
    strcpy( &InfoText[ 7 ][ 7 ], " FIXED WIDTH" );
  
  
  PrintIText( InfoWin->RPort, &InfoIText[ NUMLINES - 1 ], 0, 0 );
}
