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

otvgdef.c
Go to the documentation of this file.
00001 /***************************************************************************/
00002 /*                                                                         */
00003 /*  otvgdef.c                                                              */
00004 /*                                                                         */
00005 /*    OpenType GDEF table validation (body).                               */
00006 /*                                                                         */
00007 /*  Copyright 2004, 2005, 2007 by                                          */
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 #include "otvalid.h"
00020 #include "otvcommn.h"
00021 
00022 
00023   /*************************************************************************/
00024   /*                                                                       */
00025   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
00026   /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
00027   /* messages during execution.                                            */
00028   /*                                                                       */
00029 #undef  FT_COMPONENT
00030 #define FT_COMPONENT  trace_otvgdef
00031 
00032 
00033   /*************************************************************************/
00034   /*************************************************************************/
00035   /*****                                                               *****/
00036   /*****                      UTILITY FUNCTIONS                        *****/
00037   /*****                                                               *****/
00038   /*************************************************************************/
00039   /*************************************************************************/
00040 
00041 #define AttachListFunc    otv_O_x_Ox
00042 #define LigCaretListFunc  otv_O_x_Ox
00043 
00044   /* sets valid->extra1 (0)           */
00045 
00046   static void
00047   otv_O_x_Ox( FT_Bytes       table,
00048               OTV_Validator  valid )
00049   {
00050     FT_Bytes           p = table;
00051     FT_Bytes           Coverage;
00052     FT_UInt            GlyphCount;
00053     OTV_Validate_Func  func;
00054 
00055 
00056     OTV_ENTER;
00057 
00058     OTV_LIMIT_CHECK( 4 );
00059     Coverage   = table + FT_NEXT_USHORT( p );
00060     GlyphCount = FT_NEXT_USHORT( p );
00061 
00062     OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
00063 
00064     otv_Coverage_validate( Coverage, valid, GlyphCount );
00065     if ( GlyphCount != otv_Coverage_get_count( Coverage ) )
00066       FT_INVALID_DATA;
00067 
00068     OTV_LIMIT_CHECK( GlyphCount * 2 );
00069 
00070     valid->nesting_level++;
00071     func          = valid->func[valid->nesting_level];
00072     valid->extra1 = 0;
00073 
00074     for ( ; GlyphCount > 0; GlyphCount-- )
00075       func( table + FT_NEXT_USHORT( p ), valid );
00076 
00077     valid->nesting_level--;
00078 
00079     OTV_EXIT;
00080   }
00081 
00082 
00083   /*************************************************************************/
00084   /*************************************************************************/
00085   /*****                                                               *****/
00086   /*****                       LIGATURE CARETS                         *****/
00087   /*****                                                               *****/
00088   /*************************************************************************/
00089   /*************************************************************************/
00090 
00091 #define CaretValueFunc  otv_CaretValue_validate
00092 
00093   static void
00094   otv_CaretValue_validate( FT_Bytes       table,
00095                            OTV_Validator  valid )
00096   {
00097     FT_Bytes  p = table;
00098     FT_UInt   CaretValueFormat;
00099 
00100 
00101     OTV_ENTER;
00102 
00103     OTV_LIMIT_CHECK( 4 );
00104 
00105     CaretValueFormat = FT_NEXT_USHORT( p );
00106 
00107     OTV_TRACE(( " (format = %d)\n", CaretValueFormat ));
00108 
00109     switch ( CaretValueFormat )
00110     {
00111     case 1:     /* CaretValueFormat1 */
00112       /* skip Coordinate, no test */
00113       break;
00114 
00115     case 2:     /* CaretValueFormat2 */
00116       /* skip CaretValuePoint, no test */
00117       break;
00118 
00119     case 3:     /* CaretValueFormat3 */
00120       p += 2;   /* skip Coordinate */
00121 
00122       OTV_LIMIT_CHECK( 2 );
00123 
00124       /* DeviceTable */
00125       otv_Device_validate( table + FT_NEXT_USHORT( p ), valid );
00126       break;
00127 
00128     default:
00129       FT_INVALID_FORMAT;
00130     }
00131 
00132     OTV_EXIT;
00133   }
00134 
00135 
00136   /*************************************************************************/
00137   /*************************************************************************/
00138   /*****                                                               *****/
00139   /*****                         GDEF TABLE                            *****/
00140   /*****                                                               *****/
00141   /*************************************************************************/
00142   /*************************************************************************/
00143 
00144   /* sets valid->glyph_count */
00145 
00146   FT_LOCAL_DEF( void )
00147   otv_GDEF_validate( FT_Bytes      table,
00148                      FT_Bytes      gsub,
00149                      FT_Bytes      gpos,
00150                      FT_UInt       glyph_count,
00151                      FT_Validator  ftvalid )
00152   {
00153     OTV_ValidatorRec  validrec;
00154     OTV_Validator     valid = &validrec;
00155     FT_Bytes          p     = table;
00156     FT_UInt           table_size;
00157     FT_Bool           need_MarkAttachClassDef;
00158 
00159     OTV_OPTIONAL_TABLE( GlyphClassDef );
00160     OTV_OPTIONAL_TABLE( AttachListOffset );
00161     OTV_OPTIONAL_TABLE( LigCaretListOffset );
00162     OTV_OPTIONAL_TABLE( MarkAttachClassDef );
00163 
00164 
00165     valid->root = ftvalid;
00166 
00167     FT_TRACE3(( "validating GDEF table\n" ));
00168     OTV_INIT;
00169 
00170     OTV_LIMIT_CHECK( 12 );
00171 
00172     if ( FT_NEXT_ULONG( p ) != 0x10000UL )          /* Version */
00173       FT_INVALID_FORMAT;
00174 
00175     /* MarkAttachClassDef has been added to the OpenType */
00176     /* specification without increasing GDEF's version,  */
00177     /* so we use this ugly hack to find out whether the  */
00178     /* table is needed actually.                         */
00179 
00180     need_MarkAttachClassDef = FT_BOOL(
00181       otv_GSUBGPOS_have_MarkAttachmentType_flag( gsub ) ||
00182       otv_GSUBGPOS_have_MarkAttachmentType_flag( gpos ) );
00183 
00184     if ( need_MarkAttachClassDef )
00185       table_size = 12;              /* OpenType >= 1.2 */
00186     else
00187       table_size = 10;              /* OpenType < 1.2  */
00188 
00189     valid->glyph_count = glyph_count;
00190 
00191     OTV_OPTIONAL_OFFSET( GlyphClassDef );
00192     OTV_SIZE_CHECK( GlyphClassDef );
00193     if ( GlyphClassDef )
00194       otv_ClassDef_validate( table + GlyphClassDef, valid );
00195 
00196     OTV_OPTIONAL_OFFSET( AttachListOffset );
00197     OTV_SIZE_CHECK( AttachListOffset );
00198     if ( AttachListOffset )
00199     {
00200       OTV_NEST2( AttachList, AttachPoint );
00201       OTV_RUN( table + AttachListOffset, valid );
00202     }
00203 
00204     OTV_OPTIONAL_OFFSET( LigCaretListOffset );
00205     OTV_SIZE_CHECK( LigCaretListOffset );
00206     if ( LigCaretListOffset )
00207     {
00208       OTV_NEST3( LigCaretList, LigGlyph, CaretValue );
00209       OTV_RUN( table + LigCaretListOffset, valid );
00210     }
00211 
00212     if ( need_MarkAttachClassDef )
00213     {
00214       OTV_OPTIONAL_OFFSET( MarkAttachClassDef );
00215       OTV_SIZE_CHECK( MarkAttachClassDef );
00216       if ( MarkAttachClassDef )
00217         otv_ClassDef_validate( table + MarkAttachClassDef, valid );
00218     }
00219 
00220     FT_TRACE4(( "\n" ));
00221   }
00222 
00223 
00224 /* END */

Generated on Sat May 26 2012 04:32:45 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.