misc/libfreetype/src/gxvalid/gxvmort0.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
/*  gxvmort0.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 type0 (Indic Script Rearrangement) 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
  static const char* GXV_Mort_IndicScript_Msg[] =
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
    "no change",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    "Ax => xA",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    "xD => Dx",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    "AxD => DxA",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    "ABx => xAB",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    "ABx => xBA",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
    "xCD => CDx",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
    "xCD => DCx",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
    "AxCD => CDxA",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    "AxCD => DCxA",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
    "ABxD => DxAB",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    "ABxD => DxBA",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    "ABxCD => CDxAB",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    "ABxCD => CDxBA",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    "ABxCD => DCxAB",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    "ABxCD => DCxBA",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
  gxv_mort_subtable_type0_entry_validate(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    FT_Byte                         state,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    FT_UShort                       flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    GXV_StateTable_GlyphOffsetCPtr  glyphOffset_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
    FT_Bytes                        table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    FT_Bytes                        limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    GXV_Validator                   valid )
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
    FT_UShort  markFirst;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    FT_UShort  dontAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
    FT_UShort  markLast;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
    FT_UShort  reserved;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    FT_UShort  verb = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    FT_UNUSED( state );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    FT_UNUSED( table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
    FT_UNUSED( limit );
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
    FT_UNUSED( GXV_Mort_IndicScript_Msg[verb] ); /* for the non-debugging */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    FT_UNUSED( glyphOffset_p );                  /* case                  */
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    markFirst   = (FT_UShort)( ( flags >> 15 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    dontAdvance = (FT_UShort)( ( flags >> 14 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    markLast    = (FT_UShort)( ( flags >> 13 ) & 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    reserved = (FT_UShort)( flags & 0x1FF0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    verb     = (FT_UShort)( flags & 0x000F );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    GXV_TRACE(( "  IndicScript MorphRule for glyphOffset 0x%04x",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
                glyphOffset_p->u ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    GXV_TRACE(( " markFirst=%01d", markFirst ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    GXV_TRACE(( " dontAdvance=%01d", dontAdvance ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    GXV_TRACE(( " markLast=%01d", markLast ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    GXV_TRACE(( " %02d", verb ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
    GXV_TRACE(( " %s\n", GXV_Mort_IndicScript_Msg[verb] ));
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
    if ( 0 < reserved )
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
      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
   104
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
      GXV_TRACE(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
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_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
  gxv_mort_subtable_type0_validate( FT_Bytes       table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
                                    FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
                                    GXV_Validator  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
    FT_Bytes  p = table;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
    GXV_NAME_ENTER(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
      "mort chain subtable type0 (Indic-Script Rearrangement)" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
    GXV_LIMIT_CHECK( GXV_STATETABLE_HEADER_SIZE );
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
    valid->statetable.optdata               = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    valid->statetable.optdata_load_func     = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    valid->statetable.subtable_setup_func   = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    valid->statetable.entry_glyphoffset_fmt = GXV_GLYPHOFFSET_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    valid->statetable.entry_validate_func =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
      gxv_mort_subtable_type0_entry_validate;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    gxv_StateTable_validate( p, limit, valid );
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_EXIT;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
/* END */