home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / qc / qc25 / sampler.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-15  |  1.8 KB  |  81 lines

  1. /* SAMPLER.C: Display sample text in various fonts. */
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <stdlib.h>
  5. #include <graph.h>
  6. #include <string.h>
  7.  
  8. #define NFONTS 6
  9.  
  10. main()
  11. {
  12.   static unsigned char *text[2*NFONTS] =
  13.   {
  14.       "COURIER",        "courier",
  15.       "HELV",           "helv",
  16.       "TMS RMN",        "tms rmn",
  17.       "MODERN",         "modern",
  18.       "SCRIPT",         "script",
  19.       "ROMAN",          "roman"
  20.   };
  21.   static unsigned char *face[NFONTS] =
  22.   {
  23.       "t'courier'",
  24.       "t'helv'",
  25.       "t'tms rmn'",
  26.       "t'modern'",
  27.       "t'script'",
  28.       "t'roman'"
  29.   };
  30.   static unsigned char list[20];
  31.   struct videoconfig vc;
  32.   int mode = _VRES16COLOR;
  33.   register i;
  34.  
  35.   /*  Read header info from all .FON files in
  36.    *  current directory   */
  37.   if(_registerfonts( "*.FON" )<0 )
  38.   {
  39.      _outtext("Error:  can't register fonts");
  40.      exit( 0 );
  41.   }
  42.  
  43.   /*   Set highest available video mode */
  44.   while( !_setvideomode( mode ) )
  45.      mode--;
  46.   if( mode == _TEXTMONO )
  47.      exit ( 0 );
  48.  
  49.   /*   Copy video configuration into structure vc */
  50.   _getvideoconfig( &vc );
  51.  
  52.   /*   Display six lines of sample text */
  53.   for( i = 0; i<NFONTS; i++ )
  54.   {
  55.      strcpy( list, face[i] );
  56.      strcat( list, "h30w24b" );
  57.  
  58.      if( !_setfont( list ) )
  59.      {
  60.          _setcolor( i + 1 );
  61.          _moveto( 0, (i * vc.numypixels) / NFONTS );
  62.          _outgtext( text[i * 2] );
  63.          _moveto( vc.numxpixels / 2,
  64.                      (i * vc.numypixels) / NFONTS );
  65.          _outgtext( text[(i * 2) + 1] );
  66.      }
  67.      else
  68.      {
  69.          _setvideomode( _DEFAULTMODE );
  70.          _outtext( "Error:  can't set font" );
  71.          exit( 0 );
  72.      }
  73.   }
  74.   getch();
  75.   _setvideomode( _DEFAULTMODE );
  76.  
  77.   /* Return memory when finished with fonts */
  78.   _unregisterfonts();
  79.   exit( 0 );
  80. }
  81.