misc/libfreetype/src/cff/cffgload.c
author koda
Mon, 19 Nov 2012 00:49:24 +0100
changeset 8063 06efc1ea6a40
parent 5172 88f2e05288ba
permissions -rw-r--r--
linking phsyfs on osx
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
/*  cffgload.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
/*    OpenType Glyph Loader (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 1996-2011 by                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_SFNT_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include FT_OUTLINE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include "cffobjs.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#include "cffload.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include "cffgload.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 "cfferrs.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_cffgload
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  CFF_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
    cff_op_unknown = 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    cff_op_rmoveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    cff_op_hmoveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    cff_op_vmoveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
    cff_op_rlineto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
    cff_op_hlineto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    cff_op_vlineto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    cff_op_rrcurveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    cff_op_hhcurveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
    cff_op_hvcurveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    cff_op_rcurveline,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    cff_op_rlinecurve,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    cff_op_vhcurveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
    cff_op_vvcurveto,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    cff_op_flex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    cff_op_hflex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    cff_op_hflex1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
    cff_op_flex1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    cff_op_endchar,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    cff_op_hstem,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    cff_op_vstem,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
    cff_op_hstemhm,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    cff_op_vstemhm,
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
    cff_op_hintmask,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
    cff_op_cntrmask,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
    cff_op_dotsection,  /* deprecated, acts as no-op */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
    cff_op_abs,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
    cff_op_add,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
    cff_op_sub,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
    cff_op_div,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    cff_op_neg,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    cff_op_random,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
    cff_op_mul,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
    cff_op_sqrt,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
    cff_op_blend,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
    cff_op_drop,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    cff_op_exch,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    cff_op_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    cff_op_roll,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
    cff_op_dup,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
    cff_op_put,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    cff_op_get,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    cff_op_store,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
    cff_op_load,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
    cff_op_and,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
    cff_op_or,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    cff_op_not,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    cff_op_eq,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    cff_op_ifelse,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    cff_op_callsubr,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    cff_op_callgsubr,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    cff_op_return,
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
    /* Type 1 opcodes: invalid but seen in real life */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    cff_op_hsbw,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    cff_op_closepath,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    cff_op_callothersubr,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    cff_op_pop,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    cff_op_seac,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    cff_op_sbw,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
    cff_op_setcurrentpoint,
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
    /* do not remove */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
    cff_op_max
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
  } CFF_Operator;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
#define CFF_COUNT_CHECK_WIDTH  0x80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
#define CFF_COUNT_EXACT        0x40
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
#define CFF_COUNT_CLEAR_STACK  0x20
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  /* count values which have the `CFF_COUNT_CHECK_WIDTH' flag set are  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
  /* used for checking the width and requested numbers of arguments    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
  /* only; they are set to zero afterwards                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
  /* the other two flags are informative only and unused currently     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
  static const FT_Byte  cff_argument_counts[] =
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
    0,  /* unknown */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT, /* rmoveto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
    0 | CFF_COUNT_CLEAR_STACK, /* rlineto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    0 | CFF_COUNT_CLEAR_STACK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    0 | CFF_COUNT_CLEAR_STACK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    0 | CFF_COUNT_CLEAR_STACK, /* rrcurveto */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
    0 | CFF_COUNT_CLEAR_STACK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
    0 | CFF_COUNT_CLEAR_STACK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    0 | CFF_COUNT_CLEAR_STACK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
    0 | CFF_COUNT_CLEAR_STACK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
    0 | CFF_COUNT_CLEAR_STACK,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    0 | CFF_COUNT_CLEAR_STACK,
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
    13, /* flex */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    7,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    9,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    11,
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
    0 | CFF_COUNT_CHECK_WIDTH, /* endchar */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    2 | CFF_COUNT_CHECK_WIDTH, /* hstem */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    2 | CFF_COUNT_CHECK_WIDTH,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
    2 | CFF_COUNT_CHECK_WIDTH,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
    2 | CFF_COUNT_CHECK_WIDTH,
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
    0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
    0, /* dotsection */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    1, /* abs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
    1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    1,
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
    1, /* blend */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    1, /* drop */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
    2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
    1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
    2, /* put */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    4,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    3,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
    2, /* and */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
    1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    4,
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
    1, /* callsubr */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
    1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    0,
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
    2, /* hsbw */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    5, /* seac */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
    4, /* sbw */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
    2  /* setcurrentpoint */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
  };
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
  /**********             GENERIC CHARSTRING PARSING               *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
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
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
  /*    cff_builder_init                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
  /*    Initializes a given glyph builder.                                 */
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
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
  /*    builder :: A pointer to the glyph builder to initialize.           */
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
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
  /*    face    :: The current face object.                                */
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
  /*    size    :: The current size object.                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
  /*    glyph   :: The current glyph object.                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
  /*    hinting :: Whether hinting is active.                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
  cff_builder_init( CFF_Builder*   builder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
                    TT_Face        face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
                    CFF_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
                    CFF_GlyphSlot  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
                    FT_Bool        hinting )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    builder->path_begun  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    builder->load_points = 1;
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
    builder->face   = face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    builder->glyph  = glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    builder->memory = face->root.memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    if ( glyph )
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
      FT_GlyphLoader  loader = glyph->root.internal->loader;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
      builder->loader  = loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
      builder->base    = &loader->base.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
      builder->current = &loader->current.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
      FT_GlyphLoader_Rewind( loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
      builder->hints_globals = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
      builder->hints_funcs   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
      if ( hinting && size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
        CFF_Internal  internal = (CFF_Internal)size->root.internal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
        builder->hints_globals = (void *)internal->topfont;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
        builder->hints_funcs   = glyph->root.internal->glyph_hints;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
    builder->pos_x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
    builder->pos_y = 0;
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
    builder->left_bearing.x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    builder->left_bearing.y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
    builder->advance.x      = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
    builder->advance.y      = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
  /*    cff_builder_done                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
  /*    Finalizes a given glyph builder.  Its contents can still be used   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
  /*    after the call, but the function saves important information       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
  /*    within the corresponding glyph slot.                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
  /*    builder :: A pointer to the glyph builder to finalize.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
  cff_builder_done( CFF_Builder*  builder )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
    CFF_GlyphSlot  glyph = builder->glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    if ( glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
      glyph->root.outline = *builder->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
  /*    cff_compute_bias                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
  /*    Computes the bias value in dependence of the number of glyph       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
  /*    subroutines.                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
  /*    in_charstring_type :: The `CharstringType' value of the top DICT   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
  /*                          dictionary.                                  */
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
  /*    num_subrs          :: The number of glyph subroutines.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
  /*    The bias value.                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
  static FT_Int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
  cff_compute_bias( FT_Int   in_charstring_type,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
                    FT_UInt  num_subrs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
    FT_Int  result;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
    if ( in_charstring_type == 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
      result = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
    else if ( num_subrs < 1240 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
      result = 107;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
    else if ( num_subrs < 33900U )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
      result = 1131;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
      result = 32768U;
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 result;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
  /*    cff_decoder_init                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
  /*    Initializes a given glyph decoder.                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
  /*    decoder :: A pointer to the glyph builder to initialize.           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
  /*    face      :: The current face object.                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
  /*    size      :: The current size object.                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
  /*    slot      :: The current glyph object.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
  /*    hinting   :: Whether hinting is active.                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
  /*    hint_mode :: The hinting mode.                                     */
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
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
  cff_decoder_init( CFF_Decoder*    decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
                    TT_Face         face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
                    CFF_Size        size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
                    CFF_GlyphSlot   slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
                    FT_Bool         hinting,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
                    FT_Render_Mode  hint_mode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
    CFF_Font  cff = (CFF_Font)face->extra.data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
    /* clear everything */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
    FT_MEM_ZERO( decoder, sizeof ( *decoder ) );
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
    /* initialize builder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
    cff_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
   392
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
    /* initialize Type2 decoder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
    decoder->cff          = cff;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
    decoder->num_globals  = cff->global_subrs_index.count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
    decoder->globals      = cff->global_subrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    decoder->globals_bias = cff_compute_bias(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
                              cff->top_font.font_dict.charstring_type,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
                              decoder->num_globals );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
    decoder->hint_mode    = hint_mode;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
  /* this function is used to select the subfont */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
  /* and the locals subrs array                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
  cff_decoder_prepare( CFF_Decoder*  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
                       CFF_Size      size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
                       FT_UInt       glyph_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
    CFF_Builder  *builder = &decoder->builder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
    CFF_Font      cff     = (CFF_Font)builder->face->extra.data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
    CFF_SubFont   sub     = &cff->top_font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
    FT_Error      error   = CFF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
    /* manage CID fonts */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
    if ( cff->num_subfonts )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
      FT_Byte  fd_index = cff_fd_select_get( &cff->fd_select, glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
      if ( fd_index >= cff->num_subfonts )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
        FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
        error = CFF_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
      FT_TRACE3(( "glyph index %d (subfont %d):\n", glyph_index, fd_index ));
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
      sub = cff->subfonts[fd_index];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
      if ( builder->hints_funcs && size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
        CFF_Internal  internal = (CFF_Internal)size->root.internal;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
        /* for CFFs without subfonts, this value has already been set */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
        builder->hints_globals = (void *)internal->subfonts[fd_index];
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
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
      FT_TRACE3(( "glyph index %d:\n", glyph_index ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
    decoder->num_locals    = sub->local_subrs_index.count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
    decoder->locals        = sub->local_subrs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
    decoder->locals_bias   = cff_compute_bias(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
                               decoder->cff->top_font.font_dict.charstring_type,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
                               decoder->num_locals );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
    decoder->glyph_width   = sub->private_dict.default_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
    decoder->nominal_width = sub->private_dict.nominal_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
  /* check that there is enough space for `count' more points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
  check_points( CFF_Builder*  builder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
                FT_Int        count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
    return FT_GLYPHLOADER_CHECK_POINTS( builder->loader, count, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
  /* add a new point, do not check space */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
  cff_builder_add_point( CFF_Builder*  builder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
                         FT_Pos        x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
                         FT_Pos        y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
                         FT_Byte       flag )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
    FT_Outline*  outline = builder->current;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
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
    if ( builder->load_points )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
      FT_Vector*  point   = outline->points + outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
      FT_Byte*    control = (FT_Byte*)outline->tags + outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
      point->x = x >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
      point->y = y >> 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
      *control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
    outline->n_points++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
  /* check space for a new on-curve point, then add it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
  cff_builder_add_point1( CFF_Builder*  builder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
                          FT_Pos        x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
                          FT_Pos        y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
    error = check_points( builder, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
      cff_builder_add_point( builder, x, y, 1 );
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
  /* check space for a new contour, then add it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
  cff_builder_add_contour( CFF_Builder*  builder )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
    FT_Outline*  outline = builder->current;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
    FT_Error     error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
    if ( !builder->load_points )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
      outline->n_contours++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
      return CFF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
    error = FT_GLYPHLOADER_CHECK_POINTS( builder->loader, 0, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
      if ( outline->n_contours > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
        outline->contours[outline->n_contours - 1] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
          (short)( outline->n_points - 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
      outline->n_contours++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
  /* if a path was begun, add its first on-curve point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
  cff_builder_start_point( CFF_Builder*  builder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
                           FT_Pos        x,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
                           FT_Pos        y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
    FT_Error  error = CFF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
    /* test whether we are building a new contour */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
    if ( !builder->path_begun )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
      builder->path_begun = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
      error = cff_builder_add_contour( builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
        error = cff_builder_add_point1( builder, x, y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
    }
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
  /* close the current contour */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
  cff_builder_close_contour( CFF_Builder*  builder )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
    FT_Outline*  outline = builder->current;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
    FT_Int       first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
    if ( !outline )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
    first = outline->n_contours <= 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
            ? 0 : outline->contours[outline->n_contours - 2] + 1;
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
    /* We must not include the last point in the path if it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
    /* is located on the first point.                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
    if ( outline->n_points > 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
      FT_Vector*  p1      = outline->points + first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
      FT_Vector*  p2      = outline->points + outline->n_points - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
      FT_Byte*    control = (FT_Byte*)outline->tags + outline->n_points - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
      /* `delete' last point only if it coincides with the first    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
      /* point and if it is not a control point (which can happen). */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
      if ( p1->x == p2->x && p1->y == p2->y )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
        if ( *control == FT_CURVE_TAG_ON )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
          outline->n_points--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
    if ( outline->n_contours > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
      /* Don't add contours only consisting of one point, i.e., */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
      /* check whether begin point and last point are the same. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
      if ( first == outline->n_points - 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
        outline->n_contours--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
        outline->n_points--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
        outline->contours[outline->n_contours - 1] =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
          (short)( outline->n_points - 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
  static FT_Int
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
  cff_lookup_glyph_by_stdcharcode( CFF_Font  cff,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
                                   FT_Int    charcode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
    FT_UInt    n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
    FT_UShort  glyph_sid;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
    /* CID-keyed fonts don't have glyph names */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    if ( !cff->charset.sids )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
      return -1;
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
    /* check range of standard char code */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
    if ( charcode < 0 || charcode > 255 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
      return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
    /* Get code to SID mapping from `cff_standard_encoding'. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    glyph_sid = cff_get_standard_encoding( (FT_UInt)charcode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
    for ( n = 0; n < cff->num_glyphs; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
      if ( cff->charset.sids[n] == glyph_sid )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
        return n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
    return -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
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
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
  cff_get_glyph_data( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
                      FT_UInt    glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
                      FT_Byte**  pointer,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
                      FT_ULong*  length )
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
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
    /* For incremental fonts get the character data using the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
    /* callback function.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
    if ( face->root.internal->incremental_interface )
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
      FT_Data   data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
      FT_Error  error =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
                  face->root.internal->incremental_interface->funcs->get_glyph_data(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
                    face->root.internal->incremental_interface->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
                    glyph_index, &data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
      *pointer = (FT_Byte*)data.pointer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
      *length = data.length;
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
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
      CFF_Font  cff  = (CFF_Font)(face->extra.data);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
      return cff_index_access_element( &cff->charstrings_index, glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
                                       pointer, length );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
  cff_free_glyph_data( TT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
                       FT_Byte**  pointer,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
                       FT_ULong   length )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
#ifndef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
    FT_UNUSED( length );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
    /* For incremental fonts get the character data using the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
    /* callback function.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
    if ( face->root.internal->incremental_interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
      FT_Data data;
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
      data.pointer = *pointer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
      data.length  = length;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
      face->root.internal->incremental_interface->funcs->free_glyph_data(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
        face->root.internal->incremental_interface->object, &data );
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
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
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
      CFF_Font  cff = (CFF_Font)(face->extra.data);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
      cff_index_forget_element( &cff->charstrings_index, pointer );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
  cff_operator_seac( CFF_Decoder*  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
                     FT_Pos        asb,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
                     FT_Pos        adx,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
                     FT_Pos        ady,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
                     FT_Int        bchar,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
                     FT_Int        achar )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
    CFF_Builder*  builder = &decoder->builder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
    FT_Int        bchar_index, achar_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
    TT_Face       face = decoder->builder.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
    FT_Vector     left_bearing, advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
    FT_Byte*      charstring;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
    FT_ULong      charstring_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
    FT_Pos        glyph_width;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
    if ( decoder->seac )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
      FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
      return CFF_Err_Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
    adx += decoder->builder.left_bearing.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
    ady += decoder->builder.left_bearing.y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
    /* Incremental fonts don't necessarily have valid charsets.        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
    /* They use the character code, not the glyph index, in this case. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
    if ( face->root.internal->incremental_interface )
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
      bchar_index = bchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
      achar_index = achar;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
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
      CFF_Font cff = (CFF_Font)(face->extra.data);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
      bchar_index = cff_lookup_glyph_by_stdcharcode( cff, bchar );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
      achar_index = cff_lookup_glyph_by_stdcharcode( cff, achar );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
    if ( bchar_index < 0 || achar_index < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
      FT_ERROR(( "cff_operator_seac:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
                 " invalid seac character code arguments\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
      return CFF_Err_Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
    /* 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
   763
    /* 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
   764
    if ( builder->no_recurse )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
      FT_GlyphSlot    glyph  = (FT_GlyphSlot)builder->glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
      FT_GlyphLoader  loader = glyph->internal->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
      FT_SubGlyph     subg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
      /* reallocate subglyph array if necessary */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
      error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
      subg = loader->current.subglyphs;
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
      /* subglyph 0 = base character */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
      subg->index = bchar_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
      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
   781
                    FT_SUBGLYPH_FLAG_USE_MY_METRICS;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
      subg->arg1  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
      subg->arg2  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
      subg++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
      /* subglyph 1 = accent character */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
      subg->index = achar_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
      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
   789
      subg->arg1  = (FT_Int)( adx >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
      subg->arg2  = (FT_Int)( ady >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
      /* set up remaining glyph fields */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
      glyph->num_subglyphs = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
      glyph->subglyphs     = loader->base.subglyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
      glyph->format        = FT_GLYPH_FORMAT_COMPOSITE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
      loader->current.num_subglyphs = 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
    FT_GlyphLoader_Prepare( builder->loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
    /* First load `bchar' in builder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
    error = cff_get_glyph_data( face, bchar_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
                                &charstring, &charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
      /* the seac operator must not be nested */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
      decoder->seac = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
      error = cff_decoder_parse_charstrings( decoder, charstring,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
                                             charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
      decoder->seac = FALSE;
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
      cff_free_glyph_data( face, &charstring, charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
    /* Save the left bearing, advance and glyph width of the base */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
    /* character 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
   821
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
    left_bearing = builder->left_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
    advance      = builder->advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
    glyph_width  = decoder->glyph_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
    builder->left_bearing.x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
    builder->left_bearing.y = 0;
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
    builder->pos_x = adx - asb;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
    builder->pos_y = ady;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
    /* Now load `achar' on top of the base outline. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
    error = cff_get_glyph_data( face, achar_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
                                &charstring, &charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
      /* the seac operator must not be nested */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
      decoder->seac = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
      error = cff_decoder_parse_charstrings( decoder, charstring,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
                                             charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
      decoder->seac = FALSE;
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
      cff_free_glyph_data( face, &charstring, charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
        goto Exit;
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
    /* Restore the left side bearing, advance and glyph width */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
    /* of the base character.                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
    builder->left_bearing = left_bearing;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
    builder->advance      = advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
    decoder->glyph_width  = glyph_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
    builder->pos_x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
    builder->pos_y = 0;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
  /*************************************************************************/
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
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
  /*    cff_decoder_parse_charstrings                                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
  /*    Parses a given Type 2 charstrings program.                         */
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
  /* <InOut>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
  /*    decoder         :: The current Type 1 decoder.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
  /* <Input>                                                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
  /*    charstring_base :: The base of the charstring stream.              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
  /*    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
   878
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
  /* <Return>                                                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
  /*    FreeType error code.  0 means success.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
  cff_decoder_parse_charstrings( CFF_Decoder*  decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
                                 FT_Byte*      charstring_base,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
                                 FT_ULong      charstring_len )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
    FT_Error           error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
    CFF_Decoder_Zone*  zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
    FT_Byte*           ip;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
    FT_Byte*           limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
    CFF_Builder*       builder = &decoder->builder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
    FT_Pos             x, y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
    FT_Fixed           seed;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
    FT_Fixed*          stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
    FT_Int             charstring_type =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
                         decoder->cff->top_font.font_dict.charstring_type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
    T2_Hints_Funcs     hinter;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
    /* set default width */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
    decoder->num_hints  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
    decoder->read_width = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
    /* 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
   906
    seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed              ^
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
                         (FT_PtrDist)(char*)&decoder           ^
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
                         (FT_PtrDist)(char*)&charstring_base ) &
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
                         FT_ULONG_MAX ) ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
    seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
    if ( seed == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
      seed = 0x7384;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
    /* initialize the decoder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
    decoder->top  = decoder->stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
    decoder->zone = decoder->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
    zone          = decoder->zones;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
    stack         = decoder->top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
    hinter = (T2_Hints_Funcs)builder->hints_funcs;
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
    builder->path_begun = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
    zone->base           = charstring_base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
    limit = zone->limit  = charstring_base + charstring_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
    ip    = zone->cursor = zone->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
    error = CFF_Err_Ok;
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
    x = builder->pos_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
    y = builder->pos_y;
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
    /* begin hints recording session, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
    if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
      hinter->open( hinter->hints );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
    /* now execute loop */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
    while ( ip < limit )
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
      CFF_Operator  op;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
      FT_Byte       v;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
      /********************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
      /*                                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
      /* Decode operator or operand                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
      /*                                                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
      v = *ip++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
      if ( v >= 32 || v == 28 )
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
        FT_Int    shift = 16;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
        FT_Int32  val;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
        /* this is an operand, push it on the stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
        if ( v == 28 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
          if ( ip + 1 >= limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
          val = (FT_Short)( ( (FT_Short)ip[0] << 8 ) | ip[1] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
          ip += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
        else if ( v < 247 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
          val = (FT_Int32)v - 139;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
        else if ( v < 251 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
          if ( ip >= limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
          val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
        else if ( v < 255 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
          if ( ip >= limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
          val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
          if ( ip + 3 >= limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
          val = ( (FT_Int32)ip[0] << 24 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
                ( (FT_Int32)ip[1] << 16 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
                ( (FT_Int32)ip[2] <<  8 ) |
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
                            ip[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
          ip    += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
          if ( charstring_type == 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
            shift = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
        if ( decoder->top - stack >= CFF_MAX_OPERANDS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
          goto Stack_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
        val           <<= shift;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
        *decoder->top++ = val;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
#ifdef FT_DEBUG_LEVEL_TRACE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
        if ( !( val & 0xFFFFL ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
          FT_TRACE4(( " %ld", (FT_Int32)( val >> 16 ) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
          FT_TRACE4(( " %.2f", val / 65536.0 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
        /* The specification says that normally arguments are to be taken */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
        /* from the bottom of the stack.  However, this seems not to be   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
        /* correct, at least for Acroread 7.0.8 on GNU/Linux: It pops the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
        /* arguments similar to a PS interpreter.                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
        FT_Fixed*  args     = decoder->top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
        FT_Int     num_args = (FT_Int)( args - decoder->stack );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
        FT_Int     req_args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
        /* find operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
        op = cff_op_unknown;
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
        switch ( v )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
        case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
          op = cff_op_hstem;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
        case 3:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
          op = cff_op_vstem;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
        case 4:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
          op = cff_op_vmoveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
        case 5:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
          op = cff_op_rlineto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
        case 6:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
          op = cff_op_hlineto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
        case 7:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
          op = cff_op_vlineto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
        case 8:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
          op = cff_op_rrcurveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
        case 9:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
          op = cff_op_closepath;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
        case 10:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
          op = cff_op_callsubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
        case 11:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
          op = cff_op_return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
        case 12:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
            if ( ip >= limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
            v = *ip++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
            switch ( v )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
            case 0:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
              op = cff_op_dotsection;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
            case 1: /* this is actually the Type1 vstem3 operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
              op = cff_op_vstem;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
            case 2: /* this is actually the Type1 hstem3 operator */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
              op = cff_op_hstem;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
            case 3:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
              op = cff_op_and;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
            case 4:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
              op = cff_op_or;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
            case 5:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
              op = cff_op_not;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
            case 6:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
              op = cff_op_seac;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
            case 7:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
              op = cff_op_sbw;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
            case 8:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
              op = cff_op_store;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
            case 9:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
              op = cff_op_abs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
            case 10:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
              op = cff_op_add;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
            case 11:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1092
              op = cff_op_sub;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
            case 12:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
              op = cff_op_div;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
            case 13:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
              op = cff_op_load;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
            case 14:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
              op = cff_op_neg;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
            case 15:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
              op = cff_op_eq;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
            case 16:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
              op = cff_op_callothersubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
            case 17:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
              op = cff_op_pop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1111
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
            case 18:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
              op = cff_op_drop;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
            case 20:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
              op = cff_op_put;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1117
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
            case 21:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
              op = cff_op_get;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
            case 22:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
              op = cff_op_ifelse;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
            case 23:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
              op = cff_op_random;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
            case 24:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
              op = cff_op_mul;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
            case 26:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
              op = cff_op_sqrt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
            case 27:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
              op = cff_op_dup;
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
            case 28:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
              op = cff_op_exch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1139
            case 29:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1140
              op = cff_op_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
            case 30:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
              op = cff_op_roll;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
            case 33:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
              op = cff_op_setcurrentpoint;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
            case 34:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
              op = cff_op_hflex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
            case 35:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
              op = cff_op_flex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
            case 36:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1155
              op = cff_op_hflex1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1156
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
            case 37:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
              op = cff_op_flex1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1160
            default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1161
              FT_TRACE4(( " unknown op (12, %d)\n", v ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1163
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1164
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1165
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1166
        case 13:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
          op = cff_op_hsbw;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1168
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1169
        case 14:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1170
          op = cff_op_endchar;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1171
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1172
        case 16:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1173
          op = cff_op_blend;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1175
        case 18:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1176
          op = cff_op_hstemhm;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1178
        case 19:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1179
          op = cff_op_hintmask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
        case 20:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
          op = cff_op_cntrmask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
        case 21:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
          op = cff_op_rmoveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
        case 22:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
          op = cff_op_hmoveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
        case 23:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
          op = cff_op_vstemhm;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1193
        case 24:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1194
          op = cff_op_rcurveline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1196
        case 25:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1197
          op = cff_op_rlinecurve;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1198
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1199
        case 26:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1200
          op = cff_op_vvcurveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1201
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1202
        case 27:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
          op = cff_op_hhcurveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1204
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1205
        case 29:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
          op = cff_op_callgsubr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1207
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1208
        case 30:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1209
          op = cff_op_vhcurveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1210
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1211
        case 31:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1212
          op = cff_op_hvcurveto;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1213
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1214
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1215
          FT_TRACE4(( " unknown op (%d)\n", v ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1216
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1217
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1218
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1219
        if ( op == cff_op_unknown )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1220
          continue;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1221
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1222
        /* check arguments */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1223
        req_args = cff_argument_counts[op];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1224
        if ( req_args & CFF_COUNT_CHECK_WIDTH )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1225
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1226
          if ( num_args > 0 && decoder->read_width )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1227
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1228
            /* If `nominal_width' is non-zero, the number is really a      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1229
            /* difference against `nominal_width'.  Else, the number here  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1230
            /* is truly a width, not a difference against `nominal_width'. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1231
            /* If the font does not set `nominal_width', then              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1232
            /* `nominal_width' defaults to zero, and so we can set         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1233
            /* `glyph_width' to `nominal_width' plus number on the stack   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1234
            /* -- for either case.                                         */
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
            FT_Int  set_width_ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1237
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1239
            switch ( op )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1240
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1241
            case cff_op_hmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1242
            case cff_op_vmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1243
              set_width_ok = num_args & 2;
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 cff_op_hstem:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1247
            case cff_op_vstem:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1248
            case cff_op_hstemhm:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1249
            case cff_op_vstemhm:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1250
            case cff_op_rmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1251
            case cff_op_hintmask:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1252
            case cff_op_cntrmask:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1253
              set_width_ok = num_args & 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1254
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1256
            case cff_op_endchar:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1257
              /* If there is a width specified for endchar, we either have */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1258
              /* 1 argument or 5 arguments.  We like to argue.             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1259
              set_width_ok = ( num_args == 5 ) || ( num_args == 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1260
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1261
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1262
            default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1263
              set_width_ok = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1264
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1265
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1266
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1267
            if ( set_width_ok )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1268
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1269
              decoder->glyph_width = decoder->nominal_width +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1270
                                       ( stack[0] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1271
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1272
              if ( decoder->width_only )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1273
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1274
                /* we only want the advance width; stop here */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1275
                break;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1278
              /* Consumed an argument. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1279
              num_args--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1280
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1281
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1282
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1283
          decoder->read_width = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1284
          req_args            = 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1287
        req_args &= 0x000F;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1288
        if ( num_args < req_args )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1289
          goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1290
        args     -= req_args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1291
        num_args -= req_args;
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
        /* At this point, `args' points to the first argument of the  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1294
        /* operand in case `req_args' isn't zero.  Otherwise, we have */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1295
        /* to adjust `args' manually.                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1296
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1297
        /* Note that we only pop arguments from the stack which we    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1298
        /* really need and can digest so that we can continue in case */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1299
        /* of superfluous stack elements.                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1300
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1301
        switch ( op )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1302
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1303
        case cff_op_hstem:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1304
        case cff_op_vstem:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1305
        case cff_op_hstemhm:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1306
        case cff_op_vstemhm:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1307
          /* the number of arguments is always even here */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1308
          FT_TRACE4((
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1309
              op == cff_op_hstem   ? " hstem\n"   :
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1310
            ( op == cff_op_vstem   ? " vstem\n"   :
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1311
            ( op == cff_op_hstemhm ? " hstemhm\n" : " vstemhm\n" ) ) ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1312
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1313
          if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1314
            hinter->stems( hinter->hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1315
                           ( op == cff_op_hstem || op == cff_op_hstemhm ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1316
                           num_args / 2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1317
                           args - ( num_args & ~1 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1318
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1319
          decoder->num_hints += num_args / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1320
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1321
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1322
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1323
        case cff_op_hintmask:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1324
        case cff_op_cntrmask:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1325
          FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" ));
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
          /* implement vstem when needed --                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1328
          /* the specification doesn't say it, but this also works */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1329
          /* with the 'cntrmask' operator                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1330
          /*                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1331
          if ( num_args > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1332
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1333
            if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1334
              hinter->stems( hinter->hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1335
                             0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1336
                             num_args / 2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1337
                             args - ( num_args & ~1 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1338
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1339
            decoder->num_hints += num_args / 2;
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
          /* In a valid charstring there must be at least one byte */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1343
          /* after `hintmask' or `cntrmask' (e.g., for a `return'  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1344
          /* instruction).  Additionally, there must be space for  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1345
          /* `num_hints' bits.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1346
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1347
          if ( ( ip + ( ( decoder->num_hints + 7 ) >> 3 ) ) >= limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1348
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1349
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1350
          if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1351
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1352
            if ( op == cff_op_hintmask )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1353
              hinter->hintmask( hinter->hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1354
                                builder->current->n_points,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1355
                                decoder->num_hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1356
                                ip );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1357
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1358
              hinter->counter( hinter->hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1359
                               decoder->num_hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1360
                               ip );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1361
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1362
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1363
#ifdef FT_DEBUG_LEVEL_TRACE
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_UInt maskbyte;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1367
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1368
            FT_TRACE4(( " (maskbytes:" ));
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
            for ( maskbyte = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1371
                  maskbyte < (FT_UInt)( ( decoder->num_hints + 7 ) >> 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1372
                  maskbyte++, ip++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1373
              FT_TRACE4(( " 0x%02X", *ip ));
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
            FT_TRACE4(( ")\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1376
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1377
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1378
          ip += ( decoder->num_hints + 7 ) >> 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1379
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1380
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1381
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1382
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1383
        case cff_op_rmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1384
          FT_TRACE4(( " rmoveto\n" ));
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
          cff_builder_close_contour( builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1387
          builder->path_begun = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1388
          x   += args[-2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1389
          y   += args[-1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1390
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1391
          break;
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
        case cff_op_vmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1394
          FT_TRACE4(( " vmoveto\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1396
          cff_builder_close_contour( builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1397
          builder->path_begun = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1398
          y   += args[-1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1399
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1400
          break;
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
        case cff_op_hmoveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1403
          FT_TRACE4(( " hmoveto\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1404
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1405
          cff_builder_close_contour( builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1406
          builder->path_begun = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1407
          x   += args[-1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1408
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1409
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1410
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1411
        case cff_op_rlineto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1412
          FT_TRACE4(( " rlineto\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1413
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1414
          if ( cff_builder_start_point ( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1415
               check_points( builder, num_args / 2 )     )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1416
            goto Fail;
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
          if ( num_args < 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1419
            goto Stack_Underflow;
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
          args -= num_args & ~1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1422
          while ( args < decoder->top )
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
            x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1425
            y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1426
            cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1427
            args += 2;
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
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1430
          break;
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
        case cff_op_hlineto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1433
        case cff_op_vlineto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1434
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1435
            FT_Int  phase = ( op == cff_op_hlineto );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1438
            FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1439
                                             : " vlineto\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1440
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1441
            if ( num_args < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1442
              goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1444
            /* there exist subsetted fonts (found in PDFs) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1445
            /* which call `hlineto' without arguments      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1446
            if ( num_args == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1447
              break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1448
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1449
            if ( cff_builder_start_point ( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1450
                 check_points( builder, num_args )         )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1451
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1452
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1453
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1454
            while ( args < decoder->top )
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
              if ( phase )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1457
                x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1458
              else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1459
                y += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1460
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1461
              if ( cff_builder_add_point1( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1462
                goto Fail;
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
              args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1465
              phase ^= 1;
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
            args = stack;
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
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1470
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1471
        case cff_op_rrcurveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1472
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1473
            FT_Int  nargs;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1476
            FT_TRACE4(( " rrcurveto\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1477
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1478
            if ( num_args < 6 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1479
              goto Stack_Underflow;
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
            nargs = num_args - num_args % 6;
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
            if ( cff_builder_start_point ( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1484
                 check_points( builder, nargs / 2 )     )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1485
              goto Fail;
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
            args -= nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1488
            while ( args < decoder->top )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1489
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1490
              x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1491
              y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1492
              cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1493
              x += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1494
              y += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1495
              cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1496
              x += args[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1497
              y += args[5];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1498
              cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1499
              args += 6;
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
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1502
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1503
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1504
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1505
        case cff_op_vvcurveto:
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
            FT_Int  nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1509
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1510
            FT_TRACE4(( " vvcurveto\n" ));
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
            if ( num_args < 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1513
              goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1514
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1515
            /* if num_args isn't of the form 4n or 4n+1, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1516
            /* we reduce it to 4n+1                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1517
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1518
            nargs = num_args - num_args % 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1519
            if ( num_args - nargs > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1520
              nargs += 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1521
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1522
            if ( cff_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1523
              goto Fail;
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
            args -= nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1526
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1527
            if ( nargs & 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1528
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1529
              x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1530
              args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1531
              nargs--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1532
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1533
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1534
            if ( check_points( builder, 3 * ( nargs / 4 ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1535
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1536
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1537
            while ( args < decoder->top )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1538
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1539
              y += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1540
              cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1541
              x += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1542
              y += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1543
              cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1544
              y += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1545
              cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1546
              args += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1547
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1548
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1549
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1550
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1551
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1552
        case cff_op_hhcurveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1553
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1554
            FT_Int  nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1555
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_TRACE4(( " hhcurveto\n" ));
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
            if ( num_args < 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1560
              goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1561
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1562
            /* if num_args isn't of the form 4n or 4n+1, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1563
            /* we reduce it to 4n+1                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1564
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1565
            nargs = num_args - num_args % 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1566
            if ( num_args - nargs > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1567
              nargs += 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1568
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1569
            if ( cff_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1570
              goto Fail;
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
            args -= nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1573
            if ( nargs & 1 )
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
              y += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1576
              args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1577
              nargs--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1578
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1580
            if ( check_points( builder, 3 * ( nargs / 4 ) ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1581
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1582
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1583
            while ( args < decoder->top )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1584
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1585
              x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1586
              cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1587
              x += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1588
              y += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1589
              cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1590
              x += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1591
              cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1592
              args += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1593
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1594
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1595
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1596
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1597
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1598
        case cff_op_vhcurveto:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1599
        case cff_op_hvcurveto:
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
            FT_Int  phase;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1602
            FT_Int  nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1603
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1604
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1605
            FT_TRACE4(( op == cff_op_vhcurveto ? " vhcurveto\n"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1606
                                               : " hvcurveto\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1607
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1608
            if ( cff_builder_start_point( builder, x, y ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1609
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1610
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1611
            if ( num_args < 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1612
              goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1613
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1614
            /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1615
            /* we reduce it to the largest one which fits             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1616
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1617
            nargs = num_args - num_args % 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1618
            if ( num_args - nargs > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1619
              nargs += 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1620
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1621
            args -= nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1622
            if ( check_points( builder, ( nargs / 4 ) * 3 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1623
              goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1624
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1625
            phase = ( op == cff_op_hvcurveto );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1626
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1627
            while ( nargs >= 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1628
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1629
              nargs -= 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1630
              if ( phase )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1631
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1632
                x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1633
                cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1634
                x += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1635
                y += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1636
                cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1637
                y += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1638
                if ( nargs == 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1639
                  x += args[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1640
                cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1641
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1642
              else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1643
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1644
                y += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1645
                cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1646
                x += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1647
                y += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1648
                cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1649
                x += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1650
                if ( nargs == 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1651
                  y += args[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1652
                cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1653
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1654
              args  += 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1655
              phase ^= 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1656
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1657
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1658
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1659
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1660
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1661
        case cff_op_rlinecurve:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1662
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1663
            FT_Int  num_lines;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1664
            FT_Int  nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1665
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1667
            FT_TRACE4(( " rlinecurve\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1668
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1669
            if ( num_args < 8 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1670
              goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1671
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1672
            nargs     = num_args & ~1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1673
            num_lines = ( nargs - 6 ) / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1674
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1675
            if ( cff_builder_start_point( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1676
                 check_points( builder, num_lines + 3 )   )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1677
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1678
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1679
            args -= nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1680
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1681
            /* first, add the line segments */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1682
            while ( num_lines > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1683
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1684
              x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1685
              y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1686
              cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1687
              args += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1688
              num_lines--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1689
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1690
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1691
            /* then the curve */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1692
            x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1693
            y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1694
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1695
            x += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1696
            y += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1697
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1698
            x += args[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1699
            y += args[5];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1700
            cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1701
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1702
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1703
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1704
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1705
        case cff_op_rcurveline:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1706
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1707
            FT_Int  num_curves;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1708
            FT_Int  nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1709
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1710
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1711
            FT_TRACE4(( " rcurveline\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1712
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1713
            if ( num_args < 8 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1714
              goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1715
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1716
            nargs      = num_args - 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1717
            nargs      = nargs - nargs % 6 + 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1718
            num_curves = ( nargs - 2 ) / 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1719
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1720
            if ( cff_builder_start_point ( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1721
                 check_points( builder, num_curves * 3 + 2 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1722
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1723
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1724
            args -= nargs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1725
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1726
            /* first, add the curves */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1727
            while ( num_curves > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1728
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1729
              x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1730
              y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1731
              cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1732
              x += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1733
              y += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1734
              cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1735
              x += args[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1736
              y += args[5];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1737
              cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1738
              args += 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1739
              num_curves--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1740
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1741
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1742
            /* then the final line */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1743
            x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1744
            y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1745
            cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1746
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1747
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1748
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1749
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1750
        case cff_op_hflex1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1751
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1752
            FT_Pos start_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1753
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1754
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1755
            FT_TRACE4(( " hflex1\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1756
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1757
            /* adding five more points: 4 control points, 1 on-curve point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1758
            /* -- make sure we have enough space for the start point if it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1759
            /* needs to be added                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1760
            if ( cff_builder_start_point( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1761
                 check_points( builder, 6 )               )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1762
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1763
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1764
            /* record the starting point's y position for later use */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1765
            start_y = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1766
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1767
            /* first control point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1768
            x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1769
            y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1770
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1771
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1772
            /* second control point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1773
            x += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1774
            y += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1775
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1776
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1777
            /* join point; on curve, with y-value the same as the last */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1778
            /* control point's y-value                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1779
            x += args[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1780
            cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1781
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1782
            /* third control point, with y-value the same as the join */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1783
            /* point's y-value                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1784
            x += args[5];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1785
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1786
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1787
            /* fourth control point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1788
            x += args[6];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1789
            y += args[7];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1790
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1791
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1792
            /* ending point, with y-value the same as the start   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1793
            x += args[8];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1794
            y  = start_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1795
            cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1796
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1797
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1798
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1799
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1800
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1801
        case cff_op_hflex:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1802
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1803
            FT_Pos start_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1804
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1805
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1806
            FT_TRACE4(( " hflex\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1807
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1808
            /* adding six more points; 4 control points, 2 on-curve points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1809
            if ( cff_builder_start_point( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1810
                 check_points( builder, 6 )               )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1811
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1812
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1813
            /* record the starting point's y-position for later use */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1814
            start_y = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1815
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1816
            /* first control point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1817
            x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1818
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1819
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1820
            /* second control point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1821
            x += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1822
            y += args[2];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1823
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1824
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1825
            /* join point; on curve, with y-value the same as the last */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1826
            /* control point's y-value                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1827
            x += args[3];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1828
            cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1829
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1830
            /* third control point, with y-value the same as the join */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1831
            /* point's y-value                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1832
            x += args[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1833
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1834
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1835
            /* fourth control point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1836
            x += args[5];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1837
            y  = start_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1838
            cff_builder_add_point( builder, x, y, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1839
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1840
            /* ending point, with y-value the same as the start point's */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1841
            /* y-value -- we don't add this point, though               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1842
            x += args[6];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1843
            cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1844
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1845
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1846
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1847
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1848
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1849
        case cff_op_flex1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1850
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1851
            FT_Pos     start_x, start_y; /* record start x, y values for */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1852
                                         /* alter use                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1853
            FT_Fixed   dx = 0, dy = 0;   /* used in horizontal/vertical  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1854
                                         /* algorithm below              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1855
            FT_Int     horizontal, count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1856
            FT_Fixed*  temp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1857
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1858
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1859
            FT_TRACE4(( " flex1\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1861
            /* adding six more points; 4 control points, 2 on-curve points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1862
            if ( cff_builder_start_point( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1863
                 check_points( builder, 6 )               )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1864
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1865
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1866
            /* record the starting point's x, y position for later use */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1867
            start_x = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1868
            start_y = y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1869
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1870
            /* XXX: figure out whether this is supposed to be a horizontal */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1871
            /*      or vertical flex; the Type 2 specification is vague... */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1872
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1873
            temp = args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1874
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1875
            /* grab up to the last argument */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1876
            for ( count = 5; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1877
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1878
              dx += temp[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1879
              dy += temp[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1880
              temp += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1881
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1882
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1883
            if ( dx < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1884
              dx = -dx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1885
            if ( dy < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1886
              dy = -dy;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1887
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1888
            /* strange test, but here it is... */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1889
            horizontal = ( dx > dy );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1890
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1891
            for ( count = 5; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1892
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1893
              x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1894
              y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1895
              cff_builder_add_point( builder, x, y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1896
                                     (FT_Bool)( count == 3 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1897
              args += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1898
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1899
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1900
            /* is last operand an x- or y-delta? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1901
            if ( horizontal )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1902
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1903
              x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1904
              y  = start_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1905
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1906
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1907
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1908
              x  = start_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1909
              y += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1910
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1911
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1912
            cff_builder_add_point( builder, x, y, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1913
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1914
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1915
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1916
           }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1917
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1918
        case cff_op_flex:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1919
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1920
            FT_UInt  count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1921
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1922
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1923
            FT_TRACE4(( " flex\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1924
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1925
            if ( cff_builder_start_point( builder, x, y ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1926
                 check_points( builder, 6 )               )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1927
              goto Fail;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1928
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1929
            for ( count = 6; count > 0; count-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1930
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1931
              x += args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1932
              y += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1933
              cff_builder_add_point( builder, x, y,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1934
                                     (FT_Bool)( count == 4 || count == 1 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1935
              args += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1936
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1937
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1938
            args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1939
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1940
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1941
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1942
        case cff_op_seac:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1943
            FT_TRACE4(( " seac\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1944
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1945
            error = cff_operator_seac( decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1946
                                       args[0], args[1], args[2],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1947
                                       (FT_Int)( args[3] >> 16 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1948
                                       (FT_Int)( args[4] >> 16 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1949
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1950
            /* add current outline to the glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1951
            FT_GlyphLoader_Add( builder->loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1952
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1953
            /* return now! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1954
            FT_TRACE4(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1955
            return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1956
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1957
        case cff_op_endchar:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1958
          FT_TRACE4(( " endchar\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1959
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1960
          /* We are going to emulate the seac operator. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1961
          if ( num_args >= 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1962
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1963
            /* Save glyph width so that the subglyphs don't overwrite it. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1964
            FT_Pos  glyph_width = decoder->glyph_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1965
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1966
            error = cff_operator_seac( decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1967
                                       0L, args[-4], args[-3],
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1968
                                       (FT_Int)( args[-2] >> 16 ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1969
                                       (FT_Int)( args[-1] >> 16 ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1970
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1971
            decoder->glyph_width = glyph_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1972
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1973
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1974
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1975
            if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1976
              error = CFF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1977
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1978
            cff_builder_close_contour( builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1979
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1980
            /* close hints recording session */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1981
            if ( hinter )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1982
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1983
              if ( hinter->close( hinter->hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1984
                                  builder->current->n_points ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1985
                goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1986
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1987
              /* 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
  1988
              hinter->apply( hinter->hints,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1989
                             builder->current,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1990
                             (PSH_Globals)builder->hints_globals,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1991
                             decoder->hint_mode );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1992
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1993
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1994
            /* add current outline to the glyph slot */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1995
            FT_GlyphLoader_Add( builder->loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1996
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1997
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1998
          /* return now! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1999
          FT_TRACE4(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2000
          return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2001
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2002
        case cff_op_abs:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2003
          FT_TRACE4(( " abs\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2004
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2005
          if ( args[0] < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2006
            args[0] = -args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2007
          args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2008
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2009
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2010
        case cff_op_add:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2011
          FT_TRACE4(( " add\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2012
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2013
          args[0] += args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2014
          args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2015
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2016
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2017
        case cff_op_sub:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2018
          FT_TRACE4(( " sub\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2019
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2020
          args[0] -= args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2021
          args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2022
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2023
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2024
        case cff_op_div:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2025
          FT_TRACE4(( " div\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2026
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2027
          args[0] = FT_DivFix( args[0], args[1] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2028
          args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2029
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2030
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2031
        case cff_op_neg:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2032
          FT_TRACE4(( " neg\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2033
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2034
          args[0] = -args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2035
          args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2036
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2037
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2038
        case cff_op_random:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2039
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2040
            FT_Fixed  Rand;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2041
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2042
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2043
            FT_TRACE4(( " rand\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2044
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2045
            Rand = seed;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2046
            if ( Rand >= 0x8000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2047
              Rand++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2048
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2049
            args[0] = Rand;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2050
            seed    = FT_MulFix( seed, 0x10000L - seed );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2051
            if ( seed == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2052
              seed += 0x2873;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2053
            args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2054
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2055
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2056
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2057
        case cff_op_mul:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2058
          FT_TRACE4(( " mul\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2059
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2060
          args[0] = FT_MulFix( args[0], args[1] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2061
          args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2062
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2063
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2064
        case cff_op_sqrt:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2065
          FT_TRACE4(( " sqrt\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2066
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2067
          if ( args[0] > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2068
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2069
            FT_Int    count = 9;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2070
            FT_Fixed  root  = args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2071
            FT_Fixed  new_root;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2072
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2073
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2074
            for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2075
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2076
              new_root = ( root + FT_DivFix( args[0], root ) + 1 ) >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2077
              if ( new_root == root || count <= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2078
                break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2079
              root = new_root;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2080
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2081
            args[0] = new_root;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2082
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2083
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2084
            args[0] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2085
          args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2086
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2087
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2088
        case cff_op_drop:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2089
          /* nothing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2090
          FT_TRACE4(( " drop\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2091
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2092
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2093
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2094
        case cff_op_exch:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2095
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2096
            FT_Fixed  tmp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2097
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2098
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2099
            FT_TRACE4(( " exch\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2101
            tmp     = args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2102
            args[0] = args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2103
            args[1] = tmp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2104
            args   += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2105
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2106
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2108
        case cff_op_index:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2109
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2110
            FT_Int  idx = (FT_Int)( args[0] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2111
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2112
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2113
            FT_TRACE4(( " index\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2115
            if ( idx < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2116
              idx = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2117
            else if ( idx > num_args - 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2118
              idx = num_args - 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2119
            args[0] = args[-( idx + 1 )];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2120
            args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2121
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2122
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2123
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2124
        case cff_op_roll:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2125
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2126
            FT_Int  count = (FT_Int)( args[0] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2127
            FT_Int  idx   = (FT_Int)( args[1] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2130
            FT_TRACE4(( " roll\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2131
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2132
            if ( count <= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2133
              count = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2135
            args -= count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2136
            if ( args < stack )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2137
              goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2139
            if ( idx >= 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2140
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2141
              while ( idx > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2142
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2143
                FT_Fixed  tmp = args[count - 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2144
                FT_Int    i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2147
                for ( i = count - 2; i >= 0; i-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2148
                  args[i + 1] = args[i];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2149
                args[0] = tmp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2150
                idx--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2151
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2152
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2153
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2154
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2155
              while ( idx < 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2156
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2157
                FT_Fixed  tmp = args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2158
                FT_Int    i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2159
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2161
                for ( i = 0; i < count - 1; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2162
                  args[i] = args[i + 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2163
                args[count - 1] = tmp;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2164
                idx++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2165
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2166
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2167
            args += count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2168
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2169
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2170
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2171
        case cff_op_dup:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2172
          FT_TRACE4(( " dup\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2173
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2174
          args[1] = args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2175
          args += 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2176
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2177
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2178
        case cff_op_put:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2179
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2180
            FT_Fixed  val = args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2181
            FT_Int    idx = (FT_Int)( args[1] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2182
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2184
            FT_TRACE4(( " put\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2185
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2186
            if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2187
              decoder->buildchar[idx] = val;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2188
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2189
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2190
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2191
        case cff_op_get:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2192
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2193
            FT_Int    idx = (FT_Int)( args[0] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2194
            FT_Fixed  val = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2195
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2196
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2197
            FT_TRACE4(( " get\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2198
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2199
            if ( idx >= 0 && idx < CFF_MAX_TRANS_ELEMENTS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2200
              val = decoder->buildchar[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2201
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2202
            args[0] = val;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2203
            args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2204
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2205
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2206
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2207
        case cff_op_store:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2208
          FT_TRACE4(( " store\n"));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2210
          goto Unimplemented;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2211
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2212
        case cff_op_load:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2213
          FT_TRACE4(( " load\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2215
          goto Unimplemented;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2216
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2217
        case cff_op_dotsection:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2218
          /* this operator is deprecated and ignored by the parser */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2219
          FT_TRACE4(( " dotsection\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2220
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2221
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2222
        case cff_op_closepath:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2223
          /* this is an invalid Type 2 operator; however, there        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2224
          /* exist fonts which are incorrectly converted from probably */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2225
          /* Type 1 to CFF, and some parsers seem to accept it         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2226
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2227
          FT_TRACE4(( " closepath (invalid op)\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2228
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2229
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2230
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2231
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2232
        case cff_op_hsbw:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2233
          /* this is an invalid Type 2 operator; however, there        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2234
          /* exist fonts which are incorrectly converted from probably */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2235
          /* Type 1 to CFF, and some parsers seem to accept it         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2236
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2237
          FT_TRACE4(( " hsbw (invalid op)\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2239
          decoder->glyph_width = decoder->nominal_width + ( args[1] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2240
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2241
          decoder->builder.left_bearing.x = args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2242
          decoder->builder.left_bearing.y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2243
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2244
          x    = decoder->builder.pos_x + args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2245
          y    = decoder->builder.pos_y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2246
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2247
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2249
        case cff_op_sbw:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2250
          /* this is an invalid Type 2 operator; however, there        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2251
          /* exist fonts which are incorrectly converted from probably */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2252
          /* Type 1 to CFF, and some parsers seem to accept it         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2253
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2254
          FT_TRACE4(( " sbw (invalid op)\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2256
          decoder->glyph_width = decoder->nominal_width + ( args[2] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2257
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2258
          decoder->builder.left_bearing.x = args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2259
          decoder->builder.left_bearing.y = args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2260
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2261
          x    = decoder->builder.pos_x + args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2262
          y    = decoder->builder.pos_y + args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2263
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2264
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2265
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2266
        case cff_op_setcurrentpoint:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2267
          /* this is an invalid Type 2 operator; however, there        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2268
          /* exist fonts which are incorrectly converted from probably */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2269
          /* Type 1 to CFF, and some parsers seem to accept it         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2270
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2271
          FT_TRACE4(( " setcurrentpoint (invalid op)\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2272
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2273
          x    = decoder->builder.pos_x + args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2274
          y    = decoder->builder.pos_y + args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2275
          args = stack;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2276
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2278
        case cff_op_callothersubr:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2279
          /* this is an invalid Type 2 operator; however, there        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2280
          /* exist fonts which are incorrectly converted from probably */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2281
          /* Type 1 to CFF, and some parsers seem to accept it         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2282
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2283
          FT_TRACE4(( " callothersubr (invalid op)\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2284
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2285
          /* subsequent `pop' operands should add the arguments,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2286
          /* this is the implementation described for `unknown' other  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2287
          /* subroutines in the Type1 spec.                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2288
          /*                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2289
          /* XXX Fix return arguments (see discussion below).          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2290
          args -= 2 + ( args[-2] >> 16 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2291
          if ( args < stack )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2292
            goto Stack_Underflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2293
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2295
        case cff_op_pop:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2296
          /* this is an invalid Type 2 operator; however, there        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2297
          /* exist fonts which are incorrectly converted from probably */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2298
          /* Type 1 to CFF, and some parsers seem to accept it         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2299
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2300
          FT_TRACE4(( " pop (invalid op)\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2302
          /* XXX Increasing `args' is wrong: After a certain number of */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2303
          /* `pop's we get a stack overflow.  Reason for doing it is   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2304
          /* code like this (actually found in a CFF font):            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2305
          /*                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2306
          /*   17 1 3 callothersubr                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2307
          /*   pop                                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2308
          /*   callsubr                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2309
          /*                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2310
          /* Since we handle `callothersubr' as a no-op, and           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2311
          /* `callsubr' needs at least one argument, `pop' can't be a  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2312
          /* no-op too as it basically should be.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2313
          /*                                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2314
          /* The right solution would be to provide real support for   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2315
          /* `callothersubr' as done in `t1decode.c', however, given   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2316
          /* the fact that CFF fonts with `pop' are invalid, it is     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2317
          /* questionable whether it is worth the time.                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2318
          args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2319
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2320
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2321
        case cff_op_and:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2322
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2323
            FT_Fixed  cond = args[0] && args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2324
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2325
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2326
            FT_TRACE4(( " and\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2327
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2328
            args[0] = cond ? 0x10000L : 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2329
            args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2330
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2331
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2333
        case cff_op_or:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2334
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2335
            FT_Fixed  cond = args[0] || args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2337
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2338
            FT_TRACE4(( " or\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2339
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2340
            args[0] = cond ? 0x10000L : 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2341
            args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2342
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2343
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2344
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2345
        case cff_op_eq:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2346
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2347
            FT_Fixed  cond = !args[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2348
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2349
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2350
            FT_TRACE4(( " eq\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2351
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2352
            args[0] = cond ? 0x10000L : 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2353
            args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2354
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2355
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2356
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2357
        case cff_op_ifelse:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2358
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2359
            FT_Fixed  cond = ( args[2] <= args[3] );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2360
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2361
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2362
            FT_TRACE4(( " ifelse\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2363
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2364
            if ( !cond )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2365
              args[0] = args[1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2366
            args++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2367
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2368
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2370
        case cff_op_callsubr:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2371
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2372
            FT_UInt  idx = (FT_UInt)( ( args[0] >> 16 ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2373
                                      decoder->locals_bias );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2374
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2375
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2376
            FT_TRACE4(( " callsubr(%d)\n", idx ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2377
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2378
            if ( idx >= decoder->num_locals )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2379
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2380
              FT_ERROR(( "cff_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2381
                         " invalid local subr index\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2382
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2383
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2384
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2385
            if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2386
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2387
              FT_ERROR(( "cff_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2388
                         " too many nested subrs\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2389
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2390
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2392
            zone->cursor = ip;  /* save current instruction pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2393
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2394
            zone++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2395
            zone->base   = decoder->locals[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2396
            zone->limit  = decoder->locals[idx + 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2397
            zone->cursor = zone->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2399
            if ( !zone->base || zone->limit == zone->base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2400
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2401
              FT_ERROR(( "cff_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2402
                         " invoking empty subrs\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2403
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2404
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2405
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2406
            decoder->zone = zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2407
            ip            = zone->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2408
            limit         = zone->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2409
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2410
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2411
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2412
        case cff_op_callgsubr:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2413
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2414
            FT_UInt  idx = (FT_UInt)( ( args[0] >> 16 ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2415
                                      decoder->globals_bias );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2416
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2418
            FT_TRACE4(( " callgsubr(%d)\n", idx ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2419
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2420
            if ( idx >= decoder->num_globals )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2421
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2422
              FT_ERROR(( "cff_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2423
                         " invalid global subr index\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2424
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2425
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2426
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2427
            if ( zone - decoder->zones >= CFF_MAX_SUBRS_CALLS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2428
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2429
              FT_ERROR(( "cff_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2430
                         " too many nested subrs\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2431
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2432
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2434
            zone->cursor = ip;  /* save current instruction pointer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2435
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2436
            zone++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2437
            zone->base   = decoder->globals[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2438
            zone->limit  = decoder->globals[idx + 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2439
            zone->cursor = zone->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2440
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2441
            if ( !zone->base || zone->limit == zone->base )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2442
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2443
              FT_ERROR(( "cff_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2444
                         " invoking empty subrs\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2445
              goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2446
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2447
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2448
            decoder->zone = zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2449
            ip            = zone->base;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2450
            limit         = zone->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2451
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2452
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2453
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2454
        case cff_op_return:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2455
          FT_TRACE4(( " return\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2456
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2457
          if ( decoder->zone <= decoder->zones )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2458
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2459
            FT_ERROR(( "cff_decoder_parse_charstrings:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2460
                       " unexpected return\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2461
            goto Syntax_Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2462
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2464
          decoder->zone--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2465
          zone  = decoder->zone;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2466
          ip    = zone->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2467
          limit = zone->limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2468
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2469
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2470
        default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2471
        Unimplemented:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2472
          FT_ERROR(( "Unimplemented opcode: %d", ip[-1] ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2473
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2474
          if ( ip[-1] == 12 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2475
            FT_ERROR(( " %d", ip[0] ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2476
          FT_ERROR(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2477
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2478
          return CFF_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2479
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2480
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2481
        decoder->top = args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2482
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2483
        if ( decoder->top - stack >= CFF_MAX_OPERANDS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2484
          goto Stack_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2485
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2486
      } /* general operator processing */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2488
    } /* while ip < limit */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2489
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2490
    FT_TRACE4(( "..end..\n\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2491
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2492
  Fail:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2493
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2495
  Syntax_Error:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2496
    FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2497
    return CFF_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2498
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2499
  Stack_Underflow:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2500
    FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2501
    return CFF_Err_Too_Few_Arguments;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2503
  Stack_Overflow:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2504
    FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2505
    return CFF_Err_Stack_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2506
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2507
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2509
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2510
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2511
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2512
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2513
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2514
  /**********            COMPUTE THE MAXIMUM ADVANCE WIDTH         *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2515
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2516
  /**********    The following code is in charge of computing      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2517
  /**********    the maximum advance width of the font.  It        *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2518
  /**********    quickly processes each glyph charstring to        *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2519
  /**********    extract the value from either a `sbw' or `seac'   *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2520
  /**********    operator.                                         *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2521
  /**********                                                      *********/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2522
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2523
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2524
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2525
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2526
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2527
#if 0 /* unused until we support pure CFF fonts */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2529
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2530
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2531
  cff_compute_max_advance( TT_Face  face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2532
                           FT_Int*  max_advance )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2533
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2534
    FT_Error     error = CFF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2535
    CFF_Decoder  decoder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2536
    FT_Int       glyph_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2537
    CFF_Font     cff = (CFF_Font)face->other;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2538
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2539
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2540
    *max_advance = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2541
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2542
    /* Initialize load decoder */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2543
    cff_decoder_init( &decoder, face, 0, 0, 0, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2544
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2545
    decoder.builder.metrics_only = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2546
    decoder.builder.load_points  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2547
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2548
    /* For each glyph, parse the glyph charstring and extract */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2549
    /* the advance width.                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2550
    for ( glyph_index = 0; glyph_index < face->root.num_glyphs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2551
          glyph_index++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2552
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2553
      FT_Byte*  charstring;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2554
      FT_ULong  charstring_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2555
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2556
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2557
      /* now get load the unscaled outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2558
      error = cff_get_glyph_data( face, glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2559
                                  &charstring, &charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2560
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2561
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2562
        error = cff_decoder_prepare( &decoder, size, glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2563
        if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2564
          error = cff_decoder_parse_charstrings( &decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2565
                                                 charstring,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2566
                                                 charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2567
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2568
        cff_free_glyph_data( face, &charstring, &charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2569
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2570
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2571
      /* ignore the error if one has occurred -- skip to next glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2572
      error = CFF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2573
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2575
    *max_advance = decoder.builder.advance.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2576
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2577
    return CFF_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2578
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2581
#endif /* 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2582
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2583
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2584
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2585
  cff_slot_load( CFF_GlyphSlot  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2586
                 CFF_Size       size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2587
                 FT_UInt        glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2588
                 FT_Int32       load_flags )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2589
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2590
    FT_Error     error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2591
    CFF_Decoder  decoder;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2592
    TT_Face      face = (TT_Face)glyph->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2593
    FT_Bool      hinting, force_scaling;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2594
    CFF_Font     cff  = (CFF_Font)face->extra.data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2595
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2596
    FT_Matrix    font_matrix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2597
    FT_Vector    font_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2598
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2599
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2600
    force_scaling = FALSE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2601
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2602
    /* in a CID-keyed font, consider `glyph_index' as a CID and map */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2603
    /* it immediately to the real glyph_index -- if it isn't a      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2604
    /* subsetted font, glyph_indices and CIDs are identical, though */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2605
    if ( cff->top_font.font_dict.cid_registry != 0xFFFFU &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2606
         cff->charset.cids                               )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2607
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2608
      /* don't handle CID 0 (.notdef) which is directly mapped to GID 0 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2609
      if ( glyph_index != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2610
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2611
        glyph_index = cff_charset_cid_to_gindex( &cff->charset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2612
                                                 glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2613
        if ( glyph_index == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2614
          return CFF_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2615
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2616
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2617
    else if ( glyph_index >= cff->num_glyphs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2618
      return CFF_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2619
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2620
    if ( load_flags & FT_LOAD_NO_RECURSE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2621
      load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2622
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2623
    glyph->x_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2624
    glyph->y_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2625
    if ( size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2626
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2627
      glyph->x_scale = size->root.metrics.x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2628
      glyph->y_scale = size->root.metrics.y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2629
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2630
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2631
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2632
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2633
    /* try to load embedded bitmap if any              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2634
    /*                                                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2635
    /* XXX: The convention should be emphasized in     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2636
    /*      the documents because it can be confusing. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2637
    if ( size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2638
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2639
      CFF_Face      cff_face = (CFF_Face)size->root.face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2640
      SFNT_Service  sfnt     = (SFNT_Service)cff_face->sfnt;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2641
      FT_Stream     stream   = cff_face->root.stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2642
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2643
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2644
      if ( size->strike_index != 0xFFFFFFFFUL      &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2645
           sfnt->load_eblc                         &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2646
           ( load_flags & FT_LOAD_NO_BITMAP ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2647
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2648
        TT_SBit_MetricsRec  metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2649
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2650
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2651
        error = sfnt->load_sbit_image( face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2652
                                       size->strike_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2653
                                       glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2654
                                       (FT_Int)load_flags,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2655
                                       stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2656
                                       &glyph->root.bitmap,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2657
                                       &metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2658
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2659
        if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2660
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2661
          glyph->root.outline.n_points   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2662
          glyph->root.outline.n_contours = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2663
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2664
          glyph->root.metrics.width  = (FT_Pos)metrics.width  << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2665
          glyph->root.metrics.height = (FT_Pos)metrics.height << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2666
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2667
          glyph->root.metrics.horiBearingX = (FT_Pos)metrics.horiBearingX << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2668
          glyph->root.metrics.horiBearingY = (FT_Pos)metrics.horiBearingY << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2669
          glyph->root.metrics.horiAdvance  = (FT_Pos)metrics.horiAdvance  << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2670
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2671
          glyph->root.metrics.vertBearingX = (FT_Pos)metrics.vertBearingX << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2672
          glyph->root.metrics.vertBearingY = (FT_Pos)metrics.vertBearingY << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2673
          glyph->root.metrics.vertAdvance  = (FT_Pos)metrics.vertAdvance  << 6;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2674
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2675
          glyph->root.format = FT_GLYPH_FORMAT_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2676
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2677
          if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2678
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2679
            glyph->root.bitmap_left = metrics.vertBearingX;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2680
            glyph->root.bitmap_top  = metrics.vertBearingY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2681
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2682
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2683
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2684
            glyph->root.bitmap_left = metrics.horiBearingX;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2685
            glyph->root.bitmap_top  = metrics.horiBearingY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2686
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2687
          return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2688
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2689
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2690
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2691
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2692
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2693
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2694
    /* return immediately if we only want the embedded bitmaps */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2695
    if ( load_flags & FT_LOAD_SBITS_ONLY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2696
      return CFF_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2697
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2698
    /* if we have a CID subfont, use its matrix (which has already */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2699
    /* been multiplied with the root matrix)                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2700
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2701
    /* this scaling is only relevant if the PS hinter isn't active */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2702
    if ( cff->num_subfonts )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2703
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2704
      FT_ULong  top_upm, sub_upm;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2705
      FT_Byte   fd_index = cff_fd_select_get( &cff->fd_select,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2706
                                              glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2707
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2708
      if ( fd_index >= cff->num_subfonts ) 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2709
        fd_index = cff->num_subfonts - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2710
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2711
      top_upm = cff->top_font.font_dict.units_per_em;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2712
      sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2713
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2714
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2715
      font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2716
      font_offset = cff->subfonts[fd_index]->font_dict.font_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2717
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2718
      if ( top_upm != sub_upm )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2719
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2720
        glyph->x_scale = FT_MulDiv( glyph->x_scale, top_upm, sub_upm );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2721
        glyph->y_scale = FT_MulDiv( glyph->y_scale, top_upm, sub_upm );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2722
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2723
        force_scaling = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2724
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2725
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2726
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2727
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2728
      font_matrix = cff->top_font.font_dict.font_matrix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2729
      font_offset = cff->top_font.font_dict.font_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2730
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2731
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2732
    glyph->root.outline.n_points   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2733
    glyph->root.outline.n_contours = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2734
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2735
    hinting = FT_BOOL( ( load_flags & FT_LOAD_NO_SCALE   ) == 0 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2736
                       ( load_flags & FT_LOAD_NO_HINTING ) == 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2737
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2738
    glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;  /* by default */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2739
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2740
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2741
      FT_Byte*  charstring;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2742
      FT_ULong  charstring_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2743
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2744
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2745
      cff_decoder_init( &decoder, face, size, glyph, hinting,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2746
                        FT_LOAD_TARGET_MODE( load_flags ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2748
      if ( load_flags & FT_LOAD_ADVANCE_ONLY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2749
        decoder.width_only = TRUE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2750
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2751
      decoder.builder.no_recurse =
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2752
        (FT_Bool)( load_flags & FT_LOAD_NO_RECURSE );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2753
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2754
      /* now load the unscaled outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2755
      error = cff_get_glyph_data( face, glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2756
                                  &charstring, &charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2757
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2758
        goto Glyph_Build_Finished;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2759
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2760
      error = cff_decoder_prepare( &decoder, size, glyph_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2761
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2762
        goto Glyph_Build_Finished;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2763
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2764
      error = cff_decoder_parse_charstrings( &decoder,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2765
                                             charstring,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2766
                                             charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2767
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2768
      cff_free_glyph_data( face, &charstring, charstring_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2769
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2770
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2771
        goto Glyph_Build_Finished;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2772
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2773
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2774
      /* Control data and length may not be available for incremental */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2775
      /* fonts.                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2776
      if ( face->root.internal->incremental_interface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2777
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2778
        glyph->root.control_data = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2779
        glyph->root.control_len = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2780
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2781
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2782
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2783
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2784
      /* We set control_data and control_len if charstrings is loaded. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2785
      /* See how charstring loads at cff_index_access_element() in     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2786
      /* cffload.c.                                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2787
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2788
        CFF_Index  csindex = &cff->charstrings_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2789
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2790
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2791
        if ( csindex->offsets )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2792
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2793
          glyph->root.control_data = csindex->bytes +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2794
                                     csindex->offsets[glyph_index] - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2795
          glyph->root.control_len  = charstring_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2796
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2797
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2798
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2799
  Glyph_Build_Finished:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2800
      /* save new glyph tables, if no error */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2801
      if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2802
        cff_builder_done( &decoder.builder );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2803
      /* XXX: anything to do for broken glyph entry? */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2804
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2805
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2806
#ifdef FT_CONFIG_OPTION_INCREMENTAL
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2807
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2808
    /* Incremental fonts can optionally override the metrics. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2809
    if ( !error                                                               &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2810
         face->root.internal->incremental_interface                           &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2811
         face->root.internal->incremental_interface->funcs->get_glyph_metrics )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2812
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2813
      FT_Incremental_MetricsRec  metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2814
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2815
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2816
      metrics.bearing_x = decoder.builder.left_bearing.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2817
      metrics.bearing_y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2818
      metrics.advance   = decoder.builder.advance.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2819
      metrics.advance_v = decoder.builder.advance.y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2820
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2821
      error = face->root.internal->incremental_interface->funcs->get_glyph_metrics(
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2822
                face->root.internal->incremental_interface->object,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2823
                glyph_index, FALSE, &metrics );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2824
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2825
      decoder.builder.left_bearing.x = metrics.bearing_x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2826
      decoder.builder.advance.x      = metrics.advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2827
      decoder.builder.advance.y      = metrics.advance_v;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2828
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2829
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2830
#endif /* FT_CONFIG_OPTION_INCREMENTAL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2831
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2832
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2833
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2834
      /* Now, set the metrics -- this is rather simple, as   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2835
      /* the left side bearing is the xMin, and the top side */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2836
      /* bearing the yMax.                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2837
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2838
      /* For composite glyphs, return only left side bearing and */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2839
      /* advance width.                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2840
      if ( load_flags & FT_LOAD_NO_RECURSE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2841
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2842
        FT_Slot_Internal  internal = glyph->root.internal;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2843
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2844
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2845
        glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2846
        glyph->root.metrics.horiAdvance  = decoder.glyph_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2847
        internal->glyph_matrix           = font_matrix;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2848
        internal->glyph_delta            = font_offset;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2849
        internal->glyph_transformed      = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2850
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2851
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2852
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2853
        FT_BBox            cbox;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2854
        FT_Glyph_Metrics*  metrics = &glyph->root.metrics;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2855
        FT_Vector          advance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2856
        FT_Bool            has_vertical_info;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2857
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2858
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2859
        /* copy the _unscaled_ advance width */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2860
        metrics->horiAdvance                    = decoder.glyph_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2861
        glyph->root.linearHoriAdvance           = decoder.glyph_width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2862
        glyph->root.internal->glyph_transformed = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2863
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2864
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2865
        has_vertical_info = FT_BOOL( face->vertical_info                   &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2866
                                     face->vertical.number_Of_VMetrics > 0 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2867
                                     face->vertical.long_metrics           );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2868
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2869
        has_vertical_info = FT_BOOL( face->vertical_info                   &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2870
                                     face->vertical.number_Of_VMetrics > 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2871
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2872
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2873
        /* get the vertical metrics from the vtmx table if we have one */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2874
        if ( has_vertical_info )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2875
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2876
          FT_Short   vertBearingY = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2877
          FT_UShort  vertAdvance  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2878
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2879
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2880
          ( (SFNT_Service)face->sfnt )->get_metrics( face, 1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2881
                                                     glyph_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2882
                                                     &vertBearingY,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2883
                                                     &vertAdvance );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2884
          metrics->vertBearingY = vertBearingY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2885
          metrics->vertAdvance  = vertAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2886
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2887
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2888
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2889
          /* make up vertical ones */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2890
          if ( face->os2.version != 0xFFFFU )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2891
            metrics->vertAdvance = (FT_Pos)( face->os2.sTypoAscender -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2892
                                             face->os2.sTypoDescender );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2893
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2894
            metrics->vertAdvance = (FT_Pos)( face->horizontal.Ascender -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2895
                                             face->horizontal.Descender );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2896
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2897
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2898
        glyph->root.linearVertAdvance = metrics->vertAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2899
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2900
        glyph->root.format = FT_GLYPH_FORMAT_OUTLINE;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2901
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2902
        glyph->root.outline.flags = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2903
        if ( size && size->root.metrics.y_ppem < 24 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2904
          glyph->root.outline.flags |= FT_OUTLINE_HIGH_PRECISION;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2905
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2906
        glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2907
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2908
        if ( !( font_matrix.xx == 0x10000L &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2909
                font_matrix.yy == 0x10000L &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2910
                font_matrix.xy == 0        &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2911
                font_matrix.yx == 0        ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2912
          FT_Outline_Transform( &glyph->root.outline, &font_matrix );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2913
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2914
        if ( !( font_offset.x == 0 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2915
                font_offset.y == 0 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2916
          FT_Outline_Translate( &glyph->root.outline,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2917
                                font_offset.x, font_offset.y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2918
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2919
        advance.x = metrics->horiAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2920
        advance.y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2921
        FT_Vector_Transform( &advance, &font_matrix );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2922
        metrics->horiAdvance = advance.x + font_offset.x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2923
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2924
        advance.x = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2925
        advance.y = metrics->vertAdvance;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2926
        FT_Vector_Transform( &advance, &font_matrix );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2927
        metrics->vertAdvance = advance.y + font_offset.y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2928
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2929
        if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 || force_scaling )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2930
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2931
          /* scale the outline and the metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2932
          FT_Int       n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2933
          FT_Outline*  cur     = &glyph->root.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2934
          FT_Vector*   vec     = cur->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2935
          FT_Fixed     x_scale = glyph->x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2936
          FT_Fixed     y_scale = glyph->y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2937
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2938
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2939
          /* First of all, scale the points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2940
          if ( !hinting || !decoder.builder.hints_funcs )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2941
            for ( n = cur->n_points; n > 0; n--, vec++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2942
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2943
              vec->x = FT_MulFix( vec->x, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2944
              vec->y = FT_MulFix( vec->y, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2945
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2946
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2947
          /* Then scale the metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2948
          metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, x_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2949
          metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2950
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2951
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2952
        /* compute the other metrics */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2953
        FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2954
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2955
        metrics->width  = cbox.xMax - cbox.xMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2956
        metrics->height = cbox.yMax - cbox.yMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2957
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2958
        metrics->horiBearingX = cbox.xMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2959
        metrics->horiBearingY = cbox.yMax;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2960
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2961
        if ( has_vertical_info )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2962
          metrics->vertBearingX = metrics->horiBearingX -
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2963
                                    metrics->horiAdvance / 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2964
        else 
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2965
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2966
          if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2967
            ft_synthesize_vertical_metrics( metrics,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2968
                                            metrics->vertAdvance );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2969
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2970
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2971
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2972
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2973
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2974
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2975
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2976
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  2977
/* END */