misc/libfreetype/src/psaux/t1decode.c
author nemo
Tue, 14 Jun 2011 16:50:41 -0400
changeset 5243 f2e31a7f953a
parent 5172 88f2e05288ba
permissions -rw-r--r--
check alternate script loading path
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
/*  t1decode.c                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    PostScript Type 1 decoding routines (body).                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*            2010 by                                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_INTERNAL_CALC_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_POSTSCRIPT_HINTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include FT_OUTLINE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#include "t1decode.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include "psobjs.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
#include "psauxerr.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
  /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
  /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
  /* messages during execution.                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
#define FT_COMPONENT  trace_t1decode
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
  typedef enum  T1_Operator_
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    op_none = 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    op_endchar,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    op_hsbw,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    op_seac,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    op_sbw,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
    op_closepath,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
    op_hlineto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
    op_hmoveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    op_hvcurveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
    op_rlineto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    op_rmoveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    op_rrcurveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    op_vhcurveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    op_vlineto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    op_vmoveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    op_dotsection,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
    op_hstem,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
    op_hstem3,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    op_vstem,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    op_vstem3,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    op_div,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    op_callothersubr,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
    op_callsubr,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    op_pop,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
    op_return,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    op_setcurrentpoint,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    op_unknown15,
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
    op_max    /* never remove this one */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  } T1_Operator;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
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
  static
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  const FT_Int  t1_args_count[op_max] =
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
    0, /* none */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    0, /* endchar */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    2, /* hsbw */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    5, /* seac */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
    4, /* sbw */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    0, /* closepath */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    1, /* hlineto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    1, /* hmoveto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    4, /* hvcurveto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    2, /* rlineto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    2, /* rmoveto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    6, /* rrcurveto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    4, /* vhcurveto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    1, /* vlineto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
    1, /* vmoveto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    0, /* dotsection */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    2, /* hstem */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    6, /* hstem3 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    2, /* vstem */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
    6, /* vstem3 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
    2, /* div */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
   -1, /* callothersubr */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    1, /* callsubr */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    0, /* pop */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    0, /* return */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
    2, /* setcurrentpoint */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    2  /* opcode 15 (undocumented and obsolete) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
  /*    t1_lookup_glyph_by_stdcharcode                                     */
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
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
  /*    Looks up a given glyph by its StandardEncoding charcode.  Used to  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
  /*    implement the SEAC Type 1 operator.                                */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  /*    face     :: The current face object.                               */
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
  /*    charcode :: The character code to look for.                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
  /*    A glyph index in the font face.  Returns -1 if the corresponding   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
  /*    glyph wasn't found.                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
  static FT_Int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  t1_lookup_glyph_by_stdcharcode( T1_Decoder  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
                                  FT_Int      charcode )
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
    FT_UInt             n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
    const FT_String*    glyph_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
    FT_Service_PsCMaps  psnames = decoder->psnames;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    /* check range of standard char code */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    if ( charcode < 0 || charcode > 255 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
      return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    glyph_name = psnames->adobe_std_strings(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
                   psnames->adobe_std_encoding[charcode]);
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
    for ( n = 0; n < decoder->num_glyphs; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      FT_String*  name = (FT_String*)decoder->glyph_names[n];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
      if ( name                               &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
           name[0] == glyph_name[0]           &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
           ft_strcmp( name, glyph_name ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
        return n;
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
    return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
  /*    t1operator_seac                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
  /*    Implements the `seac' Type 1 operator for a Type 1 decoder.        */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
  /*    decoder :: The current CID decoder.                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
  /*    asb     :: The accent's side bearing.                              */
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
  /*    adx     :: The horizontal offset of the accent.                    */
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
  /*    ady     :: The vertical offset of the accent.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
  /*    bchar   :: The base character's StandardEncoding charcode.         */
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
  /*    achar   :: The accent character's StandardEncoding charcode.       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
  /*    FreeType error code.  0 means success.                             */
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
  t1operator_seac( T1_Decoder  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
                   FT_Pos      asb,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
                   FT_Pos      adx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
                   FT_Pos      ady,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
                   FT_Int      bchar,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
                   FT_Int      achar )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    FT_Error     error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
    FT_Int       bchar_index, achar_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    FT_Int       n_base_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
    FT_Outline*  base = decoder->builder.base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    FT_Vector    left_bearing, advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    T1_Face      face  = (T1_Face)decoder->builder.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
#endif     
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    if ( decoder->seac )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
      FT_ERROR(( "t1operator_seac: invalid nested seac\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
      return PSaux_Err_Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    /* seac weirdness */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
    adx += decoder->builder.left_bearing.x;
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
    /* `glyph_names' is set to 0 for CID fonts which do not */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
    /* include an encoding.  How can we deal with these?    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    if ( decoder->glyph_names == 0                   &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
         !face->root.internal->incremental_interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    if ( decoder->glyph_names == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
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
      FT_ERROR(( "t1operator_seac:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
                 " glyph names table not available in this font\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
      return PSaux_Err_Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
    if ( face->root.internal->incremental_interface )
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
      /* the caller must handle the font encoding also */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
      bchar_index = bchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
      achar_index = achar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
#endif
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
      bchar_index = t1_lookup_glyph_by_stdcharcode( decoder, bchar );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
      achar_index = t1_lookup_glyph_by_stdcharcode( decoder, achar );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
    if ( bchar_index < 0 || achar_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
      FT_ERROR(( "t1operator_seac:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
                 " invalid seac character code arguments\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
      return PSaux_Err_Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    }
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
    /* if we are trying to load a composite glyph, do not load the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
    /* accent character and return the array of subglyphs.         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
    if ( decoder->builder.no_recurse )
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
      FT_GlyphSlot    glyph  = (FT_GlyphSlot)decoder->builder.glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
      FT_GlyphLoader  loader = glyph->internal->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
      FT_SubGlyph     subg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
      /* reallocate subglyph array if necessary */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
      error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
        goto Exit;
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
      subg = loader->current.subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
      /* subglyph 0 = base character */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
      subg->index = bchar_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
      subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
                    FT_SUBGLYPH_FLAG_USE_MY_METRICS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
      subg->arg1  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
      subg->arg2  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
      subg++;
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
      /* subglyph 1 = accent character */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
      subg->index = achar_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
      subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
      subg->arg1  = (FT_Int)FIXED_TO_INT( adx - asb );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
      subg->arg2  = (FT_Int)FIXED_TO_INT( ady );
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
      /* set up remaining glyph fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
      glyph->num_subglyphs = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
      glyph->subglyphs     = loader->base.subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
      glyph->format        = FT_GLYPH_FORMAT_COMPOSITE;
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
      loader->current.num_subglyphs = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    /* First load `bchar' in builder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
    /* now load the unscaled outline */
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_GlyphLoader_Prepare( decoder->builder.loader );  /* prepare loader */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    /* the seac operator must not be nested */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    decoder->seac = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
    error = t1_decoder_parse_glyph( decoder, bchar_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    decoder->seac = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
    /* save the left bearing and width of the base character */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
    /* as they will be erased by the next load.              */
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
    left_bearing = decoder->builder.left_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
    advance      = decoder->builder.advance;
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
    decoder->builder.left_bearing.x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
    decoder->builder.left_bearing.y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
    decoder->builder.pos_x = adx - asb;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
    decoder->builder.pos_y = ady;
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
    /* Now load `achar' on top of */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    /* the base outline           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
    /* the seac operator must not be nested */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
    decoder->seac = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
    error = t1_decoder_parse_glyph( decoder, achar_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
    decoder->seac = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    /* restore the left side bearing and   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
    /* advance width of the base character */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    decoder->builder.left_bearing = left_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
    decoder->builder.advance      = advance;
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
    decoder->builder.pos_x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
    decoder->builder.pos_y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
    return error;
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
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
  /*    t1_decoder_parse_charstrings                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
  /*    Parses a given Type 1 charstrings program.                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
  /*    decoder         :: The current Type 1 decoder.                     */
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
  /*    charstring_base :: The base address of the charstring stream.      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
  /*    charstring_len  :: The length in bytes of the charstring stream.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
  t1_decoder_parse_charstrings( T1_Decoder  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
                                FT_Byte*    charstring_base,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
                                FT_UInt     charstring_len )
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
    FT_Error         error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
    T1_Decoder_Zone  zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
    FT_Byte*         ip;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
    FT_Byte*         limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
    T1_Builder       builder = &decoder->builder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
    FT_Pos           x, y, orig_x, orig_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
    FT_Int           known_othersubr_result_cnt   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    FT_Int           unknown_othersubr_result_cnt = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
    FT_Bool          large_int;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
    FT_Fixed         seed;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
    T1_Hints_Funcs   hinter;
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
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
    FT_Bool          bol = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
    /* compute random seed from stack address of parameter */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
    seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed              ^
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
                         (FT_PtrDist)(char*)&decoder           ^
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
                         (FT_PtrDist)(char*)&charstring_base ) &
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
                         FT_ULONG_MAX ) ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
    seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    if ( seed == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
      seed = 0x7384;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
    /* First of all, initialize the decoder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
    decoder->top  = decoder->stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
    decoder->zone = decoder->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
    zone          = decoder->zones;
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
    builder->parse_state = T1_Parse_Start;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
    hinter = (T1_Hints_Funcs)builder->hints_funcs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
    /* a font that reads BuildCharArray without setting */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
    /* its values first is buggy, but ...               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
    FT_ASSERT( ( decoder->len_buildchar == 0 ) ==
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
               ( decoder->buildchar == NULL )  );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
    if ( decoder->len_buildchar > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
      ft_memset( &decoder->buildchar[0],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
                 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
                 sizeof( decoder->buildchar[0] ) * decoder->len_buildchar );
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
    FT_TRACE4(( "\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
                "Start charstring\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
    zone->base           = charstring_base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    limit = zone->limit  = charstring_base + charstring_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
    ip    = zone->cursor = zone->base;
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
    error = PSaux_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
    x = orig_x = builder->pos_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
    y = orig_y = builder->pos_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
    /* begin hints recording session, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
    if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
      hinter->open( hinter->hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
    large_int = FALSE;
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
    /* now, execute loop */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
    while ( ip < limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
      FT_Long*     top   = decoder->top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
      T1_Operator  op    = op_none;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
      FT_Int32     value = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
      FT_ASSERT( known_othersubr_result_cnt == 0   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
                 unknown_othersubr_result_cnt == 0 );
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
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
      if ( bol )
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_TRACE5(( " (%d)", decoder->top - decoder->stack ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        bol = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
#endif
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
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
      /* Decode operator or operand                                        */
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
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
      /* first of all, decompress operator or value */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
      switch ( *ip++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
      case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
        op = op_hstem;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
      case 3:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
        op = op_vstem;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
      case 4:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
        op = op_vmoveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
      case 5:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
        op = op_rlineto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
      case 6:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
        op = op_hlineto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
      case 7:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
        op = op_vlineto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
      case 8:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
        op = op_rrcurveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
      case 9:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
        op = op_closepath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
      case 10:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
        op = op_callsubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
      case 11:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
        op = op_return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
      case 13:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
        op = op_hsbw;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
      case 14:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
        op = op_endchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
        break;
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
      case 15:          /* undocumented, obsolete operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
        op = op_unknown15;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
        break;
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
      case 21:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
        op = op_rmoveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
      case 22:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
        op = op_hmoveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
      case 30:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
        op = op_vhcurveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
      case 31:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
        op = op_hvcurveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
        break;
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
      case 12:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
        if ( ip > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
          FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
                     " invalid escape (12+EOF)\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
          goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
        switch ( *ip++ )
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
        case 0:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
          op = op_dotsection;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
        case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
          op = op_vstem3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
        case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
          op = op_hstem3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
        case 6:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
          op = op_seac;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
        case 7:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
          op = op_sbw;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
        case 12:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
          op = op_div;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
        case 16:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
          op = op_callothersubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
        case 17:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
          op = op_pop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
        case 33:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
          op = op_setcurrentpoint;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
          break;
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
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
          FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
                     " invalid escape (12+%d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
                     ip[-1] ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
          goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
      case 255:    /* four bytes integer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
        if ( ip + 4 > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
          FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
                     " unexpected EOF in integer\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
          goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
        value = (FT_Int32)( ( (FT_Long)ip[0] << 24 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
                            ( (FT_Long)ip[1] << 16 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
                            ( (FT_Long)ip[2] << 8  ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
                                       ip[3]         );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
        ip += 4;
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
        /* According to the specification, values > 32000 or < -32000 must */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
        /* be followed by a `div' operator to make the result be in the    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
        /* range [-32000;32000].  We expect that the second argument of    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
        /* `div' is not a large number.  Additionally, we don't handle     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
        /* stuff like `<large1> <large2> <num> div <num> div' or           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
        /* <large1> <large2> <num> div div'.  This is probably not allowed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
        /* anyway.                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
        if ( value > 32000 || value < -32000 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
          if ( large_int )
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
            FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
                       " no `div' after large integer\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
            large_int = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
          if ( !large_int )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
            value <<= 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
        if ( ip[-1] >= 32 )
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
          if ( ip[-1] < 247 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
            value = (FT_Int32)ip[-1] - 139;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
            if ( ++ip > limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
              FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
                         " unexpected EOF in integer\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
            if ( ip[-2] < 251 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
              value =  ( ( (FT_Int32)ip[-2] - 247 ) << 8 ) + ip[-1] + 108;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
              value = -( ( ( (FT_Int32)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
          if ( !large_int )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
            value <<= 16;
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
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
          FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
                     " invalid byte (%d)\n", ip[-1] ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
          goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
      if ( unknown_othersubr_result_cnt > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
        switch ( op )
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
        case op_callsubr:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
        case op_return:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
        case op_none:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
        case op_pop:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
          /* all operands have been transferred by previous pops */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
          unknown_othersubr_result_cnt = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
      }
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
      if ( large_int && !( op == op_none || op == op_div ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
        FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
                   " no `div' after large integer\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
        large_int = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
      /*********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
      /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
      /*  Push value on stack, or process operator                         */
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
      if ( op == op_none )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
        if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
          FT_ERROR(( "t1_decoder_parse_charstrings: stack overflow\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
          goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
        if ( large_int )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
          FT_TRACE4(( " %ld", value ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
          FT_TRACE4(( " %ld", (FT_Int32)( value >> 16 ) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
#endif
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
        *top++       = value;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
        decoder->top = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
      else if ( op == op_callothersubr )  /* callothersubr */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
        FT_Int  subr_no;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
        FT_Int  arg_cnt;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
        FT_TRACE4(( " callothersubr\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
        bol = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
#endif
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
        if ( top - decoder->stack < 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
          goto Stack_Underflow;
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
        top -= 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
        subr_no = (FT_Int)( top[1] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
        arg_cnt = (FT_Int)( top[0] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
        /***********************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
        /*                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
        /* remove all operands to callothersubr from the stack     */
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
        /* for handled othersubrs, where we know the number of     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
        /* arguments, we increase the stack by the value of        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
        /* known_othersubr_result_cnt                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
        /*                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
        /* for unhandled othersubrs the following pops adjust the  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
        /* stack pointer as necessary                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
        if ( arg_cnt > top - decoder->stack )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
          goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
        top -= arg_cnt;
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
        known_othersubr_result_cnt   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
        unknown_othersubr_result_cnt = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
        /* XXX TODO: The checks to `arg_count == <whatever>'       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
        /* might not be correct; an othersubr expects a certain    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
        /* number of operands on the PostScript stack (as opposed  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
        /* to the T1 stack) but it doesn't have to put them there  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
        /* by itself; previous othersubrs might have left the      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
        /* operands there if they were not followed by an          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
        /* appropriate number of pops                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
        /*                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
        /* On the other hand, Adobe Reader 7.0.8 for Linux doesn't */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
        /* accept a font that contains charstrings like            */
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
        /*     100 200 2 20 callothersubr                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
        /*     300 1 20 callothersubr pop                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
        /*                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
        /* Perhaps this is the reason why BuildCharArray exists.   */
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
        switch ( subr_no )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
        case 1:                     /* start flex feature */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
          if ( arg_cnt != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
            goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
          decoder->flex_state        = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
          decoder->num_flex_vectors  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
          if ( ( error = t1_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
                 != PSaux_Err_Ok                                   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
               ( error = t1_builder_check_points( builder, 6 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
                 != PSaux_Err_Ok                                   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
        case 2:                     /* add flex vectors */
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
            FT_Int  idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
            if ( arg_cnt != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
              goto Unexpected_OtherSubr;
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
            /* note that we should not add a point for index 0; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
            /* this will move our current position to the flex  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
            /* point without adding any point to the outline    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
            idx = decoder->num_flex_vectors++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
            if ( idx > 0 && idx < 7 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
              t1_builder_add_point( builder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
                                    x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
                                    y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
                                    (FT_Byte)( idx == 3 || idx == 6 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
          break;
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
        case 0:                     /* end flex feature */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
          if ( arg_cnt != 3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
            goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
          if ( decoder->flex_state       == 0 ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
               decoder->num_flex_vectors != 7 )
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
            FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
                       " unexpected flex end\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
          /* the two `results' are popped by the following setcurrentpoint */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
          top[0] = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
          top[1] = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
          known_othersubr_result_cnt = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
          break;
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
        case 3:                     /* change hints */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
          if ( arg_cnt != 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
            goto Unexpected_OtherSubr;
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
          known_othersubr_result_cnt = 1;
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
          if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
            hinter->reset( hinter->hints, builder->current->n_points );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
          break;
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
        case 12:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
        case 13:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
          /* counter control hints, clear stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
          top = decoder->stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
          break;
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
        case 14:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
        case 15:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
        case 16:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
        case 17:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
        case 18:                    /* multiple masters */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
            PS_Blend  blend = decoder->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
            FT_UInt   num_points, nn, mm;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
            FT_Long*  delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
            FT_Long*  values;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
            if ( !blend )
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
              FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
                         " unexpected multiple masters operator\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
            num_points = (FT_UInt)subr_no - 13 + ( subr_no == 18 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
            if ( arg_cnt != (FT_Int)( num_points * blend->num_designs ) )
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
              FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
                         " incorrect number of multiple masters arguments\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
            /* we want to compute:                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
            /*                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
            /*  a0*w0 + a1*w1 + ... + ak*wk                          */
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
            /* but we only have the a0, a1-a0, a2-a0, .. ak-a0       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
            /* however, given that w0 + w1 + ... + wk == 1, we can   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
            /* rewrite it easily as:                                 */
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
            /*  a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
            /*                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
            /* where k == num_designs-1                              */
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
            /* I guess that's why it's written in this `compact'     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
            /* form.                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
            /*                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
            delta  = top + num_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
            values = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
            for ( nn = 0; nn < num_points; nn++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
              FT_Long  tmp = values[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
              for ( mm = 1; mm < blend->num_designs; mm++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
                tmp += FT_MulFix( *delta++, blend->weight_vector[mm] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
              *values++ = tmp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
            known_othersubr_result_cnt = num_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
            break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
        case 19:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
          /* <idx> 1 19 callothersubr                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
          /* => replace elements starting from index cvi( <idx> ) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
          /*    of BuildCharArray with WeightVector               */
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
            FT_Int    idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
            PS_Blend  blend = decoder->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
            if ( arg_cnt != 1 || blend == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
              goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
            idx = (FT_Int)( top[0] >> 16 );
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
            if ( idx < 0                                           ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
                 idx + blend->num_designs > decoder->len_buildchar )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
              goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
            ft_memcpy( &decoder->buildchar[idx],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
                       blend->weight_vector,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
                       blend->num_designs *
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
                         sizeof( blend->weight_vector[0] ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
          break;
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
        case 20:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
          /* <arg1> <arg2> 2 20 callothersubr pop   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
          /* ==> push <arg1> + <arg2> onto T1 stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
          if ( arg_cnt != 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
            goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
          top[0] += top[1]; /* XXX (over|under)flow */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
          known_othersubr_result_cnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
          break;
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
        case 21:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
          /* <arg1> <arg2> 2 21 callothersubr pop   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
          /* ==> push <arg1> - <arg2> onto T1 stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
          if ( arg_cnt != 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
            goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
          top[0] -= top[1]; /* XXX (over|under)flow */
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
          known_othersubr_result_cnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
          break;
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
        case 22:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
          /* <arg1> <arg2> 2 22 callothersubr pop   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
          /* ==> push <arg1> * <arg2> onto T1 stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
          if ( arg_cnt != 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
            goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
          top[0] = FT_MulFix( top[0], top[1] );
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
          known_othersubr_result_cnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
          break;
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
        case 23:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
          /* <arg1> <arg2> 2 23 callothersubr pop   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
          /* ==> push <arg1> / <arg2> onto T1 stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
          if ( arg_cnt != 2 || top[1] == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
            goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
          top[0] = FT_DivFix( top[0], top[1] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
          known_othersubr_result_cnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
        case 24:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
          /* <val> <idx> 2 24 callothersubr               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
          /* ==> set BuildCharArray[cvi( <idx> )] = <val> */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
            FT_Int    idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
            PS_Blend  blend = decoder->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
            if ( arg_cnt != 2 || blend == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
              goto Unexpected_OtherSubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
            idx = (FT_Int)( top[1] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
            if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
              goto Unexpected_OtherSubr;
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
            decoder->buildchar[idx] = top[0];
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
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
        case 25:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
          /* <idx> 1 25 callothersubr pop        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
          /* ==> push BuildCharArray[cvi( idx )] */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
          /*     onto T1 stack                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
            FT_Int    idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
            PS_Blend  blend = decoder->blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
            if ( arg_cnt != 1 || blend == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
              goto Unexpected_OtherSubr;
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
            idx = (FT_Int)( top[0] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
            if ( idx < 0 || (FT_UInt) idx >= decoder->len_buildchar )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
              goto Unexpected_OtherSubr;
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
            top[0] = decoder->buildchar[idx];
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
          known_othersubr_result_cnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
        case 26:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
          /* <val> mark <idx> ==> set BuildCharArray[cvi( <idx> )] = <val>, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
          /*                      leave mark on T1 stack                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
          /* <val> <idx>      ==> set BuildCharArray[cvi( <idx> )] = <val>  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
          XXX which routine has left its mark on the (PostScript) stack?;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
#endif
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
        case 27:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
          /* <res1> <res2> <val1> <val2> 4 27 callothersubr pop */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
          /* ==> push <res1> onto T1 stack if <val1> <= <val2>, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
          /*     otherwise push <res2>                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
          if ( arg_cnt != 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
            goto Unexpected_OtherSubr;
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
          if ( top[2] > top[3] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
            top[0] = top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
          known_othersubr_result_cnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
        case 28:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
          /* 0 28 callothersubr pop                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
          /* => push random value from interval [0, 1) onto stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
          if ( arg_cnt != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
            goto Unexpected_OtherSubr;
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
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
            FT_Fixed  Rand;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
            Rand = seed;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
            if ( Rand >= 0x8000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
              Rand++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
            top[0] = Rand;
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
            seed = FT_MulFix( seed, 0x10000L - seed );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
            if ( seed == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
              seed += 0x2873;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
          known_othersubr_result_cnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
          break;
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
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
          FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
                     " unknown othersubr [%d %d], wish me luck\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
                     arg_cnt, subr_no ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
          unknown_othersubr_result_cnt = arg_cnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
          break;
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
        Unexpected_OtherSubr:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
          FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
                     " invalid othersubr [%d %d]\n", arg_cnt, subr_no ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
          goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
        top += known_othersubr_result_cnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
        decoder->top = top;
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
      else  /* general operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
        FT_Int  num_args = t1_args_count[op];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
        FT_ASSERT( num_args >= 0 );
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
        if ( top - decoder->stack < num_args )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
          goto Stack_Underflow;
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
        /* XXX Operators usually take their operands from the        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
        /*     bottom of the stack, i.e., the operands are           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
        /*     decoder->stack[0], ..., decoder->stack[num_args - 1]; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
        /*     only div, callsubr, and callothersubr are different.  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
        /*     In practice it doesn't matter (?).                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
        switch ( op )
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
        case op_callsubr:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
        case op_div:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
        case op_callothersubr:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
        case op_pop:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
        case op_return:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
          break;
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
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
          if ( top - decoder->stack != num_args )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
            FT_TRACE0(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
                        " too much operands on the stack"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
                        " (seen %d, expected %d)\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
                        top - decoder->stack, num_args ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
            break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
#endif /* FT_DEBUG_LEVEL_TRACE */
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
        top -= num_args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
        switch ( op )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
        case op_endchar:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
          FT_TRACE4(( " endchar\n" ));
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
          t1_builder_close_contour( builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
          /* close hints recording session */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
          if ( hinter )
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
            if ( hinter->close( hinter->hints, builder->current->n_points ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
            /* apply hints to the loaded glyph outline now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
            hinter->apply( hinter->hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
                           builder->current,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
                           (PSH_Globals)builder->hints_globals,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
                           decoder->hint_mode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
          /* add current outline to the glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
          FT_GlyphLoader_Add( builder->loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
          /* the compiler should optimize away this empty loop but ... */
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
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
          if ( decoder->len_buildchar > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
            FT_UInt  i;
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
            FT_TRACE4(( "BuildCharArray = [ " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
            for ( i = 0; i < decoder->len_buildchar; ++i )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
              FT_TRACE4(( "%d ", decoder->buildchar[ i ] ));
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
            FT_TRACE4(( "]\n" ));
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
#endif /* FT_DEBUG_LEVEL_TRACE */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
          FT_TRACE4(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1111
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
          /* return now! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
          return PSaux_Err_Ok;
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
        case op_hsbw:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
          FT_TRACE4(( " hsbw" ));
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
          builder->parse_state = T1_Parse_Have_Width;
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
          builder->left_bearing.x += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
          builder->advance.x       = top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
          builder->advance.y       = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
          orig_x = x = builder->pos_x + top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
          orig_y = y = builder->pos_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
          FT_UNUSED( orig_y );
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
          /* the `metrics_only' indicates that we only want to compute */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
          /* the glyph's metrics (lsb + advance width), not load the   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
          /* rest of it; so exit immediately                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
          if ( builder->metrics_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
            return PSaux_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1136
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
        case op_seac:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
          return t1operator_seac( decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1139
                                  top[0],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1140
                                  top[1],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
                                  top[2],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
                                  (FT_Int)( top[3] >> 16 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
                                  (FT_Int)( top[4] >> 16 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
        case op_sbw:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
          FT_TRACE4(( " sbw" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
          builder->parse_state = T1_Parse_Have_Width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
          builder->left_bearing.x += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
          builder->left_bearing.y += top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
          builder->advance.x       = top[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
          builder->advance.y       = top[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1155
          x = builder->pos_x + top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1156
          y = builder->pos_y + top[1];
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
          /* the `metrics_only' indicates that we only want to compute */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
          /* the glyph's metrics (lsb + advance width), not load the   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1160
          /* rest of it; so exit immediately                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1161
          if ( builder->metrics_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
            return PSaux_Err_Ok;
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
          break;
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
        case op_closepath:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
          FT_TRACE4(( " closepath" ));
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
          /* if there is no path, `closepath' is a no-op */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1170
          if ( builder->parse_state == T1_Parse_Have_Path   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1171
               builder->parse_state == T1_Parse_Have_Moveto )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1172
            t1_builder_close_contour( builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1173
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
          builder->parse_state = T1_Parse_Have_Width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1175
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
        case op_hlineto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1178
          FT_TRACE4(( " hlineto" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1179
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
          if ( ( error = t1_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
                 != PSaux_Err_Ok )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
          x += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
          goto Add_Line;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
        case op_hmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
          FT_TRACE4(( " hmoveto" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
          x += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
          if ( !decoder->flex_state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1193
            if ( builder->parse_state == T1_Parse_Start )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1194
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
            builder->parse_state = T1_Parse_Have_Moveto;
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
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1198
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1199
        case op_hvcurveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1200
          FT_TRACE4(( " hvcurveto" ));
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
          if ( ( error = t1_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
                 != PSaux_Err_Ok                                   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1204
               ( error = t1_builder_check_points( builder, 3 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1205
                 != PSaux_Err_Ok                                   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
            goto Fail;
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
          x += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1209
          t1_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1210
          x += top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1211
          y += top[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1212
          t1_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1213
          y += top[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1214
          t1_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1215
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1216
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1217
        case op_rlineto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1218
          FT_TRACE4(( " rlineto" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1220
          if ( ( error = t1_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1221
                 != PSaux_Err_Ok )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1222
            goto Fail;
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
          x += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1225
          y += top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1227
        Add_Line:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1228
          if ( ( error = t1_builder_add_point1( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1229
                 != PSaux_Err_Ok )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1230
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1231
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1232
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1233
        case op_rmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1234
          FT_TRACE4(( " rmoveto" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1235
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1236
          x += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1237
          y += top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1238
          if ( !decoder->flex_state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1239
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1240
            if ( builder->parse_state == T1_Parse_Start )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1241
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1242
            builder->parse_state = T1_Parse_Have_Moveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1243
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1244
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1245
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1246
        case op_rrcurveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1247
          FT_TRACE4(( " rrcurveto" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1249
          if ( ( error = t1_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1250
                 != PSaux_Err_Ok                                   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1251
               ( error = t1_builder_check_points( builder, 3 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1252
                 != PSaux_Err_Ok                                   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1253
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1254
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1255
          x += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1256
          y += top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1257
          t1_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1258
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1259
          x += top[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1260
          y += top[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1261
          t1_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1263
          x += top[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1264
          y += top[5];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1265
          t1_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1266
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1268
        case op_vhcurveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1269
          FT_TRACE4(( " vhcurveto" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1271
          if ( ( error = t1_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1272
                 != PSaux_Err_Ok                                   ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1273
               ( error = t1_builder_check_points( builder, 3 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1274
                 != PSaux_Err_Ok                                   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1275
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1277
          y += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1278
          t1_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1279
          x += top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1280
          y += top[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1281
          t1_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1282
          x += top[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1283
          t1_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1284
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1285
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1286
        case op_vlineto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1287
          FT_TRACE4(( " vlineto" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1288
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1289
          if ( ( error = t1_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1290
                 != PSaux_Err_Ok )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1291
            goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1293
          y += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1294
          goto Add_Line;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1296
        case op_vmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1297
          FT_TRACE4(( " vmoveto" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1299
          y += top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1300
          if ( !decoder->flex_state )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1301
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1302
            if ( builder->parse_state == T1_Parse_Start )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1303
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1304
            builder->parse_state = T1_Parse_Have_Moveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1305
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1306
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1307
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1308
        case op_div:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1309
          FT_TRACE4(( " div" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1310
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1311
          /* if `large_int' is set, we divide unscaled numbers; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1312
          /* otherwise, we divide numbers in 16.16 format --    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1313
          /* in both cases, it is the same operation            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1314
          *top = FT_DivFix( top[0], top[1] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1315
          ++top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1317
          large_int = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1318
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1319
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1320
        case op_callsubr:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1321
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1322
            FT_Int  idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1325
            FT_TRACE4(( " callsubr" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1327
            idx = (FT_Int)( top[0] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1328
            if ( idx < 0 || idx >= (FT_Int)decoder->num_subrs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1329
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1330
              FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1331
                         " invalid subrs index\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1332
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1333
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1334
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1335
            if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1336
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1337
              FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1338
                         " too many nested subrs\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1339
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1340
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1342
            zone->cursor = ip;  /* save current instruction pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1344
            zone++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1345
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1346
            /* The Type 1 driver stores subroutines without the seed bytes. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1347
            /* The CID driver stores subroutines with seed bytes.  This     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1348
            /* case is taken care of when decoder->subrs_len == 0.          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1349
            zone->base = decoder->subrs[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1350
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1351
            if ( decoder->subrs_len )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1352
              zone->limit = zone->base + decoder->subrs_len[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1353
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1354
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1355
              /* We are using subroutines from a CID font.  We must adjust */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1356
              /* for the seed bytes.                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1357
              zone->base  += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1358
              zone->limit  = decoder->subrs[idx + 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1359
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1360
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1361
            zone->cursor = zone->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1363
            if ( !zone->base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1364
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1365
              FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1366
                         " invoking empty subrs\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1367
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1368
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1370
            decoder->zone = zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1371
            ip            = zone->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1372
            limit         = zone->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1373
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1374
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1375
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1376
        case op_pop:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1377
          FT_TRACE4(( " pop" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1378
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1379
          if ( known_othersubr_result_cnt > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1380
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1381
            known_othersubr_result_cnt--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1382
            /* ignore, we pushed the operands ourselves */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1383
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1384
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1385
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1386
          if ( unknown_othersubr_result_cnt == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1387
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1388
            FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1389
                       " no more operands for othersubr\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1390
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1391
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1392
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1393
          unknown_othersubr_result_cnt--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1394
          top++;   /* `push' the operand to callothersubr onto the stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1395
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1397
        case op_return:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1398
          FT_TRACE4(( " return" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1399
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1400
          if ( zone <= decoder->zones )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1401
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1402
            FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1403
                       " unexpected return\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1404
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1405
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1406
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1407
          zone--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1408
          ip            = zone->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1409
          limit         = zone->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1410
          decoder->zone = zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1411
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1412
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1413
        case op_dotsection:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1414
          FT_TRACE4(( " dotsection" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1415
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1416
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1418
        case op_hstem:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1419
          FT_TRACE4(( " hstem" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1420
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1421
          /* record horizontal hint */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1422
          if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1423
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1424
            /* top[0] += builder->left_bearing.y; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1425
            hinter->stem( hinter->hints, 1, top );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1426
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1427
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1429
        case op_hstem3:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1430
          FT_TRACE4(( " hstem3" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1431
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1432
          /* record horizontal counter-controlled hints */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1433
          if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1434
            hinter->stem3( hinter->hints, 1, top );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1435
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1436
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1437
        case op_vstem:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1438
          FT_TRACE4(( " vstem" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1440
          /* record vertical hint */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1441
          if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1442
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1443
            top[0] += orig_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1444
            hinter->stem( hinter->hints, 0, top );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1445
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1446
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1447
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1448
        case op_vstem3:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1449
          FT_TRACE4(( " vstem3" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1450
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1451
          /* record vertical counter-controlled hints */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1452
          if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1453
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1454
            FT_Pos  dx = orig_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1455
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1456
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1457
            top[0] += dx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1458
            top[2] += dx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1459
            top[4] += dx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1460
            hinter->stem3( hinter->hints, 0, top );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1461
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1462
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1464
        case op_setcurrentpoint:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1465
          FT_TRACE4(( " setcurrentpoint" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1466
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1467
          /* From the T1 specification, section 6.4:                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1468
          /*                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1469
          /*   The setcurrentpoint command is used only in          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1470
          /*   conjunction with results from OtherSubrs procedures. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1471
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1472
          /* known_othersubr_result_cnt != 0 is already handled     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1473
          /* above.                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1474
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1475
          /* Note, however, that both Ghostscript and Adobe         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1476
          /* Distiller handle this situation by silently ignoring   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1477
          /* the inappropriate `setcurrentpoint' instruction.  So   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1478
          /* we do the same.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1479
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1480
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1481
          if ( decoder->flex_state != 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1482
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1483
            FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1484
                       " unexpected `setcurrentpoint'\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1485
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1486
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1487
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1488
            ...
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1489
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1490
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1491
          x = top[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1492
          y = top[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1493
          decoder->flex_state = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1494
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1495
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1496
        case op_unknown15:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1497
          FT_TRACE4(( " opcode_15" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1498
          /* nothing to do except to pop the two arguments */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1499
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1500
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1501
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1502
          FT_ERROR(( "t1_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1503
                     " unhandled opcode %d\n", op ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1504
          goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1505
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1507
        /* XXX Operators usually clear the operand stack;  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1508
        /*     only div, callsubr, callothersubr, pop, and */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1509
        /*     return are different.                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1510
        /*     In practice it doesn't matter (?).          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1511
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1512
        decoder->top = top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1513
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1514
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1515
        FT_TRACE4(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1516
        bol = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1517
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1518
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1519
      } /* general operator processing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1521
    } /* while ip < limit */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1522
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1523
    FT_TRACE4(( "..end..\n\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1524
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1525
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1526
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1528
  Syntax_Error:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1529
    return PSaux_Err_Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1530
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1531
  Stack_Underflow:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1532
    return PSaux_Err_Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1533
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1534
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1535
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1536
  /* parse a single Type 1 glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1537
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1538
  t1_decoder_parse_glyph( T1_Decoder  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1539
                          FT_UInt     glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1540
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1541
    return decoder->parse_callback( decoder, glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1542
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1543
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1545
  /* initialize T1 decoder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1546
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1547
  t1_decoder_init( T1_Decoder           decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1548
                   FT_Face              face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1549
                   FT_Size              size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1550
                   FT_GlyphSlot         slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1551
                   FT_Byte**            glyph_names,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1552
                   PS_Blend             blend,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1553
                   FT_Bool              hinting,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1554
                   FT_Render_Mode       hint_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1555
                   T1_Decoder_Callback  parse_callback )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1556
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1557
    FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1558
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1559
    /* retrieve PSNames interface from list of current modules */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1560
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1561
      FT_Service_PsCMaps  psnames = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1562
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1563
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1564
      FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1565
      if ( !psnames )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1566
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1567
        FT_ERROR(( "t1_decoder_init:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1568
                   " the `psnames' module is not available\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1569
        return PSaux_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1570
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1571
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1572
      decoder->psnames = psnames;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1573
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1575
    t1_builder_init( &decoder->builder, face, size, slot, hinting );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1576
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1577
    /* decoder->buildchar and decoder->len_buildchar have to be  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1578
    /* initialized by the caller since we cannot know the length */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1579
    /* of the BuildCharArray                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1581
    decoder->num_glyphs     = (FT_UInt)face->num_glyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1582
    decoder->glyph_names    = glyph_names;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1583
    decoder->hint_mode      = hint_mode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1584
    decoder->blend          = blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1585
    decoder->parse_callback = parse_callback;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1586
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1587
    decoder->funcs          = t1_decoder_funcs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1588
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1589
    return PSaux_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1590
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1591
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1592
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1593
  /* finalize T1 decoder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1594
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1595
  t1_decoder_done( T1_Decoder  decoder )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1596
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1597
    t1_builder_done( &decoder->builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1598
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1599
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1600
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1601
/* END */