misc/libfreetype/src/autofit/afcjk.c
author Leonard
Sat, 03 Dec 2011 15:15:14 +0100
changeset 6482 07eeb905620e
parent 5172 88f2e05288ba
permissions -rw-r--r--
GCI task: iOS German
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
/*  afcjk.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 for CJK script (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 2006-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
   *  The algorithm is based on akito's autohint patch, available here:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
   *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
   *  http://www.kde.gr.jp/~akito/patch/freetype2/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include "aftypes.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#include "aflatin.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#ifdef AF_CONFIG_OPTION_CJK
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
#include "afcjk.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
#include "aferrors.h"
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
#ifdef AF_CONFIG_OPTION_USE_WARPER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
#include "afwarp.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  /*****              C J K   G L O B A L   M E T R I C S              *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  /*************************************************************************/
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
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  af_cjk_metrics_init( AF_LatinMetrics  metrics,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
                       FT_Face          face )
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
    FT_CharMap  oldmap = face->charmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    metrics->units_per_em = face->units_per_EM;
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
    /* TODO are there blues? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
      face->charmap = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
      /* latin's version would suffice */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
      af_latin_metrics_init_widths( metrics, face, 0x7530 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
      af_latin_metrics_check_digits( metrics, face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
    FT_Set_Charmap( face, oldmap );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    return AF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
  af_cjk_metrics_scale_dim( AF_LatinMetrics  metrics,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
                            AF_Scaler        scaler,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
                            AF_Dimension     dim )
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
    AF_LatinAxis  axis;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    axis = &metrics->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
    if ( dim == AF_DIMENSION_HORZ )
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
      axis->scale = scaler->x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
      axis->delta = scaler->x_delta;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
      axis->scale = scaler->y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
      axis->delta = scaler->y_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
  af_cjk_metrics_scale( AF_LatinMetrics  metrics,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
                        AF_Scaler        scaler )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    metrics->root.scaler = *scaler;
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
    af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_HORZ );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    af_cjk_metrics_scale_dim( metrics, scaler, AF_DIMENSION_VERT );
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
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  /*****              C J K   G L Y P H   A N A L Y S I S              *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
  af_cjk_hints_compute_segments( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
                                 AF_Dimension   dim )
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
    AF_AxisHints  axis          = &hints->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
    AF_Segment    segments      = axis->segments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
    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
   123
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    AF_Segment    seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    error = af_latin_hints_compute_segments( hints, dim );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
      return error;
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
    /* a segment is round if it doesn't have successive */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    /* on-curve points.                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
    for ( seg = segments; seg < segment_limit; seg++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
      AF_Point  pt   = seg->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
      AF_Point  last = seg->last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
      AF_Flags  f0   = (AF_Flags)(pt->flags & AF_FLAG_CONTROL);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
      AF_Flags  f1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
      seg->flags &= ~AF_EDGE_ROUND;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
      for ( ; pt != last; f0 = f1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
        pt = pt->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
        f1 = (AF_Flags)(pt->flags & AF_FLAG_CONTROL);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
        if ( !f0 && !f1 )
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
        if ( pt == last )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
          seg->flags |= AF_EDGE_ROUND;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    return AF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
  af_cjk_hints_link_segments( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
                              AF_Dimension   dim )
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
    AF_AxisHints  axis          = &hints->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    AF_Segment    segments      = axis->segments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    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
   167
    AF_Direction  major_dir     = axis->major_dir;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    AF_Segment    seg1, seg2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
    FT_Pos        len_threshold;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    FT_Pos        dist_threshold;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    len_threshold = AF_LATIN_CONSTANT( hints->metrics, 8 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    dist_threshold = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
                                                  : hints->y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    dist_threshold = FT_DivFix( 64 * 3, dist_threshold );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    /* now compare each segment to the others */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    for ( seg1 = segments; seg1 < segment_limit; seg1++ )
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
      /* the fake segments are for metrics hinting only */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      if ( seg1->first == seg1->last )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      if ( seg1->dir != major_dir )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
      for ( seg2 = segments; seg2 < segment_limit; seg2++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
        if ( seg2 != seg1 && seg1->dir + seg2->dir == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
          FT_Pos  dist = seg2->pos - seg1->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
          if ( dist < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
            continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
            FT_Pos  min = seg1->min_coord;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
            FT_Pos  max = seg1->max_coord;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
            FT_Pos  len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
            if ( min < seg2->min_coord )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
              min = seg2->min_coord;
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
            if ( max > seg2->max_coord )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
              max = seg2->max_coord;
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
            len = max - min;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
            if ( len >= len_threshold )
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
              if ( dist * 8 < seg1->score * 9                        &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
                   ( dist * 8 < seg1->score * 7 || seg1->len < len ) )
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
                seg1->score = dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
                seg1->len   = len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
                seg1->link  = seg2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
              if ( dist * 8 < seg2->score * 9                        &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
                   ( dist * 8 < seg2->score * 7 || seg2->len < len ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
                seg2->score = dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
                seg2->len   = len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
                seg2->link  = seg1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
     *  now compute the `serif' segments
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
     *  In Hanzi, some strokes are wider on one or both of the ends.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
     *  We either identify the stems on the ends as serifs or remove
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
     *  the linkage, depending on the length of the stems.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
     *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
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
      AF_Segment  link1, link2;
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 ( seg1 = segments; seg1 < segment_limit; seg1++ )
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
        link1 = seg1->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
        if ( !link1 || link1->link != seg1 || link1->pos <= seg1->pos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
        if ( seg1->score >= dist_threshold )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
        for ( seg2 = segments; seg2 < segment_limit; seg2++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
          if ( seg2->pos > seg1->pos || seg1 == seg2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
            continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
          link2 = seg2->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
          if ( !link2 || link2->link != seg2 || link2->pos < link1->pos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
            continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
          if ( seg1->pos == seg2->pos && link1->pos == link2->pos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
            continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
          if ( seg2->score <= seg1->score || seg1->score * 4 <= seg2->score )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
            continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
          /* seg2 < seg1 < link1 < link2 */
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
          if ( seg1->len >= seg2->len * 3 )
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
            AF_Segment  seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
            for ( seg = segments; seg < segment_limit; seg++ )
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
              AF_Segment  link = seg->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
              if ( link == seg2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
                seg->link  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
                seg->serif = link1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
              else if ( link == link2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
                seg->link  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
                seg->serif = seg1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
            seg1->link = link1->link = 0;
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
            break;
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
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
    for ( seg1 = segments; seg1 < segment_limit; seg1++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
      seg2 = seg1->link;
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
      if ( seg2 )
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
        seg2->num_linked++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
        if ( seg2->link != seg1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
          seg1->link = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
          if ( seg2->score < dist_threshold || seg1->score < seg2->score * 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
            seg1->serif = seg2->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
            seg2->num_linked--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
  af_cjk_hints_compute_edges( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
                              AF_Dimension   dim )
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
    AF_AxisHints  axis   = &hints->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    FT_Error      error  = AF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
    FT_Memory     memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
    AF_LatinAxis  laxis  = &((AF_LatinMetrics)hints->metrics)->axis[dim];
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
    AF_Segment    segments      = axis->segments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
    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
   336
    AF_Segment    seg;
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
    FT_Fixed      scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
    FT_Pos        edge_distance_threshold;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    axis->num_edges = 0;
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
    scale = ( dim == AF_DIMENSION_HORZ ) ? hints->x_scale
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
                                         : hints->y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
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
    /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    /* We begin by generating a sorted table of edges for the current    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    /* direction.  To do so, we simply scan each segment and try to find */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
    /* an edge in our table that corresponds to its position.            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
    /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
    /* If no edge is found, we create and insert a new edge in the       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
    /* sorted table.  Otherwise, we simply add the segment to the edge's */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
    /* list which is then processed in the second step to compute the    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
    /* edge's properties.                                                */
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
    /* Note that the edges table is sorted along the segment/edge        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    /* position.                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
    /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
    /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
    edge_distance_threshold = FT_MulFix( laxis->edge_distance_threshold,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
                                         scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    if ( edge_distance_threshold > 64 / 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
      edge_distance_threshold = FT_DivFix( 64 / 4, scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
      edge_distance_threshold = laxis->edge_distance_threshold;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
    for ( seg = segments; seg < segment_limit; seg++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
      AF_Edge  found = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
      FT_Pos   best  = 0xFFFFU;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
      FT_Int   ee;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
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
      /* look for an edge corresponding to the segment */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
      for ( ee = 0; ee < axis->num_edges; ee++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
        AF_Edge  edge = axis->edges + ee;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
        FT_Pos   dist;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
        if ( edge->dir != seg->dir )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
        dist = seg->pos - edge->fpos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
        if ( dist < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
          dist = -dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
        if ( dist < edge_distance_threshold && dist < best )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
          AF_Segment  link = seg->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
          /* check whether all linked segments of the candidate edge */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
          /* can make a single edge.                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
          if ( link )
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
            AF_Segment  seg1 = edge->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
            AF_Segment  link1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
            FT_Pos      dist2 = 0;
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
            do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
              link1 = seg1->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
              if ( link1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
                dist2 = AF_SEGMENT_DIST( link, link1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
                if ( dist2 >= edge_distance_threshold )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
                  break;
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
            } while ( ( seg1 = seg1->edge_next ) != edge->first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
            if ( dist2 >= edge_distance_threshold )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
              continue;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
          best  = dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
          found = edge;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
      if ( !found )
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
        AF_Edge  edge;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
        /* insert a new edge in the list and */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
        /* sort according to the position    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
        error = af_axis_hints_new_edge( axis, seg->pos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
                                        (AF_Direction)seg->dir,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
                                        memory, &edge );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
        /* add the segment to the new edge's list */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        FT_ZERO( edge );
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
        edge->first    = seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
        edge->last     = seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
        edge->fpos     = seg->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
        edge->opos     = edge->pos = FT_MulFix( seg->pos, scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
        seg->edge_next = seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
        edge->dir      = seg->dir;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
      else
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
        /* if an edge was found, simply add the segment to the edge's */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
        /* list                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
        seg->edge_next         = found->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
        found->last->edge_next = seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
        found->last            = seg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
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
    /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
    /* Good, we now compute each edge's properties according to segments */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
    /* found on its position.  Basically, these are as follows.          */
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
    /*  - edge's main direction                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
    /*  - stem edge, serif edge or both (which defaults to stem then)    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
    /*  - rounded edge, straight or both (which defaults to straight)    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
    /*  - link for edge                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
    /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
    /* first of all, set the `edge' field in each segment -- this is     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
    /* required in order to compute edge links                           */
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
    /* Note that removing this loop and setting the `edge' field of each */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
    /* segment directly in the code above slows down execution speed for */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
    /* some reasons on platforms like the Sun.                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
      AF_Edge  edges      = axis->edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
      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
   481
      AF_Edge  edge;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
      for ( edge = edges; edge < edge_limit; edge++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
        seg = edge->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
        if ( seg )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
          do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
            seg->edge = edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
            seg       = seg->edge_next;
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
          } while ( seg != edge->first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
      }
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
      /* now compute each edge properties */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
      for ( edge = edges; edge < edge_limit; edge++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
        FT_Int  is_round    = 0;  /* does it contain round segments?    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
        FT_Int  is_straight = 0;  /* does it contain straight segments? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
        seg = edge->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
        do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
          FT_Bool  is_serif;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
          /* check for roundness of segment */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
          if ( seg->flags & AF_EDGE_ROUND )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
            is_round++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
            is_straight++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
          /* check for links -- if seg->serif is set, then seg->link must */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
          /* be ignored                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
          is_serif = (FT_Bool)( seg->serif && seg->serif->edge != edge );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
          if ( seg->link || is_serif )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
            AF_Edge     edge2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
            AF_Segment  seg2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
            edge2 = edge->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
            seg2  = seg->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
            if ( is_serif )
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
              seg2  = seg->serif;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
              edge2 = edge->serif;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
            if ( edge2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
              FT_Pos  edge_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
              FT_Pos  seg_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
              edge_delta = edge->fpos - edge2->fpos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
              if ( edge_delta < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
                edge_delta = -edge_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
              seg_delta = AF_SEGMENT_DIST( seg, seg2 );
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
              if ( seg_delta < edge_delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
                edge2 = seg2->edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
              edge2 = seg2->edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
            if ( is_serif )
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
              edge->serif   = edge2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
              edge2->flags |= AF_EDGE_SERIF;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
              edge->link  = edge2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
          seg = seg->edge_next;
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
        } while ( seg != edge->first );
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
        /* set the round/straight flags */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
        edge->flags = AF_EDGE_NORMAL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
        if ( is_round > 0 && is_round >= is_straight )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
          edge->flags |= AF_EDGE_ROUND;
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
        /* get rid of serifs if link is set                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
        /* XXX: This gets rid of many unpleasant artefacts! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
        /*      Example: the `c' in cour.pfa at size 13     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
        if ( edge->serif && edge->link )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
          edge->serif = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
      }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
  af_cjk_hints_detect_features( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
                                AF_Dimension   dim )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
    FT_Error  error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
    error = af_cjk_hints_compute_segments( hints, dim );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
    if ( !error )
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
      af_cjk_hints_link_segments( hints, dim );
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
      error = af_cjk_hints_compute_edges( hints, dim );
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
  }
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
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
  af_cjk_hints_init( AF_GlyphHints    hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
                     AF_LatinMetrics  metrics )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
    FT_Render_Mode  mode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
    FT_UInt32       scaler_flags, other_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
    af_glyph_hints_rescale( hints, (AF_ScriptMetrics)metrics );
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
     *  correct x_scale and y_scale when needed, since they may have
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
     *  been modified af_cjk_scale_dim above
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
    hints->x_scale = metrics->axis[AF_DIMENSION_HORZ].scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    hints->x_delta = metrics->axis[AF_DIMENSION_HORZ].delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
    hints->y_scale = metrics->axis[AF_DIMENSION_VERT].scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
    hints->y_delta = metrics->axis[AF_DIMENSION_VERT].delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
    /* compute flags depending on render mode, etc. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
    mode = metrics->root.scaler.render_mode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
#ifdef AF_CONFIG_OPTION_USE_WARPER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
      metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
#endif
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
    scaler_flags = hints->scaler_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
    other_flags  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
     *  We snap the width of vertical stems for the monochrome and
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
     *  horizontal LCD rendering targets only.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
    if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
      other_flags |= AF_LATIN_HINTS_HORZ_SNAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
     *  We snap the width of horizontal stems for the monochrome and
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
     *  vertical LCD rendering targets only.
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
    if ( mode == FT_RENDER_MODE_MONO || mode == FT_RENDER_MODE_LCD_V )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
      other_flags |= AF_LATIN_HINTS_VERT_SNAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
     *  We adjust stems to full pixels only if we don't use the `light' mode.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
    if ( mode != FT_RENDER_MODE_LIGHT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
      other_flags |= AF_LATIN_HINTS_STEM_ADJUST;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
    if ( mode == FT_RENDER_MODE_MONO )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
      other_flags |= AF_LATIN_HINTS_MONO;
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
    scaler_flags |= AF_SCALER_FLAG_NO_ADVANCE;
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
    hints->scaler_flags = scaler_flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
    hints->other_flags  = other_flags;
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
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
  /*****          C J K   G L Y P H   G R I D - F I T T I N G          *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
  /*************************************************************************/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
  /* snap a given width in scaled coordinates to one of the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
  /* current standard widths                                */
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
  static FT_Pos
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
  af_cjk_snap_width( AF_Width  widths,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
                     FT_Int    count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
                     FT_Pos    width )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
    int     n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
    FT_Pos  best      = 64 + 32 + 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
    FT_Pos  reference = width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
    FT_Pos  scaled;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
    for ( n = 0; n < count; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
      FT_Pos  w;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
      FT_Pos  dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
      w = widths[n].cur;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
      dist = width - w;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
      if ( dist < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
        dist = -dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
      if ( dist < best )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
        best      = dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
        reference = w;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
    scaled = FT_PIX_ROUND( reference );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
    if ( width >= reference )
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
      if ( width < scaled + 48 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
        width = reference;
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
    else
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
      if ( width > scaled - 48 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
        width = reference;
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
    return width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
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
  /* compute the snapped width of a given stem */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
  static FT_Pos
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
  af_cjk_compute_stem_width( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
                             AF_Dimension   dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
                             FT_Pos         width,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
                             AF_Edge_Flags  base_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
                             AF_Edge_Flags  stem_flags )
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
    AF_LatinMetrics  metrics  = (AF_LatinMetrics) hints->metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    AF_LatinAxis     axis     = & metrics->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
    FT_Pos           dist     = width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
    FT_Int           sign     = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
    FT_Int           vertical = ( dim == AF_DIMENSION_VERT );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    FT_UNUSED( base_flags );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
    FT_UNUSED( stem_flags );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
    if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
      return width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
    if ( dist < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
      dist = -width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
      sign = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
    if ( (  vertical && !AF_LATIN_HINTS_DO_VERT_SNAP( hints ) ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
         ( !vertical && !AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
      /* smooth hinting process: very lightly quantize the stem width */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
      if ( axis->width_count > 0 )
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
        if ( FT_ABS( dist - axis->widths[0].cur ) < 40 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
          dist = axis->widths[0].cur;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
          if ( dist < 48 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
            dist = 48;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
          goto Done_Width;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
      if ( dist < 54 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
        dist += ( 54 - dist ) / 2 ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
      else if ( dist < 3 * 64 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
        FT_Pos  delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
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
        delta  = dist & 63;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
        dist  &= -64;
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 ( delta < 10 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
          dist += delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
        else if ( delta < 22 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
          dist += 10;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
        else if ( delta < 42 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
          dist += delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
        else if ( delta < 54 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
          dist += 54;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
          dist += delta;
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
    else
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
      /* strong hinting process: snap the stem width to integer pixels */
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
      dist = af_cjk_snap_width( axis->widths, axis->width_count, dist );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
      if ( vertical )
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
        /* in the case of vertical hinting, always round */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
        /* the stem heights to integer pixels            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
        if ( dist >= 64 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
          dist = ( dist + 16 ) & ~63;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
          dist = 64;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
        if ( AF_LATIN_HINTS_DO_MONO( hints ) )
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
          /* monochrome horizontal hinting: snap widths to integer pixels */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
          /* with a different threshold                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
          if ( dist < 64 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
            dist = 64;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
            dist = ( dist + 32 ) & ~63;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
        else
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
          /* for horizontal anti-aliased hinting, we adopt a more subtle */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
          /* approach: we strengthen small stems, round stems whose size */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
          /* is between 1 and 2 pixels to an integer, otherwise nothing  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
          if ( dist < 48 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
            dist = ( dist + 64 ) >> 1;
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
          else if ( dist < 128 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
            dist = ( dist + 22 ) & ~63;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
            /* round otherwise to prevent color fringes in LCD mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
            dist = ( dist + 32 ) & ~63;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
  Done_Width:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
    if ( sign )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
      dist = -dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
    return dist;
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
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
  /* align one stem edge relative to the previous stem edge */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
  af_cjk_align_linked_edge( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
                            AF_Dimension   dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
                            AF_Edge        base_edge,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
                            AF_Edge        stem_edge )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
    FT_Pos  dist = stem_edge->opos - base_edge->opos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
    FT_Pos  fitted_width = af_cjk_compute_stem_width(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
                             hints, dim, dist,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
                             (AF_Edge_Flags)base_edge->flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
                             (AF_Edge_Flags)stem_edge->flags );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
    stem_edge->pos = base_edge->pos + fitted_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
  af_cjk_align_serif_edge( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
                           AF_Edge        base,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
                           AF_Edge        serif )
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_UNUSED( hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
    serif->pos = base->pos + ( serif->opos - base->opos );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
  /*************************************************************************/
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
  /****                                                                 ****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
  /****                    E D G E   H I N T I N G                      ****/
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
  /*************************************************************************/
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
#define AF_LIGHT_MODE_MAX_HORZ_GAP    9
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
#define AF_LIGHT_MODE_MAX_VERT_GAP   15
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
#define AF_LIGHT_MODE_MAX_DELTA_ABS  14
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
  static FT_Pos
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
  af_hint_normal_stem( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
                       AF_Edge        edge,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
                       AF_Edge        edge2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
                       FT_Pos         anchor,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
                       AF_Dimension   dim )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
    FT_Pos  org_len, cur_len, org_center;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
    FT_Pos  cur_pos1, cur_pos2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
    FT_Pos  d_off1, u_off1, d_off2, u_off2, delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
    FT_Pos  offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
    FT_Pos  threshold = 64;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
    if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
      if ( ( edge->flags  & AF_EDGE_ROUND ) &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
           ( edge2->flags & AF_EDGE_ROUND ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
        if ( dim == AF_DIMENSION_VERT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
          threshold = 64 - AF_LIGHT_MODE_MAX_HORZ_GAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
          threshold = 64 - AF_LIGHT_MODE_MAX_VERT_GAP;
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
      else
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
        if ( dim == AF_DIMENSION_VERT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
          threshold = 64 - AF_LIGHT_MODE_MAX_HORZ_GAP / 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
          threshold = 64 - AF_LIGHT_MODE_MAX_VERT_GAP / 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
    org_len    = edge2->opos - edge->opos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
    cur_len    = af_cjk_compute_stem_width( hints, dim, org_len,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
                                            (AF_Edge_Flags)edge->flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
                                            (AF_Edge_Flags)edge2->flags );
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
    org_center = ( edge->opos + edge2->opos ) / 2 + anchor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
    cur_pos1   = org_center - cur_len / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
    cur_pos2   = cur_pos1 + cur_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
    d_off1     = cur_pos1 - FT_PIX_FLOOR( cur_pos1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
    d_off2     = cur_pos2 - FT_PIX_FLOOR( cur_pos2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
    u_off1     = 64 - d_off1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
    u_off2     = 64 - d_off2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
    delta      = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
    if ( d_off1 == 0 || d_off2 == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   939
      goto Exit;
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
    if ( cur_len <= threshold )
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
      if ( d_off2 < cur_len )
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
        if ( u_off1 <= d_off2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
          delta =  u_off1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
          delta = -d_off2;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
    }
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
    if ( threshold < 64 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
      if ( d_off1 >= threshold || u_off1 >= threshold ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
           d_off2 >= threshold || u_off2 >= threshold )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
    offset = cur_len % 64;
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 ( offset < 32 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
      if ( u_off1 <= offset || d_off2 <= offset )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
      offset = 64 - threshold;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
    d_off1 = threshold - u_off1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
    u_off1 = u_off1    - offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
    u_off2 = threshold - d_off2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
    d_off2 = d_off2    - offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
    if ( d_off1 <= u_off1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
      u_off1 = -d_off1;
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
    if ( d_off2 <= u_off2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
      u_off2 = -d_off2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
    if ( FT_ABS( u_off1 ) <= FT_ABS( u_off2 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
      delta = u_off1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
      delta = u_off2;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
#if 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
    if ( !AF_LATIN_HINTS_DO_STEM_ADJUST( hints ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
      if ( delta > AF_LIGHT_MODE_MAX_DELTA_ABS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
        delta = AF_LIGHT_MODE_MAX_DELTA_ABS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
      else if ( delta < -AF_LIGHT_MODE_MAX_DELTA_ABS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
        delta = -AF_LIGHT_MODE_MAX_DELTA_ABS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
    cur_pos1 += delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
    if ( edge->opos < edge2->opos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
      edge->pos  = cur_pos1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
      edge2->pos = cur_pos1 + cur_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
    }
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
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
      edge->pos  = cur_pos1 + cur_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
      edge2->pos = cur_pos1;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
    return delta;
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
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
  af_cjk_hint_edges( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
                     AF_Dimension   dim )
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
    AF_AxisHints  axis       = &hints->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
    AF_Edge       edges      = axis->edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
    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
  1023
    FT_PtrDist    n_edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
    AF_Edge       edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
    AF_Edge       anchor   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
    FT_Pos        delta    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
    FT_Int        skipped  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
    FT_Bool       has_last_stem = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
    FT_Pos        last_stem_pos = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
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
    /* now we align all stem edges. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
    for ( edge = edges; edge < edge_limit; edge++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
      AF_Edge  edge2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
      if ( edge->flags & AF_EDGE_DONE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
      /* skip all non-stem edges */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
      edge2 = edge->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
      if ( !edge2 )
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
        skipped++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
        continue;
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
      /* Some CJK characters have so many stems that
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
       * the hinter is likely to merge two adjacent ones.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
       * To solve this problem, if either edge of a stem
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
       * is too close to the previous one, we avoid
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
       * aligning the two edges, but rather interpolate
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
       * their locations at the end of this function in
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
       * order to preserve the space between the stems.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
      if ( has_last_stem                       &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
           ( edge->pos  < last_stem_pos + 64 ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
             edge2->pos < last_stem_pos + 64 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
        skipped++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
      }
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
      /* now align the stem */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
      if ( edge2 < edge )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
        af_cjk_align_linked_edge( hints, dim, edge2, edge );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
        edge->flags |= AF_EDGE_DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
        /* We rarely reaches here it seems;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
         * usually the two edges belonging
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
         * to one stem are marked as DONE together
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
        has_last_stem = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
        last_stem_pos = edge->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
      if ( dim != AF_DIMENSION_VERT && !anchor )
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
        if ( fixedpitch )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
          AF_Edge     left  = edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
          AF_Edge     right = edge_limit - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
          AF_EdgeRec  left1, left2, right1, right2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
          FT_Pos      target, center1, center2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
          FT_Pos      delta1, delta2, d1, d2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1092
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
          while ( right > left && !right->link )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
            right--;
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
          left1  = *left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
          left2  = *left->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
          right1 = *right->link;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
          right2 = *right;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
          delta  = ( ( ( hinter->pp2.x + 32 ) & -64 ) - hinter->pp2.x ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
          target = left->opos + ( right->opos - left->opos ) / 2 + delta - 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
          delta1  = delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
          delta1 += af_hint_normal_stem( hints, left, left->link,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
                                         delta1, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
          if ( left->link != right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
            af_hint_normal_stem( hints, right->link, right, delta1, 0 );
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
          center1 = left->pos + ( right->pos - left->pos ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
          if ( center1 >= target )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
            delta2 = delta - 32;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
            delta2 = delta + 32;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1117
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
          delta2 += af_hint_normal_stem( hints, &left1, &left2, delta2, 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
          if ( delta1 != delta2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
            if ( left->link != right )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
              af_hint_normal_stem( hints, &right1, &right2, delta2, 0 );
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
            center2 = left1.pos + ( right2.pos - left1.pos ) / 2;
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
            d1 = center1 - target;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
            d2 = center2 - target;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
            if ( FT_ABS( d2 ) < FT_ABS( d1 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
              left->pos       = left1.pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
              left->link->pos = left2.pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
              if ( left->link != right )
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
                right->link->pos = right1.pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
                right->pos       = right2.pos;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
              delta1 = delta2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
            }
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
          delta               = delta1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
          right->link->flags |= AF_EDGE_DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
          right->flags       |= AF_EDGE_DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
          delta = af_hint_normal_stem( hints, edge, edge2, 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
                                       AF_DIMENSION_HORZ );
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
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
        af_hint_normal_stem( hints, edge, edge2, delta, dim );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1160
      printf( "stem (%d,%d) adjusted (%.1f,%.1f)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1161
               edge - edges, edge2 - edges,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
               ( edge->pos - edge->opos ) / 64.0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1163
               ( edge2->pos - edge2->opos ) / 64.0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1164
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1166
      anchor = edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
      edge->flags  |= AF_EDGE_DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1168
      edge2->flags |= AF_EDGE_DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1169
      has_last_stem = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1170
      last_stem_pos = edge2->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1171
    }
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
    /* make sure that lowercase m's maintain their symmetry */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1175
    /* In general, lowercase m's have six vertical edges if they are sans */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1176
    /* serif, or twelve if they are with serifs.  This implementation is  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
    /* based on that assumption, and seems to work very well with most    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1178
    /* faces.  However, if for a certain face this assumption is not      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1179
    /* true, the m is just rendered like before.  In addition, any stem   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
    /* correction will only be applied to symmetrical glyphs (even if the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
    /* glyph is not an m), so the potential for unwanted distortion is    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
    /* relatively low.                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
    /* We don't handle horizontal edges since we can't easily assure that */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
    /* the third (lowest) stem aligns with the base line; it might end up */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
    /* one pixel higher or lower.                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
    n_edges = edge_limit - edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
    if ( dim == AF_DIMENSION_HORZ && ( n_edges == 6 || n_edges == 12 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
      AF_Edge  edge1, edge2, edge3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
      FT_Pos   dist1, dist2, span;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
      if ( n_edges == 6 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1196
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1197
        edge1 = edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1198
        edge2 = edges + 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1199
        edge3 = edges + 4;
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
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1202
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
        edge1 = edges + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1204
        edge2 = edges + 5;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1205
        edge3 = edges + 9;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1208
      dist1 = edge2->opos - edge1->opos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1209
      dist2 = edge3->opos - edge2->opos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1211
      span = dist1 - dist2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1212
      if ( span < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1213
        span = -span;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1215
      if ( edge1->link == edge1 + 1 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1216
           edge2->link == edge2 + 1 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1217
           edge3->link == edge3 + 1 && span < 8 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1218
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1219
        delta = edge3->pos - ( 2 * edge2->pos - edge1->pos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1220
        edge3->pos -= delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1221
        if ( edge3->link )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1222
          edge3->link->pos -= delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1223
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1224
        /* move the serifs along with the stem */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1225
        if ( n_edges == 12 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1226
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1227
          ( edges + 8 )->pos -= delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1228
          ( edges + 11 )->pos -= delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1229
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1231
        edge3->flags |= AF_EDGE_DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1232
        if ( edge3->link )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1233
          edge3->link->flags |= AF_EDGE_DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1234
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1235
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1236
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1237
    if ( !skipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1238
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1239
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1240
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1241
     *  now hint the remaining edges (serifs and single) in order
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1242
     *  to complete our processing
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1243
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1244
    for ( edge = edges; edge < edge_limit; edge++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1245
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1246
      if ( edge->flags & AF_EDGE_DONE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1247
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1249
      if ( edge->serif )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1250
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1251
        af_cjk_align_serif_edge( hints, edge->serif, edge );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1252
        edge->flags |= AF_EDGE_DONE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1253
        skipped--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1254
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1255
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1257
    if ( !skipped )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1258
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1260
    for ( edge = edges; edge < edge_limit; edge++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1261
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1262
      AF_Edge  before, after;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1263
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1264
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1265
      if ( edge->flags & AF_EDGE_DONE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1266
        continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1268
      before = after = edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1270
      while ( --before >= edges )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1271
        if ( before->flags & AF_EDGE_DONE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1272
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1273
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1274
      while ( ++after < edge_limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1275
        if ( after->flags & AF_EDGE_DONE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1276
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1278
      if ( before >= edges || after < edge_limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1279
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1280
        if ( before < edges )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1281
          af_cjk_align_serif_edge( hints, after, edge );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1282
        else if ( after >= edge_limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1283
          af_cjk_align_serif_edge( hints, before, edge );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1284
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1285
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1286
          if ( after->fpos == before->fpos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1287
            edge->pos = before->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1288
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1289
            edge->pos = before->pos +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1290
                        FT_MulDiv( edge->fpos - before->fpos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1291
                                   after->pos - before->pos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1292
                                   after->fpos - before->fpos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1293
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1294
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1295
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1296
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1297
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1299
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1300
  af_cjk_align_edge_points( AF_GlyphHints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1301
                            AF_Dimension   dim )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1302
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1303
    AF_AxisHints  axis       = & hints->axis[dim];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1304
    AF_Edge       edges      = axis->edges;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1305
    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
  1306
    AF_Edge       edge;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1307
    FT_Bool       snapping;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1308
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1309
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1310
    snapping = FT_BOOL( ( dim == AF_DIMENSION_HORZ             &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1311
                          AF_LATIN_HINTS_DO_HORZ_SNAP( hints ) )  ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1312
                        ( dim == AF_DIMENSION_VERT             &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1313
                          AF_LATIN_HINTS_DO_VERT_SNAP( hints ) )  );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1314
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1315
    for ( edge = edges; edge < edge_limit; edge++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1316
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1317
      /* move the points of each segment     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1318
      /* in each edge to the edge's position */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1319
      AF_Segment  seg = edge->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1321
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1322
      if ( snapping )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1323
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1324
        do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1325
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1326
          AF_Point  point = seg->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1327
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1328
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1329
          for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1330
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1331
            if ( dim == AF_DIMENSION_HORZ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1332
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1333
              point->x      = edge->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1334
              point->flags |= AF_FLAG_TOUCH_X;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1335
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1336
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1337
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1338
              point->y      = edge->pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1339
              point->flags |= AF_FLAG_TOUCH_Y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1340
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1342
            if ( point == seg->last )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1343
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1345
            point = point->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1346
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1347
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1348
          seg = seg->edge_next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1349
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1350
        } while ( seg != edge->first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1351
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1352
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1353
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1354
        FT_Pos  delta = edge->pos - edge->opos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1356
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1357
        do
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1358
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1359
          AF_Point  point = seg->first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1360
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1361
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1362
          for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1363
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1364
            if ( dim == AF_DIMENSION_HORZ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1365
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1366
              point->x     += delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1367
              point->flags |= AF_FLAG_TOUCH_X;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1368
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1369
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1370
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1371
              point->y     += delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1372
              point->flags |= AF_FLAG_TOUCH_Y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1373
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1374
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1375
            if ( point == seg->last )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1376
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1377
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1378
            point = point->next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1379
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1380
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1381
          seg = seg->edge_next;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1382
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1383
        } while ( seg != edge->first );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1384
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1385
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1386
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1387
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1388
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1389
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1390
  af_cjk_hints_apply( AF_GlyphHints    hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1391
                      FT_Outline*      outline,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1392
                      AF_LatinMetrics  metrics )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1393
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1394
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1395
    int       dim;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1397
    FT_UNUSED( metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1399
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1400
    error = af_glyph_hints_reload( hints, outline );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1401
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1402
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1404
    /* analyze glyph outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1405
    if ( AF_HINTS_DO_HORIZONTAL( hints ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1406
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1407
      error = af_cjk_hints_detect_features( hints, AF_DIMENSION_HORZ );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1408
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1409
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1410
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1411
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1412
    if ( AF_HINTS_DO_VERTICAL( hints ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1413
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1414
      error = af_cjk_hints_detect_features( hints, AF_DIMENSION_VERT );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1415
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1416
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1417
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1419
    /* grid-fit the outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1420
    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
  1421
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1422
      if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1423
           ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) )   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1424
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1425
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1426
#ifdef AF_CONFIG_OPTION_USE_WARPER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1427
        if ( dim == AF_DIMENSION_HORZ                                  &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1428
             metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1429
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1430
          AF_WarperRec  warper;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1431
          FT_Fixed      scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1432
          FT_Pos        delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1434
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1435
          af_warper_compute( &warper, hints, (AF_Dimension)dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1436
                             &scale, &delta );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1437
          af_glyph_hints_scale_dim( hints, (AF_Dimension)dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1438
                                    scale, delta );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1439
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1440
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1441
#endif /* AF_CONFIG_OPTION_USE_WARPER */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1442
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1443
        af_cjk_hint_edges( hints, (AF_Dimension)dim );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1444
        af_cjk_align_edge_points( hints, (AF_Dimension)dim );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1445
        af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1446
        af_glyph_hints_align_weak_points( hints, (AF_Dimension)dim );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1447
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1448
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1449
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1450
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1451
    af_glyph_hints_dump_points( hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1452
    af_glyph_hints_dump_segments( hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1453
    af_glyph_hints_dump_edges( hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1454
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1455
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1456
    af_glyph_hints_save( hints, outline );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1457
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1458
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1459
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1460
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1462
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1463
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1464
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1465
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1466
  /*****                C J K   S C R I P T   C L A S S                *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1467
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1468
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1469
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1470
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1471
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1472
  /* this corresponds to Unicode 6.0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1473
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1474
  static const AF_Script_UniRangeRec  af_cjk_uniranges[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1475
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1476
    AF_UNIRANGE_REC(  0x2E80UL,  0x2EFFUL ),  /* CJK Radicals Supplement                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1477
    AF_UNIRANGE_REC(  0x2F00UL,  0x2FDFUL ),  /* Kangxi Radicals                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1478
    AF_UNIRANGE_REC(  0x2FF0UL,  0x2FFFUL ),  /* Ideographic Description Characters      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1479
    AF_UNIRANGE_REC(  0x3000UL,  0x303FUL ),  /* CJK Symbols and Punctuation             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1480
    AF_UNIRANGE_REC(  0x3040UL,  0x309FUL ),  /* Hiragana                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1481
    AF_UNIRANGE_REC(  0x30A0UL,  0x30FFUL ),  /* Katakana                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1482
    AF_UNIRANGE_REC(  0x3100UL,  0x312FUL ),  /* Bopomofo                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1483
    AF_UNIRANGE_REC(  0x3130UL,  0x318FUL ),  /* Hangul Compatibility Jamo               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1484
    AF_UNIRANGE_REC(  0x3190UL,  0x319FUL ),  /* Kanbun                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1485
    AF_UNIRANGE_REC(  0x31A0UL,  0x31BFUL ),  /* Bopomofo Extended                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1486
    AF_UNIRANGE_REC(  0x31C0UL,  0x31EFUL ),  /* CJK Strokes                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1487
    AF_UNIRANGE_REC(  0x31F0UL,  0x31FFUL ),  /* Katakana Phonetic Extensions            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1488
    AF_UNIRANGE_REC(  0x3200UL,  0x32FFUL ),  /* Enclosed CJK Letters and Months         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1489
    AF_UNIRANGE_REC(  0x3300UL,  0x33FFUL ),  /* CJK Compatibility                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1490
    AF_UNIRANGE_REC(  0x3400UL,  0x4DBFUL ),  /* CJK Unified Ideographs Extension A      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1491
    AF_UNIRANGE_REC(  0x4DC0UL,  0x4DFFUL ),  /* Yijing Hexagram Symbols                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1492
    AF_UNIRANGE_REC(  0x4E00UL,  0x9FFFUL ),  /* CJK Unified Ideographs                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1493
    AF_UNIRANGE_REC(  0xA960UL,  0xA97FUL ),  /* Hangul Jamo Extended-A                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1494
    AF_UNIRANGE_REC(  0xAC00UL,  0xD7AFUL ),  /* Hangul Syllables                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1495
    AF_UNIRANGE_REC(  0xD7B0UL,  0xD7FFUL ),  /* Hangul Jamo Extended-B                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1496
    AF_UNIRANGE_REC(  0xF900UL,  0xFAFFUL ),  /* CJK Compatibility Ideographs            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1497
    AF_UNIRANGE_REC(  0xFE10UL,  0xFE1FUL ),  /* Vertical forms                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1498
    AF_UNIRANGE_REC(  0xFE30UL,  0xFE4FUL ),  /* CJK Compatibility Forms                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1499
    AF_UNIRANGE_REC(  0xFF00UL,  0xFFEFUL ),  /* Halfwidth and Fullwidth Forms           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1500
    AF_UNIRANGE_REC( 0x1B000UL, 0x1B0FFUL ),  /* Kana Supplement                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1501
    AF_UNIRANGE_REC( 0x1D300UL, 0x1D35FUL ),  /* Tai Xuan Hing Symbols                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1502
    AF_UNIRANGE_REC( 0x1F200UL, 0x1F2FFUL ),  /* Enclosed Ideographic Supplement         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1503
    AF_UNIRANGE_REC( 0x20000UL, 0x2A6DFUL ),  /* CJK Unified Ideographs Extension B      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1504
    AF_UNIRANGE_REC( 0x2A700UL, 0x2B73FUL ),  /* CJK Unified Ideographs Extension C      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1505
    AF_UNIRANGE_REC( 0x2B740UL, 0x2B81FUL ),  /* CJK Unified Ideographs Extension D      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1506
    AF_UNIRANGE_REC( 0x2F800UL, 0x2FA1FUL ),  /* CJK Compatibility Ideographs Supplement */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1507
    AF_UNIRANGE_REC(       0UL,       0UL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1508
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1509
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1510
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1511
  AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1512
    AF_SCRIPT_CJK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1513
    af_cjk_uniranges,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1514
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1515
    sizeof( AF_LatinMetricsRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1516
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1517
    (AF_Script_InitMetricsFunc) af_cjk_metrics_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1518
    (AF_Script_ScaleMetricsFunc)af_cjk_metrics_scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1519
    (AF_Script_DoneMetricsFunc) NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1521
    (AF_Script_InitHintsFunc)   af_cjk_hints_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1522
    (AF_Script_ApplyHintsFunc)  af_cjk_hints_apply
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1523
  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1524
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1525
#else /* !AF_CONFIG_OPTION_CJK */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1526
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1527
  static const AF_Script_UniRangeRec  af_cjk_uniranges[] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1528
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1529
    AF_UNIRANGE_REC( 0UL, 0UL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1530
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1531
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1532
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1533
  AF_DEFINE_SCRIPT_CLASS(af_cjk_script_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1534
    AF_SCRIPT_CJK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1535
    af_cjk_uniranges,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1536
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1537
    sizeof( AF_LatinMetricsRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1538
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1539
    (AF_Script_InitMetricsFunc) NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1540
    (AF_Script_ScaleMetricsFunc)NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1541
    (AF_Script_DoneMetricsFunc) NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1542
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1543
    (AF_Script_InitHintsFunc)   NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1544
    (AF_Script_ApplyHintsFunc)  NULL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1545
  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1546
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1547
#endif /* !AF_CONFIG_OPTION_CJK */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1548
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1549
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1550
/* END */