home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: SysTools / SysTools.zip / ft-beta.zip / freetype / lib / extend / ttgasp.c < prev    next >
C/C++ Source or Header  |  1997-10-06  |  2KB  |  67 lines

  1. /*******************************************************************
  2.  *
  3.  *  ttgasp.c                                                    1.0
  4.  *
  5.  *    Gasp table support API extension body     
  6.  *
  7.  *  Copyright 1996, 1997 by
  8.  *  David Turner, Robert Wilhelm, and Werner Lemberg.
  9.  *
  10.  *  This file is part of the FreeType project, and may only be used
  11.  *  modified and distributed under the terms of the FreeType project
  12.  *  license, LICENSE.TXT. By continuing to use, modify or distribute
  13.  *  this file you indicate that you have read the license and
  14.  *  understand and accept it fully.
  15.  *
  16.  *
  17.  *  The gasp table is currently loaded by the core engine, but the 
  18.  *  standard API doesn't give access to it. This file is used to
  19.  *  demonstrate the use of a simple API extension.            
  20.  *
  21.  *  The additional API functions are defined in the file "ftxgasp.h"
  22.  *  while they're implemented in "ttgasp.c"
  23.  *
  24.  ******************************************************************/
  25.  
  26. #include "tttypes.h"
  27. #include "ttobjs.h"
  28. #include "tttables.h"
  29. #include "ftxgasp.h"
  30.  
  31.  TT_Error  TT_Get_Face_Gasp_Flags( TT_Face  face,
  32.                                    int      point_size,
  33.                                    int*     grid_fit,
  34.                                    int*     smooth_font )
  35.  {
  36.    PFace  faze = HANDLE_Face( face );
  37.    Int    i, flag;
  38.  
  39.    if (!faze)
  40.      return TT_Err_Invalid_Face_Handle;
  41.  
  42.    if ( faze->gasp.numRanges == 0 ||
  43.         !faze->gasp.gaspRanges )
  44.      return TT_Err_Table_Missing;
  45.  
  46.    for ( i = 0; i < faze->gasp.numRanges; i++ )
  47.    {
  48.      if ( point_size <= faze->gasp.gaspRanges[i].maxPPEM )
  49.      {
  50.        flag = faze->gasp.gaspRanges[i].gaspFlag;
  51.  
  52.        *grid_fit    = ( (flag & GASP_GRIDFIT) != 0 );
  53.        *smooth_font = ( (flag & GASP_DOGRAY ) != 0 );
  54.  
  55.        return TT_Err_Ok;
  56.      }
  57.    }
  58.    /* for very large font, we enable font smoothing and discard */
  59.    /* grid fitting                                              */
  60.  
  61.    *grid_fit    = 0;
  62.    *smooth_font = 1;
  63.  
  64.    return TT_Err_Ok;
  65.  }
  66.  
  67.