misc/libfreetype/src/gxvalid/gxvfeat.c
author koda
Sat, 24 Sep 2011 21:54:11 +0200
changeset 6017 24631fd2fb9e
parent 5172 88f2e05288ba
permissions -rw-r--r--
better memory cleanup for audiomanager and position of lower stats button
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
/*  gxvfeat.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 feat 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, 2008 by                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  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
     9
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  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
    12
/*  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
    13
/*  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
    14
/*  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
    15
/*  understand and accept it fully.                                        */
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
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
/* 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
    22
/* 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
    23
/* Promotion Agency(IPA), Japan.                                           */
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "gxvalid.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#include "gxvcommn.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
#include "gxvfeat.h"
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
  /* 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
    36
  /* 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
    37
  /* messages during execution.                                            */
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
#define FT_COMPONENT  trace_gxvfeat
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
  /*************************************************************************/
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
  /*****                      Data and Types                           *****/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
  typedef struct  GXV_feat_DataRec_
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
    FT_UInt    reserved_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    FT_UShort  feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    FT_UShort  setting;
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
  } GXV_feat_DataRec, *GXV_feat_Data;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
#define GXV_FEAT_DATA( field )  GXV_TABLE_DATA( feat, field )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
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
  typedef enum  GXV_FeatureFlagsMask_
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
    GXV_FEAT_MASK_EXCLUSIVE_SETTINGS = 0x8000U,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    GXV_FEAT_MASK_DYNAMIC_DEFAULT    = 0x4000,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    GXV_FEAT_MASK_UNUSED             = 0x3F00,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
    GXV_FEAT_MASK_DEFAULT_SETTING    = 0x00FF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
  } GXV_FeatureFlagsMask;
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
  /*************************************************************************/
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
  /*****                      UTILITY FUNCTIONS                        *****/
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
  /*************************************************************************/
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
  gxv_feat_registry_validate( FT_UShort      feature,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
                              FT_UShort      nSettings,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
                              FT_Bool        exclusive,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
                              GXV_Validator  valid )
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
    GXV_NAME_ENTER( "feature in registry" );
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
    GXV_TRACE(( " (feature = %u)\n", feature ));
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
    if ( feature >= gxv_feat_registry_length )
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
      GXV_TRACE(( "feature number %d is out of range %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
                  feature, gxv_feat_registry_length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
      if ( valid->root->level == FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    }
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
    if ( gxv_feat_registry[feature].existence == 0 )
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
      GXV_TRACE(( "feature number %d is in defined range but doesn't exist\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
                  feature ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
      if ( valid->root->level == FT_VALIDATE_PARANOID )
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
      goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    if ( gxv_feat_registry[feature].apple_reserved )
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
      /* Don't use here. Apple is reserved. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
      GXV_TRACE(( "feature number %d is reserved by Apple\n", feature ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
      if ( valid->root->level >= FT_VALIDATE_TIGHT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
        FT_INVALID_DATA;
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
    if ( nSettings != gxv_feat_registry[feature].nSettings )
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
      GXV_TRACE(( "feature %d: nSettings %d != defined nSettings %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
                  feature, nSettings,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
                  gxv_feat_registry[feature].nSettings ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
      if ( valid->root->level >= FT_VALIDATE_TIGHT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
        FT_INVALID_DATA;
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
    if ( exclusive != gxv_feat_registry[feature].exclusive )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
      GXV_TRACE(( "exclusive flag %d differs from predefined value\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
                  exclusive ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
      if ( valid->root->level >= FT_VALIDATE_TIGHT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
        FT_INVALID_DATA;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  }
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
  gxv_feat_name_index_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
                                FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
                                GXV_Validator  valid )
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
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    FT_Short  nameIndex;
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
    GXV_NAME_ENTER( "nameIndex" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    GXV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
    nameIndex = FT_NEXT_SHORT ( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    GXV_TRACE(( " (nameIndex = %d)\n", nameIndex ));
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
    gxv_sfntName_validate( (FT_UShort)nameIndex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
                           255,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
                           32768U,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
                           valid );
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_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
  gxv_feat_setting_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
                             FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
                             FT_Bool        exclusive,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
                             GXV_Validator  valid )
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
    FT_Bytes   p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    FT_UShort  setting;
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
    GXV_NAME_ENTER( "setting" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    GXV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    setting = FT_NEXT_USHORT( p );
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
    /* If we have exclusive setting, the setting should be odd. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    if ( exclusive && ( setting % 2 ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
      FT_INVALID_DATA;
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_feat_name_index_validate( p, limit, valid );
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
    GXV_FEAT_DATA( setting ) = setting;
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
    GXV_EXIT;
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
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
  gxv_feat_name_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
                          FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
                          GXV_Validator  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
    FT_Bytes   p             = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    FT_UInt    reserved_size = GXV_FEAT_DATA( reserved_size );
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
    FT_UShort  feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    FT_UShort  nSettings;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    FT_ULong   settingTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    FT_UShort  featureFlags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    FT_Bool    exclusive;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    FT_Int     last_setting;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    FT_UInt    i;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    GXV_NAME_ENTER( "name" );
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
    /* feature + nSettings + settingTable + featureFlags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    GXV_LIMIT_CHECK( 2 + 2 + 4 + 2 );
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
    feature = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    GXV_FEAT_DATA( feature ) = feature;
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
    nSettings    = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    settingTable = FT_NEXT_ULONG ( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    featureFlags = FT_NEXT_USHORT( p );
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
    if ( settingTable < reserved_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
      FT_INVALID_OFFSET;
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
    if ( valid->root->level == FT_VALIDATE_PARANOID   &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
         ( featureFlags & GXV_FEAT_MASK_UNUSED ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
      FT_INVALID_DATA;
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
    exclusive = FT_BOOL( featureFlags & GXV_FEAT_MASK_EXCLUSIVE_SETTINGS );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    if ( exclusive )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
      FT_Byte  dynamic_default;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
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
      if ( featureFlags & GXV_FEAT_MASK_DYNAMIC_DEFAULT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
        dynamic_default = (FT_Byte)( featureFlags &
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
                                     GXV_FEAT_MASK_DEFAULT_SETTING );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
        dynamic_default = 0;
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
      /* If exclusive, check whether default setting is in the range. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
      if ( !( dynamic_default < nSettings ) )
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    gxv_feat_registry_validate( feature, nSettings, exclusive, valid );
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
    gxv_feat_name_index_validate( p, limit, valid );
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
    p = valid->root->base + settingTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    for ( last_setting = -1, i = 0; i < nSettings; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
      gxv_feat_setting_validate( p, limit, exclusive, valid );
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
      if ( valid->root->level == FT_VALIDATE_PARANOID       &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
           (FT_Int)GXV_FEAT_DATA( setting ) <= last_setting )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
        FT_INVALID_FORMAT;
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
      last_setting = (FT_Int)GXV_FEAT_DATA( setting );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
      /* setting + nameIndex */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
      p += ( 2 + 2 );
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
    GXV_EXIT;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
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
  /*************************************************************************/
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
  /*****                         feat TABLE                            *****/
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
  /*************************************************************************/
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
  gxv_feat_validate( FT_Bytes      table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
                     FT_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
                     FT_Validator  ftvalid )
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
    GXV_ValidatorRec  validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
    GXV_Validator     valid = &validrec;
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
    GXV_feat_DataRec  featrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    GXV_feat_Data     feat = &featrec;
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
    FT_Bytes          p     = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
    FT_Bytes          limit = 0;
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
    FT_UInt           featureNameCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    FT_UInt           i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    FT_Int            last_feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
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
    valid->root       = ftvalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
    valid->table_data = feat;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
    valid->face       = face;
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
    FT_TRACE3(( "validating `feat' table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
    GXV_INIT;
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
    feat->reserved_size = 0;
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
    /* version + featureNameCount + none_0 + none_1  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    GXV_LIMIT_CHECK( 4 + 2 + 2 + 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    feat->reserved_size += 4 + 2 + 2 + 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
    if ( FT_NEXT_ULONG( p ) != 0x00010000UL ) /* Version */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    featureNameCount = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
    GXV_TRACE(( " (featureNameCount = %d)\n", featureNameCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
    if ( valid->root->level != FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
      p += 6;                   /* skip (none) and (none) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
      if ( FT_NEXT_USHORT( p ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
      if ( FT_NEXT_ULONG( p )  != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
    feat->reserved_size += featureNameCount * ( 2 + 2 + 4 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    for ( last_feature = -1, i = 0; i < featureNameCount; i++ )
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
      gxv_feat_name_validate( p, limit, valid );
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
      if ( valid->root->level == FT_VALIDATE_PARANOID       &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
           (FT_Int)GXV_FEAT_DATA( feature ) <= last_feature )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
        FT_INVALID_FORMAT;
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
      last_feature = GXV_FEAT_DATA( feature );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
      p += 2 + 2 + 4 + 2 + 2;
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
    FT_TRACE4(( "\n" ));
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
/* END */