ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

gxvopbd.c
Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  gxvopbd.c                                                              */
00004 /*                                                                         */
00005 /*    TrueTypeGX/AAT opbd table validation (body).                         */
00006 /*                                                                         */
00007 /*  Copyright 2004, 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
00008 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
00009 /*                                                                         */
00010 /*  This file is part of the FreeType project, and may only be used,       */
00011 /*  modified, and distributed under the terms of the FreeType project      */
00012 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
00013 /*  this file you indicate that you have read the license and              */
00014 /*  understand and accept it fully.                                        */
00015 /*                                                                         */
00016 /***************************************************************************/
00017 
00018 /***************************************************************************/
00019 /*                                                                         */
00020 /* gxvalid is derived from both gxlayout module and otvalid module.        */
00021 /* Development of gxlayout is supported by the Information-technology      */
00022 /* Promotion Agency(IPA), Japan.                                           */
00023 /*                                                                         */
00024 /***************************************************************************/
00025 
00026 
00027 #include "gxvalid.h"
00028 #include "gxvcommn.h"
00029 
00030 
00031   /*************************************************************************/
00032   /*                                                                       */
00033   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
00034   /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
00035   /* messages during execution.                                            */
00036   /*                                                                       */
00037 #undef  FT_COMPONENT
00038 #define FT_COMPONENT  trace_gxvopbd
00039 
00040 
00041   /*************************************************************************/
00042   /*************************************************************************/
00043   /*****                                                               *****/
00044   /*****                      Data and Types                           *****/
00045   /*****                                                               *****/
00046   /*************************************************************************/
00047   /*************************************************************************/
00048 
00049   typedef struct  GXV_opbd_DataRec_
00050   {
00051     FT_UShort  format;
00052     FT_UShort  valueOffset_min;
00053 
00054   } GXV_opbd_DataRec, *GXV_opbd_Data;
00055 
00056 
00057 #define GXV_OPBD_DATA( FIELD )  GXV_TABLE_DATA( opbd, FIELD )
00058 
00059 
00060   /*************************************************************************/
00061   /*************************************************************************/
00062   /*****                                                               *****/
00063   /*****                      UTILITY FUNCTIONS                        *****/
00064   /*****                                                               *****/
00065   /*************************************************************************/
00066   /*************************************************************************/
00067 
00068   static void
00069   gxv_opbd_LookupValue_validate( FT_UShort            glyph,
00070                                  GXV_LookupValueCPtr  value_p,
00071                                  GXV_Validator        valid )
00072   {
00073     /* offset in LookupTable is measured from the head of opbd table */
00074     FT_Bytes   p     = valid->root->base + value_p->u;
00075     FT_Bytes   limit = valid->root->limit;
00076     FT_Short   delta_value;
00077     int        i;
00078 
00079 
00080     if ( value_p->u < GXV_OPBD_DATA( valueOffset_min ) )
00081       GXV_OPBD_DATA( valueOffset_min ) = value_p->u;
00082 
00083     for ( i = 0; i < 4; i++ )
00084     {
00085       GXV_LIMIT_CHECK( 2 );
00086       delta_value = FT_NEXT_SHORT( p );
00087 
00088       if ( GXV_OPBD_DATA( format ) )    /* format 1, value is ctrl pt. */
00089       {
00090         if ( delta_value == -1 )
00091           continue;
00092 
00093         gxv_ctlPoint_validate( glyph, delta_value, valid );
00094       }
00095       else                              /* format 0, value is distance */
00096         continue;
00097     }
00098   }
00099 
00100 
00101   /*
00102     opbd ---------------------+
00103                               |
00104     +===============+         |
00105     | lookup header |         |
00106     +===============+         |
00107     | BinSrchHeader |         |
00108     +===============+         |
00109     | lastGlyph[0]  |         |
00110     +---------------+         |
00111     | firstGlyph[0] |         |  head of opbd sfnt table
00112     +---------------+         |             +
00113     | offset[0]     |    ->   |          offset            [byte]
00114     +===============+         |             +
00115     | lastGlyph[1]  |         | (glyphID - firstGlyph) * 4 * sizeof(FT_Short) [byte]
00116     +---------------+         |
00117     | firstGlyph[1] |         |
00118     +---------------+         |
00119     | offset[1]     |         |
00120     +===============+         |
00121                               |
00122      ....                     |
00123                               |
00124     48bit value array         |
00125     +===============+         |
00126     |     value     | <-------+
00127     |               |
00128     |               |
00129     |               |
00130     +---------------+
00131     .... */
00132 
00133   static GXV_LookupValueDesc
00134   gxv_opbd_LookupFmt4_transit( FT_UShort            relative_gindex,
00135                                GXV_LookupValueCPtr  base_value_p,
00136                                FT_Bytes             lookuptbl_limit,
00137                                GXV_Validator        valid )
00138   {
00139     GXV_LookupValueDesc  value;
00140 
00141     FT_UNUSED( lookuptbl_limit );
00142     FT_UNUSED( valid );
00143 
00144     /* XXX: check range? */
00145     value.u = (FT_UShort)( base_value_p->u +
00146                            relative_gindex * 4 * sizeof ( FT_Short ) );
00147 
00148     return value;
00149   }
00150 
00151 
00152   /*************************************************************************/
00153   /*************************************************************************/
00154   /*****                                                               *****/
00155   /*****                         opbd TABLE                            *****/
00156   /*****                                                               *****/
00157   /*************************************************************************/
00158   /*************************************************************************/
00159 
00160   FT_LOCAL_DEF( void )
00161   gxv_opbd_validate( FT_Bytes      table,
00162                      FT_Face       face,
00163                      FT_Validator  ftvalid )
00164   {
00165     GXV_ValidatorRec  validrec;
00166     GXV_Validator     valid = &validrec;
00167     GXV_opbd_DataRec  opbdrec;
00168     GXV_opbd_Data     opbd  = &opbdrec;
00169     FT_Bytes          p     = table;
00170     FT_Bytes          limit = 0;
00171 
00172     FT_ULong  version;
00173 
00174 
00175     valid->root       = ftvalid;
00176     valid->table_data = opbd;
00177     valid->face       = face;
00178 
00179     FT_TRACE3(( "validating `opbd' table\n" ));
00180     GXV_INIT;
00181     GXV_OPBD_DATA( valueOffset_min ) = 0xFFFFU;
00182 
00183 
00184     GXV_LIMIT_CHECK( 4 + 2 );
00185     version                 = FT_NEXT_ULONG( p );
00186     GXV_OPBD_DATA( format ) = FT_NEXT_USHORT( p );
00187 
00188 
00189     /* only 0x00010000 is defined (1996) */
00190     GXV_TRACE(( "(version=0x%08x)\n", version ));
00191     if ( 0x00010000UL != version )
00192       FT_INVALID_FORMAT;
00193 
00194     /* only values 0 and 1 are defined (1996) */
00195     GXV_TRACE(( "(format=0x%04x)\n", GXV_OPBD_DATA( format ) ));
00196     if ( 0x0001 < GXV_OPBD_DATA( format ) )
00197       FT_INVALID_FORMAT;
00198 
00199     valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
00200     valid->lookupval_func   = gxv_opbd_LookupValue_validate;
00201     valid->lookupfmt4_trans = gxv_opbd_LookupFmt4_transit;
00202 
00203     gxv_LookupTable_validate( p, limit, valid );
00204     p += valid->subtable_length;
00205 
00206     if ( p > table + GXV_OPBD_DATA( valueOffset_min ) )
00207     {
00208       GXV_TRACE((
00209         "found overlap between LookupTable and opbd_value array\n" ));
00210       FT_INVALID_OFFSET;
00211     }
00212 
00213     FT_TRACE4(( "\n" ));
00214   }
00215 
00216 
00217 /* END */

Generated on Sat May 26 2012 04:32:44 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.