21#include FT_INTERNAL_STREAM_H
22#include FT_INTERNAL_DEBUG_H
23#include FT_INTERNAL_CALC_H
24#include FT_INTERNAL_POSTSCRIPT_AUX_H
38#define FT_COMPONENT trace_cffparse
62 parser->num_designs = num_designs;
63 parser->num_axes = num_axes;
72 parser->stackSize = stackSize;
126 val = (
v - 247 ) * 256 +
p[0] + 108;
133 val = -(
v - 251 ) * 256 -
p[0] - 108;
189 FT_Int sign = 0, exponent_sign = 0, have_overflow = 0;
190 FT_Long exponent_add, integer_length, fraction_length;
222 nib = (
FT_Int)(
p[0] >> phase ) & 0xF;
232 if (
number >= 0xCCCCCCCL )
259 nib = (
p[0] >> phase ) & 0xF;
268 else if (
number < 0xCCCCCCCL && fraction_length < 9 )
298 nib = (
p[0] >> phase ) & 0xF;
304 if ( exponent > 1000 )
307 exponent = exponent * 10 + nib;
311 exponent = -exponent;
326 exponent += power_ten + exponent_add;
331 fraction_length += integer_length;
332 exponent += integer_length;
334 if ( fraction_length <= 5 )
339 *scaling = exponent - fraction_length + 1;
349 new_fraction_length =
FT_MIN( exponent, 5 );
350 shift = new_fraction_length - fraction_length;
354 exponent -= new_fraction_length;
363 exponent -= fraction_length;
366 exponent -= fraction_length;
377 *scaling = exponent - 4;
382 *scaling = exponent - 5;
388 integer_length += exponent;
389 fraction_length -= exponent;
391 if ( integer_length > 5 )
393 if ( integer_length < -5 )
397 if ( integer_length < 0 )
400 fraction_length += integer_length;
404 if ( fraction_length == 10 )
407 fraction_length -= 1;
411 if ( fraction_length > 0 )
463 else if ( **
d == 255 )
473 ( ( ( (FT_UInt32)*(
d[0] + 1 ) << 24 ) |
474 ( (FT_UInt32)*(
d[0] + 2 ) << 16 ) |
475 ( (FT_UInt32)*(
d[0] + 3 ) << 8 ) |
476 (FT_UInt32)*(
d[0] + 4 ) ) + 0x8000U ) >> 16 );
479 ( ( ( (FT_UInt32)*(
d[0] + 1 ) << 16 ) |
480 ( (FT_UInt32)*(
d[0] + 2 ) << 8 ) |
481 (FT_UInt32)*(
d[0] + 3 ) ) + 0x80U ) >> 8 );
507 val =
val > 0 ? 0x7FFFFFFFL : -0x7FFFFFFFL;
519 else if (
val < -0x7FFF )
576 for ( integer_length = 5; integer_length < 10; integer_length++ )
582 *scaling = integer_length - 4;
587 *scaling = integer_length - 5;
616 FT_Long min_scaling, max_scaling;
633 for (
i = 0;
i < 6;
i++ )
638 if ( scalings[
i] > max_scaling )
639 max_scaling = scalings[
i];
640 if ( scalings[
i] < min_scaling )
641 min_scaling = scalings[
i];
645 if ( max_scaling < -9 ||
647 ( max_scaling - min_scaling ) < 0 ||
648 ( max_scaling - min_scaling ) > 9 )
653 " strange scaling values (minimum %d, maximum %d),\n"
655 " using default matrix\n", min_scaling, max_scaling ));
668 for (
i = 0;
i < 6;
i++ )
706 (
double)
matrix->xx / *upm / 65536,
707 (
double)
matrix->xy / *upm / 65536,
708 (
double)
matrix->yx / *upm / 65536,
709 (
double)
matrix->yy / *upm / 65536,
710 (
double)
offset->x / *upm / 65536,
711 (
double)
offset->y / *upm / 65536 ));
767 FT_ERROR((
"cff_parse_private_dict: Invalid dictionary size\n" ));
776 FT_ERROR((
"cff_parse_private_dict: Invalid dictionary offset\n" ));
806 FT_TRACE1((
"Multiple Master CFFs not supported yet,"
807 " handling first master design only\n" ));
810 " handling first master design only)\n" ));
821 if ( num_designs > 16 || num_designs < 2 )
823 FT_ERROR((
"cff_parse_multiple_master:"
824 " Invalid number of designs\n" ));
858 FT_TRACE1((
"cff_parse_cid_ros: real supplement is rounded\n" ));
861 FT_TRACE1((
"cff_parse_cid_ros: negative supplement %d is found\n",
895 FT_ERROR((
" cff_parse_vsindex: vsindex not allowed after blend\n" ));
929 blend = &subFont->
blend;
945 if ( numBlends >
parser->stackSize )
947 FT_ERROR((
"cff_parse_blend: Invalid number of blends\n" ));
954 numBlends == 1 ?
"" :
"s" ));
958 blend->usedBV =
TRUE;
994#define CFF_FIELD_NUM( code, name, id ) \
995 CFF_FIELD( code, name, id, cff_kind_num )
996#define CFF_FIELD_FIXED( code, name, id ) \
997 CFF_FIELD( code, name, id, cff_kind_fixed )
998#define CFF_FIELD_FIXED_1000( code, name, id ) \
999 CFF_FIELD( code, name, id, cff_kind_fixed_thousand )
1000#define CFF_FIELD_STRING( code, name, id ) \
1001 CFF_FIELD( code, name, id, cff_kind_string )
1002#define CFF_FIELD_BOOL( code, name, id ) \
1003 CFF_FIELD( code, name, id, cff_kind_bool )
1006#ifndef FT_CONFIG_OPTION_PIC
1010#undef CFF_FIELD_DELTA
1013#ifndef FT_DEBUG_LEVEL_TRACE
1016#define CFF_FIELD_CALLBACK( code, name, id ) \
1018 cff_kind_callback, \
1021 cff_parse_ ## name, \
1025#define CFF_FIELD_BLEND( code, id ) \
1034#define CFF_FIELD( code, name, id, kind ) \
1038 FT_FIELD_OFFSET( name ), \
1039 FT_FIELD_SIZE( name ), \
1043#define CFF_FIELD_DELTA( code, name, max, id ) \
1047 FT_FIELD_OFFSET( name ), \
1048 FT_FIELD_SIZE_DELTA( name ), \
1051 FT_FIELD_OFFSET( num_ ## name ) \
1059 { 0, 0, 0, 0, 0, 0, 0 }
1067#define CFF_FIELD_CALLBACK( code, name, id ) \
1069 cff_kind_callback, \
1072 cff_parse_ ## name, \
1077#define CFF_FIELD_BLEND( code, id ) \
1087#define CFF_FIELD( code, name, id, kind ) \
1091 FT_FIELD_OFFSET( name ), \
1092 FT_FIELD_SIZE( name ), \
1097#define CFF_FIELD_DELTA( code, name, max, id ) \
1101 FT_FIELD_OFFSET( name ), \
1102 FT_FIELD_SIZE_DELTA( name ), \
1105 FT_FIELD_OFFSET( num_ ## name ), \
1114 { 0, 0, 0, 0, 0, 0, 0, 0 }
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++;
1166#ifndef FT_DEBUG_LEVEL_TRACE
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; \
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; \
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_ ); \
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; \
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_; \
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_; \
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_; \
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_; \
1290 *output_class = clazz;
1304#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
1327 if (
v >= 27 &&
v != 31 &&
v != 255 )
1331 goto Stack_Overflow;
1362#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
1376 charstring_base = ++
p;
1388 charstring_len = (
FT_ULong)(
p - charstring_base ) + 1;
1396 decoder.
cff = &cff_rec;
1401 FT_ERROR((
"cff_parser_run: cannot access `psaux' module\n" ));
1407 &decoder, charstring_base, charstring_len, 1 );
1418 q = charstring_base - 1;
1428 goto Stack_Overflow;
1443 if (
num & 0xFFFFU )
1449 *
q++ = (
num & 0xFF000000U ) >> 24;
1450 *
q++ = (
num & 0x00FF0000U ) >> 16;
1451 *
q++ = (
num & 0x0000FF00U ) >> 8;
1452 *
q++ =
num & 0x000000FFU;
1462 else if (
num <= 1131 )
1480 else if (
num <= 1131 )
1509 goto Stack_Overflow;
1522 code = 0x100 |
p[0];
1542 goto Stack_Underflow;
1544 switch (
field->kind )
1560 switch (
field->size )
1578#ifdef FT_DEBUG_LEVEL_TRACE
1579 switch (
field->kind )
1610 field->count_offset;
1615 if ( num_args >
field->array_max )
1616 num_args =
field->array_max;
1624 while ( num_args > 0 )
1627 switch (
field->size )
cff_blend_build_vector(CFF_Blend blend, FT_UInt vsindex, FT_UInt lenNDV, FT_Fixed *NDV)
cff_blend_doBlend(CFF_SubFont subFont, CFF_Parser parser, FT_UInt numBlends)
cff_blend_check_vector(CFF_Blend blend, FT_UInt vsindex, FT_UInt lenNDV, FT_Fixed *NDV)
cff_parser_init(CFF_Parser parser, FT_UInt code, void *object, FT_Library library, FT_UInt stackSize, FT_UShort num_designs, FT_UShort num_axes)
static FT_Fixed cff_parse_fixed(CFF_Parser parser, FT_Byte **d)
cff_parse_num(CFF_Parser parser, FT_Byte **d)
static FT_Long cff_parse_integer(FT_Byte *start, FT_Byte *limit)
static FT_Error cff_parse_maxstack(CFF_Parser parser)
static FT_Error cff_parse_font_bbox(CFF_Parser parser)
static FT_Error cff_parse_vsindex(CFF_Parser parser)
static FT_Fixed cff_parse_fixed_dynamic(CFF_Parser parser, FT_Byte **d, FT_Long *scaling)
static FT_Fixed cff_parse_fixed_scaled(CFF_Parser parser, FT_Byte **d, FT_Long scaling)
static FT_Fixed do_fixed(CFF_Parser parser, FT_Byte **d, FT_Long scaling)
static const FT_Long power_tens[]
cff_parser_done(CFF_Parser parser)
static FT_Error cff_parse_font_matrix(CFF_Parser parser)
static FT_Fixed cff_parse_real(FT_Byte *start, FT_Byte *limit, FT_Long power_ten, FT_Long *scaling)
static FT_Error cff_parse_private_dict(CFF_Parser parser)
static const CFF_Field_Handler cff_field_handlers[]
static FT_Error cff_parse_multiple_master(CFF_Parser parser)
static FT_Error cff_parse_blend(CFF_Parser parser)
static FT_Error cff_parse_cid_ros(CFF_Parser parser)
cff_parser_run(CFF_Parser parser, FT_Byte *start, FT_Byte *limit)
static const FT_Long power_ten_limits[]
#define CFF2_DEFAULT_STACK
@ cff_kind_fixed_thousand
#define CFF_FIELD_HANDLERS_GET
struct CFF_PrivateRec_ * CFF_Private
struct CFF_FontRecDictRec_ * CFF_FontRecDict
#define FT_DEBUG_LEVEL_TRACE
FT_DivFix(FT_Long a, FT_Long b)
#define FT_ASSERT(condition)
#define FT_ERROR(varformat)
#define FT_TRACE1(varformat)
#define FT_TRACE4(varformat)
#define FT_NEW_ARRAY(ptr, count)
#define FT_ALLOC(ptr, size)
FT_Get_Module_Interface(FT_Library library, const char *mod_name)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
FT_BEGIN_HEADER typedef unsigned char FT_Bool
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble GLdouble q
GLboolean GLenum GLenum GLvoid * values
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static unsigned int number
static char memory[1024 *256]
struct PSAux_ServiceRec_ * PSAux_Service
FT_Fixed stack[CFF_MAX_OPERANDS+1]
CFF_FontRecDictRec font_dict
const CFF_Decoder_FuncsRec * cff_decoder_funcs
enum parser_state stack[4]