misc/libfreetype/src/autofit/afhints.c
author unc0rr
Wed, 05 Dec 2012 23:51:04 +0400
branchflibqtfrontend
changeset 8230 bd4b8f9488a4
parent 5172 88f2e05288ba
permissions -rw-r--r--
Show who's in game to spectators
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
/*  afhints.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
/*    Auto-fitter hinting routines (body).                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2003-2007, 2009-2011 by                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include "afhints.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include "aferrors.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_INTERNAL_CALC_H
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
  /* Get new segment for given axis. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
  af_axis_hints_new_segment( AF_AxisHints  axis,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
                             FT_Memory     memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
                             AF_Segment   *asegment )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
    FT_Error    error   = AF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
    AF_Segment  segment = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
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
    if ( axis->num_segments >= axis->max_segments )
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
      FT_Int  old_max = axis->max_segments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
      FT_Int  new_max = old_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
      FT_Int  big_max = (FT_Int)( FT_INT_MAX / sizeof ( *segment ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
      if ( old_max >= big_max )
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
        error = AF_Err_Out_Of_Memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
      new_max += ( new_max >> 2 ) + 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
      if ( new_max < old_max || new_max > big_max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
        new_max = big_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
      if ( FT_RENEW_ARRAY( axis->segments, old_max, new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
      axis->max_segments = new_max;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    segment = axis->segments + axis->num_segments++;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
    *asegment = segment;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
  /* Get new edge for given axis, direction, and position. */
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
  FT_LOCAL( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
  af_axis_hints_new_edge( AF_AxisHints  axis,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
                          FT_Int        fpos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
                          AF_Direction  dir,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
                          FT_Memory     memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
                          AF_Edge      *aedge )
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
    FT_Error  error = AF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    AF_Edge   edge  = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    AF_Edge   edges;
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
    if ( axis->num_edges >= axis->max_edges )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
      FT_Int  old_max = axis->max_edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
      FT_Int  new_max = old_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
      FT_Int  big_max = (FT_Int)( FT_INT_MAX / sizeof ( *edge ) );
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
      if ( old_max >= big_max )
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
        error = AF_Err_Out_Of_Memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
      new_max += ( new_max >> 2 ) + 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
      if ( new_max < old_max || new_max > big_max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
        new_max = big_max;
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
      if ( FT_RENEW_ARRAY( axis->edges, old_max, new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
        goto Exit;
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
      axis->max_edges = new_max;
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
    edges = axis->edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    edge  = edges + axis->num_edges;
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
    while ( edge > edges )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
      if ( edge[-1].fpos < fpos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
      /* we want the edge with same position and minor direction */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
      /* to appear before those in the major one in the list     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
      if ( edge[-1].fpos == fpos && dir == axis->major_dir )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
      edge[0] = edge[-1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
      edge--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    axis->num_edges++;
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
    FT_ZERO( edge );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
    edge->fpos = (FT_Short)fpos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    edge->dir  = (FT_Char)dir;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    *aedge = edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
#ifdef FT_DEBUG_AUTOFIT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
#include FT_CONFIG_STANDARD_LIBRARY_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  static const char*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
  af_dir_str( AF_Direction  dir )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    const char*  result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    switch ( dir )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    case AF_DIR_UP:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
      result = "up";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    case AF_DIR_DOWN:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      result = "down";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    case AF_DIR_LEFT:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
      result = "left";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    case AF_DIR_RIGHT:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
      result = "right";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
      result = "none";
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
    return result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
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
#define AF_INDEX_NUM( ptr, base )  ( (ptr) ? ( (ptr) - (base) ) : -1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
#ifdef __cplusplus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
  extern "C" {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
  void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
  af_glyph_hints_dump_points( AF_GlyphHints  hints )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    AF_Point  points = hints->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    AF_Point  limit  = points + hints->num_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    AF_Point  point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    printf( "Table of points:\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    printf(   "  [ index |  xorg |  yorg | xscale | yscale"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
              " |  xfit |  yfit |  flags ]\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    for ( point = points; point < limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
      printf( "  [ %5d | %5d | %5d | %6.2f | %6.2f"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
              " | %5.2f | %5.2f | %c%c%c%c%c%c ]\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
              point - points,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
              point->fx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
              point->fy,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
              point->ox / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
              point->oy / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
              point->x / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
              point->y / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
              ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) ? 'w' : ' ',
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
              ( point->flags & AF_FLAG_INFLECTION )         ? 'i' : ' ',
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
              ( point->flags & AF_FLAG_EXTREMA_X )          ? '<' : ' ',
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
              ( point->flags & AF_FLAG_EXTREMA_Y )          ? 'v' : ' ',
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
              ( point->flags & AF_FLAG_ROUND_X )            ? '(' : ' ',
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
              ( point->flags & AF_FLAG_ROUND_Y )            ? 'u' : ' ');
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    printf( "\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
#ifdef __cplusplus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
  static const char*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
  af_edge_flags_to_string( AF_Edge_Flags  flags )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    static char  temp[32];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    int          pos = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    if ( flags & AF_EDGE_ROUND )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
      ft_memcpy( temp + pos, "round", 5 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
      pos += 5;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    if ( flags & AF_EDGE_SERIF )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
      if ( pos > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
        temp[pos++] = ' ';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
      ft_memcpy( temp + pos, "serif", 5 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
      pos += 5;
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
    if ( pos == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
      return "normal";
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
    temp[pos] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    return temp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
  /* Dump the array of linked segments. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
#ifdef __cplusplus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
  extern "C" {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
  void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
  af_glyph_hints_dump_segments( AF_GlyphHints  hints )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    FT_Int  dimension;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    for ( dimension = 1; dimension >= 0; dimension-- )
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
      AF_AxisHints  axis     = &hints->axis[dimension];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
      AF_Segment    segments = axis->segments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
      AF_Segment    limit    = segments + axis->num_segments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
      AF_Segment    seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
      printf ( "Table of %s segments:\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
               dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
      printf ( "  [ index |  pos  |  dir  | link | serif |"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
               " height | extra |    flags    ]\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
      for ( seg = segments; seg < limit; seg++ )
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
        printf ( "  [ %5d | %5.2g | %5s | %4d | %5d | %6d | %5d | %11s ]\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
                 seg - segments,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
                 dimension == AF_DIMENSION_HORZ ? (int)seg->first->ox / 64.0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
                                                : (int)seg->first->oy / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
                 af_dir_str( (AF_Direction)seg->dir ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
                 AF_INDEX_NUM( seg->link, segments ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
                 AF_INDEX_NUM( seg->serif, segments ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
                 seg->height,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
                 seg->height - ( seg->max_coord - seg->min_coord ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
                 af_edge_flags_to_string( seg->flags ) );
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
      printf( "\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
#ifdef __cplusplus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
#endif
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
  /* Dump the array of linked edges. */
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
#ifdef __cplusplus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
  extern "C" {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
  void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
  af_glyph_hints_dump_edges( AF_GlyphHints  hints )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
    FT_Int  dimension;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
    for ( dimension = 1; dimension >= 0; dimension-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
      AF_AxisHints  axis  = &hints->axis[dimension];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
      AF_Edge       edges = axis->edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
      AF_Edge       limit = edges + axis->num_edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
      AF_Edge       edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
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
      /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
       *  note: AF_DIMENSION_HORZ corresponds to _vertical_ edges
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
       *        since they have a constant X coordinate.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
      printf ( "Table of %s edges:\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
               dimension == AF_DIMENSION_HORZ ? "vertical" : "horizontal" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
      printf ( "  [ index |  pos  |  dir  | link |"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
               " serif | blue | opos  |  pos  |    flags    ]\n" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
      for ( edge = edges; edge < limit; edge++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
        printf ( "  [ %5d | %5.2g | %5s | %4d |"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
                 " %5d |   %c  | %5.2f | %5.2f | %11s ]\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
                 edge - edges,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
                 (int)edge->opos / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
                 af_dir_str( (AF_Direction)edge->dir ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
                 AF_INDEX_NUM( edge->link, edges ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
                 AF_INDEX_NUM( edge->serif, edges ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
                 edge->blue_edge ? 'y' : 'n',
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
                 edge->opos / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
                 edge->pos / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
                 af_edge_flags_to_string( edge->flags ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
      printf( "\n" );
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
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
#ifdef __cplusplus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
#endif
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
#else /* !FT_DEBUG_AUTOFIT */
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
  /* these empty stubs are only used to link the `ftgrid' test program */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
  /* if debugging is disabled                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
#ifdef __cplusplus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
  extern "C" {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
#endif
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
  void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
  af_glyph_hints_dump_points( AF_GlyphHints  hints )
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
    FT_UNUSED( hints );
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
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
  void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
  af_glyph_hints_dump_segments( AF_GlyphHints  hints )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
    FT_UNUSED( hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
  void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
  af_glyph_hints_dump_edges( AF_GlyphHints  hints )
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
    FT_UNUSED( hints );
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
#ifdef __cplusplus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
#endif /* !FT_DEBUG_AUTOFIT */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
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
  /* Compute the direction value of a given vector. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
  FT_LOCAL_DEF( AF_Direction )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
  af_direction_compute( FT_Pos  dx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
                        FT_Pos  dy )
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
    FT_Pos        ll, ss;  /* long and short arm lengths */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    AF_Direction  dir;     /* candidate direction        */
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
    if ( dy >= dx )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
      if ( dy >= -dx )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
        dir = AF_DIR_UP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
        ll  = dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
        ss  = dx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
        dir = AF_DIR_LEFT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
        ll  = -dx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
        ss  = dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
      }
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
    else /* dy < dx */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
      if ( dy >= -dx )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
        dir = AF_DIR_RIGHT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
        ll  = dx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
        ss  = dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
      else
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
        dir = AF_DIR_DOWN;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
        ll  = dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
        ss  = dx;
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
    /* return no direction if arm lengths differ too much */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
    /* (value 14 is heuristic)                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    ss *= 14;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
    if ( FT_ABS( ll ) <= FT_ABS( ss ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
      dir = AF_DIR_NONE;
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
    return dir;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
  af_glyph_hints_init( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
                       FT_Memory      memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
    FT_ZERO( hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
    hints->memory = memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
  af_glyph_hints_done( AF_GlyphHints  hints )
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
    if ( hints && hints->memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
      FT_Memory  memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
      int        dim;
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
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
       *  note that we don't need to free the segment and edge
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
       *  buffers since they are really within the hints->points array
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
      for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        AF_AxisHints  axis = &hints->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
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
        axis->num_segments = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
        axis->max_segments = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
        FT_FREE( axis->segments );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
        axis->num_edges = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
        axis->max_edges = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
        FT_FREE( axis->edges );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
      }
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
      FT_FREE( hints->contours );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
      hints->max_contours = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
      hints->num_contours = 0;
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
      FT_FREE( hints->points );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
      hints->num_points = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
      hints->max_points = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
      hints->memory = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
    }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
  /* Reset metrics. */
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
  af_glyph_hints_rescale( AF_GlyphHints     hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
                          AF_ScriptMetrics  metrics )
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
    hints->metrics      = metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
    hints->scaler_flags = metrics->scaler.flags;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
  /* Recompute all AF_Point in AF_GlyphHints from the definitions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
  /* in a source outline.                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
  af_glyph_hints_reload( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
                         FT_Outline*    outline )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
    FT_Error   error   = AF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
    AF_Point   points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
    FT_UInt    old_max, new_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
    FT_Fixed   x_scale = hints->x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
    FT_Fixed   y_scale = hints->y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
    FT_Pos     x_delta = hints->x_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
    FT_Pos     y_delta = hints->y_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
    FT_Memory  memory  = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
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
    hints->num_points   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
    hints->num_contours = 0;
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
    hints->axis[0].num_segments = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
    hints->axis[0].num_edges    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
    hints->axis[1].num_segments = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
    hints->axis[1].num_edges    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
    /* first of all, reallocate the contours array if necessary */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
    new_max = (FT_UInt)outline->n_contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
    old_max = hints->max_contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
    if ( new_max > old_max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
      new_max = ( new_max + 3 ) & ~3; /* round up to a multiple of 4 */
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
      if ( FT_RENEW_ARRAY( hints->contours, old_max, new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
        goto Exit;
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
      hints->max_contours = new_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
     *  then reallocate the points arrays if necessary --
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
     *  note that we reserve two additional point positions, used to
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
     *  hint metrics appropriately
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
    new_max = (FT_UInt)( outline->n_points + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
    old_max = hints->max_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
    if ( new_max > old_max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
      new_max = ( new_max + 2 + 7 ) & ~7; /* round up to a multiple of 8 */
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
      if ( FT_RENEW_ARRAY( hints->points, old_max, new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
      hints->max_points = new_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
    hints->num_points   = outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
    hints->num_contours = outline->n_contours;
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
    /* We can't rely on the value of `FT_Outline.flags' to know the fill   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
    /* direction used for a glyph, given that some fonts are broken (e.g., */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
    /* the Arphic ones).  We thus recompute it each time we need to.       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
    /*                                                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
    hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_UP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
    hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_LEFT;
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
    if ( FT_Outline_Get_Orientation( outline ) == FT_ORIENTATION_POSTSCRIPT )
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
      hints->axis[AF_DIMENSION_HORZ].major_dir = AF_DIR_DOWN;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
      hints->axis[AF_DIMENSION_VERT].major_dir = AF_DIR_RIGHT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
    hints->x_scale = x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
    hints->y_scale = y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    hints->x_delta = x_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
    hints->y_delta = y_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
    hints->xmin_delta = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
    hints->xmax_delta = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
    points = hints->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
    if ( hints->num_points == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
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
      AF_Point  point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
      AF_Point  point_limit = points + hints->num_points;
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
      /* compute coordinates & Bezier flags, next and prev */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
        FT_Vector*  vec           = outline->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
        char*       tag           = outline->tags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
        AF_Point    end           = points + outline->contours[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
        AF_Point    prev          = end;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
        FT_Int      contour_index = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
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
        for ( point = points; point < point_limit; point++, vec++, tag++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
          point->fx = (FT_Short)vec->x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
          point->fy = (FT_Short)vec->y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
          point->ox = point->x = FT_MulFix( vec->x, x_scale ) + x_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
          point->oy = point->y = FT_MulFix( vec->y, y_scale ) + y_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
          switch ( FT_CURVE_TAG( *tag ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
          case FT_CURVE_TAG_CONIC:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
            point->flags = AF_FLAG_CONIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
          case FT_CURVE_TAG_CUBIC:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
            point->flags = AF_FLAG_CUBIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
          default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
            point->flags = AF_FLAG_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
          point->prev = prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
          prev->next  = point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
          prev        = point;
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
          if ( point == end )
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
            if ( ++contour_index < outline->n_contours )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
              end  = points + outline->contours[contour_index];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
              prev = end;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
          }
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
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
      /* set up the contours array */
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
        AF_Point*  contour       = hints->contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
        AF_Point*  contour_limit = contour + hints->num_contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
        short*     end           = outline->contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
        short      idx           = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
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
        for ( ; contour < contour_limit; contour++, end++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
          contour[0] = points + idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
          idx        = (short)( end[0] + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
      /* compute directions of in & out vectors */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
        AF_Point      first  = points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
        AF_Point      prev   = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
        FT_Pos        in_x   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
        FT_Pos        in_y   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
        AF_Direction  in_dir = AF_DIR_NONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
        for ( point = points; point < point_limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
          AF_Point  next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
          FT_Pos    out_x, out_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
          if ( point == first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
            prev   = first->prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
            in_x   = first->fx - prev->fx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
            in_y   = first->fy - prev->fy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
            in_dir = af_direction_compute( in_x, in_y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
            first  = prev + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
          point->in_dir = (FT_Char)in_dir;
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
          next  = point->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
          out_x = next->fx - point->fx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
          out_y = next->fy - point->fy;
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
          in_dir         = af_direction_compute( out_x, out_y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
          point->out_dir = (FT_Char)in_dir;
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
          /* check for weak points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
          if ( point->flags & ( AF_FLAG_CONIC | AF_FLAG_CUBIC ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
          Is_Weak_Point:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
            point->flags |= AF_FLAG_WEAK_INTERPOLATION;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
          else if ( point->out_dir == point->in_dir )
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
            if ( point->out_dir != AF_DIR_NONE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
              goto Is_Weak_Point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
            if ( ft_corner_is_flat( in_x, in_y, out_x, out_y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
              goto Is_Weak_Point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
          else if ( point->in_dir == -point->out_dir )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
            goto Is_Weak_Point;
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
          in_x = out_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
          in_y = out_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
          prev = point;
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
      }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
  /* Store the hinted outline in an FT_Outline structure. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
  af_glyph_hints_save( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
                       FT_Outline*    outline )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
    AF_Point    point = hints->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
    AF_Point    limit = point + hints->num_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
    FT_Vector*  vec   = outline->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
    char*       tag   = outline->tags;
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
    for ( ; point < limit; point++, vec++, tag++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
      vec->x = point->x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
      vec->y = point->y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
      if ( point->flags & AF_FLAG_CONIC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
        tag[0] = FT_CURVE_TAG_CONIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
      else if ( point->flags & AF_FLAG_CUBIC )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
        tag[0] = FT_CURVE_TAG_CUBIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
        tag[0] = FT_CURVE_TAG_ON;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
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
  /****************************************************************
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
   *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
   *                     EDGE POINT GRID-FITTING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
   *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
   ****************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
  /* Align all points of an edge to the same coordinate value, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
  /* either horizontally or vertically.                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
  af_glyph_hints_align_edge_points( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
                                    AF_Dimension   dim )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    AF_AxisHints  axis          = & hints->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
    AF_Segment    segments      = axis->segments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
    AF_Segment    segment_limit = segments + axis->num_segments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
    AF_Segment    seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
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
    if ( dim == AF_DIMENSION_HORZ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
      for ( seg = segments; seg < segment_limit; seg++ )
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
        AF_Edge   edge = seg->edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
        AF_Point  point, first, last;
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 ( edge == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
          continue;
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
        first = seg->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
        last  = seg->last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
        point = first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
        for (;;)
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
          point->x      = edge->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
          point->flags |= AF_FLAG_TOUCH_X;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
          if ( point == last )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
          point = point->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
        }
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
      for ( seg = segments; seg < segment_limit; seg++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
        AF_Edge   edge = seg->edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
        AF_Point  point, first, last;
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
        if ( edge == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
          continue;
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
        first = seg->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
        last  = seg->last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
        point = first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
        for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
          point->y      = edge->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
          point->flags |= AF_FLAG_TOUCH_Y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
          if ( point == last )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
            break;
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
          point = point->next;
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
      }
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
  }
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
  /****************************************************************
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
   *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
   *                    STRONG POINT INTERPOLATION
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
   ****************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
  /* Hint the strong points -- this is equivalent to the TrueType `IP' */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
  /* hinting instruction.                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
  af_glyph_hints_align_strong_points( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
                                      AF_Dimension   dim )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
    AF_Point      points      = hints->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
    AF_Point      point_limit = points + hints->num_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
    AF_AxisHints  axis        = &hints->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
    AF_Edge       edges       = axis->edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
    AF_Edge       edge_limit  = edges + axis->num_edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
    AF_Flags      touch_flag;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
    if ( dim == AF_DIMENSION_HORZ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
      touch_flag = AF_FLAG_TOUCH_X;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
      touch_flag  = AF_FLAG_TOUCH_Y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
    if ( edges < edge_limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
      AF_Point  point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
      AF_Edge   edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
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
      for ( point = points; point < point_limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
        FT_Pos  u, ou, fu;  /* point position */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
        FT_Pos  delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
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
        if ( point->flags & touch_flag )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
        /* if this point is candidate to weak interpolation, we       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
        /* interpolate it after all strong points have been processed */
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
        if (  ( point->flags & AF_FLAG_WEAK_INTERPOLATION ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
             !( point->flags & AF_FLAG_INFLECTION )         )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
        if ( dim == AF_DIMENSION_VERT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
          u  = point->fy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
          ou = point->oy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
          u  = point->fx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
          ou = point->ox;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
        fu = u;
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
        /* is the point before the first edge? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
        edge  = edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
        delta = edge->fpos - u;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
        if ( delta >= 0 )
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
          u = edge->pos - ( edge->opos - ou );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
          goto Store_Point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
        /* is the point after the last edge? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
        edge  = edge_limit - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
        delta = u - edge->fpos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
        if ( delta >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
          u = edge->pos + ( ou - edge->opos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
          goto Store_Point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
        }
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
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
          FT_PtrDist  min, max, mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
          FT_Pos      fpos;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
          /* find enclosing edges */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
          min = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
          max = edge_limit - edges;
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 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
          /* for a small number of edges, a linear search is better */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
          if ( max <= 8 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
            FT_PtrDist  nn;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
            for ( nn = 0; nn < max; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
              if ( edges[nn].fpos >= u )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
                break;
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
            if ( edges[nn].fpos == u )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
              u = edges[nn].pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
              goto Store_Point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
            min = nn;
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
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
          while ( min < max )
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
            mid  = ( max + min ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
            edge = edges + mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
            fpos = edge->fpos;
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 ( u < fpos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
              max = mid;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
            else if ( u > fpos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
              min = mid + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
              /* we are on the edge */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
              u = edge->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
              goto Store_Point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
            }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
          /* point is not on an edge */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
            AF_Edge  before = edges + min - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
            AF_Edge  after  = edges + min + 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
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
            /* assert( before && after && before != after ) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
            if ( before->scale == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
              before->scale = FT_DivFix( after->pos - before->pos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
                                         after->fpos - before->fpos );
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
            u = before->pos + FT_MulFix( fu - before->fpos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
                                         before->scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
        }
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
      Store_Point:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
        /* save the point position */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
        if ( dim == AF_DIMENSION_HORZ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
          point->x = u;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
          point->y = u;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
        point->flags |= touch_flag;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
      }
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
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
  /****************************************************************
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
   *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
   *                    WEAK POINT INTERPOLATION
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
   *
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
  /* Shift the original coordinates of all points between `p1' and */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
  /* `p2' to get hinted coordinates, using the same difference as  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
  /* given by `ref'.                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
  af_iup_shift( AF_Point  p1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
                AF_Point  p2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
                AF_Point  ref )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
    AF_Point  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
    FT_Pos    delta = ref->u - ref->v;
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
    if ( delta == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
      return;
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
    for ( p = p1; p < ref; p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
      p->u = p->v + delta;
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
    for ( p = ref + 1; p <= p2; p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
      p->u = p->v + delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
  /* Interpolate the original coordinates of all points between `p1' and  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
  /* `p2' to get hinted coordinates, using `ref1' and `ref2' as the       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
  /* reference points.  The `u' and `v' members are the current and       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
  /* original coordinate values, respectively.                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
  /*                                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
  /* Details can be found in the TrueType bytecode specification.         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
  af_iup_interp( AF_Point  p1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
                 AF_Point  p2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
                 AF_Point  ref1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
                 AF_Point  ref2 )
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
    AF_Point  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
    FT_Pos    u;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
    FT_Pos    v1 = ref1->v;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
    FT_Pos    v2 = ref2->v;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
    FT_Pos    d1 = ref1->u - v1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
    FT_Pos    d2 = ref2->u - v2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
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
    if ( p1 > p2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
    if ( v1 == v2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
      for ( p = p1; p <= p2; p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
        u = p->v;
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
        if ( u <= v1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
          u += d1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
          u += d2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
        p->u = u;
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
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
    }
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 ( v1 < v2 )
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
      for ( p = p1; p <= p2; p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
        u = p->v;
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
        if ( u <= v1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
          u += d1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
        else if ( u >= v2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
          u += d2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
          u = ref1->u + FT_MulDiv( u - v1, ref2->u - ref1->u, v2 - v1 );
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
        p->u = u;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
      }
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
    else
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
      for ( p = p1; p <= p2; p++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
        u = p->v;
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 ( u <= v2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
          u += d2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
        else if ( u >= v1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
          u += d1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
          u = ref1->u + FT_MulDiv( u - v1, ref2->u - ref1->u, v2 - v1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
        p->u = u;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
      }
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
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
  /* Hint the weak points -- this is equivalent to the TrueType `IUP' */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
  /* hinting instruction.                                             */
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
  af_glyph_hints_align_weak_points( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
                                    AF_Dimension   dim )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
    AF_Point   points        = hints->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
    AF_Point   point_limit   = points + hints->num_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
    AF_Point*  contour       = hints->contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
    AF_Point*  contour_limit = contour + hints->num_contours;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
    AF_Flags   touch_flag;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
    AF_Point   point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
    AF_Point   end_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
    AF_Point   first_point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
    /* PASS 1: Move segment points to edge positions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
    if ( dim == AF_DIMENSION_HORZ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
      touch_flag = AF_FLAG_TOUCH_X;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
      for ( point = points; point < point_limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
        point->u = point->x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
        point->v = point->ox;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
      touch_flag = AF_FLAG_TOUCH_Y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
      for ( point = points; point < point_limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
        point->u = point->y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
        point->v = point->oy;
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
    point = points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
    for ( ; contour < contour_limit; contour++ )
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
      AF_Point  first_touched, last_touched;
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
      point       = *contour;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
      end_point   = point->prev;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
      first_point = point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
      /* find first touched point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
      for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
        if ( point > end_point )  /* no touched point in contour */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
          goto NextContour;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
        if ( point->flags & touch_flag )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
        point++;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
      first_touched = point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
      last_touched  = point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
      for (;;)
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_ASSERT( point <= end_point                 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
                   ( point->flags & touch_flag ) != 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
        /* skip any touched neighbours */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
        while ( point < end_point                    &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
                ( point[1].flags & touch_flag ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
          point++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
        last_touched = point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
        /* find the next touched point, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
        point++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
        for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
          if ( point > end_point )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
            goto EndContour;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
          if ( ( point->flags & touch_flag ) != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
            break;
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
          point++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
        }
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
        /* interpolate between last_touched and point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
        af_iup_interp( last_touched + 1, point - 1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
                       last_touched, point );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
    EndContour:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
      /* special case: only one point was touched */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
      if ( last_touched == first_touched )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
        af_iup_shift( first_point, end_point, first_touched );
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
      else /* interpolate the last part */
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
        if ( last_touched < end_point )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
          af_iup_interp( last_touched + 1, end_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
                         last_touched, first_touched );
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
        if ( first_touched > points )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
          af_iup_interp( first_point, first_touched - 1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
                         last_touched, first_touched );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
      }
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
    NextContour:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
      ;
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
    /* now save the interpolated values back to x/y */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1166
    if ( dim == AF_DIMENSION_HORZ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1168
      for ( point = points; point < point_limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1169
        point->x = point->u;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1172
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1173
      for ( point = points; point < point_limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
        point->y = point->u;
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
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
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
#ifdef AF_CONFIG_OPTION_USE_WARPER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
  /* Apply (small) warp scale and warp delta for given dimension. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
  af_glyph_hints_scale_dim( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
                            AF_Dimension   dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
                            FT_Fixed       scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
                            FT_Pos         delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
    AF_Point  points       = hints->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
    AF_Point  points_limit = points + hints->num_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
    AF_Point  point;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
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
    if ( dim == AF_DIMENSION_HORZ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1196
      for ( point = points; point < points_limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1197
        point->x = FT_MulFix( point->fx, scale ) + delta;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1200
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1201
      for ( point = points; point < points_limit; point++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1202
        point->y = FT_MulFix( point->fy, scale ) + delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
    }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
#endif /* AF_CONFIG_OPTION_USE_WARPER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1208
/* END */