freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][download-test-fonts] 5 commits: Update 'dlg' su


From: David Turner (@david.freetype)
Subject: [Git][freetype/freetype][download-test-fonts] 5 commits: Update 'dlg' subproject.
Date: Mon, 12 Jul 2021 07:34:48 +0000

David Turner pushed to branch download-test-fonts at FreeType / FreeType

Commits:

28 changed files:

Changes:

  • ChangeLog
    1
    +2021-07-12  David Turner  <david@freetype.org>
    
    2
    +
    
    3
    +	Replaces download-test-fonts.sh with download-test-fonts.py which
    
    4
    +	does the same work, and also avoids downloading anything if the
    
    5
    +	files are already installed with the right content.
    
    6
    +
    
    7
    +	Now uses the first 8 byte of each file's sha256 hash for the digest.
    
    8
    +
    
    9
    +	* tests/scripts/download-test-fonts.sh: Removed
    
    10
    +	* tests/scripts/download-test-fonts.py: New script
    
    11
    +	* tests/README.md: Updated
    
    12
    +
    
    13
    +2021-07-12  David Turner  <david@freetype.org>
    
    14
    +
    
    15
    +	Remove obsolete AF_Angle type and related sources.
    
    16
    +
    
    17
    +	Move the af_sort_xxx() functions from afangles.c to afhints.c in
    
    18
    +	order to get rid of the obsolete angle-related types, macros and
    
    19
    +	function definitions.
    
    20
    +
    
    21
    +	* src/autofit/*: Remove code.
    
    22
    +
    
    23
    +2021-07-12  David Turner  <david@freetype.org>
    
    24
    +
    
    25
    +	Remove experimental auto-hinting 'warp' mode.
    
    26
    +
    
    27
    +	This feature was always experimental, and probably nevery worked
    
    28
    +	properly. This patch completely removes it from the source code,
    
    29
    +	except for a documentation block describing it for historical
    
    30
    +	purpose.
    
    31
    +
    
    32
    +	* devel/ftoption.h: Remove AF_CONFIG_OPTION_USE_WARPER.
    
    33
    +	* include/freetype/config/ftoption.h: Remove AF_CONFIG_OPTION_USE_WARPER.
    
    34
    +	* include/freetype/ftdriver.h: Document 'warping' property as obsolete.
    
    35
    +	* src/autofit/*: Remove any warp mode related code.
    
    36
    +
    
    37
    +2021-07-12  David Turner  <david@freetype.org>
    
    38
    +
    
    39
    +	Remove experimental "Latin2" writing system (FT_OPTION_AUTOFIT2)
    
    40
    +
    
    41
    +	This code has always been experimental and was never compiled anyway
    
    42
    +	(FT_OPTION_AUTOFIT2 does not appear in ftoption.h or even any of our
    
    43
    +	build files).
    
    44
    +
    
    45
    +	* include/freetype/internal/fttrace.h: Remove 'FT_TRACE_DEF( aflatin2 )'.
    
    46
    +	* src/autofit/aflatin2.[hc]: Removed.
    
    47
    +	* src/autofit/afloader.c: Remove undocumented hook to activate Latin2 system.
    
    48
    +	* src/autofit/afstyles.h: Remove ltn2_dflt style definition.
    
    49
    +	* src/autofit/afwrtsys.h: Remove LATIN2 writing system definition.
    
    50
    +	* src/autofit/autofit.c: Updated.
    
    51
    +
    
    1 52
     2021-07-05  Werner Lemberg  <wl@gnu.org>
    
    2 53
     
    
    3 54
     	* src/base/ftlcdfil.c (FT_Library_SetLcdGeometry): Fix argument.
    

  • devel/ftoption.h
    ... ... @@ -907,24 +907,6 @@ FT_BEGIN_HEADER
    907 907
     #endif
    
    908 908
     
    
    909 909
     
    
    910
    -  /**************************************************************************
    
    911
    -   *
    
    912
    -   * Compile 'autofit' module with warp hinting.  The idea of the warping
    
    913
    -   * code is to slightly scale and shift a glyph within a single dimension so
    
    914
    -   * that as much of its segments are aligned (more or less) on the grid.  To
    
    915
    -   * find out the optimal scaling and shifting value, various parameter
    
    916
    -   * combinations are tried and scored.
    
    917
    -   *
    
    918
    -   * You can switch warping on and off with the `warping` property of the
    
    919
    -   * auto-hinter (see file `ftdriver.h` for more information; by default it
    
    920
    -   * is switched off).
    
    921
    -   *
    
    922
    -   * This experimental option is not active if the rendering mode is
    
    923
    -   * `FT_RENDER_MODE_LIGHT`.
    
    924
    -   */
    
    925
    -#define AF_CONFIG_OPTION_USE_WARPER
    
    926
    -
    
    927
    -
    
    928 910
       /**************************************************************************
    
    929 911
        *
    
    930 912
        * Use TrueType-like size metrics for 'light' auto-hinting.
    

  • include/freetype/config/ftoption.h
    ... ... @@ -909,24 +909,6 @@ FT_BEGIN_HEADER
    909 909
     #endif
    
    910 910
     
    
    911 911
     
    
    912
    -  /**************************************************************************
    
    913
    -   *
    
    914
    -   * Compile 'autofit' module with warp hinting.  The idea of the warping
    
    915
    -   * code is to slightly scale and shift a glyph within a single dimension so
    
    916
    -   * that as much of its segments are aligned (more or less) on the grid.  To
    
    917
    -   * find out the optimal scaling and shifting value, various parameter
    
    918
    -   * combinations are tried and scored.
    
    919
    -   *
    
    920
    -   * You can switch warping on and off with the `warping` property of the
    
    921
    -   * auto-hinter (see file `ftdriver.h` for more information; by default it
    
    922
    -   * is switched off).
    
    923
    -   *
    
    924
    -   * This experimental option is not active if the rendering mode is
    
    925
    -   * `FT_RENDER_MODE_LIGHT`.
    
    926
    -   */
    
    927
    -#define AF_CONFIG_OPTION_USE_WARPER
    
    928
    -
    
    929
    -
    
    930 912
       /**************************************************************************
    
    931 913
        *
    
    932 914
        * Use TrueType-like size metrics for 'light' auto-hinting.
    

  • include/freetype/ftdriver.h
    ... ... @@ -1162,11 +1162,11 @@ FT_BEGIN_HEADER
    1162 1162
        *   warping
    
    1163 1163
        *
    
    1164 1164
        * @description:
    
    1165
    -   *   **Experimental only**
    
    1165
    +   *   **Obsolete**
    
    1166 1166
        *
    
    1167
    -   *   If FreeType gets compiled with option `AF_CONFIG_OPTION_USE_WARPER` to
    
    1168
    -   *   activate the warp hinting code in the auto-hinter, this property
    
    1169
    -   *   switches warping on and off.
    
    1167
    +   *   This property was always experimental and probably never worked
    
    1168
    +   *   correctly. It was entirely removed from the FreeType 2 sources.
    
    1169
    +   *   This entry is only here for historical reference.
    
    1170 1170
        *
    
    1171 1171
        *   Warping only works in 'normal' auto-hinting mode replacing it.  The
    
    1172 1172
        *   idea of the code is to slightly scale and shift a glyph along the
    
    ... ... @@ -1175,36 +1175,6 @@ FT_BEGIN_HEADER
    1175 1175
        *   out a glyph's optimal scaling and shifting value, various parameter
    
    1176 1176
        *   combinations are tried and scored.
    
    1177 1177
        *
    
    1178
    -   *   By default, warping is off.
    
    1179
    -   *
    
    1180
    -   * @note:
    
    1181
    -   *   This property can be used with @FT_Property_Get also.
    
    1182
    -   *
    
    1183
    -   *   This property can be set via the `FREETYPE_PROPERTIES` environment
    
    1184
    -   *   variable (using values 1 and 0 for 'on' and 'off', respectively).
    
    1185
    -   *
    
    1186
    -   *   The warping code can also change advance widths.  Have a look at the
    
    1187
    -   *   `lsb_delta` and `rsb_delta` fields in the @FT_GlyphSlotRec structure
    
    1188
    -   *   for details on improving inter-glyph distances while rendering.
    
    1189
    -   *
    
    1190
    -   *   Since warping is a global property of the auto-hinter it is best to
    
    1191
    -   *   change its value before rendering any face.  Otherwise, you should
    
    1192
    -   *   reload all faces that get auto-hinted in 'normal' hinting mode.
    
    1193
    -   *
    
    1194
    -   * @example:
    
    1195
    -   *   This example shows how to switch on warping (omitting the error
    
    1196
    -   *   handling).
    
    1197
    -   *
    
    1198
    -   *   ```
    
    1199
    -   *     FT_Library  library;
    
    1200
    -   *     FT_Bool     warping = 1;
    
    1201
    -   *
    
    1202
    -   *
    
    1203
    -   *     FT_Init_FreeType( &library );
    
    1204
    -   *
    
    1205
    -   *     FT_Property_Set( library, "autofitter", "warping", &warping );
    
    1206
    -   *   ```
    
    1207
    -   *
    
    1208 1178
        * @since:
    
    1209 1179
        *   2.6
    
    1210 1180
        *
    

  • include/freetype/internal/fttrace.h
    ... ... @@ -159,7 +159,6 @@ FT_TRACE_DEF( afglobal )
    159 159
     FT_TRACE_DEF( afhints )
    
    160 160
     FT_TRACE_DEF( afmodule )
    
    161 161
     FT_TRACE_DEF( aflatin )
    
    162
    -FT_TRACE_DEF( aflatin2 )
    
    163 162
     FT_TRACE_DEF( afshaper )
    
    164 163
     FT_TRACE_DEF( afwarp )
    
    165 164
     
    

  • src/autofit/afangles.c deleted
    1
    -/****************************************************************************
    
    2
    - *
    
    3
    - * afangles.c
    
    4
    - *
    
    5
    - *   Routines used to compute vector angles with limited accuracy
    
    6
    - *   and very high speed.  It also contains sorting routines (body).
    
    7
    - *
    
    8
    - * Copyright (C) 2003-2021 by
    
    9
    - * David Turner, Robert Wilhelm, and Werner Lemberg.
    
    10
    - *
    
    11
    - * This file is part of the FreeType project, and may only be used,
    
    12
    - * modified, and distributed under the terms of the FreeType project
    
    13
    - * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    
    14
    - * this file you indicate that you have read the license and
    
    15
    - * understand and accept it fully.
    
    16
    - *
    
    17
    - */
    
    18
    -
    
    19
    -
    
    20
    -#include "aftypes.h"
    
    21
    -
    
    22
    -
    
    23
    -  /*
    
    24
    -   * We are not using `af_angle_atan' anymore, but we keep the source
    
    25
    -   * code below just in case...
    
    26
    -   */
    
    27
    -
    
    28
    -
    
    29
    -#if 0
    
    30
    -
    
    31
    -
    
    32
    -  /*
    
    33
    -   * The trick here is to realize that we don't need a very accurate angle
    
    34
    -   * approximation.  We are going to use the result of `af_angle_atan' to
    
    35
    -   * only compare the sign of angle differences, or check whether its
    
    36
    -   * magnitude is very small.
    
    37
    -   *
    
    38
    -   * The approximation
    
    39
    -   *
    
    40
    -   *   dy * PI / (|dx|+|dy|)
    
    41
    -   *
    
    42
    -   * should be enough, and much faster to compute.
    
    43
    -   */
    
    44
    -  FT_LOCAL_DEF( AF_Angle )
    
    45
    -  af_angle_atan( FT_Fixed  dx,
    
    46
    -                 FT_Fixed  dy )
    
    47
    -  {
    
    48
    -    AF_Angle  angle;
    
    49
    -    FT_Fixed  ax = dx;
    
    50
    -    FT_Fixed  ay = dy;
    
    51
    -
    
    52
    -
    
    53
    -    if ( ax < 0 )
    
    54
    -      ax = -ax;
    
    55
    -    if ( ay < 0 )
    
    56
    -      ay = -ay;
    
    57
    -
    
    58
    -    ax += ay;
    
    59
    -
    
    60
    -    if ( ax == 0 )
    
    61
    -      angle = 0;
    
    62
    -    else
    
    63
    -    {
    
    64
    -      angle = ( AF_ANGLE_PI2 * dy ) / ( ax + ay );
    
    65
    -      if ( dx < 0 )
    
    66
    -      {
    
    67
    -        if ( angle >= 0 )
    
    68
    -          angle = AF_ANGLE_PI - angle;
    
    69
    -        else
    
    70
    -          angle = -AF_ANGLE_PI - angle;
    
    71
    -      }
    
    72
    -    }
    
    73
    -
    
    74
    -    return angle;
    
    75
    -  }
    
    76
    -
    
    77
    -
    
    78
    -#elif 0
    
    79
    -
    
    80
    -
    
    81
    -  /* the following table has been automatically generated with */
    
    82
    -  /* the `mather.py' Python script                             */
    
    83
    -
    
    84
    -#define AF_ATAN_BITS  8
    
    85
    -
    
    86
    -  static const FT_Byte  af_arctan[1L << AF_ATAN_BITS] =
    
    87
    -  {
    
    88
    -     0,  0,  1,  1,  1,  2,  2,  2,
    
    89
    -     3,  3,  3,  3,  4,  4,  4,  5,
    
    90
    -     5,  5,  6,  6,  6,  7,  7,  7,
    
    91
    -     8,  8,  8,  9,  9,  9, 10, 10,
    
    92
    -    10, 10, 11, 11, 11, 12, 12, 12,
    
    93
    -    13, 13, 13, 14, 14, 14, 14, 15,
    
    94
    -    15, 15, 16, 16, 16, 17, 17, 17,
    
    95
    -    18, 18, 18, 18, 19, 19, 19, 20,
    
    96
    -    20, 20, 21, 21, 21, 21, 22, 22,
    
    97
    -    22, 23, 23, 23, 24, 24, 24, 24,
    
    98
    -    25, 25, 25, 26, 26, 26, 26, 27,
    
    99
    -    27, 27, 28, 28, 28, 28, 29, 29,
    
    100
    -    29, 30, 30, 30, 30, 31, 31, 31,
    
    101
    -    31, 32, 32, 32, 33, 33, 33, 33,
    
    102
    -    34, 34, 34, 34, 35, 35, 35, 35,
    
    103
    -    36, 36, 36, 36, 37, 37, 37, 38,
    
    104
    -    38, 38, 38, 39, 39, 39, 39, 40,
    
    105
    -    40, 40, 40, 41, 41, 41, 41, 42,
    
    106
    -    42, 42, 42, 42, 43, 43, 43, 43,
    
    107
    -    44, 44, 44, 44, 45, 45, 45, 45,
    
    108
    -    46, 46, 46, 46, 46, 47, 47, 47,
    
    109
    -    47, 48, 48, 48, 48, 48, 49, 49,
    
    110
    -    49, 49, 50, 50, 50, 50, 50, 51,
    
    111
    -    51, 51, 51, 51, 52, 52, 52, 52,
    
    112
    -    52, 53, 53, 53, 53, 53, 54, 54,
    
    113
    -    54, 54, 54, 55, 55, 55, 55, 55,
    
    114
    -    56, 56, 56, 56, 56, 57, 57, 57,
    
    115
    -    57, 57, 57, 58, 58, 58, 58, 58,
    
    116
    -    59, 59, 59, 59, 59, 59, 60, 60,
    
    117
    -    60, 60, 60, 61, 61, 61, 61, 61,
    
    118
    -    61, 62, 62, 62, 62, 62, 62, 63,
    
    119
    -    63, 63, 63, 63, 63, 64, 64, 64
    
    120
    -  };
    
    121
    -
    
    122
    -
    
    123
    -  FT_LOCAL_DEF( AF_Angle )
    
    124
    -  af_angle_atan( FT_Fixed  dx,
    
    125
    -                 FT_Fixed  dy )
    
    126
    -  {
    
    127
    -    AF_Angle  angle;
    
    128
    -
    
    129
    -
    
    130
    -    /* check trivial cases */
    
    131
    -    if ( dy == 0 )
    
    132
    -    {
    
    133
    -      angle = 0;
    
    134
    -      if ( dx < 0 )
    
    135
    -        angle = AF_ANGLE_PI;
    
    136
    -      return angle;
    
    137
    -    }
    
    138
    -    else if ( dx == 0 )
    
    139
    -    {
    
    140
    -      angle = AF_ANGLE_PI2;
    
    141
    -      if ( dy < 0 )
    
    142
    -        angle = -AF_ANGLE_PI2;
    
    143
    -      return angle;
    
    144
    -    }
    
    145
    -
    
    146
    -    angle = 0;
    
    147
    -    if ( dx < 0 )
    
    148
    -    {
    
    149
    -      dx = -dx;
    
    150
    -      dy = -dy;
    
    151
    -      angle = AF_ANGLE_PI;
    
    152
    -    }
    
    153
    -
    
    154
    -    if ( dy < 0 )
    
    155
    -    {
    
    156
    -      FT_Pos  tmp;
    
    157
    -
    
    158
    -
    
    159
    -      tmp = dx;
    
    160
    -      dx  = -dy;
    
    161
    -      dy  = tmp;
    
    162
    -      angle -= AF_ANGLE_PI2;
    
    163
    -    }
    
    164
    -
    
    165
    -    if ( dx == 0 && dy == 0 )
    
    166
    -      return 0;
    
    167
    -
    
    168
    -    if ( dx == dy )
    
    169
    -      angle += AF_ANGLE_PI4;
    
    170
    -    else if ( dx > dy )
    
    171
    -      angle += af_arctan[FT_DivFix( dy, dx ) >> ( 16 - AF_ATAN_BITS )];
    
    172
    -    else
    
    173
    -      angle += AF_ANGLE_PI2 -
    
    174
    -               af_arctan[FT_DivFix( dx, dy ) >> ( 16 - AF_ATAN_BITS )];
    
    175
    -
    
    176
    -    if ( angle > AF_ANGLE_PI )
    
    177
    -      angle -= AF_ANGLE_2PI;
    
    178
    -
    
    179
    -    return angle;
    
    180
    -  }
    
    181
    -
    
    182
    -
    
    183
    -#endif /* 0 */
    
    184
    -
    
    185
    -
    
    186
    -  FT_LOCAL_DEF( void )
    
    187
    -  af_sort_pos( FT_UInt  count,
    
    188
    -               FT_Pos*  table )
    
    189
    -  {
    
    190
    -    FT_UInt  i, j;
    
    191
    -    FT_Pos   swap;
    
    192
    -
    
    193
    -
    
    194
    -    for ( i = 1; i < count; i++ )
    
    195
    -    {
    
    196
    -      for ( j = i; j > 0; j-- )
    
    197
    -      {
    
    198
    -        if ( table[j] >= table[j - 1] )
    
    199
    -          break;
    
    200
    -
    
    201
    -        swap         = table[j];
    
    202
    -        table[j]     = table[j - 1];
    
    203
    -        table[j - 1] = swap;
    
    204
    -      }
    
    205
    -    }
    
    206
    -  }
    
    207
    -
    
    208
    -
    
    209
    -  FT_LOCAL_DEF( void )
    
    210
    -  af_sort_and_quantize_widths( FT_UInt*  count,
    
    211
    -                               AF_Width  table,
    
    212
    -                               FT_Pos    threshold )
    
    213
    -  {
    
    214
    -    FT_UInt      i, j;
    
    215
    -    FT_UInt      cur_idx;
    
    216
    -    FT_Pos       cur_val;
    
    217
    -    FT_Pos       sum;
    
    218
    -    AF_WidthRec  swap;
    
    219
    -
    
    220
    -
    
    221
    -    if ( *count == 1 )
    
    222
    -      return;
    
    223
    -
    
    224
    -    /* sort */
    
    225
    -    for ( i = 1; i < *count; i++ )
    
    226
    -    {
    
    227
    -      for ( j = i; j > 0; j-- )
    
    228
    -      {
    
    229
    -        if ( table[j].org >= table[j - 1].org )
    
    230
    -          break;
    
    231
    -
    
    232
    -        swap         = table[j];
    
    233
    -        table[j]     = table[j - 1];
    
    234
    -        table[j - 1] = swap;
    
    235
    -      }
    
    236
    -    }
    
    237
    -
    
    238
    -    cur_idx = 0;
    
    239
    -    cur_val = table[cur_idx].org;
    
    240
    -
    
    241
    -    /* compute and use mean values for clusters not larger than  */
    
    242
    -    /* `threshold'; this is very primitive and might not yield   */
    
    243
    -    /* the best result, but normally, using reference character  */
    
    244
    -    /* `o', `*count' is 2, so the code below is fully sufficient */
    
    245
    -    for ( i = 1; i < *count; i++ )
    
    246
    -    {
    
    247
    -      if ( table[i].org - cur_val > threshold ||
    
    248
    -           i == *count - 1                    )
    
    249
    -      {
    
    250
    -        sum = 0;
    
    251
    -
    
    252
    -        /* fix loop for end of array */
    
    253
    -        if ( table[i].org - cur_val <= threshold &&
    
    254
    -             i == *count - 1                     )
    
    255
    -          i++;
    
    256
    -
    
    257
    -        for ( j = cur_idx; j < i; j++ )
    
    258
    -        {
    
    259
    -          sum         += table[j].org;
    
    260
    -          table[j].org = 0;
    
    261
    -        }
    
    262
    -        table[cur_idx].org = sum / (FT_Pos)j;
    
    263
    -
    
    264
    -        if ( i < *count - 1 )
    
    265
    -        {
    
    266
    -          cur_idx = i + 1;
    
    267
    -          cur_val = table[cur_idx].org;
    
    268
    -        }
    
    269
    -      }
    
    270
    -    }
    
    271
    -
    
    272
    -    cur_idx = 1;
    
    273
    -
    
    274
    -    /* compress array to remove zero values */
    
    275
    -    for ( i = 1; i < *count; i++ )
    
    276
    -    {
    
    277
    -      if ( table[i].org )
    
    278
    -        table[cur_idx++] = table[i];
    
    279
    -    }
    
    280
    -
    
    281
    -    *count = cur_idx;
    
    282
    -  }
    
    283
    -
    
    284
    -
    
    285
    -/* END */

  • src/autofit/afangles.h deleted
    1
    -/*
    
    2
    - * afangles.h
    
    3
    - *
    
    4
    - * This is a dummy file, used to please the build system.  It is never
    
    5
    - * included by the auto-fitter sources.
    
    6
    - *
    
    7
    - */

  • src/autofit/afcjk.c
    ... ... @@ -37,11 +37,6 @@
    37 37
     #include "aferrors.h"
    
    38 38
     
    
    39 39
     
    
    40
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    41
    -#include "afwarp.h"
    
    42
    -#endif
    
    43
    -
    
    44
    -
    
    45 40
       /**************************************************************************
    
    46 41
        *
    
    47 42
        * The macro FT_COMPONENT is used in trace mode.  It is an implicit
    
    ... ... @@ -1400,11 +1395,6 @@
    1400 1395
         /* compute flags depending on render mode, etc. */
    
    1401 1396
         mode = metrics->root.scaler.render_mode;
    
    1402 1397
     
    
    1403
    -#if 0 /* AF_CONFIG_OPTION_USE_WARPER */
    
    1404
    -    if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
    
    1405
    -      metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
    
    1406
    -#endif
    
    1407
    -
    
    1408 1398
         scaler_flags = hints->scaler_flags;
    
    1409 1399
         other_flags  = 0;
    
    1410 1400
     
    
    ... ... @@ -1433,12 +1423,6 @@
    1433 1423
     
    
    1434 1424
         scaler_flags |= AF_SCALER_FLAG_NO_ADVANCE;
    
    1435 1425
     
    
    1436
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    1437
    -    /* get (global) warper flag */
    
    1438
    -    if ( !metrics->root.globals->module->warping )
    
    1439
    -      scaler_flags |= AF_SCALER_FLAG_NO_WARPER;
    
    1440
    -#endif
    
    1441
    -
    
    1442 1426
         hints->scaler_flags = scaler_flags;
    
    1443 1427
         hints->other_flags  = other_flags;
    
    1444 1428
     
    
    ... ... @@ -2321,25 +2305,6 @@
    2321 2305
           if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
    
    2322 2306
                ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) )   )
    
    2323 2307
           {
    
    2324
    -
    
    2325
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    2326
    -        if ( dim == AF_DIMENSION_HORZ                                  &&
    
    2327
    -             metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL &&
    
    2328
    -             AF_HINTS_DO_WARP( hints )                                 )
    
    2329
    -        {
    
    2330
    -          AF_WarperRec  warper;
    
    2331
    -          FT_Fixed      scale;
    
    2332
    -          FT_Pos        delta;
    
    2333
    -
    
    2334
    -
    
    2335
    -          af_warper_compute( &warper, hints, (AF_Dimension)dim,
    
    2336
    -                             &scale, &delta );
    
    2337
    -          af_glyph_hints_scale_dim( hints, (AF_Dimension)dim,
    
    2338
    -                                    scale, delta );
    
    2339
    -          continue;
    
    2340
    -        }
    
    2341
    -#endif /* AF_CONFIG_OPTION_USE_WARPER */
    
    2342
    -
    
    2343 2308
             af_cjk_hint_edges( hints, (AF_Dimension)dim );
    
    2344 2309
             af_cjk_align_edge_points( hints, (AF_Dimension)dim );
    
    2345 2310
             af_glyph_hints_align_strong_points( hints, (AF_Dimension)dim );
    

  • src/autofit/afhints.c
    ... ... @@ -32,6 +32,104 @@
    32 32
     #define FT_COMPONENT  afhints
    
    33 33
     
    
    34 34
     
    
    35
    +  FT_LOCAL_DEF( void )
    
    36
    +  af_sort_pos( FT_UInt  count,
    
    37
    +               FT_Pos*  table )
    
    38
    +  {
    
    39
    +    FT_UInt  i, j;
    
    40
    +    FT_Pos   swap;
    
    41
    +
    
    42
    +
    
    43
    +    for ( i = 1; i < count; i++ )
    
    44
    +    {
    
    45
    +      for ( j = i; j > 0; j-- )
    
    46
    +      {
    
    47
    +        if ( table[j] >= table[j - 1] )
    
    48
    +          break;
    
    49
    +
    
    50
    +        swap         = table[j];
    
    51
    +        table[j]     = table[j - 1];
    
    52
    +        table[j - 1] = swap;
    
    53
    +      }
    
    54
    +    }
    
    55
    +  }
    
    56
    +
    
    57
    +
    
    58
    +  FT_LOCAL_DEF( void )
    
    59
    +  af_sort_and_quantize_widths( FT_UInt*  count,
    
    60
    +                               AF_Width  table,
    
    61
    +                               FT_Pos    threshold )
    
    62
    +  {
    
    63
    +    FT_UInt      i, j;
    
    64
    +    FT_UInt      cur_idx;
    
    65
    +    FT_Pos       cur_val;
    
    66
    +    FT_Pos       sum;
    
    67
    +    AF_WidthRec  swap;
    
    68
    +
    
    69
    +
    
    70
    +    if ( *count == 1 )
    
    71
    +      return;
    
    72
    +
    
    73
    +    /* sort */
    
    74
    +    for ( i = 1; i < *count; i++ )
    
    75
    +    {
    
    76
    +      for ( j = i; j > 0; j-- )
    
    77
    +      {
    
    78
    +        if ( table[j].org >= table[j - 1].org )
    
    79
    +          break;
    
    80
    +
    
    81
    +        swap         = table[j];
    
    82
    +        table[j]     = table[j - 1];
    
    83
    +        table[j - 1] = swap;
    
    84
    +      }
    
    85
    +    }
    
    86
    +
    
    87
    +    cur_idx = 0;
    
    88
    +    cur_val = table[cur_idx].org;
    
    89
    +
    
    90
    +    /* compute and use mean values for clusters not larger than  */
    
    91
    +    /* `threshold'; this is very primitive and might not yield   */
    
    92
    +    /* the best result, but normally, using reference character  */
    
    93
    +    /* `o', `*count' is 2, so the code below is fully sufficient */
    
    94
    +    for ( i = 1; i < *count; i++ )
    
    95
    +    {
    
    96
    +      if ( table[i].org - cur_val > threshold ||
    
    97
    +           i == *count - 1                    )
    
    98
    +      {
    
    99
    +        sum = 0;
    
    100
    +
    
    101
    +        /* fix loop for end of array */
    
    102
    +        if ( table[i].org - cur_val <= threshold &&
    
    103
    +             i == *count - 1                     )
    
    104
    +          i++;
    
    105
    +
    
    106
    +        for ( j = cur_idx; j < i; j++ )
    
    107
    +        {
    
    108
    +          sum         += table[j].org;
    
    109
    +          table[j].org = 0;
    
    110
    +        }
    
    111
    +        table[cur_idx].org = sum / (FT_Pos)j;
    
    112
    +
    
    113
    +        if ( i < *count - 1 )
    
    114
    +        {
    
    115
    +          cur_idx = i + 1;
    
    116
    +          cur_val = table[cur_idx].org;
    
    117
    +        }
    
    118
    +      }
    
    119
    +    }
    
    120
    +
    
    121
    +    cur_idx = 1;
    
    122
    +
    
    123
    +    /* compress array to remove zero values */
    
    124
    +    for ( i = 1; i < *count; i++ )
    
    125
    +    {
    
    126
    +      if ( table[i].org )
    
    127
    +        table[cur_idx++] = table[i];
    
    128
    +    }
    
    129
    +
    
    130
    +    *count = cur_idx;
    
    131
    +  }
    
    132
    +
    
    35 133
       /* Get new segment for given axis. */
    
    36 134
     
    
    37 135
       FT_LOCAL_DEF( FT_Error )
    
    ... ... @@ -1688,33 +1786,4 @@
    1688 1786
       }
    
    1689 1787
     
    
    1690 1788
     
    
    1691
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    1692
    -
    
    1693
    -  /* Apply (small) warp scale and warp delta for given dimension. */
    
    1694
    -
    
    1695
    -  FT_LOCAL_DEF( void )
    
    1696
    -  af_glyph_hints_scale_dim( AF_GlyphHints  hints,
    
    1697
    -                            AF_Dimension   dim,
    
    1698
    -                            FT_Fixed       scale,
    
    1699
    -                            FT_Pos         delta )
    
    1700
    -  {
    
    1701
    -    AF_Point  points       = hints->points;
    
    1702
    -    AF_Point  points_limit = points + hints->num_points;
    
    1703
    -    AF_Point  point;
    
    1704
    -
    
    1705
    -
    
    1706
    -    if ( dim == AF_DIMENSION_HORZ )
    
    1707
    -    {
    
    1708
    -      for ( point = points; point < points_limit; point++ )
    
    1709
    -        point->x = FT_MulFix( point->fx, scale ) + delta;
    
    1710
    -    }
    
    1711
    -    else
    
    1712
    -    {
    
    1713
    -      for ( point = points; point < points_limit; point++ )
    
    1714
    -        point->y = FT_MulFix( point->fy, scale ) + delta;
    
    1715
    -    }
    
    1716
    -  }
    
    1717
    -
    
    1718
    -#endif /* AF_CONFIG_OPTION_USE_WARPER */
    
    1719
    -
    
    1720 1789
     /* END */

  • src/autofit/afhints.h
    ... ... @@ -408,10 +408,6 @@ FT_BEGIN_HEADER
    408 408
     #define AF_HINTS_DO_ADVANCE( h )                                \
    
    409 409
               !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_ADVANCE )
    
    410 410
     
    
    411
    -#define AF_HINTS_DO_WARP( h )                                  \
    
    412
    -          !AF_HINTS_TEST_SCALER( h, AF_SCALER_FLAG_NO_WARPER )
    
    413
    -
    
    414
    -
    
    415 411
     
    
    416 412
       FT_LOCAL( AF_Direction )
    
    417 413
       af_direction_compute( FT_Pos  dx,
    
    ... ... @@ -459,14 +455,6 @@ FT_BEGIN_HEADER
    459 455
       af_glyph_hints_align_weak_points( AF_GlyphHints  hints,
    
    460 456
                                         AF_Dimension   dim );
    
    461 457
     
    
    462
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    463
    -  FT_LOCAL( void )
    
    464
    -  af_glyph_hints_scale_dim( AF_GlyphHints  hints,
    
    465
    -                            AF_Dimension   dim,
    
    466
    -                            FT_Fixed       scale,
    
    467
    -                            FT_Pos         delta );
    
    468
    -#endif
    
    469
    -
    
    470 458
       FT_LOCAL( void )
    
    471 459
       af_glyph_hints_done( AF_GlyphHints  hints );
    
    472 460
     
    

  • src/autofit/afindic.c
    ... ... @@ -27,11 +27,6 @@
    27 27
     #include "aferrors.h"
    
    28 28
     
    
    29 29
     
    
    30
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    31
    -#include "afwarp.h"
    
    32
    -#endif
    
    33
    -
    
    34
    -
    
    35 30
       static FT_Error
    
    36 31
       af_indic_metrics_init( AF_CJKMetrics  metrics,
    
    37 32
                              FT_Face        face )
    

  • src/autofit/aflatin.c
    ... ... @@ -24,11 +24,6 @@
    24 24
     #include "aferrors.h"
    
    25 25
     
    
    26 26
     
    
    27
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    28
    -#include "afwarp.h"
    
    29
    -#endif
    
    30
    -
    
    31
    -
    
    32 27
       /**************************************************************************
    
    33 28
        *
    
    34 29
        * The macro FT_COMPONENT is used in trace mode.  It is an implicit
    
    ... ... @@ -2636,11 +2631,6 @@
    2636 2631
         /* compute flags depending on render mode, etc. */
    
    2637 2632
         mode = metrics->root.scaler.render_mode;
    
    2638 2633
     
    
    2639
    -#if 0 /* #ifdef AF_CONFIG_OPTION_USE_WARPER */
    
    2640
    -    if ( mode == FT_RENDER_MODE_LCD || mode == FT_RENDER_MODE_LCD_V )
    
    2641
    -      metrics->root.scaler.render_mode = mode = FT_RENDER_MODE_NORMAL;
    
    2642
    -#endif
    
    2643
    -
    
    2644 2634
         scaler_flags = hints->scaler_flags;
    
    2645 2635
         other_flags  = 0;
    
    2646 2636
     
    
    ... ... @@ -2678,12 +2668,6 @@
    2678 2668
              ( face->style_flags & FT_STYLE_FLAG_ITALIC ) != 0          )
    
    2679 2669
           scaler_flags |= AF_SCALER_FLAG_NO_HORIZONTAL;
    
    2680 2670
     
    
    2681
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    2682
    -    /* get (global) warper flag */
    
    2683
    -    if ( !metrics->root.globals->module->warping )
    
    2684
    -      scaler_flags |= AF_SCALER_FLAG_NO_WARPER;
    
    2685
    -#endif
    
    2686
    -
    
    2687 2671
         hints->scaler_flags = scaler_flags;
    
    2688 2672
         hints->other_flags  = other_flags;
    
    2689 2673
     
    
    ... ... @@ -3600,24 +3584,6 @@
    3600 3584
         /* grid-fit the outline */
    
    3601 3585
         for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
    
    3602 3586
         {
    
    3603
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    3604
    -      if ( dim == AF_DIMENSION_HORZ                                  &&
    
    3605
    -           metrics->root.scaler.render_mode == FT_RENDER_MODE_NORMAL &&
    
    3606
    -           AF_HINTS_DO_WARP( hints )                                 )
    
    3607
    -      {
    
    3608
    -        AF_WarperRec  warper;
    
    3609
    -        FT_Fixed      scale;
    
    3610
    -        FT_Pos        delta;
    
    3611
    -
    
    3612
    -
    
    3613
    -        af_warper_compute( &warper, hints, (AF_Dimension)dim,
    
    3614
    -                           &scale, &delta );
    
    3615
    -        af_glyph_hints_scale_dim( hints, (AF_Dimension)dim,
    
    3616
    -                                  scale, delta );
    
    3617
    -        continue;
    
    3618
    -      }
    
    3619
    -#endif /* AF_CONFIG_OPTION_USE_WARPER */
    
    3620
    -
    
    3621 3587
           if ( ( dim == AF_DIMENSION_HORZ && AF_HINTS_DO_HORIZONTAL( hints ) ) ||
    
    3622 3588
                ( dim == AF_DIMENSION_VERT && AF_HINTS_DO_VERTICAL( hints ) )   )
    
    3623 3589
           {
    

  • src/autofit/aflatin2.c deleted
    1
    -/* ATTENTION: This file doesn't compile.  It is only here as a reference */
    
    2
    -/*            of an alternative latin hinting algorithm that was always  */
    
    3
    -/*            marked as experimental.                                    */
    
    4
    -
    
    5
    -
    
    6
    -/****************************************************************************
    
    7
    - *
    
    8
    - * aflatin2.c
    
    9
    - *
    
    10
    - *   Auto-fitter hinting routines for latin writing system (body).
    
    11
    - *
    
    12
    - * Copyright (C) 2003-2021 by
    
    13
    - * David Turner, Robert Wilhelm, and Werner Lemberg.
    
    14
    - *
    
    15
    - * This file is part of the FreeType project, and may only be used,
    
    16
    - * modified, and distributed under the terms of the FreeType project
    
    17
    - * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    
    18
    - * this file you indicate that you have read the license and
    
    19
    - * understand and accept it fully.
    
    20
    - *
    
    21
    - */
    
    22
    -
    
    23
    -
    
    24
    -#include <freetype/ftadvanc.h>
    
    25
    -
    
    26
    -
    
    27
    -#ifdef FT_OPTION_AUTOFIT2
    
    28
    -
    
    29
    -#include "afglobal.h"
    
    30
    -#include "aflatin.h"
    
    31
    -#include "aflatin2.h"
    
    32
    -#include "aferrors.h"
    
    33
    -
    
    34
    -
    
    35
    -#ifdef AF_CONFIG_OPTION_USE_WARPER
    
    36
    -#include "afwarp.h"
    
    37
    -#endif
    
    38
    -
    
    39
    -
    
    40
    -  /**************************************************************************
    
    41
    -   *
    
    42
    -   * The macro FT_COMPONENT is used in trace mode.  It is an implicit
    
    43
    -   * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
    
    44
    -   * messages during execution.
    
    45
    -   */
    
    46
    -#undef  FT_COMPONENT
    
    47
    -#define FT_COMPONENT  aflatin2
    
    48
    -
    
    49
    -
    
    50
    -  FT_LOCAL_DEF( FT_Error )
    
    51
    -  af_latin2_hints_compute_segments( AF_GlyphHints  hints,
    
    52
    -                                    AF_Dimension   dim );
    
    53
    -
    
    54
    -  FT_LOCAL_DEF( void )
    
    55
    -  af_latin2_hints_link_segments( AF_GlyphHints  hints,
    
    56
    -                                 AF_Dimension   dim );
    
    57
    -
    
    58
    -  /*************************************************************************/
    
    59
    -  /*************************************************************************/
    
    60
    -  /*****                                                               *****/
    
    61
    -  /*****            L A T I N   G L O B A L   M E T R I C S            *****/
    
    62
    -  /*****                                                               *****/
    
    63
    -  /*************************************************************************/
    
    64
    -  /*************************************************************************/
    
    65
    -
    
    66
    -  FT_LOCAL_DEF( void )
    
    67
    -  af_latin2_metrics_init_widths( AF_LatinMetrics  metrics,
    
    68
    -                                 FT_Face          face )
    
    69
    -  {
    
    70
    -    /* scan the array of segments in each direction */
    
    71
    -    AF_GlyphHintsRec  hints[1];
    
    72
    -
    
    73
    -
    
    74
    -    af_glyph_hints_init( hints, face->memory );
    
    75
    -
    
    76
    -    metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
    
    77
    -    metrics->axis[AF_DIMENSION_VERT].width_count = 0;
    
    78
    -
    
    79
    -    {
    
    80
    -      FT_Error             error;
    
    81
    -      FT_UInt              glyph_index;
    
    82
    -      int                  dim;
    
    83
    -      AF_LatinMetricsRec   dummy[1];
    
    84
    -      AF_Scaler            scaler = &dummy->root.scaler;
    
    85
    -
    
    86
    -
    
    87
    -      glyph_index = FT_Get_Char_Index(
    
    88
    -                      face,
    
    89
    -                      metrics->root.style_class->standard_char );
    
    90
    -      if ( glyph_index == 0 )
    
    91
    -        goto Exit;
    
    92
    -
    
    93
    -      error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
    
    94
    -      if ( error || face->glyph->outline.n_points <= 0 )
    
    95
    -        goto Exit;
    
    96
    -
    
    97
    -      FT_ZERO( dummy );
    
    98
    -
    
    99
    -      dummy->units_per_em = metrics->units_per_em;
    
    100
    -      scaler->x_scale     = scaler->y_scale = 0x10000L;
    
    101
    -      scaler->x_delta     = scaler->y_delta = 0;
    
    102
    -      scaler->face        = face;
    
    103
    -      scaler->render_mode = FT_RENDER_MODE_NORMAL;
    
    104
    -      scaler->flags       = 0;
    
    105
    -
    
    106
    -      af_glyph_hints_rescale( hints, (AF_StyleMetrics)dummy );
    
    107
    -
    
    108
    -      error = af_glyph_hints_reload( hints, &face->glyph->outline );
    
    109
    -      if ( error )
    
    110
    -        goto Exit;
    
    111
    -
    
    112
    -      for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
    
    113
    -      {
    
    114
    -        AF_LatinAxis  axis    = &metrics->axis[dim];
    
    115
    -        AF_AxisHints  axhints = &hints->axis[dim];
    
    116
    -        AF_Segment    seg, limit, link;
    
    117
    -        FT_UInt       num_widths = 0;
    
    118
    -
    
    119
    -
    
    120
    -        error = af_latin2_hints_compute_segments( hints,
    
    121
    -                                                 (AF_Dimension)dim );
    
    122
    -        if ( error )
    
    123
    -          goto Exit;
    
    124
    -
    
    125
    -        af_latin2_hints_link_segments( hints,
    
    126
    -                                      (AF_Dimension)dim );
    
    127
    -
    
    128
    -        seg   = axhints->segments;
    
    129
    -        limit = seg + axhints->num_segments;
    
    130
    -
    
    131
    -        for ( ; seg < limit; seg++ )
    
    132
    -        {
    
    133
    -          link = seg->link;
    
    134
    -
    
    135
    -          /* we only consider stem segments there! */
    
    136
    -          if ( link && link->link == seg && link > seg )
    
    137
    -          {
    
    138
    -            FT_Pos  dist;
    
    139
    -
    
    140
    -
    
    141
    -            dist = seg->pos - link->pos;
    
    142
    -            if ( dist < 0 )
    
    143
    -              dist = -dist;
    
    144
    -
    
    145
    -            if ( num_widths < AF_LATIN_MAX_WIDTHS )
    
    146
    -              axis->widths[num_widths++].org = dist;
    
    147
    -          }
    
    148
    -        }
    
    149
    -
    
    150
    -        af_sort_widths( num_widths, axis->widths );
    
    151
    -        axis->width_count = num_widths;
    
    152
    -      }
    
    153
    -
    
    154
    -  Exit:
    
    155
    -      for ( dim = 0; dim < AF_DIMENSION_MAX; dim++ )
    
    156
    -      {
    
    157
    -        AF_LatinAxis  axis = &metrics->axis[dim];
    
    158
    -        FT_Pos        stdw;
    
    159
    -
    
    160
    -
    
    161
    -        stdw = ( axis->width_count > 0 )
    
    162
    -                 ? axis->widths[0].org
    
    163
    -                 : AF_LATIN_CONSTANT( metrics, 50 );
    
    164
    -
    
    165
    -        /* let's try 20% of the smallest width */
    
    166
    -        axis->edge_distance_threshold = stdw / 5;
    
    167
    -        axis->standard_width          = stdw;
    
    168
    -        axis->extra_light             = 0;
    
    169
    -      }
    
    170
    -    }
    
    171
    -
    
    172
    -    af_glyph_hints_done( hints );
    
    173
    -  }
    
    174
    -
    
    175
    -
    
    176
    -
    
    177
    -#define AF_LATIN_MAX_TEST_CHARACTERS  12
    
    178
    -
    
    179
    -
    
    180
    -  static const char af_latin2_blue_chars[AF_LATIN_MAX_BLUES]
    
    181
    -                                        [AF_LATIN_MAX_TEST_CHARACTERS+1] =
    
    182
    -  {
    
    183
    -    "THEZOCQS",
    
    184
    -    "HEZLOCUS",
    
    185
    -    "fijkdbh",
    
    186
    -    "xzroesc",
    
    187
    -    "xzroesc",
    
    188
    -    "pqgjy"
    
    189
    -  };
    
    190
    -
    
    191
    -
    
    192
    -  static void
    
    193
    -  af_latin2_metrics_init_blues( AF_LatinMetrics  metrics,
    
    194
    -                                FT_Face          face )
    
    195
    -  {
    
    196
    -    FT_Pos        flats [AF_LATIN_MAX_TEST_CHARACTERS];
    
    197
    -    FT_Pos        rounds[AF_LATIN_MAX_TEST_CHARACTERS];
    
    198
    -    FT_Int        num_flats;
    
    199
    -    FT_Int        num_rounds;
    
    200
    -    FT_Int        bb;
    
    201
    -    AF_LatinBlue  blue;
    
    202
    -    FT_Error      error;
    
    203
    -    AF_LatinAxis  axis  = &metrics->axis[AF_DIMENSION_VERT];
    
    204
    -    FT_GlyphSlot  glyph = face->glyph;
    
    205
    -
    
    206
    -
    
    207
    -    /* we compute the blues simply by loading each character from the     */
    
    208
    -    /* 'af_latin2_blue_chars[blues]' string, then compute its top-most or */
    
    209
    -    /* bottom-most points (depending on `AF_IS_TOP_BLUE')                 */
    
    210
    -
    
    211
    -    FT_TRACE5(( "blue zones computation\n" ));
    
    212
    -    FT_TRACE5(( "======================\n" ));
    
    213
    -    FT_TRACE5(( "\n" ));
    
    214
    -
    
    215
    -    for ( bb = 0; bb < AF_LATIN_BLUE_MAX; bb++ )
    
    216
    -    {
    
    217
    -      const char*  p     = af_latin2_blue_chars[bb];
    
    218
    -      const char*  limit = p + AF_LATIN_MAX_TEST_CHARACTERS;
    
    219
    -      FT_Pos*      blue_ref;
    
    220
    -      FT_Pos*      blue_shoot;
    
    221
    -
    
    222
    -
    
    223
    -      FT_TRACE5(( "blue zone %d:\n", bb ));
    
    224
    -
    
    225
    -      num_flats  = 0;
    
    226
    -      num_rounds = 0;
    
    227
    -
    
    228
    -      for ( ; p < limit && *p; p++ )
    
    229
    -      {
    
    230
    -        FT_UInt     glyph_index;
    
    231
    -        FT_Int      best_point, best_y, best_first, best_last;
    
    232
    -        FT_Vector*  points;
    
    233
    -        FT_Bool     round;
    
    234
    -
    
    235
    -
    
    236
    -        /* load the character in the face -- skip unknown or empty ones */
    
    237
    -        glyph_index = FT_Get_Char_Index( face, (FT_UInt)*p );
    
    238
    -        if ( glyph_index == 0 )
    
    239
    -          continue;
    
    240
    -
    
    241
    -        error = FT_Load_Glyph( face, glyph_index, FT_LOAD_NO_SCALE );
    
    242
    -        if ( error || glyph->outline.n_points <= 0 )
    
    243
    -          continue;
    
    244
    -
    
    245
    -        /* now compute min or max point indices and coordinates */
    
    246
    -        points      = glyph->outline.points;
    
    247
    -        best_point  = -1;
    
    248
    -        best_y      = 0;  /* make compiler happy */
    
    249
    -        best_first  = 0;  /* ditto */
    
    250
    -        best_last   = 0;  /* ditto */
    
    251
    -
    
    252
    -        {
    
    253
    -          FT_Int  nn;
    
    254
    -          FT_Int  first = 0;
    
    255
    -          FT_Int  last  = -1;
    
    256
    -
    
    257
    -
    
    258
    -          for ( nn = 0; nn < glyph->outline.n_contours; first = last+1, nn++ )
    
    259
    -          {
    
    260
    -            FT_Int  old_best_point = best_point;
    
    261
    -            FT_Int  pp;
    
    262
    -
    
    263
    -
    
    264
    -            last = glyph->outline.contours[nn];
    
    265
    -
    
    266
    -            /* Avoid single-point contours since they are never rasterized. */
    
    267
    -            /* In some fonts, they correspond to mark attachment points     */
    
    268
    -            /* which are way outside of the glyph's real outline.           */
    
    269
    -            if ( last <= first )
    
    270
    -                continue;
    
    271
    -
    
    272
    -            if ( AF_LATIN_IS_TOP_BLUE( bb ) )
    
    273
    -            {
    
    274
    -              for ( pp = first; pp <= last; pp++ )
    
    275
    -                if ( best_point < 0 || points[pp].y > best_y )
    
    276
    -                {
    
    277
    -                  best_point = pp;
    
    278
    -                  best_y     = points[pp].y;
    
    279
    -                }
    
    280
    -            }
    
    281
    -            else
    
    282
    -            {
    
    283
    -              for ( pp = first; pp <= last; pp++ )
    
    284
    -                if ( best_point < 0 || points[pp].y < best_y )
    
    285
    -                {
    
    286
    -                  best_point = pp;
    
    287
    -                  best_y     = points[pp].y;
    
    288
    -                }
    
    289
    -            }
    
    290
    -
    
    291
    -            if ( best_point != old_best_point )
    
    292
    -            {
    
    293
    -              best_first = first;
    
    294
    -              best_last  = last;
    
    295
    -            }
    
    296
    -          }
    
    297
    -          FT_TRACE5(( "  %c  %d", *p, best_y ));
    
    298
    -        }
    
    299
    -
    
    300
    -        /* now check whether the point belongs to a straight or round   */
    
    301
    -        /* segment; we first need to find in which contour the extremum */
    
    302
    -        /* lies, then inspect its previous and next points              */
    
    303
    -        if ( best_point >= 0 )
    
    304
    -        {
    
    305
    -          FT_Pos  best_x = points[best_point].x;
    
    306
    -          FT_Int  start, end, prev, next;
    
    307
    -          FT_Pos  dist;
    
    308
    -
    
    309
    -
    
    310
    -          /* now look for the previous and next points that are not on the */
    
    311
    -          /* same Y coordinate.  Threshold the `closeness'...              */
    
    312
    -          start = end = best_point;
    
    313
    -
    
    314
    -          do
    
    315
    -          {
    
    316
    -            prev = start - 1;
    
    317
    -            if ( prev < best_first )
    
    318
    -              prev = best_last;
    
    319
    -
    
    320
    -            dist = FT_ABS( points[prev].y - best_y );
    
    321
    -            /* accept a small distance or a small angle (both values are */
    
    322
    -            /* heuristic; value 20 corresponds to approx. 2.9 degrees)   */
    
    323
    -            if ( dist > 5 )
    
    324
    -              if ( FT_ABS( points[prev].x - best_x ) <= 20 * dist )
    
    325
    -                break;
    
    326
    -
    
    327
    -            start = prev;
    
    328
    -
    
    329
    -          } while ( start != best_point );
    
    330
    -
    
    331
    -          do
    
    332
    -          {
    
    333
    -            next = end + 1;
    
    334
    -            if ( next > best_last )
    
    335
    -              next = best_first;
    
    336
    -
    
    337
    -            dist = FT_ABS( points[next].y - best_y );
    
    338
    -            if ( dist > 5 )
    
    339
    -              if ( FT_ABS( points[next].x - best_x ) <= 20 * dist )
    
    340
    -                break;
    
    341
    -
    
    342
    -            end = next;
    
    343
    -
    
    344
    -          } while ( end != best_point );
    
    345
    -
    
    346
    -          /* now, set the `round' flag depending on the segment's kind */
    
    347
    -          round = FT_BOOL(
    
    348
    -            FT_CURVE_TAG( glyph->outline.tags[start] ) != FT_CURVE_TAG_ON ||
    
    349
    -            FT_CURVE_TAG( glyph->outline.tags[ end ] ) != FT_CURVE_TAG_ON );
    
    350
    -
    
    351
    -          FT_TRACE5(( " (%s)\n", round ? "round" : "flat" ));
    
    352
    -        }
    
    353
    -
    
    354
    -        if ( round )
    
    355
    -          rounds[num_rounds++] = best_y;
    
    356
    -        else
    
    357
    -          flats[num_flats++]   = best_y;
    
    358
    -      }
    
    359
    -
    
    360
    -      if ( num_flats == 0 && num_rounds == 0 )
    
    361
    -      {
    
    362
    -        /*
    
    363
    -         * we couldn't find a single glyph to compute this blue zone,
    
    364
    -         * we will simply ignore it then
    
    365
    -         */
    
    366
    -        FT_TRACE5(( "  empty\n" ));
    
    367
    -        continue;
    
    368
    -      }
    
    369
    -
    
    370
    -      /* we have computed the contents of the `rounds' and `flats' tables, */
    
    371
    -      /* now determine the reference and overshoot position of the blue -- */
    
    372
    -      /* we simply take the median value after a simple sort               */
    
    373
    -      af_sort_pos( num_rounds, rounds );
    
    374
    -      af_sort_pos( num_flats,  flats );
    
    375
    -
    
    376
    -      blue       = & axis->blues[axis->blue_count];
    
    377
    -      blue_ref   = & blue->ref.org;
    
    378
    -      blue_shoot = & blue->shoot.org;
    
    379
    -
    
    380
    -      axis->blue_count++;
    
    381
    -
    
    382
    -      if ( num_flats == 0 )
    
    383
    -      {
    
    384
    -        *blue_ref   =
    
    385
    -        *blue_shoot = rounds[num_rounds / 2];
    
    386
    -      }
    
    387
    -      else if ( num_rounds == 0 )
    
    388
    -      {
    
    389
    -        *blue_ref   =
    
    390
    -        *blue_shoot = flats[num_flats / 2];
    
    391
    -      }
    
    392
    -      else
    
    393
    -      {
    
    394
    -        *blue_ref   = flats[num_flats / 2];
    
    395
    -        *blue_shoot = rounds[num_rounds / 2];
    
    396
    -      }
    
    397
    -
    
    398
    -      /* there are sometimes problems: if the overshoot position of top     */
    
    399
    -      /* zones is under its reference position, or the opposite for bottom  */
    
    400
    -      /* zones.  We must thus check everything there and correct the errors */
    
    401
    -      if ( *blue_shoot != *blue_ref )
    
    402
    -      {
    
    403