misc/libfreetype/src/otvalid/otvmod.c
author nemo
Wed, 14 Sep 2011 14:14:23 -0400
changeset 5903 71466bccdf97
parent 5172 88f2e05288ba
permissions -rw-r--r--
merge
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
/*  otvmod.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
/*    FreeType's OpenType validation module implementation (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, 2006, 2007, 2008 by                              */
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
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_TRUETYPE_TABLES_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_TRUETYPE_TAGS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_OPENTYPE_VALIDATE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_SERVICE_OPENTYPE_VALIDATE_H
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
#include "otvmod.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include "otvalid.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "otvcommn.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_otvmodule
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 FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  otv_load_table( FT_Face             face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
                  FT_Tag              tag,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
                  FT_Byte* volatile*  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
                  FT_ULong*           table_len )
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
    FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    FT_Memory  memory = FT_FACE_MEMORY( face );
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
    error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    if ( error == OTV_Err_Table_Missing )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
      return OTV_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    if ( FT_ALLOC( *table, *table_len ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
      goto Exit;
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
    error = FT_Load_Sfnt_Table( face, tag, 0, *table, table_len );
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    return error;
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
  otv_validate( FT_Face volatile   face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
                FT_UInt            ot_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
                FT_Bytes          *ot_base,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
                FT_Bytes          *ot_gdef,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
                FT_Bytes          *ot_gpos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
                FT_Bytes          *ot_gsub,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
                FT_Bytes          *ot_jstf )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    FT_Error                  error = OTV_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    FT_Byte* volatile         base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    FT_Byte* volatile         gdef;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    FT_Byte* volatile         gpos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
    FT_Byte* volatile         gsub;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    FT_Byte* volatile         jstf;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    FT_Byte* volatile         math;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    FT_ULong                  len_base, len_gdef, len_gpos, len_gsub, len_jstf;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
    FT_ULong                  len_math;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    FT_UInt                   num_glyphs = (FT_UInt)face->num_glyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    FT_ValidatorRec volatile  valid;
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
    base     = gdef     = gpos     = gsub     = jstf     = math     = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    len_base = len_gdef = len_gpos = len_gsub = len_jstf = len_math = 0;
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
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
     * XXX: OpenType tables cannot handle 32-bit glyph index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
     *      although broken TrueType can have 32-bit glyph index.
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
    if ( face->num_glyphs > 0xFFFFL )
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
      FT_TRACE1(( "otv_validate: Invalid glyphs index (0x0000FFFF - 0x%08x) ",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
                  face->num_glyphs ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
      FT_TRACE1(( "are not handled by OpenType tables\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
      num_glyphs = 0xFFFF;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    /* load tables */
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
    if ( ot_flags & FT_VALIDATE_BASE )
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
      error = otv_load_table( face, TTAG_BASE, &base, &len_base );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
        goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    if ( ot_flags & FT_VALIDATE_GDEF )
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
      error = otv_load_table( face, TTAG_GDEF, &gdef, &len_gdef );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
        goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    if ( ot_flags & FT_VALIDATE_GPOS )
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
      error = otv_load_table( face, TTAG_GPOS, &gpos, &len_gpos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    if ( ot_flags & FT_VALIDATE_GSUB )
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
      error = otv_load_table( face, TTAG_GSUB, &gsub, &len_gsub );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
        goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    if ( ot_flags & FT_VALIDATE_JSTF )
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
      error = otv_load_table( face, TTAG_JSTF, &jstf, &len_jstf );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    if ( ot_flags & FT_VALIDATE_MATH )
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
      error = otv_load_table( face, TTAG_MATH, &math, &len_math );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
        goto Exit;
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
    /* validate tables */
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 ( base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
      ft_validator_init( &valid, base, base + len_base, FT_VALIDATE_DEFAULT );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
      if ( ft_setjmp( valid.jump_buffer ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
        otv_BASE_validate( base, &valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
      error = valid.error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    if ( gpos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
      ft_validator_init( &valid, gpos, gpos + len_gpos, FT_VALIDATE_DEFAULT );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      if ( ft_setjmp( valid.jump_buffer ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
        otv_GPOS_validate( gpos, num_glyphs, &valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
      error = valid.error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
        goto Exit;
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
    if ( gsub )
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_validator_init( &valid, gsub, gsub + len_gsub, FT_VALIDATE_DEFAULT );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
      if ( ft_setjmp( valid.jump_buffer ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
        otv_GSUB_validate( gsub, num_glyphs, &valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
      error = valid.error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    if ( gdef )
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
      ft_validator_init( &valid, gdef, gdef + len_gdef, FT_VALIDATE_DEFAULT );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      if ( ft_setjmp( valid.jump_buffer ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
        otv_GDEF_validate( gdef, gsub, gpos, num_glyphs, &valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
      error = valid.error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
        goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    if ( jstf )
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
      ft_validator_init( &valid, jstf, jstf + len_jstf, FT_VALIDATE_DEFAULT );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
      if ( ft_setjmp( valid.jump_buffer ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
        otv_JSTF_validate( jstf, gsub, gpos, num_glyphs, &valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
      error = valid.error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
        goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    if ( math )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
      ft_validator_init( &valid, math, math + len_math, FT_VALIDATE_DEFAULT );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
      if ( ft_setjmp( valid.jump_buffer ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
        otv_MATH_validate( math, num_glyphs, &valid );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
      error = valid.error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    *ot_base = (FT_Bytes)base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    *ot_gdef = (FT_Bytes)gdef;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
    *ot_gpos = (FT_Bytes)gpos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    *ot_gsub = (FT_Bytes)gsub;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    *ot_jstf = (FT_Bytes)jstf;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
    if ( error )
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
      FT_Memory  memory = FT_FACE_MEMORY( face );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
      FT_FREE( base );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
      FT_FREE( gdef );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
      FT_FREE( gpos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
      FT_FREE( gsub );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
      FT_FREE( jstf );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
      FT_Memory  memory = FT_FACE_MEMORY( face );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
      FT_FREE( math );                 /* Can't return this as API is frozen */
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
  static
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
  const FT_Service_OTvalidateRec  otvalid_interface =
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
    otv_validate
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
  static
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
  const FT_ServiceDescRec  otvalid_services[] =
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
    { FT_SERVICE_ID_OPENTYPE_VALIDATE, &otvalid_interface },
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    { NULL, NULL }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
  static FT_Pointer
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
  otvalid_get_service( FT_Module    module,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
                       const char*  service_id )
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
    FT_UNUSED( module );
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
    return ft_service_list_lookup( otvalid_services, service_id );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
  FT_CALLBACK_TABLE_DEF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
  const FT_Module_Class  otv_module_class =
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
    0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
    sizeof( FT_ModuleRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
    "otvalid",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
    0x20000L,
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
    0,              /* module-specific interface */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
    (FT_Module_Constructor)0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
    (FT_Module_Destructor) 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
    (FT_Module_Requester)  otvalid_get_service
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
/* END */