misc/libfreetype/src/pshinter/pshglob.c
author nemo
Sun, 03 Jun 2012 23:04:21 -0400
changeset 7174 80480d21e6ed
parent 5172 88f2e05288ba
permissions -rw-r--r--
Workaround for bug #144. This workaround had occurred to me a while ago, but wasn't sure if placing them unfairly was better than not placing them at all. Argument for not placing at all is people should probably abort the game when they notice it. Argument for placing unfairly is people can still abort, and if we really wanted them to abort, we should probably just have halted launch if all hogs failed to spawn. This way at least play can continue.
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
/*  pshglob.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
/*    PostScript hinter global hinting management (body).                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*    Inspired by the new auto-hinter module.                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  Copyright 2001, 2002, 2003, 2004, 2006, 2010 by                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  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
    12
/*  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
    13
/*  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
    14
/*  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
    15
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_FREETYPE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "pshglob.h"
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
#ifdef DEBUG_HINTER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
  PSH_Globals  ps_debug_globals = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#endif
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /*****                       STANDARD WIDTHS                         *****/
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  /* scale the widths/heights table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  psh_globals_scale_widths( PSH_Globals  globals,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
                            FT_UInt      direction )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    PSH_Dimension  dim   = &globals->dimension[direction];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    PSH_Widths     stdw  = &dim->stdw;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    FT_UInt        count = stdw->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    PSH_Width      width = stdw->widths;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    PSH_Width      stand = width;               /* standard width/height */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
    FT_Fixed       scale = dim->scale_mult;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    if ( count > 0 )
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
      width->cur = FT_MulFix( width->org, scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
      width->fit = FT_PIX_ROUND( width->cur );
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
      width++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
      count--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
      for ( ; count > 0; count--, width++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
        FT_Pos  w, dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
        w    = FT_MulFix( width->org, scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
        dist = w - stand->cur;
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
        if ( dist < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
          dist = -dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
        if ( dist < 128 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
          w = stand->cur;
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
        width->cur = w;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
        width->fit = FT_PIX_ROUND( w );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
  /* org_width is is font units, result in device pixels, 26.6 format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  FT_LOCAL_DEF( FT_Pos )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  psh_dimension_snap_width( PSH_Dimension  dimension,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
                            FT_Int         org_width )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    FT_UInt  n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    FT_Pos   width     = FT_MulFix( org_width, dimension->scale_mult );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    FT_Pos   best      = 64 + 32 + 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    FT_Pos   reference = width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
    for ( n = 0; n < dimension->stdw.count; n++ )
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
      FT_Pos  w;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
      FT_Pos  dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
      w = dimension->stdw.widths[n].cur;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
      dist = width - w;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
      if ( dist < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
        dist = -dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
      if ( dist < best )
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
        best      = dist;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
        reference = w;
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
    if ( width >= reference )
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
      width -= 0x21;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
      if ( width < reference )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
        width = reference;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
      width += 0x21;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
      if ( width > reference )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
        width = reference;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
    return width;
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
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  /*****                       BLUE ZONES                              *****/
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
  psh_blues_set_zones_0( PSH_Blues       target,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
                         FT_Bool         is_others,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
                         FT_UInt         read_count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
                         FT_Short*       read,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
                         PSH_Blue_Table  top_table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
                         PSH_Blue_Table  bot_table )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    FT_UInt  count_top = top_table->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    FT_UInt  count_bot = bot_table->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    FT_Bool  first     = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    FT_UNUSED( target );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    for ( ; read_count > 1; read_count -= 2 )
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
      FT_Int         reference, delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
      FT_UInt        count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
      PSH_Blue_Zone  zones, zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      FT_Bool        top;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      /* read blue zone entry, and select target top/bottom zone */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
      top = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
      if ( first || is_others )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
        reference = read[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
        delta     = read[0] - reference;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
        zones = bot_table->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
        count = count_bot;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
        first = 0;
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
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
        reference = read[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
        delta     = read[1] - reference;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
        zones = top_table->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
        count = count_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
        top   = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
      /* insert into sorted table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      zone = zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
      for ( ; count > 0; count--, zone++ )
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 ( reference < zone->org_ref )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
          break;
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
        if ( reference == zone->org_ref )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
          FT_Int  delta0 = zone->org_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
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
          /* we have two zones on the same reference position -- */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
          /* only keep the largest one                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
          if ( delta < 0 )
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
            if ( delta < delta0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
              zone->org_delta = delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
          else
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
            if ( delta > delta0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
              zone->org_delta = delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
          goto Skip;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
      for ( ; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
        zone[count] = zone[count-1];
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
      zone->org_ref   = reference;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
      zone->org_delta = delta;
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
      if ( top )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
        count_top++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
        count_bot++;
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
    Skip:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
      read += 2;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    top_table->count = count_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    bot_table->count = count_bot;
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
  /* Re-read blue zones from the original fonts and store them into out */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
  /* private structure.  This function re-orders, sanitizes and         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
  /* fuzz-expands the zones as well.                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
  psh_blues_set_zones( PSH_Blues  target,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
                       FT_UInt    count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
                       FT_Short*  blues,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
                       FT_UInt    count_others,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
                       FT_Short*  other_blues,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
                       FT_Int     fuzz,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
                       FT_Int     family )
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
    PSH_Blue_Table  top_table, bot_table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    FT_Int          count_top, count_bot;
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
    if ( family )
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
      top_table = &target->family_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
      bot_table = &target->family_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
      top_table = &target->normal_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
      bot_table = &target->normal_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
    }
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
    /* read the input blue zones, and build two sorted tables  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    /* (one for the top zones, the other for the bottom zones) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
    top_table->count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    bot_table->count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
    /* first, the blues */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
    psh_blues_set_zones_0( target, 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
                           count, blues, top_table, bot_table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
    psh_blues_set_zones_0( target, 1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
                           count_others, other_blues, top_table, bot_table );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
    count_top = top_table->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
    count_bot = bot_table->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    /* sanitize top table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
    if ( count_top > 0 )
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
      PSH_Blue_Zone  zone = top_table->zones;
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 ( count = count_top; count > 0; count--, zone++ )
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
        FT_Int  delta;
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 ( count > 1 )
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
          delta = zone[1].org_ref - zone[0].org_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
          if ( zone->org_delta > delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
            zone->org_delta = delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
        zone->org_bottom = zone->org_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
        zone->org_top    = zone->org_delta + zone->org_ref;
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
    /* sanitize bottom table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    if ( count_bot > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
      PSH_Blue_Zone  zone = bot_table->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
      for ( count = count_bot; count > 0; count--, zone++ )
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
        FT_Int  delta;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
        if ( count > 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
          delta = zone[0].org_ref - zone[1].org_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
          if ( zone->org_delta < delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
            zone->org_delta = delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
        zone->org_top    = zone->org_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
        zone->org_bottom = zone->org_delta + zone->org_ref;
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
    /* expand top and bottom tables with blue fuzz */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
      FT_Int         dim, top, bot, delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
      PSH_Blue_Zone  zone;
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
      zone  = top_table->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
      count = count_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
      for ( dim = 1; dim >= 0; dim-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
        if ( count > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
          /* expand the bottom of the lowest zone normally */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
          zone->org_bottom -= fuzz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
          /* expand the top and bottom of intermediate zones;    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
          /* checking that the interval is smaller than the fuzz */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
          top = zone->org_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
          for ( count--; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
            bot   = zone[1].org_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
            delta = bot - top;
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
            if ( delta < 2 * fuzz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
              zone[0].org_top = zone[1].org_bottom = top + delta / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
              zone[0].org_top    = top + fuzz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
              zone[1].org_bottom = bot - fuzz;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
            zone++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
            top = zone->org_top;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
          /* expand the top of the highest zone normally */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
          zone->org_top = top + fuzz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
        zone  = bot_table->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
        count = count_bot;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
    }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
  /* reset the blues table when the device transform changes */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
  psh_blues_scale_zones( PSH_Blues  blues,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
                         FT_Fixed   scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
                         FT_Pos     delta )
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
    FT_UInt         count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
    FT_UInt         num;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    PSH_Blue_Table  table = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
    /* Determine whether we need to suppress overshoots or    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
    /* not.  We simply need to compare the vertical scale     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
    /* parameter to the raw bluescale value.  Here is why:    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
    /*   We need to suppress overshoots for all pointsizes.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
    /*   At 300dpi that satisfies:                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    /*      pointsize < 240*bluescale + 0.49                  */
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
    /*   This corresponds to:                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
    /*      pixelsize < 1000*bluescale + 49/24                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
    /*      scale*EM_Size < 1000*bluescale + 49/24            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
    /*   However, for normal Type 1 fonts, EM_Size is 1000!   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
    /*   We thus only check:                                  */
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
    /*      scale < bluescale + 49/24000                      */
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
    /*   which we shorten to                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    /*      "scale < bluescale"                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
    /* Note that `blue_scale' is stored 1000 times its real   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
    /* value, and that `scale' converts from font units to    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
    /* fractional pixels.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
    /*                                                        */
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
    /* 1000 / 64 = 125 / 8 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
    if ( scale >= 0x20C49BAL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
      blues->no_overshoots = FT_BOOL( scale < blues->blue_scale * 8 / 125 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
      blues->no_overshoots = FT_BOOL( scale * 125 < blues->blue_scale * 8 );
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
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
    /*  The blue threshold is the font units distance under   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
    /*  which overshoots are suppressed due to the BlueShift  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
    /*  even if the scale is greater than BlueScale.          */
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
    /*  It is the smallest distance such that                 */
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
    /*    dist <= BlueShift && dist*scale <= 0.5 pixels       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
    /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
      FT_Int  threshold = blues->blue_shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
      while ( threshold > 0 && FT_MulFix( threshold, scale ) > 32 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
        threshold--;
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
      blues->blue_threshold = threshold;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
    for ( num = 0; num < 4; num++ )
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
      PSH_Blue_Zone  zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
      switch ( num )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
      case 0:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        table = &blues->normal_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
      case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        table = &blues->normal_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
      case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
        table = &blues->family_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
        table = &blues->family_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
        break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
      zone  = table->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
      count = table->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
      for ( ; count > 0; count--, zone++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
        zone->cur_top    = FT_MulFix( zone->org_top,    scale ) + delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
        zone->cur_bottom = FT_MulFix( zone->org_bottom, scale ) + delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
        zone->cur_ref    = FT_MulFix( zone->org_ref,    scale ) + delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
        zone->cur_delta  = FT_MulFix( zone->org_delta,  scale );
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
        /* round scaled reference position */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
        zone->cur_ref = FT_PIX_ROUND( zone->cur_ref );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
        if ( zone->cur_ref > zone->cur_top )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
          zone->cur_ref -= 64;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
        else if ( zone->cur_ref < zone->cur_bottom )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
          zone->cur_ref += 64;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
#endif
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
    /* process the families now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
    for ( num = 0; num < 2; num++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
      PSH_Blue_Zone   zone1, zone2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
      FT_UInt         count1, count2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
      PSH_Blue_Table  normal, family;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
      switch ( num )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
      case 0:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
        normal = &blues->normal_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
        family = &blues->family_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
        normal = &blues->normal_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
        family = &blues->family_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
      zone1  = normal->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
      count1 = normal->count;
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
      for ( ; count1 > 0; count1--, zone1++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
        /* try to find a family zone whose reference position is less */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
        /* than 1 pixel far from the current zone                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
        zone2  = family->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
        count2 = family->count;
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
        for ( ; count2 > 0; count2--, zone2++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
          FT_Pos  Delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
          Delta = zone1->org_ref - zone2->org_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
          if ( Delta < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
            Delta = -Delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
          if ( FT_MulFix( Delta, scale ) < 64 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
            zone1->cur_top    = zone2->cur_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
            zone1->cur_bottom = zone2->cur_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
            zone1->cur_ref    = zone2->cur_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
            zone1->cur_delta  = zone2->cur_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
      }
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
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
  psh_blues_snap_stem( PSH_Blues      blues,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
                       FT_Int         stem_top,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
                       FT_Int         stem_bot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
                       PSH_Alignment  alignment )
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
    PSH_Blue_Table  table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
    FT_UInt         count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
    FT_Pos          delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
    PSH_Blue_Zone   zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
    FT_Int          no_shoots;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
    alignment->align = PSH_BLUE_ALIGN_NONE;
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
    no_shoots = blues->no_overshoots;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
    /* look up stem top in top zones table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
    table = &blues->normal_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
    count = table->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    zone  = table->zones;
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
    for ( ; count > 0; count--, zone++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
      delta = stem_top - zone->org_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
      if ( delta < -blues->blue_fuzz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
        break;
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 ( stem_top <= zone->org_top + blues->blue_fuzz )
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
        if ( no_shoots || delta <= blues->blue_threshold )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
          alignment->align    |= PSH_BLUE_ALIGN_TOP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
          alignment->align_top = zone->cur_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
    /* look up stem bottom in bottom zones table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
    table = &blues->normal_bottom;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
    count = table->count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
    zone  = table->zones + count-1;
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
    for ( ; count > 0; count--, zone-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
      delta = zone->org_top - stem_bot;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
      if ( delta < -blues->blue_fuzz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
      if ( stem_bot >= zone->org_bottom - blues->blue_fuzz )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
        if ( no_shoots || delta < blues->blue_threshold )
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
          alignment->align    |= PSH_BLUE_ALIGN_BOT;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
          alignment->align_bot = zone->cur_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
        break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
  /*************************************************************************/
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
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
  /*****                        GLOBAL HINTS                           *****/
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
  psh_globals_destroy( PSH_Globals  globals )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
    if ( globals )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
      FT_Memory  memory;
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
      memory = globals->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
      globals->dimension[0].stdw.count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
      globals->dimension[1].stdw.count = 0;
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
      globals->blues.normal_top.count    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
      globals->blues.normal_bottom.count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
      globals->blues.family_top.count    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
      globals->blues.family_bottom.count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
      FT_FREE( globals );
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
#ifdef DEBUG_HINTER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
      ps_debug_globals = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
  psh_globals_new( FT_Memory     memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
                   T1_Private*   priv,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
                   PSH_Globals  *aglobals )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    PSH_Globals  globals = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
    FT_Error     error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
    if ( !FT_NEW( globals ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
      FT_UInt    count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
      FT_Short*  read;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
      globals->memory = memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
      /* copy standard widths */
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
        PSH_Dimension  dim   = &globals->dimension[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
        PSH_Width      write = dim->stdw.widths;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
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
        write->org = priv->standard_width[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
        write++;
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
        read = priv->snap_widths;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
        for ( count = priv->num_snap_widths; count > 0; count-- )
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
          write->org = *read;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
          write++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
          read++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
        dim->stdw.count = priv->num_snap_widths + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
      }
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
      /* copy standard heights */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
        PSH_Dimension  dim = &globals->dimension[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
        PSH_Width      write = dim->stdw.widths;
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
        write->org = priv->standard_height[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
        write++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
        read = priv->snap_heights;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
        for ( count = priv->num_snap_heights; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
          write->org = *read;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
          write++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
          read++;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
        dim->stdw.count = priv->num_snap_heights + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
      /* copy blue zones */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
      psh_blues_set_zones( &globals->blues, priv->num_blue_values,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
                           priv->blue_values, priv->num_other_blues,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
                           priv->other_blues, priv->blue_fuzz, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
      psh_blues_set_zones( &globals->blues, priv->num_family_blues,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
                           priv->family_blues, priv->num_family_other_blues,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
                           priv->family_other_blues, priv->blue_fuzz, 1 );
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
      globals->blues.blue_scale = priv->blue_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
      globals->blues.blue_shift = priv->blue_shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
      globals->blues.blue_fuzz  = priv->blue_fuzz;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
      globals->dimension[0].scale_mult  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
      globals->dimension[0].scale_delta = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
      globals->dimension[1].scale_mult  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
      globals->dimension[1].scale_delta = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
#ifdef DEBUG_HINTER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
      ps_debug_globals = globals;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
#endif
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
    *aglobals = globals;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
  psh_globals_set_scale( PSH_Globals  globals,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
                         FT_Fixed     x_scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
                         FT_Fixed     y_scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
                         FT_Fixed     x_delta,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
                         FT_Fixed     y_delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
    PSH_Dimension  dim = &globals->dimension[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
    dim = &globals->dimension[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
    if ( x_scale != dim->scale_mult  ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
         x_delta != dim->scale_delta )
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
      dim->scale_mult  = x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
      dim->scale_delta = x_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
      psh_globals_scale_widths( globals, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    dim = &globals->dimension[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
    if ( y_scale != dim->scale_mult  ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
         y_delta != dim->scale_delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
      dim->scale_mult  = y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
      dim->scale_delta = y_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
      psh_globals_scale_widths( globals, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
      psh_blues_scale_zones( &globals->blues, y_scale, y_delta );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
  psh_globals_funcs_init( PSH_Globals_FuncsRec*  funcs )
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
    funcs->create    = psh_globals_new;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
    funcs->set_scale = psh_globals_set_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
    funcs->destroy   = psh_globals_destroy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
/* END */