misc/libfreetype/src/gxvalid/gxvmorx1.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
/*  gxvmorx1.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 type1 (Contextual 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, 2007 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_type1_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   substitutionTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    FT_ULong   substitutionTable_length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    FT_UShort  substitutionTable_num_lookupTables;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  }  GXV_morx_subtable_type1_StateOptRec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    *GXV_morx_subtable_type1_StateOptRecData;
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
#define GXV_MORX_SUBTABLE_TYPE1_HEADER_SIZE \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
          ( GXV_STATETABLE_HEADER_SIZE + 2 )
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  gxv_morx_subtable_type1_substitutionTable_load( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
                                                  FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
                                                  GXV_Validator  valid )
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
    FT_Bytes  p = table;
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
    GXV_morx_subtable_type1_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
      (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    GXV_LIMIT_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    optdata->substitutionTable = FT_NEXT_USHORT( p );
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
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
  gxv_morx_subtable_type1_subtable_setup( FT_ULong       table_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
                                          FT_ULong       classTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
                                          FT_ULong       stateArray,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
                                          FT_ULong       entryTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
                                          FT_ULong*      classTable_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
                                          FT_ULong*      stateArray_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
                                          FT_ULong*      entryTable_length_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
                                          GXV_Validator  valid )
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
    FT_ULong  o[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    FT_ULong  *l[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    FT_ULong  buff[5];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    GXV_morx_subtable_type1_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
      (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    o[0] = classTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    o[1] = stateArray;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    o[2] = entryTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    o[3] = optdata->substitutionTable;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    l[0] = classTable_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
    l[1] = stateArray_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    l[2] = entryTable_length_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    l[3] = &(optdata->substitutionTable_length);
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
    gxv_set_length_by_ulong_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
    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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
  gxv_morx_subtable_type1_entry_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    FT_UShort                       state,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
    FT_UShort                       flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    FT_Bytes                        table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    FT_Bytes                        limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    GXV_Validator                   valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    FT_UShort  setMark;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    FT_UShort  dontAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    FT_UShort  reserved;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    FT_Short   markIndex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    FT_Short   currentIndex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
    GXV_morx_subtable_type1_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
      (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    FT_UNUSED( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
    FT_UNUSED( table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
    FT_UNUSED( limit );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    setMark      = (FT_UShort)( ( flags >> 15 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    dontAdvance  = (FT_UShort)( ( flags >> 14 ) & 1 );
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
    reserved = (FT_UShort)( flags & 0x3FFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    markIndex    = (FT_Short)( glyphOffset_p->ul >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    currentIndex = (FT_Short)( glyphOffset_p->ul       );
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
    GXV_TRACE(( " setMark=%01d dontAdvance=%01d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
                setMark, dontAdvance ));
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
    if ( 0 < reserved )
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
      GXV_TRACE(( " non-zero bits found in reserved range\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
      if ( valid->root->level >= FT_VALIDATE_PARANOID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
        FT_INVALID_DATA;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    GXV_TRACE(( "markIndex = %d, currentIndex = %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
                markIndex, currentIndex ));
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
    if ( optdata->substitutionTable_num_lookupTables < markIndex + 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
      optdata->substitutionTable_num_lookupTables =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
        (FT_Short)( markIndex + 1 );
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
    if ( optdata->substitutionTable_num_lookupTables < currentIndex + 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
      optdata->substitutionTable_num_lookupTables =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
        (FT_Short)( currentIndex + 1 );
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
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
  gxv_morx_subtable_type1_LookupValue_validate( FT_UShort            glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
                                                GXV_LookupValueCPtr  value_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
                                                GXV_Validator        valid )
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
    FT_UNUSED( glyph ); /* for the non-debugging case */
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(( "morx subtable type1 subst.: %d -> %d\n", glyph, value_p->u ));
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
    if ( value_p->u > valid->face->num_glyphs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
      FT_INVALID_GLYPH_ID;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
  static GXV_LookupValueDesc
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
  gxv_morx_subtable_type1_LookupFmt4_transit(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    FT_UShort            relative_gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    GXV_LookupValueCPtr  base_value_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    FT_Bytes             lookuptbl_limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    GXV_Validator        valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    FT_Bytes             p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    FT_Bytes             limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    FT_UShort            offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    GXV_LookupValueDesc  value;
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
    /* XXX: check range? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    offset = (FT_UShort)( base_value_p->u +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
                          relative_gindex * sizeof ( FT_UShort ) );
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
    p     = valid->lookuptbl_head + offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
    limit = lookuptbl_limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    GXV_LIMIT_CHECK ( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    value.u = FT_NEXT_USHORT( p );
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
    return value;
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
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
   * TODO: length should be limit?
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
   **/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
  gxv_morx_subtable_type1_substitutionTable_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
                                                      FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
                                                      GXV_Validator  valid )
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
    FT_Bytes   p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    FT_UShort  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    GXV_morx_subtable_type1_StateOptRecData  optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
      (GXV_morx_subtable_type1_StateOptRecData)valid->xstatetable.optdata;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    /* TODO: calculate offset/length for each lookupTables */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    valid->lookupval_func   = gxv_morx_subtable_type1_LookupValue_validate;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    valid->lookupfmt4_trans = gxv_morx_subtable_type1_LookupFmt4_transit;
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
    for ( i = 0; i < optdata->substitutionTable_num_lookupTables; i++ )
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
      FT_ULong  offset;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
      GXV_LIMIT_CHECK( 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
      offset = FT_NEXT_ULONG( p );
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_LookupTable_validate( table + offset, limit, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
    /* TODO: overlapping of lookupTables in substitutionTable */
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
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
   * subtable for Contextual glyph substitution is a modified StateTable.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
   * In addition to classTable, stateArray, entryTable, the field
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
   * `substitutionTable' is added.
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  gxv_morx_subtable_type1_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
                                    FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
                                    GXV_Validator  valid )
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
    FT_Bytes  p = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    GXV_morx_subtable_type1_StateOptRec  st_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    GXV_NAME_ENTER( "morx chain subtable type1 (Contextual Glyph Subst)" );
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_LIMIT_CHECK( GXV_MORX_SUBTABLE_TYPE1_HEADER_SIZE );
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
    st_rec.substitutionTable_num_lookupTables = 0;
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
    valid->xstatetable.optdata =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
      &st_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    valid->xstatetable.optdata_load_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
      gxv_morx_subtable_type1_substitutionTable_load;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
    valid->xstatetable.subtable_setup_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
      gxv_morx_subtable_type1_subtable_setup;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    valid->xstatetable.entry_glyphoffset_fmt =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
      GXV_GLYPHOFFSET_ULONG;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    valid->xstatetable.entry_validate_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
      gxv_morx_subtable_type1_entry_validate;
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_XStateTable_validate( p, limit, valid );
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
    gxv_morx_subtable_type1_substitutionTable_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
      table + st_rec.substitutionTable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
      table + st_rec.substitutionTable + st_rec.substitutionTable_length,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
      valid );
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
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  }
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
/* END */