misc/libfreetype/src/gxvalid/gxvmort.c
author koda
Mon, 25 Apr 2011 01:46:54 +0200
changeset 5172 88f2e05288ba
permissions -rw-r--r--
aaand let's add freetype as well while we are at it other smaller changes
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
/*  gxvmort.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 mort 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 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 "gxvmort.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "gxvfeat.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_gxvmort
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  gxv_mort_feature_validate( GXV_mort_feature  f,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
                             GXV_Validator     valid )
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
    if ( f->featureType >= gxv_feat_registry_length )
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
      GXV_TRACE(( "featureType %d is out of registered range, "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
                  "setting %d is unchecked\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
                  f->featureType, f->featureSetting ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
      if ( valid->root->level >= FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
    else if ( !gxv_feat_registry[f->featureType].existence )
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
      GXV_TRACE(( "featureType %d is within registered area "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
                  "but undefined, setting %d is unchecked\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
                  f->featureType, f->featureSetting ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
      if ( valid->root->level >= FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
        FT_INVALID_DATA;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
      FT_Byte  nSettings_max;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
      /* nSettings in gxvfeat.c is halved for exclusive on/off settings */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
      nSettings_max = gxv_feat_registry[f->featureType].nSettings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
      if ( gxv_feat_registry[f->featureType].exclusive )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
        nSettings_max = (FT_Byte)( 2 * nSettings_max );
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
      GXV_TRACE(( "featureType %d is registered", f->featureType ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
      GXV_TRACE(( "setting %d", f->featureSetting ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      if ( f->featureSetting > nSettings_max )
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
        GXV_TRACE(( "out of defined range %d", nSettings_max ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
        if ( valid->root->level >= FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
          FT_INVALID_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
      GXV_TRACE(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    }
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
    /* TODO: enableFlags must be unique value in specified chain?  */
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
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
   * nFeatureFlags is typed to FT_ULong to accept that in
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
   * mort (typed FT_UShort) and morx (typed FT_ULong).
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  gxv_mort_featurearray_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
                                  FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
                                  FT_ULong       nFeatureFlags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
                                  GXV_Validator  valid )
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
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    FT_ULong  i;
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
    GXV_mort_featureRec  f = GXV_MORT_FEATURE_OFF;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    GXV_NAME_ENTER( "mort feature list" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    for ( i = 0; i < nFeatureFlags; i++ )
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_LIMIT_CHECK( 2 + 2 + 4 + 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
      f.featureType    = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
      f.featureSetting = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
      f.enableFlags    = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
      f.disableFlags   = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
      gxv_mort_feature_validate( &f, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    if ( !IS_GXV_MORT_FEATURE_OFF( f ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
      FT_INVALID_DATA;
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
    valid->subtable_length = p - table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  }
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  gxv_mort_coverage_validate( FT_UShort      coverage,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
                              GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    FT_UNUSED( valid );
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
    if ( coverage & 0x8000U )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
      GXV_TRACE(( " this subtable is for vertical text only\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
      GXV_TRACE(( " this subtable is for horizontal text only\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    if ( coverage & 0x4000 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
      GXV_TRACE(( " this subtable is applied to glyph array "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
                  "in descending order\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
      GXV_TRACE(( " this subtable is applied to glyph array "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
                  "in ascending order\n" ));
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
    if ( coverage & 0x2000 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
      GXV_TRACE(( " this subtable is forcibly applied to "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
                  "vertical/horizontal text\n" ));
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
    if ( coverage & 0x1FF8 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      GXV_TRACE(( " coverage has non-zero bits in reserved area\n" ));
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
  gxv_mort_subtables_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
                               FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
                               FT_UShort      nSubtables,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
                               GXV_Validator  valid )
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
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    GXV_Validate_Func fmt_funcs_table[] =
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
      gxv_mort_subtable_type0_validate, /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      gxv_mort_subtable_type1_validate, /* 1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
      gxv_mort_subtable_type2_validate, /* 2 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      NULL,                             /* 3 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
      gxv_mort_subtable_type4_validate, /* 4 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
      gxv_mort_subtable_type5_validate, /* 5 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
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
    GXV_Validate_Func  func;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    FT_UShort          i;
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
    GXV_NAME_ENTER( "subtables in a chain" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    for ( i = 0; i < nSubtables; i++ )
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_UShort  length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
      FT_UShort  coverage;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
      FT_ULong   subFeatureFlags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      FT_UInt    type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
      FT_UInt    rest;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
      GXV_LIMIT_CHECK( 2 + 2 + 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
      length          = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      coverage        = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
      subFeatureFlags = FT_NEXT_ULONG( p );
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
      GXV_TRACE(( "validating chain subtable %d/%d (%d bytes)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
                  i + 1, nSubtables, length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
      type = coverage & 0x0007;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
      rest = length - ( 2 + 2 + 4 );
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
      GXV_LIMIT_CHECK( rest );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
      gxv_mort_coverage_validate( coverage, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
      if ( type > 5 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
        FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
      func = fmt_funcs_table[type];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
      if ( func == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
        GXV_TRACE(( "morx type %d is reserved\n", type ));
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
      func( p, p + rest, valid );
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
      p += rest;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    valid->subtable_length = p - table;
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
    GXV_EXIT;
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
  gxv_mort_chain_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
                           FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
                           GXV_Validator  valid )
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_Bytes   p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    FT_ULong   defaultFlags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
    FT_ULong   chainLength;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    FT_UShort  nFeatureFlags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    FT_UShort  nSubtables;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
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
    GXV_NAME_ENTER( "mort chain header" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    GXV_LIMIT_CHECK( 4 + 4 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    defaultFlags  = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    chainLength   = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    nFeatureFlags = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    nSubtables    = 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_mort_featurearray_validate( p, table + chainLength,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
                                    nFeatureFlags, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
    p += valid->subtable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
    gxv_mort_subtables_validate( p, table + chainLength, nSubtables, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    valid->subtable_length = chainLength;
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
    GXV_EXIT;
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
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
  gxv_mort_validate( FT_Bytes      table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
                     FT_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
                     FT_Validator  ftvalid )
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
    GXV_ValidatorRec  validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    GXV_Validator     valid = &validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    FT_Bytes          p     = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    FT_Bytes          limit = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    FT_ULong          version;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
    FT_ULong          nChains;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
    FT_ULong          i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
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
    valid->root = ftvalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    valid->face = face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    limit       = valid->root->limit;
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
    FT_TRACE3(( "validating `mort' table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
    GXV_INIT;
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_LIMIT_CHECK( 4 + 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
    version = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
    nChains = FT_NEXT_ULONG( p );
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
    if (version != 0x00010000UL)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
      FT_INVALID_FORMAT;
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
    for ( i = 0; i < nChains; i++ )
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
      GXV_TRACE(( "validating chain %d/%d\n", i + 1, nChains ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
      GXV_32BIT_ALIGNMENT_VALIDATE( p - table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
      gxv_mort_chain_validate( p, limit, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
      p += valid->subtable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
    FT_TRACE4(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
  }
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
/* END */