home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / graphics / fsampler.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-07  |  1.8 KB  |  89 lines

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