Esempio n. 1
0
  static void
  event_help( void )
  {
    grEvent  dummy_event;


    FTDemo_Display_Clear( display );
    grSetLineHeight( 10 );
    grGotoxy( 0, 0 );
    grSetMargin( 2, 1 );
    grGotobitmap( display->bitmap );

    grWriteln( "FreeType String Viewer - part of the FreeType test suite" );
    grLn();
    grWriteln( "This program is used to display a string of text using" );
    grWriteln( "the new convenience API of the FreeType 2 library." );
    grLn();
    grWriteln( "Use the following keys :" );
    grLn();
    grWriteln( "  F1 or ?   : display this help screen" );
    grLn();
    grWriteln( "  a         : toggle anti-aliasing" );
    grWriteln( "  b         : toggle embedded bitmaps (and disable rotation)" );
    grWriteln( "  f         : toggle forced auto-hinting" );
    grWriteln( "  h         : toggle outline hinting" );
    grLn();
    grWriteln( "  1-2       : select rendering mode" );
    grWriteln( "  k         : cycle through kerning modes" );
    grWriteln( "  t         : cycle through kerning degrees" );
    grWriteln( "  V         : toggle vertical rendering" );
    grLn();
    grWriteln( "  G         : toggle gamma correction" );
    grWriteln( "  g         : increase gamma by 0.1" );
    grWriteln( "  v         : decrease gamma by 0.1" );
    grLn();
    grWriteln( "  n         : next font" );
    grWriteln( "  p         : previous font" );
    grLn();
    grWriteln( "  Up        : increase pointsize by 1 unit" );
    grWriteln( "  Down      : decrease pointsize by 1 unit" );
    grWriteln( "  Page Up   : increase pointsize by 10 units" );
    grWriteln( "  Page Down : decrease pointsize by 10 units" );
    grLn();
    grWriteln( "  Right     : rotate counter-clockwise" );
    grWriteln( "  Left      : rotate clockwise" );
    grWriteln( "  F7        : big rotate counter-clockwise" );
    grWriteln( "  F8        : big rotate clockwise" );
    grLn();
    grWriteln( "press any key to exit this help screen" );

    grRefreshSurface( display->surface );
    grListenSurface( display->surface, gr_event_key, &dummy_event );
  }
Esempio n. 2
0
static FT_Error
Render_GammaGrid( grBitmap*  bitmap )
{
  int   g;
  int   xmargin = 10;
  int   gamma_first = 16;
  int   gamma_last  = 26;
  int   gammas      = gamma_last - gamma_first + 1;
  int   xside       = (bitmap->width-100)/gammas - xmargin;
  int   yside       = (bitmap->rows-100)/2;
  int   yrepeat     = 1;

  int   x_0     = (bitmap->width - gammas*(xside+xmargin)+xmargin)/2;
  int   y_0     = (bitmap->rows  - (8+yside*2*yrepeat))/2;
  int   pitch   = bitmap->pitch;


  if ( pitch < 0 )
    pitch = -pitch;

#if 1
  memset( bitmap->buffer, 255, pitch*bitmap->rows );
#else
 /* fill the background with a simple pattern corresponding to 50%
  * linear gray from a reasonable viewing distance
  */
  {
    int             nx, ny;
    unsigned char*  line = bitmap->buffer;
    if ( bitmap->pitch < 0 )
      line -= (bitmap->pitch*(bitmap->rows-1));

    for ( ny = 0; ny < bitmap->rows; ny++, line += bitmap->pitch )
    {
      unsigned char*  dst = line;
      int             nx;

      for ( nx = 0; nx < bitmap->width; nx++, dst += 3 )
      {
        int  color = ((nx+ny) & 1)*255;

        dst[0] = dst[1] = dst[2] = (unsigned char)color;
      }
    }
  }
#endif

  grGotobitmap( bitmap );

  for ( g = gamma_first; g <= gamma_last; g += 1 )
  {
    double gamma_value = g/10.0;
    char   temp[6];
    int    x = x_0 + (xside+xmargin)*(g-gamma_first);
    int    y = y_0;
    int    ny;

    grSetPixelMargin( x, y_0-8 );
    grGotoxy( 0, 0 );

    sprintf( temp, "%.1f", gamma_value );
    grWrite( temp );

    for ( ny = 0; ny < yrepeat; ny++, y += 2*yside )
    {
      do_rect( bitmap, x, y, xside, yside,
               (int)( 255.0 * pow( 0.5, 1.0 / gamma_value ) ) );
      do_rect( bitmap, x, y+yside, xside, yside, -1 );
    }
  }
  return 0;
}