misc/libfreetype/src/gxvalid/gxvmorx2.c
author belphegorr <szabibibi@gmail.com>
Mon, 23 Jul 2012 19:15:59 +0300
changeset 7263 644eabbc9218
parent 5172 88f2e05288ba
permissions -rw-r--r--
Added a new function: AddNewEvent, which only adds an event to the list if it doesn't already exist. Kept the old one as it might me useful to be able to add an event more than once.
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
/*  gxvmorx2.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 morx 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 "gxvmorx.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_gxvmorx
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_morx_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_ULong  ligActionTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    FT_ULong  componentTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    FT_ULong  ligatureTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    FT_ULong  ligActionTable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    FT_ULong  componentTable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    FT_ULong  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_morx_subtable_type2_StateOptRec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
    *GXV_morx_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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
#define GXV_MORX_SUBTABLE_TYPE2_HEADER_SIZE \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
          ( GXV_XSTATETABLE_HEADER_SIZE + 4 + 4 + 4 )
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
  gxv_morx_subtable_type2_opttable_load( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
                                         FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
                                         GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    GXV_morx_subtable_type2_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
      (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    GXV_LIMIT_CHECK( 4 + 4 + 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    optdata->ligActionTable = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
    optdata->componentTable = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    optdata->ligatureTable  = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
    GXV_TRACE(( "offset to ligActionTable=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
                optdata->ligActionTable ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    GXV_TRACE(( "offset to componentTable=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
                optdata->componentTable ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    GXV_TRACE(( "offset to ligatureTable=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
                optdata->ligatureTable ));
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  gxv_morx_subtable_type2_subtable_setup( FT_ULong       table_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
                                          FT_ULong       classTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
                                          FT_ULong       stateArray,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
                                          FT_ULong       entryTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
                                          FT_ULong*      classTable_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
                                          FT_ULong*      stateArray_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
                                          FT_ULong*      entryTable_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
                                          GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    FT_ULong   o[6];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
    FT_ULong*  l[6];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    FT_ULong   buff[7];
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
    GXV_morx_subtable_type2_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
      (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
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
    GXV_NAME_ENTER( "subtable boundaries setup" );
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
    o[0] = classTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    o[1] = stateArray;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
    o[2] = entryTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    o[3] = optdata->ligActionTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    o[4] = optdata->componentTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    o[5] = optdata->ligatureTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    l[0] = classTable_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    l[1] = stateArray_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    l[2] = entryTable_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    l[3] = &(optdata->ligActionTable_length);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    l[4] = &(optdata->componentTable_length);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    l[5] = &(optdata->ligatureTable_length);
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_set_length_by_ulong_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
   117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
    GXV_TRACE(( "classTable: offset=0x%08x length=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
                classTable, *classTable_length_p ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    GXV_TRACE(( "stateArray: offset=0x%08x length=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
                stateArray, *stateArray_length_p ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
    GXV_TRACE(( "entryTable: offset=0x%08x length=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
                entryTable, *entryTable_length_p ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    GXV_TRACE(( "ligActionTable: offset=0x%08x length=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
                optdata->ligActionTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
                optdata->ligActionTable_length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    GXV_TRACE(( "componentTable: offset=0x%08x length=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
                optdata->componentTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
                optdata->componentTable_length ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    GXV_TRACE(( "ligatureTable:  offset=0x%08x length=0x%08x\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
                optdata->ligatureTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
                optdata->ligatureTable_length ));
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
    GXV_EXIT;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
#define GXV_MORX_LIGACTION_ENTRY_SIZE  4
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
  gxv_morx_subtable_type2_ligActionIndex_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    FT_UShort      ligActionIndex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    /* access ligActionTable */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    GXV_morx_subtable_type2_StateOptRecData optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
      (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
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
    FT_Bytes lat_base  = table + optdata->ligActionTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
    FT_Bytes p         = lat_base +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
                         ligActionIndex * GXV_MORX_LIGACTION_ENTRY_SIZE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
    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
   155
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
    if ( p < lat_base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
      GXV_TRACE(( "p < lat_base (%d byte rewind)\n", lat_base - p ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
      FT_INVALID_OFFSET;
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
    else if ( lat_limit < p )
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
      GXV_TRACE(( "lat_limit < p (%d byte overrun)\n", p - lat_limit ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
      FT_INVALID_OFFSET;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
      /* validate entry in ligActionTable */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
      FT_ULong   lig_action;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
      FT_UShort  last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
      FT_UShort  store;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
      FT_ULong   offset;
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
      lig_action = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
      last       = (FT_UShort)( ( lig_action >> 31 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
      store      = (FT_UShort)( ( lig_action >> 30 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      offset = lig_action & 0x3FFFFFFFUL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
  gxv_morx_subtable_type2_entry_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
    FT_UShort                       state,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
    FT_UShort                       flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    FT_Bytes                        table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    FT_Bytes                        limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    GXV_Validator                   valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    FT_UShort  setComponent;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
    FT_UShort  dontAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    FT_UShort  performAction;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    FT_UShort  reserved;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    FT_UShort  ligActionIndex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    FT_UNUSED( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    FT_UNUSED( limit );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    setComponent   = (FT_UShort)( ( flags >> 15 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    dontAdvance    = (FT_UShort)( ( flags >> 14 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    performAction  = (FT_UShort)( ( flags >> 13 ) & 1 );
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
    reserved       = (FT_UShort)( flags & 0x1FFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    ligActionIndex = glyphOffset_p->u;
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 ( reserved > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
      GXV_TRACE(( "  reserved 14bit is non-zero\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    if ( 0 < ligActionIndex )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
      gxv_morx_subtable_type2_ligActionIndex_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
        table, ligActionIndex, valid );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
  gxv_morx_subtable_type2_ligatureTable_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
                                                  GXV_Validator  valid )
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
    GXV_morx_subtable_type2_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
      (GXV_morx_subtable_type2_StateOptRecData)valid->xstatetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
    FT_Bytes p     = table + optdata->ligatureTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
    FT_Bytes limit = table + optdata->ligatureTable
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
                           + optdata->ligatureTable_length;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    GXV_NAME_ENTER( "morx chain subtable type2 - substitutionTable" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
    if ( 0 != optdata->ligatureTable )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
      /* 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
   237
      while ( p < limit )
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
        FT_UShort  lig_gid;
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_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
        lig_gid = FT_NEXT_USHORT( p );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
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_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
  gxv_morx_subtable_type2_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
                                    FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
                                    GXV_Validator  valid )
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
    FT_Bytes  p = table;
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_morx_subtable_type2_StateOptRec  lig_rec;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    GXV_NAME_ENTER( "morx chain subtable type2 (Ligature Substitution)" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
    GXV_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE2_HEADER_SIZE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
    valid->xstatetable.optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
      &lig_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
    valid->xstatetable.optdata_load_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
      gxv_morx_subtable_type2_opttable_load;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
    valid->xstatetable.subtable_setup_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
      gxv_morx_subtable_type2_subtable_setup;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    valid->xstatetable.entry_glyphoffset_fmt =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
      GXV_GLYPHOFFSET_USHORT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
    valid->xstatetable.entry_validate_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
      gxv_morx_subtable_type2_entry_validate;
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
    gxv_XStateTable_validate( p, limit, valid );
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
    p += valid->subtable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
    gxv_morx_subtable_type2_ligatureTable_validate( table, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
/* END */