misc/libfreetype/src/gxvalid/gxvkern.c
author Medo <smaxein@googlemail.com>
Sat, 31 Mar 2012 20:36:03 +0200
changeset 6840 c61f842621b8
parent 5172 88f2e05288ba
permissions -rw-r--r--
Added hashcode function for Team to make it consistent with equals.
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
/*  gxvkern.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 kern 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, 2006, 2007                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  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
     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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
#include FT_SFNT_NAMES_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
#include FT_SERVICE_GX_VALIDATE_H
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
  /*************************************************************************/
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
  /* 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
    38
  /* 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
    39
  /* messages during execution.                                            */
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
#define FT_COMPONENT  trace_gxvkern
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
  /*************************************************************************/
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
  /*****                      Data and Types                           *****/
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
  /*************************************************************************/
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
  typedef enum  GXV_kern_Version_
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
    KERN_VERSION_CLASSIC = 0x0000,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    KERN_VERSION_NEW     = 0x0001
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  } GXV_kern_Version;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
  typedef enum GXV_kern_Dialect_
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
    KERN_DIALECT_UNKNOWN = 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    KERN_DIALECT_MS      = FT_VALIDATE_MS,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    KERN_DIALECT_APPLE   = FT_VALIDATE_APPLE,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    KERN_DIALECT_ANY     = FT_VALIDATE_CKERN
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
  } GXV_kern_Dialect;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
  typedef struct  GXV_kern_DataRec_
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
    GXV_kern_Version  version;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
    void             *subtable_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
    GXV_kern_Dialect  dialect_request;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
  } GXV_kern_DataRec, *GXV_kern_Data;
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
#define GXV_KERN_DATA( field )  GXV_TABLE_DATA( kern, field )
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
#define KERN_IS_CLASSIC( valid )                               \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
          ( KERN_VERSION_CLASSIC == GXV_KERN_DATA( version ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
#define KERN_IS_NEW( valid )                                   \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
          ( KERN_VERSION_NEW     == GXV_KERN_DATA( version ) )
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
#define KERN_DIALECT( valid )              \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
          GXV_KERN_DATA( dialect_request )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
#define KERN_ALLOWS_MS( valid )                       \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
          ( KERN_DIALECT( valid ) & KERN_DIALECT_MS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
#define KERN_ALLOWS_APPLE( valid )                       \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
          ( KERN_DIALECT( valid ) & KERN_DIALECT_APPLE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
#define GXV_KERN_HEADER_SIZE           ( KERN_IS_NEW( valid ) ? 8 : 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
#define GXV_KERN_SUBTABLE_HEADER_SIZE  ( KERN_IS_NEW( valid ) ? 8 : 6 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
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
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  /*****                      SUBTABLE VALIDATORS                      *****/
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
  /*************************************************************************/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
  /* ============================= format 0 ============================== */
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  gxv_kern_subtable_fmt0_pairs_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
                                         FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
                                         FT_UShort      nPairs,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
                                         GXV_Validator  valid )
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
    FT_Bytes   p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    FT_UShort  i;
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
    FT_UShort  last_gid_left  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
    FT_UShort  last_gid_right = 0;
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
    FT_UNUSED( limit );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    GXV_NAME_ENTER( "kern format 0 pairs" );
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
    for ( i = 0; i < nPairs; i++ )
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
      FT_UShort  gid_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
      FT_UShort  gid_right;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
      FT_Short   kernValue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
      /* left */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
      gid_left  = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
      gxv_glyphid_validate( gid_left, valid );
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
      /* right */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
      gid_right = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
      gxv_glyphid_validate( gid_right, valid );
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
      /* Pairs of left and right GIDs must be unique and sorted. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
      GXV_TRACE(( "left gid = %u, right gid = %u\n", gid_left, gid_right ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
      if ( gid_left == last_gid_left )
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 ( last_gid_right < gid_right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
          last_gid_right = gid_right;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
          FT_INVALID_DATA;
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
      else if ( last_gid_left < gid_left )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
        last_gid_left  = gid_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
        last_gid_right = gid_right;
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
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
        FT_INVALID_DATA;
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
      /* skip the kern value */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
      kernValue = FT_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    GXV_EXIT;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
  gxv_kern_subtable_fmt0_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
                                   FT_Bytes       limit,
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 + GXV_KERN_SUBTABLE_HEADER_SIZE;
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
    FT_UShort  nPairs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    FT_UShort  unitSize;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    GXV_NAME_ENTER( "kern subtable format 0" );
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
    unitSize = 2 + 2 + 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    nPairs   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    /* nPairs, searchRange, entrySelector, rangeShift */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    GXV_LIMIT_CHECK( 2 + 2 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    gxv_BinSrchHeader_validate( p, limit, &unitSize, &nPairs, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    p += 2 + 2 + 2 + 2;
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_kern_subtable_fmt0_pairs_validate( p, limit, nPairs, valid );
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
  /* ============================= format 1 ============================== */
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
  typedef struct  GXV_kern_fmt1_StateOptRec_
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_UShort  valueTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    FT_UShort  valueTable_length;
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
  } GXV_kern_fmt1_StateOptRec, *GXV_kern_fmt1_StateOptRecData;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
  gxv_kern_subtable_fmt1_valueTable_load( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
                                          FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
                                          GXV_Validator  valid )
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_Bytes                       p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    GXV_kern_fmt1_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
      (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    GXV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    optdata->valueTable = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
   * passed tables_size covers whole StateTable, including kern fmt1 header
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
  gxv_kern_subtable_fmt1_subtable_setup( FT_UShort      table_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
                                         FT_UShort      classTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
                                         FT_UShort      stateArray,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
                                         FT_UShort      entryTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
                                         FT_UShort*     classTable_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
                                         FT_UShort*     stateArray_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
                                         FT_UShort*     entryTable_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
                                         GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    FT_UShort  o[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    FT_UShort  *l[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    FT_UShort  buff[5];
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_kern_fmt1_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
      (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    o[0] = classTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
    o[1] = stateArray;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    o[2] = entryTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    o[3] = optdata->valueTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    l[0] = classTable_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
    l[1] = stateArray_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    l[2] = entryTable_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    l[3] = &(optdata->valueTable_length);
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_set_length_by_ushort_offset( o, l, buff, 4, table_size, 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
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
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
   * passed table & limit are of whole StateTable, not including subtables
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
  gxv_kern_subtable_fmt1_entry_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    FT_Byte                         state,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    FT_UShort                       flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
    GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    FT_Bytes                        table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    FT_Bytes                        limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
    GXV_Validator                   valid )
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
    FT_UShort  push;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
    FT_UShort  dontAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
    FT_UShort  valueOffset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
    FT_UShort  kernAction;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
    FT_UShort  kernValue;
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
    FT_UNUSED( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    FT_UNUSED( glyphOffset_p );
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
    push        = (FT_UShort)( ( flags >> 15 ) & 1      );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
    dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1      );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
    valueOffset = (FT_UShort)(   flags         & 0x3FFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
      GXV_kern_fmt1_StateOptRecData  vt_rec =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
        (GXV_kern_fmt1_StateOptRecData)valid->statetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
      FT_Bytes  p;
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
      if ( valueOffset < vt_rec->valueTable )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
        FT_INVALID_OFFSET;
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
      p     = table + valueOffset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
      limit = table + vt_rec->valueTable + vt_rec->valueTable_length;
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
      GXV_LIMIT_CHECK( 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
      kernAction = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
      kernValue  = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
  gxv_kern_subtable_fmt1_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
                                   FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
                                   GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
    FT_Bytes                   p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
    GXV_kern_fmt1_StateOptRec  vt_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    GXV_NAME_ENTER( "kern subtable format 1" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
    valid->statetable.optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
      &vt_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    valid->statetable.optdata_load_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
      gxv_kern_subtable_fmt1_valueTable_load;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    valid->statetable.subtable_setup_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
      gxv_kern_subtable_fmt1_subtable_setup;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    valid->statetable.entry_glyphoffset_fmt =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
      GXV_GLYPHOFFSET_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
    valid->statetable.entry_validate_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
      gxv_kern_subtable_fmt1_entry_validate;
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
    gxv_StateTable_validate( p, limit, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
  /* ================ Data for Class-Based Subtables 2, 3 ================ */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
  typedef enum  GXV_kern_ClassSpec_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
    GXV_KERN_CLS_L = 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    GXV_KERN_CLS_R
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
  } GXV_kern_ClassSpec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
  /* ============================= format 2 ============================== */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
  /* ---------------------- format 2 specific data ----------------------- */
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
  typedef struct  GXV_kern_subtable_fmt2_DataRec_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
    FT_UShort         rowWidth;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    FT_UShort         array;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
    FT_UShort         offset_min[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
    FT_UShort         offset_max[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
    const FT_String*  class_tag[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
    GXV_odtect_Range  odtect;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
  } GXV_kern_subtable_fmt2_DataRec, *GXV_kern_subtable_fmt2_Data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
#define GXV_KERN_FMT2_DATA( field )                         \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
        ( ( (GXV_kern_subtable_fmt2_DataRec *)              \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
              ( GXV_KERN_DATA( subtable_data ) ) )->field )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
  /* -------------------------- utility functions ----------------------- */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
  gxv_kern_subtable_fmt2_clstbl_validate( FT_Bytes            table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
                                          FT_Bytes            limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
                                          GXV_kern_ClassSpec  spec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
                                          GXV_Validator       valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
    const FT_String*  tag    = GXV_KERN_FMT2_DATA( class_tag[spec] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    GXV_odtect_Range  odtect = GXV_KERN_FMT2_DATA( odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
    FT_Bytes   p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
    FT_UShort  firstGlyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
    FT_UShort  nGlyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    GXV_NAME_ENTER( "kern format 2 classTable" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
    GXV_LIMIT_CHECK( 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
    firstGlyph = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
    nGlyphs    = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
    GXV_TRACE(( " %s firstGlyph=%d, nGlyphs=%d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
                tag, firstGlyph, nGlyphs ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
    gxv_glyphid_validate( firstGlyph, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
    gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs - 1 ), valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
    gxv_array_getlimits_ushort( p, p + ( 2 * nGlyphs ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
                                &( GXV_KERN_FMT2_DATA( offset_min[spec] ) ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
                                &( GXV_KERN_FMT2_DATA( offset_max[spec] ) ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
                                valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
    gxv_odtect_add_range( table, 2 * nGlyphs, tag, odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
  gxv_kern_subtable_fmt2_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
                                   FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
                                   GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
    GXV_ODTECT( 3, odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
    GXV_kern_subtable_fmt2_DataRec  fmt2_rec =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
      { 0, 0, { 0, 0 }, { 0, 0 }, { "leftClass", "rightClass" }, NULL };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
    FT_Bytes   p = table + GXV_KERN_SUBTABLE_HEADER_SIZE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
    FT_UShort  leftOffsetTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
    FT_UShort  rightOffsetTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    GXV_NAME_ENTER( "kern subtable format 2" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
    GXV_ODTECT_INIT( odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
    fmt2_rec.odtect = odtect;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
    GXV_KERN_DATA( subtable_data ) = &fmt2_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
    GXV_LIMIT_CHECK( 2 + 2 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
    GXV_KERN_FMT2_DATA( rowWidth ) = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
    leftOffsetTable                = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
    rightOffsetTable               = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
    GXV_KERN_FMT2_DATA( array )    = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
    GXV_TRACE(( "rowWidth = %d\n", GXV_KERN_FMT2_DATA( rowWidth ) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
    GXV_LIMIT_CHECK( leftOffsetTable );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
    GXV_LIMIT_CHECK( rightOffsetTable );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
    GXV_LIMIT_CHECK( GXV_KERN_FMT2_DATA( array ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
    gxv_kern_subtable_fmt2_clstbl_validate( table + leftOffsetTable, limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
                                            GXV_KERN_CLS_L, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
    gxv_kern_subtable_fmt2_clstbl_validate( table + rightOffsetTable, limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
                                            GXV_KERN_CLS_R, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
    if ( GXV_KERN_FMT2_DATA( offset_min[GXV_KERN_CLS_L] ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
           GXV_KERN_FMT2_DATA( offset_min[GXV_KERN_CLS_R] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
         < GXV_KERN_FMT2_DATA( array )                      )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
      FT_INVALID_OFFSET;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
    gxv_odtect_add_range( table + GXV_KERN_FMT2_DATA( array ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
                          GXV_KERN_FMT2_DATA( offset_max[GXV_KERN_CLS_L] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
                            + GXV_KERN_FMT2_DATA( offset_max[GXV_KERN_CLS_R] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
                            - GXV_KERN_FMT2_DATA( array ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
                          "array", odtect );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
    gxv_odtect_validate( odtect, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
  /* ============================= format 3 ============================== */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
  gxv_kern_subtable_fmt3_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
                                   FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
                                   GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
    FT_Bytes   p = table + GXV_KERN_SUBTABLE_HEADER_SIZE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
    FT_UShort  glyphCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
    FT_Byte    kernValueCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
    FT_Byte    leftClassCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
    FT_Byte    rightClassCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
    FT_Byte    flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
    GXV_NAME_ENTER( "kern subtable format 3" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
    GXV_LIMIT_CHECK( 2 + 1 + 1 + 1 + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    glyphCount      = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
    kernValueCount  = FT_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
    leftClassCount  = FT_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
    rightClassCount = FT_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
    flags           = FT_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
    if ( valid->face->num_glyphs != glyphCount )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
      GXV_TRACE(( "maxGID=%d, but glyphCount=%d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
                  valid->face->num_glyphs, glyphCount ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
      if ( valid->root->level >= FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
        FT_INVALID_GLYPH_ID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
     * just skip kernValue[kernValueCount]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
    GXV_LIMIT_CHECK( 2 * kernValueCount );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
    p += 2 * kernValueCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
     * check leftClass[gid] < leftClassCount
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
      FT_Byte  min, max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
      GXV_LIMIT_CHECK( glyphCount );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
      gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
      p += valid->subtable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
      if ( leftClassCount < max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
     * check rightClass[gid] < rightClassCount
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
      FT_Byte  min, max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
      GXV_LIMIT_CHECK( glyphCount );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
      gxv_array_getlimits_byte( p, p + glyphCount, &min, &max, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
      p += valid->subtable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
      if ( rightClassCount < max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
        FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
     * check kernIndex[i, j] < kernValueCount
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
      FT_UShort  i, j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
      for ( i = 0; i < leftClassCount; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
        for ( j = 0; j < rightClassCount; j++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
          GXV_LIMIT_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
          if ( kernValueCount < FT_NEXT_BYTE( p ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
            FT_INVALID_OFFSET;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
    valid->subtable_length = p - table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
  static FT_Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
  gxv_kern_coverage_new_apple_validate( FT_UShort      coverage,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
                                        FT_UShort*     format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
                                        GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
    /* new Apple-dialect */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
    FT_Bool  kernVertical;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    FT_Bool  kernCrossStream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
    FT_Bool  kernVariation;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
    FT_UNUSED( valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
    /* reserved bits = 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
    if ( coverage & 0x1FFC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
    kernVertical    = FT_BOOL( ( coverage >> 15 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
    kernCrossStream = FT_BOOL( ( coverage >> 14 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
    kernVariation   = FT_BOOL( ( coverage >> 13 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
    *format = (FT_UShort)( coverage & 0x0003 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
    GXV_TRACE(( "new Apple-dialect: "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
                "horizontal=%d, cross-stream=%d, variation=%d, format=%d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
                 !kernVertical, kernCrossStream, kernVariation, *format ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
    GXV_TRACE(( "kerning values in Apple format subtable are ignored\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
    return 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
  static FT_Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
  gxv_kern_coverage_classic_apple_validate( FT_UShort      coverage,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
                                            FT_UShort*     format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
                                            GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
    /* classic Apple-dialect */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
    FT_Bool  horizontal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
    FT_Bool  cross_stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
    /* check expected flags, but don't check if MS-dialect is impossible */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
    if ( !( coverage & 0xFD00 ) && KERN_ALLOWS_MS( valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
    /* reserved bits = 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
    if ( coverage & 0x02FC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
    horizontal   = FT_BOOL( ( coverage >> 15 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
    cross_stream = FT_BOOL( ( coverage >> 13 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
    *format = (FT_UShort)( coverage & 0x0003 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
    GXV_TRACE(( "classic Apple-dialect: "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
                "horizontal=%d, cross-stream=%d, format=%d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
                 horizontal, cross_stream, *format ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
    /* format 1 requires GX State Machine, too new for classic */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
    if ( *format == 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
    GXV_TRACE(( "kerning values in Apple format subtable are ignored\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
    return 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
  static FT_Bool
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
  gxv_kern_coverage_classic_microsoft_validate( FT_UShort      coverage,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
                                                FT_UShort*     format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
                                                GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
    /* classic Microsoft-dialect */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
    FT_Bool  horizontal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    FT_Bool  minimum;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
    FT_Bool  cross_stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
    FT_Bool  override;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
    FT_UNUSED( valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
    /* reserved bits = 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    if ( coverage & 0xFDF0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
    horizontal   = FT_BOOL(   coverage        & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
    minimum      = FT_BOOL( ( coverage >> 1 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
    cross_stream = FT_BOOL( ( coverage >> 2 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
    override     = FT_BOOL( ( coverage >> 3 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
    *format = (FT_UShort)( ( coverage >> 8 ) & 0x0003 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
    GXV_TRACE(( "classic Microsoft-dialect: "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
                "horizontal=%d, minimum=%d, cross-stream=%d, "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
                "override=%d, format=%d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
                horizontal, minimum, cross_stream, override, *format ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
    if ( *format == 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
      GXV_TRACE((
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
        "kerning values in Microsoft format 2 subtable are ignored\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
    return 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
  /*****                            MAIN                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
  static GXV_kern_Dialect
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
  gxv_kern_coverage_validate( FT_UShort      coverage,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
                              FT_UShort*     format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
                              GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
    GXV_kern_Dialect  result = KERN_DIALECT_UNKNOWN;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
    GXV_NAME_ENTER( "validating coverage" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
    GXV_TRACE(( "interprete coverage 0x%04x by Apple style\n", coverage ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
    if ( KERN_IS_NEW( valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
      if ( gxv_kern_coverage_new_apple_validate( coverage,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
                                                 format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
                                                 valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
        result = KERN_DIALECT_APPLE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
    if ( KERN_IS_CLASSIC( valid ) && KERN_ALLOWS_APPLE( valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
      if ( gxv_kern_coverage_classic_apple_validate( coverage,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
                                                     format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
                                                     valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
        result = KERN_DIALECT_APPLE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
    if ( KERN_IS_CLASSIC( valid ) && KERN_ALLOWS_MS( valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
      if ( gxv_kern_coverage_classic_microsoft_validate( coverage,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
                                                         format,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
                                                         valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
        result = KERN_DIALECT_MS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
    GXV_TRACE(( "cannot interprete coverage, broken kern subtable\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
  gxv_kern_subtable_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
                              FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
                              GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
    FT_Bytes   p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
    FT_UShort  version = 0;    /* MS only: subtable version, unused */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
    FT_ULong   length;         /* MS: 16bit, Apple: 32bit*/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
    FT_UShort  coverage;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
    FT_UShort  tupleIndex = 0; /* Apple only */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
    FT_UShort  u16[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
    FT_UShort  format = 255;   /* subtable format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
    GXV_NAME_ENTER( "kern subtable" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
    GXV_LIMIT_CHECK( 2 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
    u16[0]   = FT_NEXT_USHORT( p ); /* Apple: length_hi MS: version */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
    u16[1]   = FT_NEXT_USHORT( p ); /* Apple: length_lo MS: length */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
    coverage = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    switch ( gxv_kern_coverage_validate( coverage, &format, valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
    case KERN_DIALECT_MS:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
      version    = u16[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
      length     = u16[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
      tupleIndex = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
      GXV_TRACE(( "Subtable version = %d\n", version ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
      GXV_TRACE(( "Subtable length = %d\n", length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
    case KERN_DIALECT_APPLE:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
      version    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
      length     = ( u16[0] << 16 ) + u16[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
      tupleIndex = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
      GXV_TRACE(( "Subtable length = %d\n", length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
      if ( KERN_IS_NEW( valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
        GXV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
        tupleIndex = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
        GXV_TRACE(( "Subtable tupleIndex = %d\n", tupleIndex ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
      length = u16[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
      GXV_TRACE(( "cannot detect subtable dialect, "
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
                  "just skip %d byte\n", length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
    /* formats 1, 2, 3 require the position of the start of this subtable */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
    if ( format == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
      gxv_kern_subtable_fmt0_validate( table, table + length, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
    else if ( format == 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
      gxv_kern_subtable_fmt1_validate( table, table + length, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
    else if ( format == 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
      gxv_kern_subtable_fmt2_validate( table, table + length, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
    else if ( format == 3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
      gxv_kern_subtable_fmt3_validate( table, table + length, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
    valid->subtable_length = length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
  /*****                         kern TABLE                            *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
  gxv_kern_validate_generic( FT_Bytes          table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
                             FT_Face           face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
                             FT_Bool           classic_only,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
                             GXV_kern_Dialect  dialect_request,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
                             FT_Validator      ftvalid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
    GXV_ValidatorRec   validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
    GXV_Validator      valid = &validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
    GXV_kern_DataRec   kernrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
    GXV_kern_Data      kern = &kernrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
    FT_Bytes           p     = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
    FT_Bytes           limit = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
    FT_ULong           nTables = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
    FT_UInt            i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
    valid->root       = ftvalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
    valid->table_data = kern;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
    valid->face       = face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
    FT_TRACE3(( "validating `kern' table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
    GXV_INIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
    KERN_DIALECT( valid ) = dialect_request;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
    GXV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
    GXV_KERN_DATA( version ) = (GXV_kern_Version)FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
    GXV_TRACE(( "version 0x%04x (higher 16bit)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
                GXV_KERN_DATA( version ) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
    if ( 0x0001 < GXV_KERN_DATA( version ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
    else if ( KERN_IS_CLASSIC( valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
      GXV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
      nTables = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
    else if ( KERN_IS_NEW( valid ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
      if ( classic_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
        FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
      if ( 0x0000 != FT_NEXT_USHORT( p ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
        FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
      GXV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
      nTables = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
    for ( i = 0; i < nTables; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
      GXV_TRACE(( "validating subtable %d/%d\n", i, nTables ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
      /* p should be 32bit-aligned? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
      gxv_kern_subtable_validate( p, 0, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
      p += valid->subtable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
    FT_TRACE4(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
  gxv_kern_validate( FT_Bytes      table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
                     FT_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
                     FT_Validator  ftvalid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
    gxv_kern_validate_generic( table, face, 0, KERN_DIALECT_ANY, ftvalid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
  gxv_kern_validate_classic( FT_Bytes      table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
                             FT_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
                             FT_Int        dialect_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
                             FT_Validator  ftvalid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
    GXV_kern_Dialect  dialect_request;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
    dialect_request = (GXV_kern_Dialect)dialect_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
    gxv_kern_validate_generic( table, face, 1, dialect_request, ftvalid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
/* END */