src/java.desktop/share/native/libfreetype/src/cff/cffparse.c
changeset 54876 da3834261f0c
parent 49234 3375a8039fde
equal deleted inserted replaced
54875:bcfedddcf4ce 54876:da3834261f0c
     1 /***************************************************************************/
     1 /****************************************************************************
     2 /*                                                                         */
     2  *
     3 /*  cffparse.c                                                             */
     3  * cffparse.c
     4 /*                                                                         */
     4  *
     5 /*    CFF token stream parser (body)                                       */
     5  *   CFF token stream parser (body)
     6 /*                                                                         */
     6  *
     7 /*  Copyright 1996-2018 by                                                 */
     7  * Copyright (C) 1996-2019 by
     8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
     8  * David Turner, Robert Wilhelm, and Werner Lemberg.
     9 /*                                                                         */
     9  *
    10 /*  This file is part of the FreeType project, and may only be used,       */
    10  * This file is part of the FreeType project, and may only be used,
    11 /*  modified, and distributed under the terms of the FreeType project      */
    11  * modified, and distributed under the terms of the FreeType project
    12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
    12  * license, LICENSE.TXT.  By continuing to use, modify, or distribute
    13 /*  this file you indicate that you have read the license and              */
    13  * this file you indicate that you have read the license and
    14 /*  understand and accept it fully.                                        */
    14  * understand and accept it fully.
    15 /*                                                                         */
    15  *
    16 /***************************************************************************/
    16  */
    17 
    17 
    18 
    18 
    19 #include <ft2build.h>
    19 #include <ft2build.h>
    20 #include "cffparse.h"
    20 #include "cffparse.h"
    21 #include FT_INTERNAL_STREAM_H
    21 #include FT_INTERNAL_STREAM_H
    22 #include FT_INTERNAL_DEBUG_H
    22 #include FT_INTERNAL_DEBUG_H
    23 #include FT_INTERNAL_CALC_H
    23 #include FT_INTERNAL_CALC_H
    24 #include FT_INTERNAL_POSTSCRIPT_AUX_H
    24 #include FT_INTERNAL_POSTSCRIPT_AUX_H
       
    25 #include FT_LIST_H
    25 
    26 
    26 #include "cfferrs.h"
    27 #include "cfferrs.h"
    27 #include "cffpic.h"
       
    28 #include "cffload.h"
    28 #include "cffload.h"
    29 
    29 
    30 
    30 
    31   /*************************************************************************/
    31   /**************************************************************************
    32   /*                                                                       */
    32    *
    33   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
    33    * The macro FT_COMPONENT is used in trace mode.  It is an implicit
    34   /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
    34    * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
    35   /* messages during execution.                                            */
    35    * messages during execution.
    36   /*                                                                       */
    36    */
    37 #undef  FT_COMPONENT
    37 #undef  FT_COMPONENT
    38 #define FT_COMPONENT  trace_cffparse
    38 #define FT_COMPONENT  cffparse
    39 
    39 
    40 
    40 
    41   FT_LOCAL_DEF( FT_Error )
    41   FT_LOCAL_DEF( FT_Error )
    42   cff_parser_init( CFF_Parser  parser,
    42   cff_parser_init( CFF_Parser  parser,
    43                    FT_UInt     code,
    43                    FT_UInt     code,
   603     CFF_FontRecDict  dict   = (CFF_FontRecDict)parser->object;
   603     CFF_FontRecDict  dict   = (CFF_FontRecDict)parser->object;
   604     FT_Matrix*       matrix = &dict->font_matrix;
   604     FT_Matrix*       matrix = &dict->font_matrix;
   605     FT_Vector*       offset = &dict->font_offset;
   605     FT_Vector*       offset = &dict->font_offset;
   606     FT_ULong*        upm    = &dict->units_per_em;
   606     FT_ULong*        upm    = &dict->units_per_em;
   607     FT_Byte**        data   = parser->stack;
   607     FT_Byte**        data   = parser->stack;
   608     FT_Error         error  = FT_ERR( Stack_Underflow );
       
   609 
   608 
   610 
   609 
   611     if ( parser->top >= parser->stack + 6 )
   610     if ( parser->top >= parser->stack + 6 )
   612     {
   611     {
   613       FT_Fixed  values[6];
   612       FT_Fixed  values[6];
   614       FT_Long   scalings[6];
   613       FT_Long   scalings[6];
   615 
   614 
   616       FT_Long  min_scaling, max_scaling;
   615       FT_Long  min_scaling, max_scaling;
   617       int      i;
   616       int      i;
   618 
   617 
   619 
       
   620       error = FT_Err_Ok;
       
   621 
   618 
   622       dict->has_font_matrix = TRUE;
   619       dict->has_font_matrix = TRUE;
   623 
   620 
   624       /* We expect a well-formed font matrix, this is, the matrix elements */
   621       /* We expect a well-formed font matrix, this is, the matrix elements */
   625       /* `xx' and `yy' are of approximately the same magnitude.  To avoid  */
   622       /* `xx' and `yy' are of approximately the same magnitude.  To avoid  */
   645       if ( max_scaling < -9                  ||
   642       if ( max_scaling < -9                  ||
   646            max_scaling > 0                   ||
   643            max_scaling > 0                   ||
   647            ( max_scaling - min_scaling ) < 0 ||
   644            ( max_scaling - min_scaling ) < 0 ||
   648            ( max_scaling - min_scaling ) > 9 )
   645            ( max_scaling - min_scaling ) > 9 )
   649       {
   646       {
   650         /* Return default matrix in case of unlikely values. */
       
   651 
       
   652         FT_TRACE1(( "cff_parse_font_matrix:"
   647         FT_TRACE1(( "cff_parse_font_matrix:"
   653                     " strange scaling values (minimum %d, maximum %d),\n"
   648                     " strange scaling values (minimum %d, maximum %d),\n"
   654                     "                      "
   649                     "                      "
   655                     " using default matrix\n", min_scaling, max_scaling ));
   650                     " using default matrix\n", min_scaling, max_scaling ));
   656 
   651         goto Unlikely;
   657         matrix->xx = 0x10000L;
       
   658         matrix->yx = 0;
       
   659         matrix->xy = 0;
       
   660         matrix->yy = 0x10000L;
       
   661         offset->x  = 0;
       
   662         offset->y  = 0;
       
   663         *upm       = 1;
       
   664 
       
   665         goto Exit;
       
   666       }
   652       }
   667 
   653 
   668       for ( i = 0; i < 6; i++ )
   654       for ( i = 0; i < 6; i++ )
   669       {
   655       {
   670         FT_Fixed  value = values[i];
   656         FT_Fixed  value = values[i];
   707                   (double)matrix->xy / *upm / 65536,
   693                   (double)matrix->xy / *upm / 65536,
   708                   (double)matrix->yx / *upm / 65536,
   694                   (double)matrix->yx / *upm / 65536,
   709                   (double)matrix->yy / *upm / 65536,
   695                   (double)matrix->yy / *upm / 65536,
   710                   (double)offset->x  / *upm / 65536,
   696                   (double)offset->x  / *upm / 65536,
   711                   (double)offset->y  / *upm / 65536 ));
   697                   (double)offset->y  / *upm / 65536 ));
   712     }
   698 
   713 
   699       if ( !FT_Matrix_Check( matrix ) )
   714   Exit:
   700       {
   715     return error;
   701         FT_TRACE1(( "cff_parse_font_matrix:"
       
   702                     " degenerate values, using default matrix\n" ));
       
   703         goto Unlikely;
       
   704       }
       
   705 
       
   706       return FT_Err_Ok;
       
   707     }
       
   708     else
       
   709       return FT_THROW( Stack_Underflow );
       
   710 
       
   711   Unlikely:
       
   712     /* Return default matrix in case of unlikely values. */
       
   713 
       
   714     matrix->xx = 0x10000L;
       
   715     matrix->yx = 0;
       
   716     matrix->xy = 0;
       
   717     matrix->yy = 0x10000L;
       
   718     offset->x  = 0;
       
   719     offset->y  = 0;
       
   720     *upm       = 1;
       
   721 
       
   722     return FT_Err_Ok;
   716   }
   723   }
   717 
   724 
   718 
   725 
   719   static FT_Error
   726   static FT_Error
   720   cff_parse_font_bbox( CFF_Parser  parser )
   727   cff_parse_font_bbox( CFF_Parser  parser )
   800     FT_Error         error;
   807     FT_Error         error;
   801 
   808 
   802 
   809 
   803 #ifdef FT_DEBUG_LEVEL_TRACE
   810 #ifdef FT_DEBUG_LEVEL_TRACE
   804     /* beautify tracing message */
   811     /* beautify tracing message */
   805     if ( ft_trace_levels[FT_COMPONENT] < 4 )
   812     if ( ft_trace_levels[FT_TRACE_COMP( FT_COMPONENT )] < 4 )
   806       FT_TRACE1(( "Multiple Master CFFs not supported yet,"
   813       FT_TRACE1(( "Multiple Master CFFs not supported yet,"
   807                   " handling first master design only\n" ));
   814                   " handling first master design only\n" ));
   808     else
   815     else
   809       FT_TRACE1(( " (not supported yet,"
   816       FT_TRACE1(( " (not supported yet,"
   810                   " handling first master design only)\n" ));
   817                   " handling first master design only)\n" ));
   999           CFF_FIELD( code, name, id, cff_kind_fixed_thousand )
  1006           CFF_FIELD( code, name, id, cff_kind_fixed_thousand )
  1000 #define CFF_FIELD_STRING( code, name, id )             \
  1007 #define CFF_FIELD_STRING( code, name, id )             \
  1001           CFF_FIELD( code, name, id, cff_kind_string )
  1008           CFF_FIELD( code, name, id, cff_kind_string )
  1002 #define CFF_FIELD_BOOL( code, name, id )             \
  1009 #define CFF_FIELD_BOOL( code, name, id )             \
  1003           CFF_FIELD( code, name, id, cff_kind_bool )
  1010           CFF_FIELD( code, name, id, cff_kind_bool )
  1004 
       
  1005 
       
  1006 #ifndef FT_CONFIG_OPTION_PIC
       
  1007 
  1011 
  1008 
  1012 
  1009 #undef  CFF_FIELD
  1013 #undef  CFF_FIELD
  1010 #undef  CFF_FIELD_DELTA
  1014 #undef  CFF_FIELD_DELTA
  1011 
  1015 
  1116 
  1120 
  1117 
  1121 
  1118 #endif /* FT_DEBUG_LEVEL_TRACE */
  1122 #endif /* FT_DEBUG_LEVEL_TRACE */
  1119 
  1123 
  1120 
  1124 
  1121 #else /* FT_CONFIG_OPTION_PIC */
  1125 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
  1122 
  1126   static void
  1123 
  1127   destruct_t2s_item( FT_Memory  memory,
  1124   void
  1128                      void*      data,
  1125   FT_Destroy_Class_cff_field_handlers( FT_Library          library,
  1129                      void*      user )
  1126                                        CFF_Field_Handler*  clazz )
  1130   {
  1127   {
  1131     FT_UNUSED( user );
  1128     FT_Memory  memory = library->memory;
  1132     memory->free( memory, data );
  1129 
  1133   }
  1130 
  1134 #endif /* CFF_CONFIG_OPTION_OLD_ENGINE */
  1131     if ( clazz )
       
  1132       FT_FREE( clazz );
       
  1133   }
       
  1134 
       
  1135 
       
  1136   FT_Error
       
  1137   FT_Create_Class_cff_field_handlers( FT_Library           library,
       
  1138                                       CFF_Field_Handler**  output_class )
       
  1139   {
       
  1140     CFF_Field_Handler*  clazz  = NULL;
       
  1141     FT_Error            error;
       
  1142     FT_Memory           memory = library->memory;
       
  1143 
       
  1144     int  i = 0;
       
  1145 
       
  1146 
       
  1147 #undef CFF_FIELD
       
  1148 #define CFF_FIELD( code, name, id, kind ) i++;
       
  1149 #undef CFF_FIELD_DELTA
       
  1150 #define CFF_FIELD_DELTA( code, name, max, id ) i++;
       
  1151 #undef CFF_FIELD_CALLBACK
       
  1152 #define CFF_FIELD_CALLBACK( code, name, id ) i++;
       
  1153 #undef CFF_FIELD_BLEND
       
  1154 #define CFF_FIELD_BLEND( code, id ) i++;
       
  1155 
       
  1156 #include "cfftoken.h"
       
  1157 
       
  1158     i++; /* { 0, 0, 0, 0, 0, 0, 0 } */
       
  1159 
       
  1160     if ( FT_ALLOC( clazz, sizeof ( CFF_Field_Handler ) * i ) )
       
  1161       return error;
       
  1162 
       
  1163     i = 0;
       
  1164 
       
  1165 
       
  1166 #ifndef FT_DEBUG_LEVEL_TRACE
       
  1167 
       
  1168 
       
  1169 #undef CFF_FIELD_CALLBACK
       
  1170 #define CFF_FIELD_CALLBACK( code_, name_, id_ )        \
       
  1171           clazz[i].kind         = cff_kind_callback;   \
       
  1172           clazz[i].code         = code_ | CFFCODE;     \
       
  1173           clazz[i].offset       = 0;                   \
       
  1174           clazz[i].size         = 0;                   \
       
  1175           clazz[i].reader       = cff_parse_ ## name_; \
       
  1176           clazz[i].array_max    = 0;                   \
       
  1177           clazz[i].count_offset = 0;                   \
       
  1178           i++;
       
  1179 
       
  1180 #undef  CFF_FIELD
       
  1181 #define CFF_FIELD( code_, name_, id_, kind_ )               \
       
  1182           clazz[i].kind         = kind_;                    \
       
  1183           clazz[i].code         = code_ | CFFCODE;          \
       
  1184           clazz[i].offset       = FT_FIELD_OFFSET( name_ ); \
       
  1185           clazz[i].size         = FT_FIELD_SIZE( name_ );   \
       
  1186           clazz[i].reader       = 0;                        \
       
  1187           clazz[i].array_max    = 0;                        \
       
  1188           clazz[i].count_offset = 0;                        \
       
  1189           i++;                                              \
       
  1190 
       
  1191 #undef  CFF_FIELD_DELTA
       
  1192 #define CFF_FIELD_DELTA( code_, name_, max_, id_ )                  \
       
  1193           clazz[i].kind         = cff_kind_delta;                   \
       
  1194           clazz[i].code         = code_ | CFFCODE;                  \
       
  1195           clazz[i].offset       = FT_FIELD_OFFSET( name_ );         \
       
  1196           clazz[i].size         = FT_FIELD_SIZE_DELTA( name_ );     \
       
  1197           clazz[i].reader       = 0;                                \
       
  1198           clazz[i].array_max    = max_;                             \
       
  1199           clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
       
  1200           i++;
       
  1201 
       
  1202 #undef  CFF_FIELD_BLEND
       
  1203 #define CFF_FIELD_BLEND( code_, id_ )              \
       
  1204           clazz[i].kind         = cff_kind_blend;  \
       
  1205           clazz[i].code         = code_ | CFFCODE; \
       
  1206           clazz[i].offset       = 0;               \
       
  1207           clazz[i].size         = 0;               \
       
  1208           clazz[i].reader       = cff_parse_blend; \
       
  1209           clazz[i].array_max    = 0;               \
       
  1210           clazz[i].count_offset = 0;               \
       
  1211           i++;
       
  1212 
       
  1213 #include "cfftoken.h"
       
  1214 
       
  1215     clazz[i].kind         = 0;
       
  1216     clazz[i].code         = 0;
       
  1217     clazz[i].offset       = 0;
       
  1218     clazz[i].size         = 0;
       
  1219     clazz[i].reader       = 0;
       
  1220     clazz[i].array_max    = 0;
       
  1221     clazz[i].count_offset = 0;
       
  1222 
       
  1223 
       
  1224 #else /* FT_DEBUG_LEVEL_TRACE */
       
  1225 
       
  1226 
       
  1227 #undef CFF_FIELD_CALLBACK
       
  1228 #define CFF_FIELD_CALLBACK( code_, name_, id_ )        \
       
  1229           clazz[i].kind         = cff_kind_callback;   \
       
  1230           clazz[i].code         = code_ | CFFCODE;     \
       
  1231           clazz[i].offset       = 0;                   \
       
  1232           clazz[i].size         = 0;                   \
       
  1233           clazz[i].reader       = cff_parse_ ## name_; \
       
  1234           clazz[i].array_max    = 0;                   \
       
  1235           clazz[i].count_offset = 0;                   \
       
  1236           clazz[i].id           = id_;                 \
       
  1237           i++;
       
  1238 
       
  1239 #undef  CFF_FIELD
       
  1240 #define CFF_FIELD( code_, name_, id_, kind_ )               \
       
  1241           clazz[i].kind         = kind_;                    \
       
  1242           clazz[i].code         = code_ | CFFCODE;          \
       
  1243           clazz[i].offset       = FT_FIELD_OFFSET( name_ ); \
       
  1244           clazz[i].size         = FT_FIELD_SIZE( name_ );   \
       
  1245           clazz[i].reader       = 0;                        \
       
  1246           clazz[i].array_max    = 0;                        \
       
  1247           clazz[i].count_offset = 0;                        \
       
  1248           clazz[i].id           = id_;                      \
       
  1249           i++;                                              \
       
  1250 
       
  1251 #undef  CFF_FIELD_DELTA
       
  1252 #define CFF_FIELD_DELTA( code_, name_, max_, id_ )                  \
       
  1253           clazz[i].kind         = cff_kind_delta;                   \
       
  1254           clazz[i].code         = code_ | CFFCODE;                  \
       
  1255           clazz[i].offset       = FT_FIELD_OFFSET( name_ );         \
       
  1256           clazz[i].size         = FT_FIELD_SIZE_DELTA( name_ );     \
       
  1257           clazz[i].reader       = 0;                                \
       
  1258           clazz[i].array_max    = max_;                             \
       
  1259           clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
       
  1260           clazz[i].id           = id_;                              \
       
  1261           i++;
       
  1262 
       
  1263 #undef  CFF_FIELD_BLEND
       
  1264 #define CFF_FIELD_BLEND( code_, id_ )              \
       
  1265           clazz[i].kind         = cff_kind_blend;  \
       
  1266           clazz[i].code         = code_ | CFFCODE; \
       
  1267           clazz[i].offset       = 0;               \
       
  1268           clazz[i].size         = 0;               \
       
  1269           clazz[i].reader       = cff_parse_blend; \
       
  1270           clazz[i].array_max    = 0;               \
       
  1271           clazz[i].count_offset = 0;               \
       
  1272           clazz[i].id           = id_;             \
       
  1273           i++;
       
  1274 
       
  1275 #include "cfftoken.h"
       
  1276 
       
  1277     clazz[i].kind         = 0;
       
  1278     clazz[i].code         = 0;
       
  1279     clazz[i].offset       = 0;
       
  1280     clazz[i].size         = 0;
       
  1281     clazz[i].reader       = 0;
       
  1282     clazz[i].array_max    = 0;
       
  1283     clazz[i].count_offset = 0;
       
  1284     clazz[i].id           = 0;
       
  1285 
       
  1286 
       
  1287 #endif /* FT_DEBUG_LEVEL_TRACE */
       
  1288 
       
  1289 
       
  1290     *output_class = clazz;
       
  1291 
       
  1292     return FT_Err_Ok;
       
  1293   }
       
  1294 
       
  1295 
       
  1296 #endif /* FT_CONFIG_OPTION_PIC */
       
  1297 
  1135 
  1298 
  1136 
  1299   FT_LOCAL_DEF( FT_Error )
  1137   FT_LOCAL_DEF( FT_Error )
  1300   cff_parser_run( CFF_Parser  parser,
  1138   cff_parser_run( CFF_Parser  parser,
  1301                   FT_Byte*    start,
  1139                   FT_Byte*    start,
  1302                   FT_Byte*    limit )
  1140                   FT_Byte*    limit )
  1303   {
  1141   {
       
  1142     FT_Byte*  p     = start;
       
  1143     FT_Error  error = FT_Err_Ok;
       
  1144 
  1304 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
  1145 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
  1305     PSAux_Service  psaux;
  1146     PSAux_Service  psaux;
       
  1147 
       
  1148     FT_Library  library = parser->library;
       
  1149     FT_Memory   memory  = library->memory;
       
  1150 
       
  1151     FT_ListRec  t2s;
       
  1152 
       
  1153 
       
  1154     FT_ZERO( &t2s );
  1306 #endif
  1155 #endif
  1307 
       
  1308     FT_Byte*    p       = start;
       
  1309     FT_Error    error   = FT_Err_Ok;
       
  1310     FT_Library  library = parser->library;
       
  1311 
       
  1312     FT_UNUSED( library );
       
  1313 
       
  1314 
  1156 
  1315     parser->top    = parser->stack;
  1157     parser->top    = parser->stack;
  1316     parser->start  = start;
  1158     parser->start  = start;
  1317     parser->limit  = limit;
  1159     parser->limit  = limit;
  1318     parser->cursor = start;
  1160     parser->cursor = start;
  1319 
  1161 
  1320     while ( p < limit )
  1162     while ( p < limit )
  1321     {
  1163     {
  1322       FT_UInt  v = *p;
  1164       FT_UInt  v = *p;
       
  1165 
  1323 
  1166 
  1324       /* Opcode 31 is legacy MM T2 operator, not a number.      */
  1167       /* Opcode 31 is legacy MM T2 operator, not a number.      */
  1325       /* Opcode 255 is reserved and should not appear in fonts; */
  1168       /* Opcode 255 is reserved and should not appear in fonts; */
  1326       /* it is used internally for CFF2 blends.                 */
  1169       /* it is used internally for CFF2 blends.                 */
  1327       if ( v >= 27 && v != 31 && v != 255 )
  1170       if ( v >= 27 && v != 31 && v != 255 )
  1367         CFF_Decoder  decoder;
  1210         CFF_Decoder  decoder;
  1368         CFF_FontRec  cff_rec;
  1211         CFF_FontRec  cff_rec;
  1369         FT_Byte*     charstring_base;
  1212         FT_Byte*     charstring_base;
  1370         FT_ULong     charstring_len;
  1213         FT_ULong     charstring_len;
  1371 
  1214 
  1372         FT_Fixed*  stack;
  1215         FT_Fixed*    stack;
  1373         FT_Byte*   q;
  1216         FT_ListNode  node;
       
  1217         FT_Byte*     q;
  1374 
  1218 
  1375 
  1219 
  1376         charstring_base = ++p;
  1220         charstring_base = ++p;
  1377 
  1221 
  1378         /* search `endchar' operator */
  1222         /* search `endchar' operator */
  1403           goto Exit;
  1247           goto Exit;
  1404         }
  1248         }
  1405 
  1249 
  1406         error = psaux->cff_decoder_funcs->parse_charstrings_old(
  1250         error = psaux->cff_decoder_funcs->parse_charstrings_old(
  1407                   &decoder, charstring_base, charstring_len, 1 );
  1251                   &decoder, charstring_base, charstring_len, 1 );
       
  1252         if ( error )
       
  1253           goto Exit;
  1408 
  1254 
  1409         /* Now copy the stack data in the temporary decoder object,    */
  1255         /* Now copy the stack data in the temporary decoder object,    */
  1410         /* converting it back to charstring number representations     */
  1256         /* converting it back to charstring number representations     */
  1411         /* (this is ugly, I know).                                     */
  1257         /* (this is ugly, I know).                                     */
  1412         /*                                                             */
  1258 
  1413         /* We overwrite the original top DICT charstring under the     */
  1259         node = (FT_ListNode)memory->alloc( memory,
  1414         /* assumption that the charstring representation of the result */
  1260                                            sizeof ( FT_ListNodeRec ) );
  1415         /* of `cff_decoder_parse_charstrings' is shorter, which should */
  1261         if ( !node )
  1416         /* be always true.                                             */
  1262           goto Out_Of_Memory_Error;
  1417 
  1263 
  1418         q     = charstring_base - 1;
  1264         /* `5' is the conservative upper bound of required bytes per stack */
       
  1265         /* element.                                                        */
       
  1266         q = (FT_Byte*)memory->alloc( memory,
       
  1267                                      5 * ( decoder.top - decoder.stack ) );
       
  1268         if ( !q )
       
  1269           goto Out_Of_Memory_Error;
       
  1270 
       
  1271         node->data = q;
       
  1272 
       
  1273         FT_List_Add( &t2s, node );
       
  1274 
  1419         stack = decoder.stack;
  1275         stack = decoder.stack;
  1420 
  1276 
  1421         while ( stack < decoder.top )
  1277         while ( stack < decoder.top )
  1422         {
  1278         {
  1423           FT_ULong  num;
  1279           FT_ULong  num;
  1429 
  1285 
  1430           *parser->top++ = q;
  1286           *parser->top++ = q;
  1431 
  1287 
  1432           if ( *stack < 0 )
  1288           if ( *stack < 0 )
  1433           {
  1289           {
  1434             num = (FT_ULong)-*stack;
  1290             num = (FT_ULong)NEG_LONG( *stack );
  1435             neg = 1;
  1291             neg = 1;
  1436           }
  1292           }
  1437           else
  1293           else
  1438           {
  1294           {
  1439             num = (FT_ULong)*stack;
  1295             num = (FT_ULong)*stack;
  1521 
  1377 
  1522           code = 0x100 | p[0];
  1378           code = 0x100 | p[0];
  1523         }
  1379         }
  1524         code = code | parser->object_code;
  1380         code = code | parser->object_code;
  1525 
  1381 
  1526         for ( field = CFF_FIELD_HANDLERS_GET; field->kind; field++ )
  1382         for ( field = cff_field_handlers; field->kind; field++ )
  1527         {
  1383         {
  1528           if ( field->code == (FT_Int)code )
  1384           if ( field->code == (FT_Int)code )
  1529           {
  1385           {
  1530             /* we found our field's handler; read it */
  1386             /* we found our field's handler; read it */
  1531             FT_Long   val;
  1387             FT_Long   val;
  1670         /*       but we don't have access to subFont */
  1526         /*       but we don't have access to subFont */
  1671         if ( field->kind != cff_kind_blend )
  1527         if ( field->kind != cff_kind_blend )
  1672           parser->top = parser->stack;
  1528           parser->top = parser->stack;
  1673       }
  1529       }
  1674       p++;
  1530       p++;
  1675     }
  1531     } /* while ( p < limit ) */
  1676 
  1532 
  1677   Exit:
  1533   Exit:
       
  1534 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
       
  1535     FT_List_Finalize( &t2s, destruct_t2s_item, memory, NULL );
       
  1536 #endif
  1678     return error;
  1537     return error;
       
  1538 
       
  1539 #ifdef CFF_CONFIG_OPTION_OLD_ENGINE
       
  1540   Out_Of_Memory_Error:
       
  1541     error = FT_THROW( Out_Of_Memory );
       
  1542     goto Exit;
       
  1543 #endif
  1679 
  1544 
  1680   Stack_Overflow:
  1545   Stack_Overflow:
  1681     error = FT_THROW( Invalid_Argument );
  1546     error = FT_THROW( Invalid_Argument );
  1682     goto Exit;
  1547     goto Exit;
  1683 
  1548