misc/libfreetype/src/pshinter/pshrec.c
author nemo
Thu, 28 Feb 2013 23:15:33 -0500
changeset 8617 e7bea88096d2
parent 5172 88f2e05288ba
permissions -rw-r--r--
So. A while ago, while trying to prevent hogs blowtorching getting turned around, unc0rr altered the old range of blowtorch from 1/8th of 180° up or down, to a 4° gain in upwards and a -4° loss in downwards. He also made it so that starting tunnels could fail to erase sufficient terrain, trapping hogs. Here are a couple of workarounds to more closely approximate old behaviour (do some initial erasure, adjust min/max angles)
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
/*  pshrec.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
/*    FreeType PostScript hints recorder (body).                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2001, 2002, 2003, 2004, 2007, 2009 by                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_FREETYPE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_INTERNAL_CALC_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
#include "pshrec.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#include "pshalgo.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
#include "pshnterr.h"
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
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
#define FT_COMPONENT  trace_pshrec
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
#ifdef DEBUG_HINTER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  PS_Hints  ps_debug_hints         = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  int       ps_debug_no_horz_hints = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
  int       ps_debug_no_vert_hints = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  /*****                      PS_HINT MANAGEMENT                       *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
  /* destroy hints table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
  ps_hint_table_done( PS_Hint_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
                      FT_Memory      memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
    FT_FREE( table->hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    table->num_hints = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    table->max_hints = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
  /* ensure that a table can contain "count" elements */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
  ps_hint_table_ensure( PS_Hint_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
                        FT_UInt        count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
                        FT_Memory      memory )
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
    FT_UInt   old_max = table->max_hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    FT_UInt   new_max = count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    FT_Error  error   = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    if ( new_max > old_max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
      /* try to grow the table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
      new_max = FT_PAD_CEIL( new_max, 8 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      if ( !FT_RENEW_ARRAY( table->hints, old_max, new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
        table->max_hints = new_max;
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
    return error;
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
  ps_hint_table_alloc( PS_Hint_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
                       FT_Memory      memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
                       PS_Hint       *ahint )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    FT_UInt   count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    PS_Hint   hint = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    count = table->num_hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    count++;
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
    if ( count >= table->max_hints )
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
      error = ps_hint_table_ensure( table, count, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    hint        = table->hints + count - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    hint->pos   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    hint->len   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    hint->flags = 0;
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
    table->num_hints = count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    *ahint = hint;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
  /*****                      PS_MASK MANAGEMENT                       *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
  /* destroy mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  ps_mask_done( PS_Mask    mask,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
                FT_Memory  memory )
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
    FT_FREE( mask->bytes );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    mask->num_bits  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    mask->max_bits  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    mask->end_point = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
  /* ensure that a mask can contain "count" bits */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
  ps_mask_ensure( PS_Mask    mask,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
                  FT_UInt    count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
                  FT_Memory  memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    FT_UInt   old_max = ( mask->max_bits + 7 ) >> 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    FT_UInt   new_max = ( count          + 7 ) >> 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
    FT_Error  error   = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    if ( new_max > old_max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
      new_max = FT_PAD_CEIL( new_max, 8 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
        mask->max_bits = new_max * 8;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    return error;
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
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
  /* test a bit value in a given mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
  static FT_Int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
  ps_mask_test_bit( PS_Mask  mask,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
                    FT_Int   idx )
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
    if ( (FT_UInt)idx >= mask->num_bits )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    return mask->bytes[idx >> 3] & ( 0x80 >> ( idx & 7 ) );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
  /* clear a given bit */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
  ps_mask_clear_bit( PS_Mask  mask,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
                     FT_Int   idx )
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
    FT_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    if ( (FT_UInt)idx >= mask->num_bits )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    p    = mask->bytes + ( idx >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    p[0] = (FT_Byte)( p[0] & ~( 0x80 >> ( idx & 7 ) ) );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
  /* set a given bit, possibly grow the mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
  ps_mask_set_bit( PS_Mask    mask,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
                   FT_Int     idx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
                   FT_Memory  memory )
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
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    FT_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
    if ( idx < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    if ( (FT_UInt)idx >= mask->num_bits )
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
      error = ps_mask_ensure( mask, idx + 1, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
      mask->num_bits = idx + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    p    = mask->bytes + ( idx >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    p[0] = (FT_Byte)( p[0] | ( 0x80 >> ( idx & 7 ) ) );
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
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
  /* destroy mask table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
  ps_mask_table_done( PS_Mask_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
                      FT_Memory      memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    FT_UInt  count = table->max_masks;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    PS_Mask  mask  = table->masks;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
    for ( ; count > 0; count--, mask++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
      ps_mask_done( mask, memory );
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
    FT_FREE( table->masks );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    table->num_masks = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
    table->max_masks = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
  /* ensure that a mask table can contain "count" masks */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
  ps_mask_table_ensure( PS_Mask_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
                        FT_UInt        count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
                        FT_Memory      memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
    FT_UInt   old_max = table->max_masks;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
    FT_UInt   new_max = count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    FT_Error  error   = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    if ( new_max > old_max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
      new_max = FT_PAD_CEIL( new_max, 8 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
      if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
        table->max_masks = new_max;
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
  /* allocate a new mask in a table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
  ps_mask_table_alloc( PS_Mask_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
                       FT_Memory      memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
                       PS_Mask       *amask )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    FT_UInt   count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    PS_Mask   mask  = 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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
    count = table->num_masks;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
    count++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
    if ( count > table->max_masks )
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
      error = ps_mask_table_ensure( table, count, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
    mask             = table->masks + count - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
    mask->num_bits   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
    mask->end_point  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
    table->num_masks = count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
    *amask = mask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
    return error;
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
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
  /* return last hint mask in a table, create one if the table is empty */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
  ps_mask_table_last( PS_Mask_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
                      FT_Memory      memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
                      PS_Mask       *amask )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
    FT_UInt   count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    PS_Mask   mask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    count = table->num_masks;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    if ( count == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
      error = ps_mask_table_alloc( table, memory, &mask );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
        goto Exit;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
      mask = table->masks + count - 1;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    *amask = mask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
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
  /* set a new mask to a given bit range */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
  ps_mask_table_set_bits( PS_Mask_Table   table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
                          const FT_Byte*  source,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
                          FT_UInt         bit_pos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
                          FT_UInt         bit_count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
                          FT_Memory       memory )
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_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
    PS_Mask   mask;
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
    error = ps_mask_table_last( table, memory, &mask );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
    error = ps_mask_ensure( mask, bit_count, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
    mask->num_bits = bit_count;
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
    /* now, copy bits */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
      FT_Byte*  read  = (FT_Byte*)source + ( bit_pos >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
      FT_Int    rmask = 0x80 >> ( bit_pos & 7 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
      FT_Byte*  write = mask->bytes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
      FT_Int    wmask = 0x80;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
      FT_Int    val;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
      for ( ; bit_count > 0; bit_count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
        val = write[0] & ~wmask;
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
        if ( read[0] & rmask )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
          val |= wmask;
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
        write[0] = (FT_Byte)val;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
        rmask >>= 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
        if ( rmask == 0 )
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
          read++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
          rmask = 0x80;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
        wmask >>= 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
        if ( wmask == 0 )
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
          write++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
          wmask = 0x80;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
  /* test whether two masks in a table intersect */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
  static FT_Int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
  ps_mask_table_test_intersect( PS_Mask_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
                                FT_Int         index1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
                                FT_Int         index2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
    PS_Mask   mask1  = table->masks + index1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
    PS_Mask   mask2  = table->masks + index2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
    FT_Byte*  p1     = mask1->bytes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
    FT_Byte*  p2     = mask2->bytes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    FT_UInt   count1 = mask1->num_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
    FT_UInt   count2 = mask2->num_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
    FT_UInt   count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
    count = ( count1 <= count2 ) ? count1 : count2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
    for ( ; count >= 8; count -= 8 )
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
      if ( p1[0] & p2[0] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
        return 1;
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
      p1++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
      p2++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    if ( count == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
      return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
    return ( p1[0] & p2[0] ) & ~( 0xFF >> count );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
  }
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
  /* merge two masks, used by ps_mask_table_merge_all */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
  ps_mask_table_merge( PS_Mask_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
                       FT_Int         index1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
                       FT_Int         index2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
                       FT_Memory      memory )
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
    FT_UInt   temp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
    /* swap index1 and index2 so that index1 < index2 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
    if ( index1 > index2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
      temp   = index1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
      index1 = index2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
      index2 = temp;
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
    if ( index1 < index2 && index1 >= 0 && index2 < (FT_Int)table->num_masks )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
      /* we need to merge the bitsets of index1 and index2 with a */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
      /* simple union                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
      PS_Mask  mask1  = table->masks + index1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
      PS_Mask  mask2  = table->masks + index2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
      FT_UInt  count1 = mask1->num_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
      FT_UInt  count2 = mask2->num_bits;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
      FT_Int   delta;
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
      if ( count2 > 0 )
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
        FT_UInt   pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        FT_Byte*  read;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
        FT_Byte*  write;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
        /* if "count2" is greater than "count1", we need to grow the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
        /* first bitset, and clear the highest bits                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
        if ( count2 > count1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
          error = ps_mask_ensure( mask1, count2, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
          if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
            goto Exit;
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
          for ( pos = count1; pos < count2; pos++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
            ps_mask_clear_bit( mask1, pos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
        /* merge (unite) the bitsets */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
        read  = mask2->bytes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
        write = mask1->bytes;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
        pos   = (FT_UInt)( ( count2 + 7 ) >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
        for ( ; pos > 0; pos-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
          write[0] = (FT_Byte)( write[0] | read[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
          write++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
          read++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
      /* Now, remove "mask2" from the list.  We need to keep the masks */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
      /* sorted in order of importance, so move table elements.        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
      mask2->num_bits  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
      mask2->end_point = 0;
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
      delta = table->num_masks - 1 - index2; /* number of masks to move */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
      if ( delta > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
        /* move to end of table for reuse */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
        PS_MaskRec  dummy = *mask2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
        ft_memmove( mask2, mask2 + 1, delta * sizeof ( PS_MaskRec ) );
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
        mask2[delta] = dummy;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
      table->num_masks--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
      FT_TRACE0(( "ps_mask_table_merge: ignoring invalid indices (%d,%d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
                  index1, index2 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
  /* Try to merge all masks in a given table.  This is used to merge */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
  /* all counter masks into independent counter "paths".             */
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
  ps_mask_table_merge_all( PS_Mask_Table  table,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
                           FT_Memory      memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
    FT_Int    index1, index2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
    FT_Error  error = PSH_Err_Ok;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
    for ( index1 = table->num_masks - 1; index1 > 0; index1-- )
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
      for ( index2 = index1 - 1; index2 >= 0; index2-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
        if ( ps_mask_table_test_intersect( table, index1, index2 ) )
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
          error = ps_mask_table_merge( table, index2, index1, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
          if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
            goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
    }
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
    return error;
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
  /*****                    PS_DIMENSION MANAGEMENT                    *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
  /* finalize a given dimension */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
  ps_dimension_done( PS_Dimension  dimension,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
                     FT_Memory     memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
    ps_mask_table_done( &dimension->counters, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
    ps_mask_table_done( &dimension->masks,    memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
    ps_hint_table_done( &dimension->hints,    memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
  /* initialize a given dimension */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
  ps_dimension_init( PS_Dimension  dimension )
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
    dimension->hints.num_hints    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
    dimension->masks.num_masks    = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
    dimension->counters.num_masks = 0;
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
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 0
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
  /* set a bit at a given index in the current hint mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
  ps_dimension_set_mask_bit( PS_Dimension  dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
                             FT_UInt       idx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
                             FT_Memory     memory )
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
    PS_Mask   mask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
    /* get last hint mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
    error = ps_mask_table_last( &dim->masks, memory, &mask );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
    error = ps_mask_set_bit( mask, idx, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
  /* set the end point in a mask, called from "End" & "Reset" methods */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
  ps_dimension_end_mask( PS_Dimension  dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
                         FT_UInt       end_point )
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
    FT_UInt  count = dim->masks.num_masks;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
    PS_Mask  mask;
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
    if ( count > 0 )
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
      mask            = dim->masks.masks + count - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
      mask->end_point = end_point;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
  /* set the end point in the current mask, then create a new empty one */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
  /* (called by "Reset" method)                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
  ps_dimension_reset_mask( PS_Dimension  dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
                           FT_UInt       end_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
                           FT_Memory     memory )
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
    PS_Mask  mask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
    /* end current mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
    ps_dimension_end_mask( dim, end_point );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
    /* allocate new one */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
    return ps_mask_table_alloc( &dim->masks, memory, &mask );
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
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
  /* set a new mask, called from the "T2Stem" method */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
  ps_dimension_set_mask_bits( PS_Dimension    dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
                              const FT_Byte*  source,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
                              FT_UInt         source_pos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
                              FT_UInt         source_bits,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
                              FT_UInt         end_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
                              FT_Memory       memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    /* reset current mask, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
    error = ps_dimension_reset_mask( dim, end_point, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
    /* set bits in new mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
    error = ps_mask_table_set_bits( &dim->masks, source,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
                                    source_pos, source_bits, memory );
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
    return error;
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
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
  /* add a new single stem (called from "T1Stem" method) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
  ps_dimension_add_t1stem( PS_Dimension  dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
                           FT_Int        pos,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
                           FT_Int        len,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
                           FT_Memory     memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
                           FT_Int       *aindex )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
    FT_UInt   flags = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
    /* detect ghost stem */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
    if ( len < 0 )
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
      flags |= PS_HINT_FLAG_GHOST;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
      if ( len == -21 )
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
        flags |= PS_HINT_FLAG_BOTTOM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
        pos   += len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
      len = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
    if ( aindex )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
      *aindex = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
    /* now, lookup stem in the current hints table */
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
      PS_Mask  mask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
      FT_UInt  idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
      FT_UInt  max   = dim->hints.num_hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
      PS_Hint  hint  = dim->hints.hints;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
      for ( idx = 0; idx < max; idx++, hint++ )
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
        if ( hint->pos == pos && hint->len == len )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
      /* we need to create a new hint in the table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
      if ( idx >= max )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
        error = ps_hint_table_alloc( &dim->hints, memory, &hint );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
        hint->pos   = pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
        hint->len   = len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
        hint->flags = flags;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
      /* now, store the hint in the current mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
      error = ps_mask_table_last( &dim->masks, memory, &mask );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
      error = ps_mask_set_bit( mask, idx, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
      if ( aindex )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
        *aindex = (FT_Int)idx;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
  /* add a "hstem3/vstem3" counter to our dimension table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
  ps_dimension_add_counter( PS_Dimension  dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
                            FT_Int        hint1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
                            FT_Int        hint2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
                            FT_Int        hint3,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
                            FT_Memory     memory )
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
    FT_Error  error   = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
    FT_UInt   count   = dim->counters.num_masks;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
    PS_Mask   counter = dim->counters.masks;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
    /* try to find an existing counter mask that already uses */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    /* one of these stems here                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
    for ( ; count > 0; count--, counter++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
      if ( ps_mask_test_bit( counter, hint1 ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
           ps_mask_test_bit( counter, hint2 ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
           ps_mask_test_bit( counter, hint3 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
    /* create a new counter when needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
    if ( count == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
      error = ps_mask_table_alloc( &dim->counters, memory, &counter );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
    /* now, set the bits for our hints in the counter mask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
    error = ps_mask_set_bit( counter, hint1, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
      goto Exit;
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
    error = ps_mask_set_bit( counter, hint2, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
    error = ps_mask_set_bit( counter, hint3, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
  /* end of recording session for a given dimension */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
  ps_dimension_end( PS_Dimension  dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
                    FT_UInt       end_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
                    FT_Memory     memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
    /* end hint mask table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
    ps_dimension_end_mask( dim, end_point );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
    /* merge all counter masks into independent "paths" */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
    return ps_mask_table_merge_all( &dim->counters, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
  /*****                    PS_RECORDER MANAGEMENT                     *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
  /* destroy hints */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
  FT_LOCAL( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
  ps_hints_done( PS_Hints  hints )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
    FT_Memory  memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
    ps_dimension_done( &hints->dimension[0], memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
    ps_dimension_done( &hints->dimension[1], memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
    hints->error  = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
    hints->memory = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
  FT_LOCAL( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
  ps_hints_init( PS_Hints   hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
                 FT_Memory  memory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
    FT_MEM_ZERO( hints, sizeof ( *hints ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
    hints->memory = memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
    return PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
  /* initialize a hints for a new session */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
  ps_hints_open( PS_Hints      hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
                 PS_Hint_Type  hint_type )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
    switch ( hint_type )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
    case PS_HINT_TYPE_1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
    case PS_HINT_TYPE_2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
      hints->error     = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
      hints->hint_type = hint_type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
      ps_dimension_init( &hints->dimension[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
      ps_dimension_init( &hints->dimension[1] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
    default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
      hints->error     = PSH_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
      hints->hint_type = hint_type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
      FT_TRACE0(( "ps_hints_open: invalid charstring type\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
      break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
  /* add one or more stems to the current hints table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
  ps_hints_stem( PS_Hints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
                 FT_Int    dimension,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
                 FT_UInt   count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
                 FT_Long*  stems )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
    if ( !hints->error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
      /* limit "dimension" to 0..1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
      if ( dimension < 0 || dimension > 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
        FT_TRACE0(( "ps_hints_stem: invalid dimension (%d) used\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
                    dimension ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
        dimension = ( dimension != 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
      /* record the stems in the current hints/masks table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
      switch ( hints->hint_type )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
      case PS_HINT_TYPE_1:  /* Type 1 "hstem" or "vstem" operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
      case PS_HINT_TYPE_2:  /* Type 2 "hstem" or "vstem" operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
          PS_Dimension  dim = &hints->dimension[dimension];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
          for ( ; count > 0; count--, stems += 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
            FT_Error   error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
            FT_Memory  memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
            error = ps_dimension_add_t1stem(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
                      dim, (FT_Int)stems[0], (FT_Int)stems[1],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
                      memory, NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
            if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
              FT_ERROR(( "ps_hints_stem: could not add stem"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
                         " (%d,%d) to hints table\n", stems[0], stems[1] ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
              hints->error = error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
              return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
        FT_TRACE0(( "ps_hints_stem: called with invalid hint type (%d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
                    hints->hint_type ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
  /* add one Type1 counter stem to the current hints table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
  ps_hints_t1stem3( PS_Hints   hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
                    FT_Int     dimension,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
                    FT_Fixed*  stems )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
    if ( !hints->error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
      PS_Dimension  dim;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
      FT_Memory     memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
      FT_Int        count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
      FT_Int        idx[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
      /* limit "dimension" to 0..1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
      if ( dimension < 0 || dimension > 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
        FT_TRACE0(( "ps_hints_t1stem3: invalid dimension (%d) used\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
                    dimension ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
        dimension = ( dimension != 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
      dim = &hints->dimension[dimension];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
      /* there must be 6 elements in the 'stem' array */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
      if ( hints->hint_type == PS_HINT_TYPE_1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
        /* add the three stems to our hints/masks table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
        for ( count = 0; count < 3; count++, stems += 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
          error = ps_dimension_add_t1stem( dim,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
                                           (FT_Int)FIXED_TO_INT( stems[0] ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
                                           (FT_Int)FIXED_TO_INT( stems[1] ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
                                           memory, &idx[count] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
          if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
        /* now, add the hints to the counters table */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
        error = ps_dimension_add_counter( dim, idx[0], idx[1], idx[2],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
                                          memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
          goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   939
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   940
        FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
        error = PSH_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
    FT_ERROR(( "ps_hints_t1stem3: could not add counter stems to table\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
    hints->error = error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
  /* reset hints (only with Type 1 hints) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
  ps_hints_t1reset( PS_Hints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
                    FT_UInt   end_point )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
    FT_Error  error = PSH_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
    if ( !hints->error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
      FT_Memory  memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
      if ( hints->hint_type == PS_HINT_TYPE_1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
        error = ps_dimension_reset_mask( &hints->dimension[0],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
                                         end_point, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
          goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
        error = ps_dimension_reset_mask( &hints->dimension[1],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
                                         end_point, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
          goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
        /* invalid hint type */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
        error = PSH_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
    hints->error = error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
  /* Type2 "hintmask" operator, add a new hintmask to each direction */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
  ps_hints_t2mask( PS_Hints        hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
                   FT_UInt         end_point,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
                   FT_UInt         bit_count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
                   const FT_Byte*  bytes )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
    if ( !hints->error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
      PS_Dimension  dim    = hints->dimension;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
      FT_Memory     memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
      FT_UInt       count1 = dim[0].hints.num_hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
      FT_UInt       count2 = dim[1].hints.num_hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
      /* check bit count; must be equal to current total hint count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
      if ( bit_count !=  count1 + count2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
        FT_TRACE0(( "ps_hints_t2mask:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
                    " called with invalid bitcount %d (instead of %d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
                   bit_count, count1 + count2 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
        /* simply ignore the operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
        return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
      /* set-up new horizontal and vertical hint mask now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
      error = ps_dimension_set_mask_bits( &dim[0], bytes, count2, count1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
                                          end_point, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
      error = ps_dimension_set_mask_bits( &dim[1], bytes, 0, count2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
                                          end_point, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
    hints->error = error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
  ps_hints_t2counter( PS_Hints        hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
                      FT_UInt         bit_count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
                      const FT_Byte*  bytes )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
    if ( !hints->error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
      PS_Dimension  dim    = hints->dimension;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
      FT_Memory     memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
      FT_UInt       count1 = dim[0].hints.num_hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
      FT_UInt       count2 = dim[1].hints.num_hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
      /* check bit count, must be equal to current total hint count */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
      if ( bit_count !=  count1 + count2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
        FT_TRACE0(( "ps_hints_t2counter:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
                    " called with invalid bitcount %d (instead of %d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
                   bit_count, count1 + count2 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
        /* simply ignore the operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
        return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
      /* set-up new horizontal and vertical hint mask now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
      error = ps_dimension_set_mask_bits( &dim[0], bytes, 0, count1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
                                          0, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
      error = ps_dimension_set_mask_bits( &dim[1], bytes, count1, count2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
                                          0, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
        goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
    return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
    hints->error = error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
  /* end recording session */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
  ps_hints_close( PS_Hints  hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
                  FT_UInt   end_point )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1092
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
    error = hints->error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
      FT_Memory     memory = hints->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
      PS_Dimension  dim    = hints->dimension;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
      error = ps_dimension_end( &dim[0], end_point, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
        error = ps_dimension_end( &dim[1], end_point, memory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
#ifdef DEBUG_HINTER
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
      ps_debug_hints = hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1111
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1117
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
  /*****                TYPE 1 HINTS RECORDING INTERFACE               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
  t1_hints_open( T1_Hints  hints )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
    ps_hints_open( (PS_Hints)hints, PS_HINT_TYPE_1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
  t1_hints_stem( T1_Hints   hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
                 FT_Int     dimension,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
                 FT_Fixed*  coords )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
    FT_Pos  stems[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
    stems[0] = FIXED_TO_INT( coords[0] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
    stems[1] = FIXED_TO_INT( coords[1] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1139
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1140
    ps_hints_stem( (PS_Hints)hints, dimension, 1, stems );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
  t1_hints_funcs_init( T1_Hints_FuncsRec*  funcs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
    FT_MEM_ZERO( (char*)funcs, sizeof ( *funcs ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
    funcs->open  = (T1_Hints_OpenFunc)    t1_hints_open;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
    funcs->close = (T1_Hints_CloseFunc)   ps_hints_close;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
    funcs->stem  = (T1_Hints_SetStemFunc) t1_hints_stem;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
    funcs->stem3 = (T1_Hints_SetStem3Func)ps_hints_t1stem3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
    funcs->reset = (T1_Hints_ResetFunc)   ps_hints_t1reset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
    funcs->apply = (T1_Hints_ApplyFunc)   ps_hints_apply;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1155
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1160
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1161
  /*****                TYPE 2 HINTS RECORDING INTERFACE               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
  /*****                                                               *****/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1163
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1164
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1165
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1166
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
  t2_hints_open( T2_Hints  hints )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1168
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1169
    ps_hints_open( (PS_Hints)hints, PS_HINT_TYPE_2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1170
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1171
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1173
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
  t2_hints_stems( T2_Hints   hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1175
                  FT_Int     dimension,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1176
                  FT_Int     count,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
                  FT_Fixed*  coords )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1178
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1179
    FT_Pos  stems[32], y, n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
    FT_Int  total = count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
    y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
    while ( total > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
      /* determine number of stems to write */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
      count = total;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
      if ( count > 16 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
        count = 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
      /* compute integer stem positions in font units */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
      for ( n = 0; n < count * 2; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1193
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1194
        y       += coords[n];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
        stems[n] = FIXED_TO_INT( y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1196
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1197
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1198
      /* compute lengths */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1199
      for ( n = 0; n < count * 2; n += 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1200
        stems[n + 1] = stems[n + 1] - stems[n];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1202
      /* add them to the current dimension */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
      ps_hints_stem( (PS_Hints)hints, dimension, count, stems );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1205
      total -= count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1207
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1208
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1210
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1211
  t2_hints_funcs_init( T2_Hints_FuncsRec*  funcs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1212
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1213
    FT_MEM_ZERO( funcs, sizeof ( *funcs ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1215
    funcs->open    = (T2_Hints_OpenFunc)   t2_hints_open;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1216
    funcs->close   = (T2_Hints_CloseFunc)  ps_hints_close;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1217
    funcs->stems   = (T2_Hints_StemsFunc)  t2_hints_stems;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1218
    funcs->hintmask= (T2_Hints_MaskFunc)   ps_hints_t2mask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1219
    funcs->counter = (T2_Hints_CounterFunc)ps_hints_t2counter;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1220
    funcs->apply   = (T2_Hints_ApplyFunc)  ps_hints_apply;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1221
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1223
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1224
/* END */