misc/libfreetype/src/gxvalid/gxvtrak.c
author koda
Sat, 06 Aug 2011 07:09:30 +0200
changeset 5505 a55aab592950
parent 5172 88f2e05288ba
permissions -rw-r--r--
Ditch the renderer system in sdl1.3 and use the 'old fashioned' sdl/opengl context. This gives us more flexibility and less problem in receiving video events (expecially on mobile platform) as well as not having to care to reset the gl context every time sdl interferes. This is a major sdl1.3 update so it should be tested with care (working great on ios)
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
/*  gxvtrak.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
/*    TrueTypeGX/AAT trak table 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 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
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
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
/* gxvalid is derived from both gxlayout module and otvalid module.        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
/* Development of gxlayout is supported by the Information-technology      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
/* Promotion Agency(IPA), Japan.                                           */
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
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include "gxvalid.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "gxvcommn.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
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
  /* 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
    34
  /* 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
    35
  /* messages during execution.                                            */
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
#define FT_COMPONENT  trace_gxvtrak
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /*****                      Data and Types                           *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  /*************************************************************************/
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
     * referred track table format specification:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
     * http://developer.apple.com/fonts/TTRefMan/RM06/Chap6trak.html
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
     * last update was 1996.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
     * ----------------------------------------------
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
     * [MINIMUM HEADER]: GXV_TRAK_SIZE_MIN
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
     * version          (fixed:  32bit) = 0x00010000
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
     * format           (uint16: 16bit) = 0 is only defined (1996)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
     * horizOffset      (uint16: 16bit)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
     * vertOffset       (uint16: 16bit)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
     * reserved         (uint16: 16bit) = 0
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
     * [VARIABLE BODY]:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
     * horizData
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
     *   header         ( 2 + 2 + 4
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
     *   trackTable       + nTracks * ( 4 + 2 + 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
     *   sizeTable        + nSizes * 4 )
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
     * vertData
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
     *   header         ( 2 + 2 + 4
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
     *   trackTable       + nTracks * ( 4 + 2 + 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
     *   sizeTable        + nSizes * 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
     * ----------------------------------------------
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
  typedef struct  GXV_trak_DataRec_
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
    FT_UShort  trackValueOffset_min;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    FT_UShort  trackValueOffset_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  } GXV_trak_DataRec, *GXV_trak_Data;
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
#define GXV_TRAK_DATA( FIELD )  GXV_TABLE_DATA( trak, FIELD )
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
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
  /*************************************************************************/
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
  /*****                      UTILITY FUNCTIONS                        *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
  /*****                                                               *****/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
  gxv_trak_trackTable_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
                                FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
                                FT_UShort      nTracks,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
                                GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    FT_Bytes   p = table;
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
    FT_Fixed   track;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    FT_UShort  nameIndex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    FT_UShort  offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    FT_UShort  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    GXV_NAME_ENTER( "trackTable" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    GXV_TRAK_DATA( trackValueOffset_min ) = 0xFFFFU;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    GXV_TRAK_DATA( trackValueOffset_max ) = 0x0000;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    for ( i = 0; i < nTracks; i ++ )
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
      GXV_LIMIT_CHECK( 4 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
      track     = FT_NEXT_LONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
      nameIndex = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
      offset    = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
      if ( offset < GXV_TRAK_DATA( trackValueOffset_min ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
        GXV_TRAK_DATA( trackValueOffset_min ) = offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
      if ( offset > GXV_TRAK_DATA( trackValueOffset_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
        GXV_TRAK_DATA( trackValueOffset_max ) = offset;
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
      gxv_sfntName_validate( nameIndex, 256, 32767, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    valid->subtable_length = p - table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    GXV_EXIT;
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
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  gxv_trak_trackData_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
                               FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
                               GXV_Validator  valid )
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
    FT_UShort  nTracks;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    FT_UShort  nSizes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    FT_ULong   sizeTableOffset;
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
    GXV_ODTECT( 4, odtect );
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
    GXV_ODTECT_INIT( odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    GXV_NAME_ENTER( "trackData" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    /* read the header of trackData */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    GXV_LIMIT_CHECK( 2 + 2 + 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
    nTracks         = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    nSizes          = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    sizeTableOffset = FT_NEXT_ULONG( p );
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
    gxv_odtect_add_range( table, p - table, "trackData header", odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
    /* validate trackTable */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    gxv_trak_trackTable_validate( p, limit, nTracks, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    gxv_odtect_add_range( p, valid->subtable_length,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
                          "trackTable", odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    /* sizeTable is array of FT_Fixed, don't check contents */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
    p = valid->root->base + sizeTableOffset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    GXV_LIMIT_CHECK( nSizes * 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    gxv_odtect_add_range( p, nSizes * 4, "sizeTable", odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    /* validate trackValueOffet */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    p = valid->root->base + GXV_TRAK_DATA( trackValueOffset_min );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    if ( limit - p < nTracks * nSizes * 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
      GXV_TRACE(( "too short trackValue array\n" ));
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
    p = valid->root->base + GXV_TRAK_DATA( trackValueOffset_max );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    GXV_LIMIT_CHECK( nSizes * 2 );
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
    gxv_odtect_add_range( valid->root->base
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
                            + GXV_TRAK_DATA( trackValueOffset_min ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
                          GXV_TRAK_DATA( trackValueOffset_max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
                            - GXV_TRAK_DATA( trackValueOffset_min )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
                            + nSizes * 2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
                          "trackValue array", odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    gxv_odtect_validate( odtect, valid );
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
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
  /*************************************************************************/
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
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
  /*****                          trak TABLE                           *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  /*****                                                               *****/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
  gxv_trak_validate( FT_Bytes      table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
                     FT_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
                     FT_Validator  ftvalid )
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
    FT_Bytes          p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    FT_Bytes          limit = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    FT_Offset         table_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    GXV_ValidatorRec  validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    GXV_Validator     valid = &validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    GXV_trak_DataRec  trakrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    GXV_trak_Data     trak = &trakrec;
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
    FT_ULong   version;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    FT_UShort  format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    FT_UShort  horizOffset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    FT_UShort  vertOffset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
    FT_UShort  reserved;
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
    GXV_ODTECT( 3, odtect );
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
    GXV_ODTECT_INIT( odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    valid->root       = ftvalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    valid->table_data = trak;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    valid->face       = face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
    limit      = valid->root->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    table_size = limit - table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    FT_TRACE3(( "validating `trak' table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    GXV_INIT;
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
    GXV_LIMIT_CHECK( 4 + 2 + 2 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    version     = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    format      = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    horizOffset = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    vertOffset  = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    reserved    = FT_NEXT_USHORT( p );
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
    GXV_TRACE(( " (version = 0x%08x)\n", version ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
    GXV_TRACE(( " (format = 0x%04x)\n", format ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
    GXV_TRACE(( " (horizOffset = 0x%04x)\n", horizOffset ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
    GXV_TRACE(( " (vertOffset = 0x%04x)\n", vertOffset ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    GXV_TRACE(( " (reserved = 0x%04x)\n", reserved ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    /* Version 1.0 (always:1996) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    if ( version != 0x00010000UL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
      FT_INVALID_FORMAT;
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
    /* format 0 (always:1996) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    if ( format != 0x0000 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    GXV_32BIT_ALIGNMENT_VALIDATE( horizOffset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    GXV_32BIT_ALIGNMENT_VALIDATE( vertOffset );
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
    /* Reserved Fixed Value (always) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    if ( reserved != 0x0000 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
    /* validate trackData */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    if ( 0 < horizOffset )
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
      gxv_trak_trackData_validate( table + horizOffset, limit, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
      gxv_odtect_add_range( table + horizOffset, valid->subtable_length,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
                            "horizJustData", odtect );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
    if ( 0 < vertOffset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
      gxv_trak_trackData_validate( table + vertOffset, limit, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
      gxv_odtect_add_range( table + vertOffset, valid->subtable_length,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
                            "vertJustData", odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    gxv_odtect_validate( odtect, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
    FT_TRACE4(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
/* END */