misc/libfreetype/src/otvalid/otvcommn.c
author sheepluva
Sun, 09 Sep 2012 20:58:45 +0200
changeset 7684 db140521d102
parent 5172 88f2e05288ba
permissions -rw-r--r--
recognize client-flags h and u, ROOM_CONTROL_ACCESS will be ignored from here on
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  otvcommn.c                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    OpenType common tables validation (body).                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2004, 2005, 2006, 2007 by                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include "otvcommn.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#define FT_COMPONENT  trace_otvcommon
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  /*****                       COVERAGE TABLE                          *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  otv_Coverage_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
                         OTV_Validator  valid,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
                         FT_Int         expected_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    FT_UInt   CoverageFormat;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    FT_UInt   total = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
    OTV_NAME_ENTER( "Coverage" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    OTV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
    CoverageFormat = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    OTV_TRACE(( " (format %d)\n", CoverageFormat ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    switch ( CoverageFormat )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    case 1:     /* CoverageFormat1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
        FT_UInt  GlyphCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
        FT_UInt  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
        GlyphCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
        OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
        OTV_LIMIT_CHECK( GlyphCount * 2 );        /* GlyphArray */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
        for ( i = 0; i < GlyphCount; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
          FT_UInt  gid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
          gid = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
          if ( gid >= valid->glyph_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
            FT_INVALID_GLYPH_ID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
        total = GlyphCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    case 2:     /* CoverageFormat2 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
        FT_UInt  n, RangeCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
        FT_UInt  Start, End, StartCoverageIndex, last = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
        RangeCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
        OTV_TRACE(( " (RangeCount = %d)\n", RangeCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
        OTV_LIMIT_CHECK( RangeCount * 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
        /* RangeRecord */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
        for ( n = 0; n < RangeCount; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
          Start              = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
          End                = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
          StartCoverageIndex = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
          if ( Start > End || StartCoverageIndex != total )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
            FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
          if ( End >= valid->glyph_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
            FT_INVALID_GLYPH_ID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
          if ( n > 0 && Start <= last )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
            FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
          total += End - Start + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
          last   = End;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
    /* Generally, a coverage table offset has an associated count field.  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    /* The number of glyphs in the table should match this field.  If     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    /* there is no associated count, a value of -1 tells us not to check. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    if ( expected_count != -1 && (FT_UInt)expected_count != total )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  FT_LOCAL_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
  otv_Coverage_get_first( FT_Bytes  table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    p += 4;     /* skip CoverageFormat and Glyph/RangeCount */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    return FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
  FT_LOCAL_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
  otv_Coverage_get_last( FT_Bytes  table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
    FT_UInt   CoverageFormat = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    FT_UInt   count          = FT_NEXT_USHORT( p );     /* Glyph/RangeCount */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    FT_UInt   result = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
    switch ( CoverageFormat )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
      p += ( count - 1 ) * 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      result = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
    case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
      p += ( count - 1 ) * 6 + 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      result = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
      ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
  FT_LOCAL_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
  otv_Coverage_get_count( FT_Bytes  table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    FT_Bytes  p              = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    FT_UInt   CoverageFormat = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    FT_UInt   count          = FT_NEXT_USHORT( p );     /* Glyph/RangeCount */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    FT_UInt   result         = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    switch ( CoverageFormat )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
    case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      return count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
    case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
        FT_UInt  Start, End;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
        for ( ; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
          Start = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
          End   = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
          p    += 2;                    /* skip StartCoverageIndex */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
          result += End - Start + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
      ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
  /*****                   CLASS DEFINITION TABLE                      *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
  otv_ClassDef_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
                         OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    FT_UInt   ClassFormat;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
    OTV_NAME_ENTER( "ClassDef" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    OTV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    ClassFormat = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    OTV_TRACE(( " (format %d)\n", ClassFormat ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
    switch ( ClassFormat )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
    case 1:     /* ClassDefFormat1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
        FT_UInt  StartGlyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
        FT_UInt  GlyphCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
        OTV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
        StartGlyph = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
        GlyphCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
        OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
        OTV_LIMIT_CHECK( GlyphCount * 2 );    /* ClassValueArray */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
        if ( StartGlyph + GlyphCount - 1 >= valid->glyph_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
          FT_INVALID_GLYPH_ID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    case 2:     /* ClassDefFormat2 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
        FT_UInt  n, ClassRangeCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
        FT_UInt  Start, End, last = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
        ClassRangeCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
        OTV_TRACE(( " (ClassRangeCount = %d)\n", ClassRangeCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
        OTV_LIMIT_CHECK( ClassRangeCount * 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
        /* ClassRangeRecord */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
        for ( n = 0; n < ClassRangeCount; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
          Start = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
          End   = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
          p    += 2;                        /* skip Class */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
          if ( Start > End || ( n > 0 && Start <= last ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
            FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
          if ( End >= valid->glyph_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
            FT_INVALID_GLYPH_ID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
          last = End;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
    /* no need to check glyph indices used as input to class definition   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    /* tables since even invalid glyph indices return a meaningful result */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
  /*****                      DEVICE TABLE                             *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
  otv_Device_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
                       OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
    FT_UInt   StartSize, EndSize, DeltaFormat, count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    OTV_NAME_ENTER( "Device" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
    OTV_LIMIT_CHECK( 8 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
    StartSize   = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    EndSize     = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
    DeltaFormat = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    if ( DeltaFormat < 1 || DeltaFormat > 3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    if ( EndSize < StartSize )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
    count = EndSize - StartSize + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    OTV_LIMIT_CHECK( ( 1 << DeltaFormat ) * count / 8 );  /* DeltaValue */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
  /*****                         LOOKUPS                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
  /* uses valid->type_count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
  /* uses valid->type_funcs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
  otv_Lookup_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
                       OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    FT_Bytes           p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    FT_UInt            LookupType, SubTableCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
    OTV_Validate_Func  validate;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
    OTV_NAME_ENTER( "Lookup" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
    OTV_LIMIT_CHECK( 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
    LookupType    = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
    p            += 2;                      /* skip LookupFlag */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    SubTableCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
    OTV_TRACE(( " (type %d)\n", LookupType ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
    if ( LookupType == 0 || LookupType > valid->type_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
    validate = valid->type_funcs[LookupType - 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
    OTV_TRACE(( " (SubTableCount = %d)\n", SubTableCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
    OTV_LIMIT_CHECK( SubTableCount * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    /* SubTable */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
    for ( ; SubTableCount > 0; SubTableCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
      validate( table + FT_NEXT_USHORT( p ), valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
  /* uses valid->lookup_count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
  otv_LookupList_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
                           OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
    FT_UInt   LookupCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
    OTV_NAME_ENTER( "LookupList" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
    OTV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
    LookupCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
    OTV_TRACE(( " (LookupCount = %d)\n", LookupCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    OTV_LIMIT_CHECK( LookupCount * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
    valid->lookup_count = LookupCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
    /* Lookup */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
    for ( ; LookupCount > 0; LookupCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
      otv_Lookup_validate( table + FT_NEXT_USHORT( p ), valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
  static FT_UInt
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
  otv_LookupList_get_count( FT_Bytes  table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
    return FT_NEXT_USHORT( table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
  /*****                        FEATURES                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
  /* uses valid->lookup_count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
  otv_Feature_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
                        OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
    FT_UInt   LookupCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
    OTV_NAME_ENTER( "Feature" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
    OTV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
    p           += 2;                   /* skip FeatureParams (unused) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
    LookupCount  = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
    OTV_TRACE(( " (LookupCount = %d)\n", LookupCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
    OTV_LIMIT_CHECK( LookupCount * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
    /* LookupListIndex */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
    for ( ; LookupCount > 0; LookupCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
      if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
  static FT_UInt
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
  otv_Feature_get_count( FT_Bytes  table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
    return FT_NEXT_USHORT( table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
  /* sets valid->lookup_count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
  otv_FeatureList_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
                            FT_Bytes       lookups,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
                            OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    FT_UInt   FeatureCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
    OTV_NAME_ENTER( "FeatureList" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
    OTV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
    FeatureCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
    OTV_TRACE(( " (FeatureCount = %d)\n", FeatureCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
    OTV_LIMIT_CHECK( FeatureCount * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
    valid->lookup_count = otv_LookupList_get_count( lookups );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
    /* FeatureRecord */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
    for ( ; FeatureCount > 0; FeatureCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
      p += 4;       /* skip FeatureTag */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
      /* Feature */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
      otv_Feature_validate( table + FT_NEXT_USHORT( p ), valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
  /*****                       LANGUAGE SYSTEM                         *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
  /* uses valid->extra1 (number of features) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
  otv_LangSys_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
                        OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
    FT_UInt   ReqFeatureIndex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
    FT_UInt   FeatureCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
    OTV_NAME_ENTER( "LangSys" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
    OTV_LIMIT_CHECK( 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
    p              += 2;                    /* skip LookupOrder (unused) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
    ReqFeatureIndex = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
    FeatureCount    = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
    OTV_TRACE(( " (ReqFeatureIndex = %d)\n", ReqFeatureIndex ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
    OTV_TRACE(( " (FeatureCount = %d)\n",    FeatureCount    ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
    if ( ReqFeatureIndex != 0xFFFFU && ReqFeatureIndex >= valid->extra1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
    OTV_LIMIT_CHECK( FeatureCount * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
    /* FeatureIndex */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
    for ( ; FeatureCount > 0; FeatureCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
      if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
  /*****                           SCRIPTS                             *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
  otv_Script_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
                       OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
    FT_UInt   DefaultLangSys, LangSysCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
    OTV_NAME_ENTER( "Script" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
    OTV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
    DefaultLangSys = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
    LangSysCount   = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
    OTV_TRACE(( " (LangSysCount = %d)\n", LangSysCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
    if ( DefaultLangSys != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
      otv_LangSys_validate( table + DefaultLangSys, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
    OTV_LIMIT_CHECK( LangSysCount * 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
    /* LangSysRecord */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
    for ( ; LangSysCount > 0; LangSysCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
      p += 4;       /* skip LangSysTag */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
      /* LangSys */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
      otv_LangSys_validate( table + FT_NEXT_USHORT( p ), valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
  /* sets valid->extra1 (number of features) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
  otv_ScriptList_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
                           FT_Bytes       features,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
                           OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
    FT_UInt   ScriptCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
    OTV_NAME_ENTER( "ScriptList" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
    OTV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
    ScriptCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
    OTV_TRACE(( " (ScriptCount = %d)\n", ScriptCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
    OTV_LIMIT_CHECK( ScriptCount * 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
    valid->extra1 = otv_Feature_get_count( features );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
    /* ScriptRecord */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
    for ( ; ScriptCount > 0; ScriptCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
      p += 4;       /* skip ScriptTag */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
      otv_Script_validate( table + FT_NEXT_USHORT( p ), valid ); /* Script */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
  /*****                      UTILITY FUNCTIONS                        *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
     u:   uint16
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
     ux:  unit16 [x]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
     s:   struct
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
     sx:  struct [x]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
     sxy: struct [x], using external y count
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
     x:   uint16 x
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
     C:   Coverage
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
     O:   Offset
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
     On:  Offset (NULL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
     Ox:  Offset [x]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
     Onx: Offset (NULL) [x]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
  otv_x_Ox( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
            OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
    FT_Bytes           p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
    FT_UInt            Count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
    OTV_Validate_Func  func;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
    OTV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
    Count = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
    OTV_TRACE(( " (Count = %d)\n", Count ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
    OTV_LIMIT_CHECK( Count * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
    valid->nesting_level++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
    func = valid->func[valid->nesting_level];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
    for ( ; Count > 0; Count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
      func( table + FT_NEXT_USHORT( p ), valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
    valid->nesting_level--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
  otv_u_C_x_Ox( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
                OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
    FT_Bytes           p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
    FT_UInt            Count, Coverage;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
    OTV_Validate_Func  func;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
    p += 2;     /* skip Format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
    OTV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
    Coverage = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
    Count    = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
    OTV_TRACE(( " (Count = %d)\n", Count ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
    otv_Coverage_validate( table + Coverage, valid, Count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
    OTV_LIMIT_CHECK( Count * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
    valid->nesting_level++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
    func = valid->func[valid->nesting_level];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
    for ( ; Count > 0; Count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
      func( table + FT_NEXT_USHORT( p ), valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
    valid->nesting_level--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
  /* uses valid->extra1 (if > 0: array value limit) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
  otv_x_ux( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
            OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
    FT_UInt   Count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
    OTV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
    Count = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
    OTV_TRACE(( " (Count = %d)\n", Count ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
    OTV_LIMIT_CHECK( Count * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
    if ( valid->extra1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
      for ( ; Count > 0; Count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
        if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
          FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
  /* `ux' in the function's name is not really correct since only x-1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
  /* elements are tested                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
  /* uses valid->extra1 (array value limit) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
  otv_x_y_ux_sy( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
                 OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
    FT_UInt   Count1, Count2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
    OTV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
    Count1 = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
    Count2 = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
    OTV_TRACE(( " (Count1 = %d)\n", Count1 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
    OTV_TRACE(( " (Count2 = %d)\n", Count2 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
    if ( Count1 == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
    OTV_LIMIT_CHECK( ( Count1 - 1 ) * 2 + Count2 * 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
    p += ( Count1 - 1 ) * 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
    for ( ; Count2 > 0; Count2-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
      if ( FT_NEXT_USHORT( p ) >= Count1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
      if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
  /* `uy' in the function's name is not really correct since only y-1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
  /* elements are tested                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
  /* uses valid->extra1 (array value limit) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
  otv_x_ux_y_uy_z_uz_p_sp( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
                           OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
    FT_UInt   BacktrackCount, InputCount, LookaheadCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
    FT_UInt   Count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
    OTV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
    BacktrackCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
    OTV_TRACE(( " (BacktrackCount = %d)\n", BacktrackCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
    OTV_LIMIT_CHECK( BacktrackCount * 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
    p += BacktrackCount * 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
    InputCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
    if ( InputCount == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
    OTV_TRACE(( " (InputCount = %d)\n", InputCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
    OTV_LIMIT_CHECK( InputCount * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
    p += ( InputCount - 1 ) * 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
    LookaheadCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
    OTV_TRACE(( " (LookaheadCount = %d)\n", LookaheadCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
    OTV_LIMIT_CHECK( LookaheadCount * 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
    p += LookaheadCount * 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
    Count = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
    OTV_TRACE(( " (Count = %d)\n", Count ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
    OTV_LIMIT_CHECK( Count * 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
    for ( ; Count > 0; Count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
      if ( FT_NEXT_USHORT( p ) >= InputCount )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
      if ( FT_NEXT_USHORT( p ) >= valid->extra1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
  /* sets valid->extra1 (valid->lookup_count) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
  otv_u_O_O_x_Onx( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
                   OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
    FT_Bytes           p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
    FT_UInt            Coverage, ClassDef, ClassSetCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
    OTV_Validate_Func  func;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
    p += 2;     /* skip Format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
    OTV_LIMIT_CHECK( 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
    Coverage      = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
    ClassDef      = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
    ClassSetCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
    OTV_TRACE(( " (ClassSetCount = %d)\n", ClassSetCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
    otv_Coverage_validate( table + Coverage, valid, -1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
    otv_ClassDef_validate( table + ClassDef, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
    OTV_LIMIT_CHECK( ClassSetCount * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
    valid->nesting_level++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
    func          = valid->func[valid->nesting_level];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
    valid->extra1 = valid->lookup_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
    for ( ; ClassSetCount > 0; ClassSetCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
      FT_UInt  offset = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
      if ( offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
        func( table + offset, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
    valid->nesting_level--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
  /* uses valid->lookup_count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
  otv_u_x_y_Ox_sy( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
                   OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
    FT_UInt   GlyphCount, Count, count1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
    p += 2;     /* skip Format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
    OTV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
    GlyphCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
    Count      = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
    OTV_TRACE(( " (GlyphCount = %d)\n", GlyphCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
    OTV_TRACE(( " (Count = %d)\n",      Count      ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
    OTV_LIMIT_CHECK( GlyphCount * 2 + Count * 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
    for ( count1 = GlyphCount; count1 > 0; count1-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
    for ( ; Count > 0; Count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
      if ( FT_NEXT_USHORT( p ) >= GlyphCount )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
      if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
  /* sets valid->extra1 (valid->lookup_count)    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
  otv_u_O_O_O_O_x_Onx( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
                       OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
    FT_Bytes           p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
    FT_UInt            Coverage;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
    FT_UInt            BacktrackClassDef, InputClassDef, LookaheadClassDef;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
    FT_UInt            ChainClassSetCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
    OTV_Validate_Func  func;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
    p += 2;     /* skip Format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
    OTV_LIMIT_CHECK( 10 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   939
    Coverage           = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   940
    BacktrackClassDef  = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
    InputClassDef      = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
    LookaheadClassDef  = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
    ChainClassSetCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
    OTV_TRACE(( " (ChainClassSetCount = %d)\n", ChainClassSetCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
    otv_Coverage_validate( table + Coverage, valid, -1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
    otv_ClassDef_validate( table + BacktrackClassDef,  valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
    otv_ClassDef_validate( table + InputClassDef, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
    otv_ClassDef_validate( table + LookaheadClassDef, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
    OTV_LIMIT_CHECK( ChainClassSetCount * 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
    valid->nesting_level++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
    func          = valid->func[valid->nesting_level];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
    valid->extra1 = valid->lookup_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
    for ( ; ChainClassSetCount > 0; ChainClassSetCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
      FT_UInt  offset = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
      if ( offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
        func( table + offset, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
    valid->nesting_level--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
  /* uses valid->lookup_count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
  otv_u_x_Ox_y_Oy_z_Oz_p_sp( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
                             OTV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
    FT_UInt   BacktrackGlyphCount, InputGlyphCount, LookaheadGlyphCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
    FT_UInt   count1, count2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
    OTV_ENTER;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
    p += 2;     /* skip Format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
    OTV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
    BacktrackGlyphCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
    OTV_TRACE(( " (BacktrackGlyphCount = %d)\n", BacktrackGlyphCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
    OTV_LIMIT_CHECK( BacktrackGlyphCount * 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
    for ( ; BacktrackGlyphCount > 0; BacktrackGlyphCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
    InputGlyphCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
    OTV_TRACE(( " (InputGlyphCount = %d)\n", InputGlyphCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
    OTV_LIMIT_CHECK( InputGlyphCount * 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
    for ( count1 = InputGlyphCount; count1 > 0; count1-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
    LookaheadGlyphCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
    OTV_TRACE(( " (LookaheadGlyphCount = %d)\n", LookaheadGlyphCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
    OTV_LIMIT_CHECK( LookaheadGlyphCount * 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
    for ( ; LookaheadGlyphCount > 0; LookaheadGlyphCount-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
      otv_Coverage_validate( table + FT_NEXT_USHORT( p ), valid, -1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
    count2 = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
    OTV_TRACE(( " (Count = %d)\n", count2 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
    OTV_LIMIT_CHECK( count2 * 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
    for ( ; count2 > 0; count2-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
      if ( FT_NEXT_USHORT( p ) >= InputGlyphCount )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
      if ( FT_NEXT_USHORT( p ) >= valid->lookup_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
    OTV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
  FT_LOCAL_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
  otv_GSUBGPOS_get_Lookup_count( FT_Bytes  table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
    FT_Bytes  p = table + 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
    return otv_LookupList_get_count( table + FT_NEXT_USHORT( p ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
  FT_LOCAL_DEF( FT_UInt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
  otv_GSUBGPOS_have_MarkAttachmentType_flag( FT_Bytes  table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
    FT_Bytes  p, lookup;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
    FT_UInt   count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
    if ( !table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
    /* LookupList */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
    p      = table + 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
    table += FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
    /* LookupCount */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
    p     = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
    count = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
    for ( ; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
      FT_Bytes  oldp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
      /* Lookup */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
      lookup = table + FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
      oldp = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
      /* LookupFlag */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
      p = lookup + 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
      if ( FT_NEXT_USHORT( p ) & 0xFF00U )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
        return 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
      p = oldp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
/* END */