misc/libfreetype/src/truetype/ttgxvar.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
/*  ttgxvar.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
/*    TrueType GX Font Variation loader                                    */
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, 2009, 2010 by                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, Werner Lemberg, and George Williams.     */
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
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
  /* Apple documents the `fvar', `gvar', `cvar', and `avar' tables at      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
  /*   http://developer.apple.com/fonts/TTRefMan/RM06/Chap6[fgca]var.html  */
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
  /* The documentation for `fvar' is inconsistent.  At one point it says   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
  /* that `countSizePairs' should be 3, at another point 2.  It should     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  /* be 2.                                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
  /* The documentation for `gvar' is not intelligible; `cvar' refers you   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  /* to `gvar' and is thus also incomprehensible.                          */
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
  /* The documentation for `avar' appears correct, but Apple has no fonts  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /* with an `avar' table, so it is hard to test.                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  /* Many thanks to John Jenkins (at Apple) in figuring this out.          */
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
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
  /* Apple's `kern' table has some references to tuple indices, but as     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  /* there is no indication where these indices are defined, nor how to    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /* interpolate the kerning values (different tuples have different       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /* classes) this issue is ignored.                                       */
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
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
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
#include FT_CONFIG_CONFIG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
#include FT_INTERNAL_SFNT_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
#include FT_TRUETYPE_TAGS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
#include FT_MULTIPLE_MASTERS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
#include "ttpload.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
#include "ttgxvar.h"
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
#include "tterrors.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
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
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
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
#define FT_Stream_FTell( stream )  \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
          ( (stream)->cursor - (stream)->base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
#define FT_Stream_SeekSet( stream, off ) \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
              ( (stream)->cursor = (stream)->base+(off) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
  /*************************************************************************/
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
  /* 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
    72
  /* 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
    73
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
#define FT_COMPONENT  trace_ttgxvar
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
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
  /*************************************************************************/
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
  /*****                       Internal Routines                       *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
  /*****                                                               *****/
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
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
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
  /* The macro ALL_POINTS is used in `ft_var_readpackedpoints'.  It        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
  /* indicates that there is a delta for every point without needing to    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
  /* enumerate all of them.                                                */
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
#define ALL_POINTS  (FT_UShort*)( -1 )
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
#define GX_PT_POINTS_ARE_WORDS      0x80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
#define GX_PT_POINT_RUN_COUNT_MASK  0x7F
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
  /*    ft_var_readpackedpoints                                            */
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
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
  /*    Read a set of points to which the following deltas will apply.     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
  /*    Points are packed with a run length encoding.                      */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  /*    stream    :: The data stream.                                      */
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
  /* <Output>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
  /*    point_cnt :: The number of points read.  A zero value means that   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
  /*                 all points in the glyph will be affected, without     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  /*                 enumerating them individually.                        */
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
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  /*    An array of FT_UShort containing the affected points or the        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  /*    special value ALL_POINTS.                                          */
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
  static FT_UShort*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  ft_var_readpackedpoints( FT_Stream  stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
                           FT_UInt   *point_cnt )
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
    FT_UShort *points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    FT_Int     n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    FT_Int     runcnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    FT_Int     i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    FT_Int     j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    FT_Int     first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    FT_Memory  memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
    FT_Error   error  = TT_Err_Ok;
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
    FT_UNUSED( error );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    *point_cnt = n = FT_GET_BYTE();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    if ( n == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
      return ALL_POINTS;
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
    if ( n & GX_PT_POINTS_ARE_WORDS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
      n = FT_GET_BYTE() | ( ( n & GX_PT_POINT_RUN_COUNT_MASK ) << 8 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    if ( FT_NEW_ARRAY( points, n ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      return NULL;
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
    i = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
    while ( i < n )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
      runcnt = FT_GET_BYTE();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
      if ( runcnt & GX_PT_POINTS_ARE_WORDS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
        runcnt = runcnt & GX_PT_POINT_RUN_COUNT_MASK;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
        first  = points[i++] = FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
        if ( runcnt < 1 || i + runcnt >= n )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
          goto Exit;
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
        /* first point not included in runcount */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
        for ( j = 0; j < runcnt; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
          points[i++] = (FT_UShort)( first += FT_GET_USHORT() );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
      else
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
        first = points[i++] = FT_GET_BYTE();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
        if ( runcnt < 1 || i + runcnt >= n )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
        for ( j = 0; j < runcnt; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
          points[i++] = (FT_UShort)( first += FT_GET_BYTE() );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    return points;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
  enum
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    GX_DT_DELTAS_ARE_ZERO      = 0x80,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    GX_DT_DELTAS_ARE_WORDS     = 0x40,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
    GX_DT_DELTA_RUN_COUNT_MASK = 0x3F
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
  };
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
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
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
  /*    ft_var_readpackeddeltas                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
  /*    Read a set of deltas.  These are packed slightly differently than  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
  /*    points.  In particular there is no overall count.                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
  /*    stream    :: The data stream.                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
  /*    delta_cnt :: The number of to be read.                             */
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
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
  /*    An array of FT_Short containing the deltas for the affected        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
  /*    points.  (This only gets the deltas for one dimension.  It will    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
  /*    generally be called twice, once for x, once for y.  When used in   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
  /*    cvt table, it will only be called once.)                           */
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
  static FT_Short*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
  ft_var_readpackeddeltas( FT_Stream  stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
                           FT_Offset  delta_cnt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    FT_Short  *deltas = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    FT_UInt    runcnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
    FT_Offset  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    FT_UInt    j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
    FT_Memory  memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    FT_Error   error  = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    FT_UNUSED( error );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
    if ( FT_NEW_ARRAY( deltas, delta_cnt ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
      return NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    i = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
    while ( i < delta_cnt )
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
      runcnt = FT_GET_BYTE();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
      if ( runcnt & GX_DT_DELTAS_ARE_ZERO )
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
        /* runcnt zeroes get added */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
        for ( j = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
              j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
              ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
          deltas[i++] = 0;
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
      else if ( runcnt & GX_DT_DELTAS_ARE_WORDS )
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
        /* runcnt shorts from the stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
        for ( j = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
              j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
              ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
          deltas[i++] = FT_GET_SHORT();
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
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
        /* runcnt signed bytes from the stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
        for ( j = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
              j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) && i < delta_cnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
              ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
          deltas[i++] = FT_GET_CHAR();
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
      if ( j <= ( runcnt & GX_DT_DELTA_RUN_COUNT_MASK ) )
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
        /* Bad format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
        FT_FREE( deltas );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
        return NULL;
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
    return deltas;
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
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
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
  /*    ft_var_load_avar                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
  /*    Parse the `avar' table if present.  It need not be, so we return   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
  /*    nothing.                                                           */
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
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
  /*    face :: The font face.                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
  ft_var_load_avar( TT_Face  face )
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
    FT_Stream       stream = FT_FACE_STREAM(face);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    FT_Memory       memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
    GX_Blend        blend  = face->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    GX_AVarSegment  segment;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    FT_Error        error = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    FT_ULong        version;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
    FT_Long         axisCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
    FT_Int          i, j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
    FT_ULong        table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    FT_UNUSED( error );
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
    blend->avar_checked = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    if ( (error = face->goto_table( face, TTAG_avar, stream, &table_len )) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
    if ( FT_FRAME_ENTER( table_len ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
    version   = FT_GET_LONG();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
    axisCount = FT_GET_LONG();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
    if ( version != 0x00010000L                       ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
         axisCount != (FT_Long)blend->mmvar->num_axis )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
      goto Exit;
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
    if ( FT_NEW_ARRAY( blend->avar_segment, axisCount ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    segment = &blend->avar_segment[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
    for ( i = 0; i < axisCount; ++i, ++segment )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
      segment->pairCount = FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
      if ( FT_NEW_ARRAY( segment->correspondence, segment->pairCount ) )
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
        /* Failure.  Free everything we have done so far.  We must do */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
        /* it right now since loading the `avar' table is optional.   */
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
        for ( j = i - 1; j >= 0; --j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
          FT_FREE( blend->avar_segment[j].correspondence );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
        FT_FREE( blend->avar_segment );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
        blend->avar_segment = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
        goto Exit;
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
      for ( j = 0; j < segment->pairCount; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
        segment->correspondence[j].fromCoord =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
          FT_GET_SHORT() << 2;    /* convert to Fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
        segment->correspondence[j].toCoord =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
          FT_GET_SHORT()<<2;    /* convert to Fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
  typedef struct  GX_GVar_Head_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
    FT_Long    version;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
    FT_UShort  axisCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
    FT_UShort  globalCoordCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
    FT_ULong   offsetToCoord;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    FT_UShort  glyphCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    FT_UShort  flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
    FT_ULong   offsetToData;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
  } GX_GVar_Head;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
  /*    ft_var_load_gvar                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
  /*    Parses the `gvar' table if present.  If `fvar' is there, `gvar'    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
  /*    had better be there too.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
  /*    face :: The font face.                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
  ft_var_load_gvar( TT_Face  face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
    FT_Stream     stream = FT_FACE_STREAM(face);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
    FT_Memory     memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
    GX_Blend      blend  = face->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
    FT_UInt       i, j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
    FT_ULong      table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
    FT_ULong      gvar_start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
    FT_ULong      offsetToData;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    GX_GVar_Head  gvar_head;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
    static const FT_Frame_Field  gvar_fields[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
#define FT_STRUCTURE  GX_GVar_Head
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
      FT_FRAME_START( 20 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
        FT_FRAME_LONG  ( version ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
        FT_FRAME_USHORT( axisCount ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
        FT_FRAME_USHORT( globalCoordCount ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
        FT_FRAME_ULONG ( offsetToCoord ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
        FT_FRAME_USHORT( glyphCount ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
        FT_FRAME_USHORT( flags ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
        FT_FRAME_ULONG ( offsetToData ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
      FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
    };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
    if ( (error = face->goto_table( face, TTAG_gvar, stream, &table_len )) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
    gvar_start = FT_STREAM_POS( );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
    if ( FT_STREAM_READ_FIELDS( gvar_fields, &gvar_head ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    blend->tuplecount  = gvar_head.globalCoordCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
    blend->gv_glyphcnt = gvar_head.glyphCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
    offsetToData       = gvar_start + gvar_head.offsetToData;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
    if ( gvar_head.version   != (FT_Long)0x00010000L              ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
         gvar_head.axisCount != (FT_UShort)blend->mmvar->num_axis )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
      error = TT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
    if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
    if ( gvar_head.flags & 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
      /* long offsets (one more offset than glyphs, to mark size of last) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
      if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 4L ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
      for ( i = 0; i <= blend->gv_glyphcnt; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
        blend->glyphoffsets[i] = offsetToData + FT_GET_LONG();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
      FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
      /* short offsets (one more offset than glyphs, to mark size of last) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
      if ( FT_FRAME_ENTER( ( blend->gv_glyphcnt + 1 ) * 2L ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
      for ( i = 0; i <= blend->gv_glyphcnt; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        blend->glyphoffsets[i] = offsetToData + FT_GET_USHORT() * 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
                                              /* XXX: Undocumented: `*2'! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
      FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
    if ( blend->tuplecount != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
      if ( FT_NEW_ARRAY( blend->tuplecoords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
                         gvar_head.axisCount * blend->tuplecount ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
      if ( FT_STREAM_SEEK( gvar_start + gvar_head.offsetToCoord )       ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
           FT_FRAME_ENTER( blend->tuplecount * gvar_head.axisCount * 2L )                   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
      for ( i = 0; i < blend->tuplecount; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
        for ( j = 0 ; j < (FT_UInt)gvar_head.axisCount; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
          blend->tuplecoords[i * gvar_head.axisCount + j] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
            FT_GET_SHORT() << 2;                /* convert to FT_Fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
      FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
  /*    ft_var_apply_tuple                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
  /*    Figure out whether a given tuple (design) applies to the current   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
  /*    blend, and if so, what is the scaling factor.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
  /*    blend           :: The current blend of the font.                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
  /*    tupleIndex      :: A flag saying whether this is an intermediate   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
  /*                       tuple or not.                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
  /*    tuple_coords    :: The coordinates of the tuple in normalized axis */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
  /*                       units.                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
  /*    im_start_coords :: The initial coordinates where this tuple starts */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
  /*                       to apply (for intermediate coordinates).        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
  /*    im_end_coords   :: The final coordinates after which this tuple no */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
  /*                       longer applies (for intermediate coordinates).  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
  /*    An FT_Fixed value containing the scaling factor.                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
  static FT_Fixed
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
  ft_var_apply_tuple( GX_Blend   blend,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
                      FT_UShort  tupleIndex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
                      FT_Fixed*  tuple_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
                      FT_Fixed*  im_start_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
                      FT_Fixed*  im_end_coords )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
    FT_UInt   i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
    FT_Fixed  apply;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
    FT_Fixed  temp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
    apply = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
    for ( i = 0; i < blend->num_axis; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
      if ( tuple_coords[i] == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
        /* It's not clear why (for intermediate tuples) we don't need     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
        /* to check against start/end -- the documentation says we don't. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
        /* Similarly, it's unclear why we don't need to scale along the   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
        /* axis.                                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
      else if ( blend->normalizedcoords[i] == 0                           ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
                ( blend->normalizedcoords[i] < 0 && tuple_coords[i] > 0 ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
                ( blend->normalizedcoords[i] > 0 && tuple_coords[i] < 0 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
        apply = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
      else if ( !( tupleIndex & GX_TI_INTERMEDIATE_TUPLE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
        /* not an intermediate tuple */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
        apply = FT_MulDiv( apply,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
                           blend->normalizedcoords[i] > 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
                             ? blend->normalizedcoords[i]
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
                             : -blend->normalizedcoords[i],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
                           0x10000L );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
      else if ( blend->normalizedcoords[i] <= im_start_coords[i] ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
                blend->normalizedcoords[i] >= im_end_coords[i]   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
        apply = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
      else if ( blend->normalizedcoords[i] < tuple_coords[i] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
        temp = FT_MulDiv( blend->normalizedcoords[i] - im_start_coords[i],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
                          0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
                          tuple_coords[i] - im_start_coords[i]);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
        apply = FT_MulDiv( apply, temp, 0x10000L );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
        temp = FT_MulDiv( im_end_coords[i] - blend->normalizedcoords[i],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
                          0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
                          im_end_coords[i] - tuple_coords[i] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
        apply = FT_MulDiv( apply, temp, 0x10000L );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
    return apply;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
  /*****               MULTIPLE MASTERS SERVICE FUNCTIONS              *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
  typedef struct  GX_FVar_Head_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
    FT_Long    version;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
    FT_UShort  offsetToData;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
    FT_UShort  countSizePairs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
    FT_UShort  axisCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
    FT_UShort  axisSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
    FT_UShort  instanceCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
    FT_UShort  instanceSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
  } GX_FVar_Head;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
  typedef struct  fvar_axis_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
    FT_ULong   axisTag;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
    FT_ULong   minValue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
    FT_ULong   defaultValue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
    FT_ULong   maxValue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
    FT_UShort  flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
    FT_UShort  nameID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
  } GX_FVar_Axis;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
  /*    TT_Get_MM_Var                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
  /*    Check that the font's `fvar' table is valid, parse it, and return  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
  /*    those data.                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
  /*    face   :: The font face.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
  /*              TT_Get_MM_Var initializes the blend structure.           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
  /* <Output>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
  /*    master :: The `fvar' data (must be freed by caller).               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
  TT_Get_MM_Var( TT_Face      face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
                 FT_MM_Var*  *master )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    FT_Stream            stream = face->root.stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
    FT_Memory            memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
    FT_ULong             table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
    FT_Error             error  = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
    FT_ULong             fvar_start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
    FT_Int               i, j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
    FT_MM_Var*           mmvar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
    FT_Fixed*            next_coords;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    FT_String*           next_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
    FT_Var_Axis*         a;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
    FT_Var_Named_Style*  ns;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
    GX_FVar_Head         fvar_head;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
    static const FT_Frame_Field  fvar_fields[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
#define FT_STRUCTURE  GX_FVar_Head
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
      FT_FRAME_START( 16 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
        FT_FRAME_LONG  ( version ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
        FT_FRAME_USHORT( offsetToData ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
        FT_FRAME_USHORT( countSizePairs ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
        FT_FRAME_USHORT( axisCount ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
        FT_FRAME_USHORT( axisSize ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
        FT_FRAME_USHORT( instanceCount ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
        FT_FRAME_USHORT( instanceSize ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
      FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
    };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
    static const FT_Frame_Field  fvaraxis_fields[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
#undef  FT_STRUCTURE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
#define FT_STRUCTURE  GX_FVar_Axis
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
      FT_FRAME_START( 20 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
        FT_FRAME_ULONG ( axisTag ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
        FT_FRAME_ULONG ( minValue ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
        FT_FRAME_ULONG ( defaultValue ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
        FT_FRAME_ULONG ( maxValue ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
        FT_FRAME_USHORT( flags ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
        FT_FRAME_USHORT( nameID ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
      FT_FRAME_END
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
    };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
    if ( face->blend == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
      /* both `fvar' and `gvar' must be present */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
      if ( (error = face->goto_table( face, TTAG_gvar,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
                                      stream, &table_len )) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
      if ( (error = face->goto_table( face, TTAG_fvar,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
                                      stream, &table_len )) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
      fvar_start = FT_STREAM_POS( );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
      if ( FT_STREAM_READ_FIELDS( fvar_fields, &fvar_head ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
      if ( fvar_head.version != (FT_Long)0x00010000L                      ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
           fvar_head.countSizePairs != 2                                  ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
           fvar_head.axisSize != 20                                       ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
           /* axisCount limit implied by 16-bit instanceSize */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
           fvar_head.axisCount > 0x3FFE                                   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
           fvar_head.instanceSize != 4 + 4 * fvar_head.axisCount          ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
           /* instanceCount limit implied by limited range of name IDs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
           fvar_head.instanceCount > 0x7EFF                               ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
           fvar_head.offsetToData + fvar_head.axisCount * 20U +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
             fvar_head.instanceCount * fvar_head.instanceSize > table_len )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
        error = TT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
      if ( FT_NEW( face->blend ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
      /* cannot overflow 32-bit arithmetic because of limits above */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
      face->blend->mmvar_len =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
        sizeof ( FT_MM_Var ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
        fvar_head.axisCount * sizeof ( FT_Var_Axis ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
        fvar_head.instanceCount * sizeof ( FT_Var_Named_Style ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
        fvar_head.instanceCount * fvar_head.axisCount * sizeof ( FT_Fixed ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
        5 * fvar_head.axisCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
      if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
      face->blend->mmvar = mmvar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
      mmvar->num_axis =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
        fvar_head.axisCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
      mmvar->num_designs =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
        (FT_UInt)-1;           /* meaningless in this context; each glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
                               /* may have a different number of designs  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
                               /* (or tuples, as called by Apple)         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
      mmvar->num_namedstyles =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
        fvar_head.instanceCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
      mmvar->axis =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
        (FT_Var_Axis*)&(mmvar[1]);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
      mmvar->namedstyle =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
        (FT_Var_Named_Style*)&(mmvar->axis[fvar_head.axisCount]);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
      next_coords =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
        (FT_Fixed*)&(mmvar->namedstyle[fvar_head.instanceCount]);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
      for ( i = 0; i < fvar_head.instanceCount; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
        mmvar->namedstyle[i].coords  = next_coords;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
        next_coords                 += fvar_head.axisCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
      next_name = (FT_String*)next_coords;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
      for ( i = 0; i < fvar_head.axisCount; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
        mmvar->axis[i].name  = next_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
        next_name           += 5;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
      if ( FT_STREAM_SEEK( fvar_start + fvar_head.offsetToData ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
      a = mmvar->axis;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
      for ( i = 0; i < fvar_head.axisCount; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
        GX_FVar_Axis  axis_rec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
        if ( FT_STREAM_READ_FIELDS( fvaraxis_fields, &axis_rec ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
        a->tag     = axis_rec.axisTag;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
        a->minimum = axis_rec.minValue;     /* A Fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
        a->def     = axis_rec.defaultValue; /* A Fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
        a->maximum = axis_rec.maxValue;     /* A Fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
        a->strid   = axis_rec.nameID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
        a->name[0] = (FT_String)(   a->tag >> 24 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
        a->name[1] = (FT_String)( ( a->tag >> 16 ) & 0xFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
        a->name[2] = (FT_String)( ( a->tag >>  8 ) & 0xFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
        a->name[3] = (FT_String)( ( a->tag       ) & 0xFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
        a->name[4] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
        ++a;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
      ns = mmvar->namedstyle;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
      for ( i = 0; i < fvar_head.instanceCount; ++i, ++ns )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
        if ( FT_FRAME_ENTER( 4L + 4L * fvar_head.axisCount ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
        ns->strid       =    FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
        (void) /* flags = */ FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
        for ( j = 0; j < fvar_head.axisCount; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
          ns->coords[j] = FT_GET_ULONG();     /* A Fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
        FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
    if ( master != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
      FT_UInt  n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
      if ( FT_ALLOC( mmvar, face->blend->mmvar_len ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
      FT_MEM_COPY( mmvar, face->blend->mmvar, face->blend->mmvar_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
      mmvar->axis =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
        (FT_Var_Axis*)&(mmvar[1]);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
      mmvar->namedstyle =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
        (FT_Var_Named_Style*)&(mmvar->axis[mmvar->num_axis]);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
      next_coords =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
        (FT_Fixed*)&(mmvar->namedstyle[mmvar->num_namedstyles]);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
      for ( n = 0; n < mmvar->num_namedstyles; ++n )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
        mmvar->namedstyle[n].coords  = next_coords;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
        next_coords                 += mmvar->num_axis;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
      a = mmvar->axis;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
      next_name = (FT_String*)next_coords;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
      for ( n = 0; n < mmvar->num_axis; ++n )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
        a->name = next_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
        /* standard PostScript names for some standard apple tags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
        if ( a->tag == TTAG_wght )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
          a->name = (char *)"Weight";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
        else if ( a->tag == TTAG_wdth )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
          a->name = (char *)"Width";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
        else if ( a->tag == TTAG_opsz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
          a->name = (char *)"OpticalSize";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
        else if ( a->tag == TTAG_slnt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
          a->name = (char *)"Slant";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
        next_name += 5;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
        ++a;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
      *master = mmvar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
  /*    TT_Set_MM_Blend                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
  /*    Set the blend (normalized) coordinates for this instance of the    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
  /*    font.  Check that the `gvar' table is reasonable and does some     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
  /*    initial preparation.                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
  /*    face       :: The font.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
  /*                  Initialize the blend structure with `gvar' data.     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
  /*    num_coords :: Must be the axis count of the font.                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
  /*    coords     :: An array of num_coords, each between [-1,1].         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
  TT_Set_MM_Blend( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
                   FT_UInt    num_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
                   FT_Fixed*  coords )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
    FT_Error    error = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
    GX_Blend    blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
    FT_MM_Var*  mmvar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
    FT_UInt     i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
    FT_Memory   memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
    enum
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
      mcvt_retain,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
      mcvt_modify,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
      mcvt_load
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
    } manageCvt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
    face->doblend = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
    if ( face->blend == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
      if ( (error = TT_Get_MM_Var( face, NULL)) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
    blend = face->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
    mmvar = blend->mmvar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
    if ( num_coords != mmvar->num_axis )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
      error = TT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
    for ( i = 0; i < num_coords; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
      if ( coords[i] < -0x00010000L || coords[i] > 0x00010000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
        error = TT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
    if ( blend->glyphoffsets == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
      if ( (error = ft_var_load_gvar( face )) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
    if ( blend->normalizedcoords == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
      if ( FT_NEW_ARRAY( blend->normalizedcoords, num_coords ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
      manageCvt = mcvt_modify;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
      /* If we have not set the blend coordinates before this, then the  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
      /* cvt table will still be what we read from the `cvt ' table and  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
      /* we don't need to reload it.  We may need to change it though... */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
      manageCvt = mcvt_retain;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
      for ( i = 0; i < num_coords; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
        if ( blend->normalizedcoords[i] != coords[i] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
          manageCvt = mcvt_load;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
      /* If we don't change the blend coords then we don't need to do  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
      /* anything to the cvt table.  It will be correct.  Otherwise we */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
      /* no longer have the original cvt (it was modified when we set  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
      /* the blend last time), so we must reload and then modify it.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
    blend->num_axis = num_coords;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
    FT_MEM_COPY( blend->normalizedcoords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
                 coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
                 num_coords * sizeof ( FT_Fixed ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
    face->doblend = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
    if ( face->cvt != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   939
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   940
      switch ( manageCvt )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
      case mcvt_load:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
        /* The cvt table has been loaded already; every time we change the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
        /* blend we may need to reload and remodify the cvt table.         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
        FT_FREE( face->cvt );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
        face->cvt = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
        tt_face_load_cvt( face, face->root.stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
      case mcvt_modify:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
        /* The original cvt table is in memory.  All we need to do is */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
        /* apply the `cvar' table (if any).                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
        tt_face_vary_cvt( face, face->root.stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
      case mcvt_retain:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
        /* The cvt table is correct for this set of coordinates. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
  /*    TT_Set_Var_Design                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
  /*    Set the coordinates for the instance, measured in the user         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
  /*    coordinate system.  Parse the `avar' table (if present) to convert */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
  /*    from user to normalized coordinates.                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
  /*    face       :: The font face.                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
  /*                  Initialize the blend struct with `gvar' data.        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
  /*    num_coords :: This must be the axis count of the font.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
  /*    coords     :: A coordinate array with `num_coords' elements.       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
  TT_Set_Var_Design( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
                     FT_UInt    num_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
                     FT_Fixed*  coords )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
    FT_Error        error      = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
    FT_Fixed*       normalized = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
    GX_Blend        blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
    FT_MM_Var*      mmvar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
    FT_UInt         i, j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
    FT_Var_Axis*    a;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
    GX_AVarSegment  av;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
    FT_Memory       memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
    if ( face->blend == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
      if ( (error = TT_Get_MM_Var( face, NULL )) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
    blend = face->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
    mmvar = blend->mmvar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
    if ( num_coords != mmvar->num_axis )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
      error = TT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
    /* Axis normalization is a two stage process.  First we normalize */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
    /* based on the [min,def,max] values for the axis to be [-1,0,1]. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
    /* Then, if there's an `avar' table, we renormalize this range.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
    if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
    a = mmvar->axis;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
    for ( i = 0; i < mmvar->num_axis; ++i, ++a )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
      if ( coords[i] > a->maximum || coords[i] < a->minimum )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
        error = TT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
      if ( coords[i] < a->def )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
        normalized[i] = -FT_MulDiv( coords[i] - a->def,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
                                    0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
                                    a->minimum - a->def );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
      else if ( a->maximum == a->def )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
        normalized[i] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
        normalized[i] = FT_MulDiv( coords[i] - a->def,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
                                   0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
                                   a->maximum - a->def );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
    if ( !blend->avar_checked )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
      ft_var_load_avar( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
    if ( blend->avar_segment != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
      av = blend->avar_segment;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
      for ( i = 0; i < mmvar->num_axis; ++i, ++av )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
        for ( j = 1; j < (FT_UInt)av->pairCount; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
          if ( normalized[i] < av->correspondence[j].fromCoord )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
            normalized[i] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
              FT_MulDiv(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
                FT_MulDiv(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
                  normalized[i] - av->correspondence[j - 1].fromCoord,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
                  0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
                  av->correspondence[j].fromCoord -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
                    av->correspondence[j - 1].fromCoord ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
                av->correspondence[j].toCoord -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
                  av->correspondence[j - 1].toCoord,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
                0x10000L ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
              av->correspondence[j - 1].toCoord;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
    error = TT_Set_MM_Blend( face, num_coords, normalized );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
    FT_FREE( normalized );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
  /*****                     GX VAR PARSING ROUTINES                   *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1092
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
  /*    tt_face_vary_cvt                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
  /*    Modify the loaded cvt table according to the `cvar' table and the  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
  /*    font's blend.                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
  /*    face   :: A handle to the target face object.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
  /*    stream :: A handle to the input stream.                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1111
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
  /*    Most errors are ignored.  It is perfectly valid not to have a      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
  /*    `cvar' table even if there is a `gvar' and `fvar' table.           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1117
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
  tt_face_vary_cvt( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
                    FT_Stream  stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
    FT_Error    error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
    FT_Memory   memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
    FT_ULong    table_start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
    FT_ULong    table_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
    FT_UInt     tupleCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
    FT_ULong    offsetToData;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
    FT_ULong    here;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
    FT_UInt     i, j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
    FT_Fixed*   tuple_coords    = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
    FT_Fixed*   im_start_coords = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
    FT_Fixed*   im_end_coords   = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
    GX_Blend    blend           = face->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
    FT_UInt     point_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
    FT_UShort*  localpoints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
    FT_Short*   deltas;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
    FT_TRACE2(( "CVAR " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1139
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1140
    if ( blend == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
      FT_TRACE2(( "tt_face_vary_cvt: no blend specified\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
      error = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
    if ( face->cvt == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
      FT_TRACE2(( "tt_face_vary_cvt: no `cvt ' table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
      error = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1155
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1156
    error = face->goto_table( face, TTAG_cvar, stream, &table_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
      FT_TRACE2(( "is missing\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1161
      error = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1163
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1164
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1165
    if ( FT_FRAME_ENTER( table_len ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1166
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
      error = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1168
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1169
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1170
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1171
    table_start = FT_Stream_FTell( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1172
    if ( FT_GET_LONG() != 0x00010000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1173
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
      FT_TRACE2(( "bad table version\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1175
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1176
      error = TT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
      goto FExit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1178
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
    if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis )    ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
         FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
         FT_NEW_ARRAY( im_end_coords, blend->num_axis )   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
      goto FExit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
    tupleCount   = FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
    offsetToData = table_start + FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
    /* The documentation implies there are flags packed into the        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
    /* tuplecount, but John Jenkins says that shared points don't apply */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
    /* to `cvar', and no other flags are defined.                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
    for ( i = 0; i < ( tupleCount & 0xFFF ); ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1193
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1194
      FT_UInt   tupleDataSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
      FT_UInt   tupleIndex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1196
      FT_Fixed  apply;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1197
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1198
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1199
      tupleDataSize = FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1200
      tupleIndex    = FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1202
      /* There is no provision here for a global tuple coordinate section, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
      /* so John says.  There are no tuple indices, just embedded tuples.  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1205
      if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1207
        for ( j = 0; j < blend->num_axis; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1208
          tuple_coords[j] = FT_GET_SHORT() << 2; /* convert from        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1209
                                                 /* short frac to fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1210
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1211
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1212
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1213
        /* skip this tuple; it makes no sense */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1215
        if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1216
          for ( j = 0; j < 2 * blend->num_axis; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1217
            (void)FT_GET_SHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1218
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1219
        offsetToData += tupleDataSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1220
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1221
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1223
      if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1224
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1225
        for ( j = 0; j < blend->num_axis; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1226
          im_start_coords[j] = FT_GET_SHORT() << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1227
        for ( j = 0; j < blend->num_axis; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1228
          im_end_coords[j] = FT_GET_SHORT() << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1229
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1231
      apply = ft_var_apply_tuple( blend,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1232
                                  (FT_UShort)tupleIndex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1233
                                  tuple_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1234
                                  im_start_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1235
                                  im_end_coords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1236
      if ( /* tuple isn't active for our blend */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1237
           apply == 0                                    ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1238
           /* global points not allowed,           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1239
           /* if they aren't local, makes no sense */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1240
           !( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1241
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1242
        offsetToData += tupleDataSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1243
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1244
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1246
      here = FT_Stream_FTell( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1247
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1248
      FT_Stream_SeekSet( stream, offsetToData );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1249
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1250
      localpoints = ft_var_readpackedpoints( stream, &point_count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1251
      deltas      = ft_var_readpackeddeltas( stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1252
                                             point_count == 0 ? face->cvt_size
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1253
                                                              : point_count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1254
      if ( localpoints == NULL || deltas == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1255
        /* failure, ignore it */;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1257
      else if ( localpoints == ALL_POINTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1258
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1259
        /* this means that there are deltas for every entry in cvt */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1260
        for ( j = 0; j < face->cvt_size; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1261
          face->cvt[j] = (FT_Short)( face->cvt[j] +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1262
                                     FT_MulFix( deltas[j], apply ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1263
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1264
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1265
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1266
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1267
        for ( j = 0; j < point_count; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1268
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1269
          int  pindex = localpoints[j];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1271
          face->cvt[pindex] = (FT_Short)( face->cvt[pindex] +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1272
                                          FT_MulFix( deltas[j], apply ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1273
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1274
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1276
      if ( localpoints != ALL_POINTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1277
        FT_FREE( localpoints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1278
      FT_FREE( deltas );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1279
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1280
      offsetToData += tupleDataSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1282
      FT_Stream_SeekSet( stream, here );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1283
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1285
  FExit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1286
    FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1287
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1288
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1289
    FT_FREE( tuple_coords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1290
    FT_FREE( im_start_coords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1291
    FT_FREE( im_end_coords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1293
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1294
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1297
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1298
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1299
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1300
  /*    TT_Vary_Get_Glyph_Deltas                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1301
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1302
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1303
  /*    Load the appropriate deltas for the current glyph.                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1304
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1305
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1306
  /*    face        :: A handle to the target face object.                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1307
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1308
  /*    glyph_index :: The index of the glyph being modified.              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1309
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1310
  /*    n_points    :: The number of the points in the glyph, including    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1311
  /*                   phantom points.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1312
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1313
  /* <Output>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1314
  /*    deltas      :: The array of points to change.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1315
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1316
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1317
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1318
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1319
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1320
  TT_Vary_Get_Glyph_Deltas( TT_Face      face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1321
                            FT_UInt      glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1322
                            FT_Vector*  *deltas,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1323
                            FT_UInt      n_points )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1324
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1325
    FT_Stream   stream = face->root.stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1326
    FT_Memory   memory = stream->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1327
    GX_Blend    blend  = face->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1328
    FT_Vector*  delta_xy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1329
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1330
    FT_Error    error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1331
    FT_ULong    glyph_start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1332
    FT_UInt     tupleCount;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1333
    FT_ULong    offsetToData;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1334
    FT_ULong    here;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1335
    FT_UInt     i, j;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1336
    FT_Fixed*   tuple_coords    = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1337
    FT_Fixed*   im_start_coords = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1338
    FT_Fixed*   im_end_coords   = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1339
    FT_UInt     point_count, spoint_count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1340
    FT_UShort*  sharedpoints = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1341
    FT_UShort*  localpoints  = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1342
    FT_UShort*  points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1343
    FT_Short    *deltas_x, *deltas_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1345
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1346
    if ( !face->doblend || blend == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1347
      return TT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1348
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1349
    /* to be freed by the caller */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1350
    if ( FT_NEW_ARRAY( delta_xy, n_points ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1351
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1352
    *deltas = delta_xy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1353
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1354
    if ( glyph_index >= blend->gv_glyphcnt      ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1355
         blend->glyphoffsets[glyph_index] ==
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1356
           blend->glyphoffsets[glyph_index + 1] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1357
      return TT_Err_Ok;               /* no variation data for this glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1358
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1359
    if ( FT_STREAM_SEEK( blend->glyphoffsets[glyph_index] )   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1360
         FT_FRAME_ENTER( blend->glyphoffsets[glyph_index + 1] -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1361
                           blend->glyphoffsets[glyph_index] ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1362
      goto Fail1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1363
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1364
    glyph_start = FT_Stream_FTell( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1365
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1366
    /* each set of glyph variation data is formatted similarly to `cvar' */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1367
    /* (except we get shared points and global tuples)                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1368
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1369
    if ( FT_NEW_ARRAY( tuple_coords, blend->num_axis )    ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1370
         FT_NEW_ARRAY( im_start_coords, blend->num_axis ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1371
         FT_NEW_ARRAY( im_end_coords, blend->num_axis )   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1372
      goto Fail2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1373
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1374
    tupleCount   = FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1375
    offsetToData = glyph_start + FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1376
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1377
    if ( tupleCount & GX_TC_TUPLES_SHARE_POINT_NUMBERS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1378
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1379
      here = FT_Stream_FTell( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1380
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1381
      FT_Stream_SeekSet( stream, offsetToData );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1382
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1383
      sharedpoints = ft_var_readpackedpoints( stream, &spoint_count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1384
      offsetToData = FT_Stream_FTell( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1385
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1386
      FT_Stream_SeekSet( stream, here );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1387
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1388
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1389
    for ( i = 0; i < ( tupleCount & GX_TC_TUPLE_COUNT_MASK ); ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1390
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1391
      FT_UInt   tupleDataSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1392
      FT_UInt   tupleIndex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1393
      FT_Fixed  apply;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1394
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1396
      tupleDataSize = FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1397
      tupleIndex    = FT_GET_USHORT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1399
      if ( tupleIndex & GX_TI_EMBEDDED_TUPLE_COORD )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1400
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1401
        for ( j = 0; j < blend->num_axis; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1402
          tuple_coords[j] = FT_GET_SHORT() << 2;  /* convert from        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1403
                                                  /* short frac to fixed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1404
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1405
      else if ( ( tupleIndex & GX_TI_TUPLE_INDEX_MASK ) >= blend->tuplecount )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1406
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1407
        error = TT_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1408
        goto Fail3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1409
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1410
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1411
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1412
        FT_MEM_COPY(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1413
          tuple_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1414
          &blend->tuplecoords[(tupleIndex & 0xFFF) * blend->num_axis],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1415
          blend->num_axis * sizeof ( FT_Fixed ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1416
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1418
      if ( tupleIndex & GX_TI_INTERMEDIATE_TUPLE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1419
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1420
        for ( j = 0; j < blend->num_axis; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1421
          im_start_coords[j] = FT_GET_SHORT() << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1422
        for ( j = 0; j < blend->num_axis; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1423
          im_end_coords[j] = FT_GET_SHORT() << 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1424
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1425
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1426
      apply = ft_var_apply_tuple( blend,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1427
                                  (FT_UShort)tupleIndex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1428
                                  tuple_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1429
                                  im_start_coords,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1430
                                  im_end_coords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1431
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1432
      if ( apply == 0 )              /* tuple isn't active for our blend */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1433
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1434
        offsetToData += tupleDataSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1435
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1436
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1437
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1438
      here = FT_Stream_FTell( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1440
      if ( tupleIndex & GX_TI_PRIVATE_POINT_NUMBERS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1441
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1442
        FT_Stream_SeekSet( stream, offsetToData );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1444
        localpoints = ft_var_readpackedpoints( stream, &point_count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1445
        points      = localpoints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1446
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1447
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1448
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1449
        points      = sharedpoints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1450
        point_count = spoint_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1451
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1452
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1453
      deltas_x = ft_var_readpackeddeltas( stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1454
                                          point_count == 0 ? n_points
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1455
                                                           : point_count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1456
      deltas_y = ft_var_readpackeddeltas( stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1457
                                          point_count == 0 ? n_points
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1458
                                                           : point_count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1459
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1460
      if ( points == NULL || deltas_y == NULL || deltas_x == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1461
        ; /* failure, ignore it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1462
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1463
      else if ( points == ALL_POINTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1464
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1465
        /* this means that there are deltas for every point in the glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1466
        for ( j = 0; j < n_points; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1467
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1468
          delta_xy[j].x += FT_MulFix( deltas_x[j], apply );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1469
          delta_xy[j].y += FT_MulFix( deltas_y[j], apply );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1470
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1471
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1472
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1473
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1474
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1475
        for ( j = 0; j < point_count; ++j )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1476
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1477
          delta_xy[localpoints[j]].x += FT_MulFix( deltas_x[j], apply );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1478
          delta_xy[localpoints[j]].y += FT_MulFix( deltas_y[j], apply );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1479
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1480
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1481
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1482
      if ( localpoints != ALL_POINTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1483
        FT_FREE( localpoints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1484
      FT_FREE( deltas_x );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1485
      FT_FREE( deltas_y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1487
      offsetToData += tupleDataSize;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1488
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1489
      FT_Stream_SeekSet( stream, here );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1490
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1491
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1492
  Fail3:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1493
    FT_FREE( tuple_coords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1494
    FT_FREE( im_start_coords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1495
    FT_FREE( im_end_coords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1496
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1497
  Fail2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1498
    FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1499
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1500
  Fail1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1501
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1502
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1503
      FT_FREE( delta_xy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1504
      *deltas = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1505
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1507
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1508
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1509
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1510
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1511
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1512
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1513
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1514
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1515
  /*    tt_done_blend                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1516
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1517
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1518
  /*    Frees the blend internal data structure.                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1519
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1520
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1521
  tt_done_blend( FT_Memory  memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1522
                 GX_Blend   blend )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1523
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1524
    if ( blend != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1525
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1526
      FT_UInt  i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1529
      FT_FREE( blend->normalizedcoords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1530
      FT_FREE( blend->mmvar );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1531
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1532
      if ( blend->avar_segment != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1533
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1534
        for ( i = 0; i < blend->num_axis; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1535
          FT_FREE( blend->avar_segment[i].correspondence );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1536
        FT_FREE( blend->avar_segment );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1537
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1538
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1539
      FT_FREE( blend->tuplecoords );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1540
      FT_FREE( blend->glyphoffsets );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1541
      FT_FREE( blend );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1542
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1543
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1545
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1546
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1547
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1548
/* END */