misc/libfreetype/src/gxvalid/gxvmort2.c
author koda
Mon, 25 Apr 2011 01:46:54 +0200
changeset 5172 88f2e05288ba
permissions -rw-r--r--
aaand let's add freetype as well while we are at it other smaller changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  gxvmort2.c                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    TrueTypeGX/AAT mort table validation                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*    body for type2 (Ligature Substitution) subtable.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  Copyright 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K.,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     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 "gxvmort.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
#define FT_COMPONENT  trace_gxvmort
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  typedef struct  GXV_mort_subtable_type2_StateOptRec_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
    FT_UShort  ligActionTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    FT_UShort  componentTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    FT_UShort  ligatureTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    FT_UShort  ligActionTable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    FT_UShort  componentTable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    FT_UShort  ligatureTable_length;
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
  }  GXV_mort_subtable_type2_StateOptRec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
    *GXV_mort_subtable_type2_StateOptRecData;
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
#define GXV_MORT_SUBTABLE_TYPE2_HEADER_SIZE \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
          ( GXV_STATETABLE_HEADER_SIZE + 2 + 2 + 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  gxv_mort_subtable_type2_opttable_load( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
                                         FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
                                         GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    FT_Bytes p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    GXV_mort_subtable_type2_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
      (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    GXV_LIMIT_CHECK( 2 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
    optdata->ligActionTable = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    optdata->componentTable = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    optdata->ligatureTable  = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    GXV_TRACE(( "offset to ligActionTable=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
                optdata->ligActionTable ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
    GXV_TRACE(( "offset to componentTable=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
                optdata->componentTable ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    GXV_TRACE(( "offset to ligatureTable=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
                optdata->ligatureTable ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
  gxv_mort_subtable_type2_subtable_setup( FT_UShort      table_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
                                          FT_UShort      classTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
                                          FT_UShort      stateArray,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
                                          FT_UShort      entryTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
                                          FT_UShort      *classTable_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
                                          FT_UShort      *stateArray_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
                                          FT_UShort      *entryTable_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
                                          GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    FT_UShort  o[6];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    FT_UShort  *l[6];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    FT_UShort  buff[7];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    GXV_mort_subtable_type2_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
      (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
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
    GXV_NAME_ENTER( "subtable boundaries setup" );
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
    o[0] = classTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    o[1] = stateArray;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    o[2] = entryTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    o[3] = optdata->ligActionTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
    o[4] = optdata->componentTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    o[5] = optdata->ligatureTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    l[0] = classTable_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    l[1] = stateArray_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    l[2] = entryTable_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    l[3] = &(optdata->ligActionTable_length);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    l[4] = &(optdata->componentTable_length);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    l[5] = &(optdata->ligatureTable_length);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    gxv_set_length_by_ushort_offset( o, l, buff, 6, table_size, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    GXV_TRACE(( "classTable: offset=0x%04x length=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
                classTable, *classTable_length_p ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
    GXV_TRACE(( "stateArray: offset=0x%04x length=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
                stateArray, *stateArray_length_p ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    GXV_TRACE(( "entryTable: offset=0x%04x length=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
                entryTable, *entryTable_length_p ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
    GXV_TRACE(( "ligActionTable: offset=0x%04x length=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
                optdata->ligActionTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
                optdata->ligActionTable_length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    GXV_TRACE(( "componentTable: offset=0x%04x length=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
                optdata->componentTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
                optdata->componentTable_length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    GXV_TRACE(( "ligatureTable:  offset=0x%04x length=0x%04x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
                optdata->ligatureTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
                optdata->ligatureTable_length ));
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
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
  gxv_mort_subtable_type2_ligActionOffset_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    FT_UShort      ligActionOffset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    /* access ligActionTable */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    GXV_mort_subtable_type2_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
      (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    FT_Bytes lat_base  = table + optdata->ligActionTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    FT_Bytes p         = table + ligActionOffset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    FT_Bytes lat_limit = lat_base + optdata->ligActionTable;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    GXV_32BIT_ALIGNMENT_VALIDATE( ligActionOffset );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
    if ( p < lat_base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
      GXV_TRACE(( "too short offset 0x%04x: p < lat_base (%d byte rewind)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
                  ligActionOffset, lat_base - p ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
      /* FontValidator, ftxvalidator, ftxdumperfuser warn but continue */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      if ( valid->root->level >= FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
        FT_INVALID_OFFSET;
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
    else if ( lat_limit < p )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      GXV_TRACE(( "too large offset 0x%04x: lat_limit < p (%d byte overrun)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
                  ligActionOffset, p - lat_limit ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
      /* FontValidator, ftxvalidator, ftxdumperfuser warn but continue */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
      if ( valid->root->level >= FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
        FT_INVALID_OFFSET;
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
    else
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
      /* validate entry in ligActionTable */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
      FT_ULong   lig_action;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
      FT_UShort  last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
      FT_UShort  store;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      FT_ULong   offset;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
      lig_action = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      last   = (FT_UShort)( ( lig_action >> 31 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
      store  = (FT_UShort)( ( lig_action >> 30 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      offset = lig_action & 0x3FFFFFFFUL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
  gxv_mort_subtable_type2_entry_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    FT_Byte                         state,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    FT_UShort                       flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
    FT_Bytes                        table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    FT_Bytes                        limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
    GXV_Validator                   valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    FT_UShort setComponent;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    FT_UShort dontAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    FT_UShort offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    FT_UNUSED( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    FT_UNUSED( glyphOffset_p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    FT_UNUSED( limit );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    setComponent = (FT_UShort)( ( flags >> 15 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    dontAdvance  = (FT_UShort)( ( flags >> 14 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    offset = (FT_UShort)( flags & 0x3FFFU );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    if ( 0 < offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
      gxv_mort_subtable_type2_ligActionOffset_validate( table, offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
                                                        valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
  gxv_mort_subtable_type2_ligatureTable_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
                                                  GXV_Validator  valid )
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
    GXV_mort_subtable_type2_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
      (GXV_mort_subtable_type2_StateOptRecData)valid->statetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    FT_Bytes p     = table + optdata->ligatureTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    FT_Bytes limit = table + optdata->ligatureTable
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
                           + optdata->ligatureTable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    GXV_NAME_ENTER( "mort chain subtable type2 - substitutionTable" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    if ( 0 != optdata->ligatureTable )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
      /* Apple does not give specification of ligatureTable format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
      while ( p < limit )
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
        FT_UShort  lig_gid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
        GXV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
        lig_gid = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
  gxv_mort_subtable_type2_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
                                    FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
                                    GXV_Validator  valid )
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
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    GXV_mort_subtable_type2_StateOptRec  lig_rec;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
    GXV_NAME_ENTER( "mort chain subtable type2 (Ligature Substitution)" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    GXV_LIMIT_CHECK( GXV_MORT_SUBTABLE_TYPE2_HEADER_SIZE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    valid->statetable.optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
      &lig_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
    valid->statetable.optdata_load_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
      gxv_mort_subtable_type2_opttable_load;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
    valid->statetable.subtable_setup_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
      gxv_mort_subtable_type2_subtable_setup;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
    valid->statetable.entry_glyphoffset_fmt =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
      GXV_GLYPHOFFSET_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
    valid->statetable.entry_validate_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
      gxv_mort_subtable_type2_entry_validate;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    gxv_StateTable_validate( p, limit, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
    p += valid->subtable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
    gxv_mort_subtable_type2_ligatureTable_validate( table, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
    valid->subtable_length = p - table;
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
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
/* END */