misc/libfreetype/src/gxvalid/gxvbsln.c
author nemo
Sat, 18 Aug 2012 09:29:40 -0400
changeset 7555 acadabfb2dd1
parent 5172 88f2e05288ba
permissions -rw-r--r--
byte order
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
/*  gxvbsln.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 bsln table validation (body).                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2004, 2005 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
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  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
    11
/*  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
    12
/*  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
    13
/*  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
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
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
/* 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
    21
/* 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
    22
/* Promotion Agency(IPA), Japan.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
/*                                                                         */
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
#include "gxvalid.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "gxvcommn.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_gxvbsln
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
  /*************************************************************************/
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
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /*****                      Data and Types                           *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
#define GXV_BSLN_VALUE_COUNT  32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
#define GXV_BSLN_VALUE_EMPTY  0xFFFFU
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  typedef struct  GXV_bsln_DataRec_
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
    FT_Bytes   ctlPoints_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    FT_UShort  defaultBaseline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  } GXV_bsln_DataRec, *GXV_bsln_Data;
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
#define GXV_BSLN_DATA( field )  GXV_TABLE_DATA( bsln, field )
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
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
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
  /*****                      UTILITY FUNCTIONS                        *****/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
  gxv_bsln_LookupValue_validate( FT_UShort            glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
                                 GXV_LookupValueCPtr  value_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
                                 GXV_Validator        valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    FT_UShort   v = value_p->u;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    FT_UShort*  ctlPoints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
    FT_UNUSED( glyph );
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
    GXV_NAME_ENTER( "lookup value" );
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
    if ( v >= GXV_BSLN_VALUE_COUNT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
      FT_INVALID_DATA;
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
    ctlPoints = (FT_UShort*)GXV_BSLN_DATA( ctlPoints_p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    if ( ctlPoints && ctlPoints[v] == GXV_BSLN_VALUE_EMPTY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
      FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    +===============+ --------+
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    | lookup header |         |
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
    | BinSrchHeader |         |
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
    | lastGlyph[0]  |         |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    +---------------+         |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    | firstGlyph[0] |         |    head of lookup table
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
    | offset[0]     |    ->   |          offset            [byte]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    +===============+         |             +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    | lastGlyph[1]  |         | (glyphID - firstGlyph) * 2 [byte]
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
    | firstGlyph[1] |         |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    +---------------+         |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    | offset[1]     |         |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    +===============+         |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
                              |
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
                              |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
    16bit value array         |
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
    |     value     | <-------+
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    ...
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  static GXV_LookupValueDesc
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  gxv_bsln_LookupFmt4_transit( FT_UShort            relative_gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
                               GXV_LookupValueCPtr  base_value_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
                               FT_Bytes             lookuptbl_limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
                               GXV_Validator        valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    FT_Bytes             p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    FT_Bytes             limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    FT_UShort            offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    GXV_LookupValueDesc  value;
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
    /* XXX: check range ? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    offset = (FT_UShort)( base_value_p->u +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
                          ( relative_gindex * sizeof ( FT_UShort ) ) );
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
    p     = valid->lookuptbl_head + offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    limit = lookuptbl_limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    GXV_LIMIT_CHECK( 2 );
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
    value.u = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    return value;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
  gxv_bsln_parts_fmt0_validate( FT_Bytes       tables,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
                                FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
                                GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    FT_Bytes  p = tables;
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
    GXV_NAME_ENTER( "parts format 0" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    /* deltas */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
    GXV_LIMIT_CHECK( 2 * GXV_BSLN_VALUE_COUNT );
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
    valid->table_data = NULL;      /* No ctlPoints here. */
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_EXIT;
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
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
  gxv_bsln_parts_fmt1_validate( FT_Bytes       tables,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
                                FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
                                GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    FT_Bytes  p = tables;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
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
    GXV_NAME_ENTER( "parts format 1" );
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
    /* deltas */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    gxv_bsln_parts_fmt0_validate( p, limit, valid );
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
    /* mappingData */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    valid->lookupval_func   = gxv_bsln_LookupValue_validate;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    valid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    gxv_LookupTable_validate( p + 2 * GXV_BSLN_VALUE_COUNT,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
                              limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
                              valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
  gxv_bsln_parts_fmt2_validate( FT_Bytes       tables,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
                                FT_Bytes       limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
                                GXV_Validator  valid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    FT_Bytes   p = tables;
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
    FT_UShort  stdGlyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    FT_UShort  ctlPoint;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    FT_Int     i;
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
    FT_UShort  defaultBaseline = GXV_BSLN_DATA( defaultBaseline );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    GXV_NAME_ENTER( "parts format 2" );
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
    GXV_LIMIT_CHECK( 2 + ( 2 * GXV_BSLN_VALUE_COUNT ) );
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
    /* stdGlyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    stdGlyph = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
    GXV_TRACE(( " (stdGlyph = %u)\n", stdGlyph ));
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
    gxv_glyphid_validate( stdGlyph, valid );
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
    /* Record the position of ctlPoints */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
    GXV_BSLN_DATA( ctlPoints_p ) = p;
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
    /* ctlPoints */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    for ( i = 0; i < GXV_BSLN_VALUE_COUNT; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
      ctlPoint = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
      if ( ctlPoint == GXV_BSLN_VALUE_EMPTY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
        if ( i == defaultBaseline )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
          FT_INVALID_DATA;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
        gxv_ctlPoint_validate( stdGlyph, (FT_Short)ctlPoint, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    GXV_EXIT;
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
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  gxv_bsln_parts_fmt3_validate( FT_Bytes       tables,
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 = tables;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
    GXV_NAME_ENTER( "parts format 3" );
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
    /* stdGlyph + ctlPoints */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
    gxv_bsln_parts_fmt2_validate( p, limit, valid );
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
    /* mappingData */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    valid->lookupval_sign   = GXV_LOOKUPVALUE_UNSIGNED;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    valid->lookupval_func   = gxv_bsln_LookupValue_validate;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    valid->lookupfmt4_trans = gxv_bsln_LookupFmt4_transit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    gxv_LookupTable_validate( p + ( 2 + 2 * GXV_BSLN_VALUE_COUNT ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
                              limit,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
                              valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    GXV_EXIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
  }
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
  /*************************************************************************/
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
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
  /*****                         bsln TABLE                            *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
  gxv_bsln_validate( FT_Bytes      table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
                     FT_Face       face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
                     FT_Validator  ftvalid )
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
    GXV_ValidatorRec  validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
    GXV_Validator     valid = &validrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
    GXV_bsln_DataRec  bslnrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
    GXV_bsln_Data     bsln = &bslnrec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
    FT_Bytes  p     = table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
    FT_Bytes  limit = 0;
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
    FT_ULong   version;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
    FT_UShort  format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    FT_UShort  defaultBaseline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    GXV_Validate_Func  fmt_funcs_table [] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
      gxv_bsln_parts_fmt0_validate,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
      gxv_bsln_parts_fmt1_validate,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
      gxv_bsln_parts_fmt2_validate,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
      gxv_bsln_parts_fmt3_validate,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    valid->root       = ftvalid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
    valid->table_data = bsln;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
    valid->face       = face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
    FT_TRACE3(( "validating `bsln' table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
    GXV_INIT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
    GXV_LIMIT_CHECK( 4 + 2 + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
    version         = FT_NEXT_ULONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    format          = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    defaultBaseline = FT_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
    /* only version 1.0 is defined (1996) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    if ( version != 0x00010000UL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
    /* only format 1, 2, 3 are defined (1996) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    GXV_TRACE(( " (format = %d)\n", format ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
    if ( format > 3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    if ( defaultBaseline > 31 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
      FT_INVALID_FORMAT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    bsln->defaultBaseline = defaultBaseline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
    fmt_funcs_table[format]( p, limit, valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    FT_TRACE4(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
/* arch-tag: ebe81143-fdaa-4c68-a4d1-b57227daa3bc
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
   (do not change this comment) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
/* END */