21 #include FT_INTERNAL_STREAM_H
22 #include FT_INTERNAL_DEBUG_H
35 #define FT_COMPONENT trace_cffparse
46 parser->top = parser->stack;
47 parser->object_code = code;
91 val = ( v - 247 ) * 256 + p[0] + 108;
99 val = -( v - 251 ) * 256 - p[0] - 108;
140 FT_Long exponent_add, integer_length, fraction_length;
172 nib = ( p[0] >> phase ) & 0xF;
182 if ( number >= 0xCCCCCCCL )
185 else if ( nib || number )
188 number = number * 10 + nib;
209 nib = ( p[0] >> phase ) & 0xF;
215 if ( !nib && !number )
218 else if ( number < 0xCCCCCCCL && fraction_length < 9 )
221 number = number * 10 + nib;
248 nib = ( p[0] >> phase ) & 0xF;
253 exponent = exponent * 10 + nib;
256 if ( exponent > 1000 )
265 exponent += power_ten + exponent_add;
270 fraction_length += integer_length;
271 exponent += integer_length;
273 if ( fraction_length <= 5 )
275 if ( number > 0x7FFFL )
278 *scaling = exponent - fraction_length + 1;
284 FT_Long new_fraction_length, shift;
288 new_fraction_length =
FT_MIN( exponent, 5 );
289 exponent -= new_fraction_length;
290 shift = new_fraction_length - fraction_length;
293 if ( number > 0x7FFFL )
300 exponent -= fraction_length;
302 result = number << 16;
308 if ( ( number /
power_tens[fraction_length - 5] ) > 0x7FFFL )
311 *scaling = exponent - 4;
316 *scaling = exponent - 5;
326 if (
FT_ABS( integer_length ) > 5 )
330 if ( integer_length < 0 )
333 fraction_length += integer_length;
337 if ( fraction_length == 10 )
340 fraction_length -= 1;
344 if ( fraction_length > 0 )
346 if ( ( number /
power_tens[fraction_length] ) > 0x7FFFL )
355 if ( number > 0x7FFFL )
358 result = number << 16;
419 if ( number > 0x7FFFL )
421 for ( integer_length = 5; integer_length < 10; integer_length++ )
425 if ( ( number /
power_tens[integer_length - 5] ) > 0x7FFFL )
427 *scaling = integer_length - 4;
432 *scaling = integer_length - 5;
475 if ( scaling < 0 || scaling > 9 )
480 " strange scaling value for xx element (%d),\n"
482 " using default matrix\n", scaling ));
504 (
double)
matrix->xx / *upm / 65536,
505 (
double)
matrix->xy / *upm / 65536,
506 (
double)
matrix->yx / *upm / 65536,
507 (
double)
matrix->yy / *upm / 65536,
508 (
double)
offset->x / *upm / 65536,
509 (
double)
offset->y / *upm / 65536 ));
526 error = CFF_Err_Stack_Underflow;
555 error = CFF_Err_Stack_Underflow;
579 error = CFF_Err_Stack_Underflow;
586 FT_TRACE1((
"cff_parse_cid_ros: real supplement is rounded\n" ));
589 FT_TRACE1((
"cff_parse_cid_ros: negative supplement %d is found\n",
603 #define CFF_FIELD_NUM( code, name, id ) \
604 CFF_FIELD( code, name, id, cff_kind_num )
605 #define CFF_FIELD_FIXED( code, name, id ) \
606 CFF_FIELD( code, name, id, cff_kind_fixed )
607 #define CFF_FIELD_FIXED_1000( code, name, id ) \
608 CFF_FIELD( code, name, id, cff_kind_fixed_thousand )
609 #define CFF_FIELD_STRING( code, name, id ) \
610 CFF_FIELD( code, name, id, cff_kind_string )
611 #define CFF_FIELD_BOOL( code, name, id ) \
612 CFF_FIELD( code, name, id, cff_kind_bool )
614 #define CFFCODE_TOPDICT 0x1000
615 #define CFFCODE_PRIVATE 0x2000
618 #ifndef FT_CONFIG_OPTION_PIC
622 #undef CFF_FIELD_DELTA
625 #ifndef FT_DEBUG_LEVEL_TRACE
628 #define CFF_FIELD_CALLBACK( code, name, id ) \
633 cff_parse_ ## name, \
637 #define CFF_FIELD( code, name, id, kind ) \
641 FT_FIELD_OFFSET( name ), \
642 FT_FIELD_SIZE( name ), \
646 #define CFF_FIELD_DELTA( code, name, max, id ) \
650 FT_FIELD_OFFSET( name ), \
651 FT_FIELD_SIZE_DELTA( name ), \
654 FT_FIELD_OFFSET( num_ ## name ) \
662 { 0, 0, 0, 0, 0, 0, 0 }
670 #define CFF_FIELD_CALLBACK( code, name, id ) \
675 cff_parse_ ## name, \
680 #define CFF_FIELD( code, name, id, kind ) \
684 FT_FIELD_OFFSET( name ), \
685 FT_FIELD_SIZE( name ), \
690 #define CFF_FIELD_DELTA( code, name, max, id ) \
694 FT_FIELD_OFFSET( name ), \
695 FT_FIELD_SIZE_DELTA( name ), \
698 FT_FIELD_OFFSET( num_ ## name ), \
707 { 0, 0, 0, 0, 0, 0, 0, 0 }
730 FT_Create_Class_cff_field_handlers(
FT_Library library,
741 #define CFF_FIELD( code, name, id, kind ) i++;
742 #undef CFF_FIELD_DELTA
743 #define CFF_FIELD_DELTA( code, name, max, id ) i++;
744 #undef CFF_FIELD_CALLBACK
745 #define CFF_FIELD_CALLBACK( code, name, id ) i++;
757 #ifndef FT_DEBUG_LEVEL_TRACE
760 #undef CFF_FIELD_CALLBACK
761 #define CFF_FIELD_CALLBACK( code_, name_, id_ ) \
762 clazz[i].kind = cff_kind_callback; \
763 clazz[i].code = code_ | CFFCODE; \
764 clazz[i].offset = 0; \
766 clazz[i].reader = cff_parse_ ## name_; \
767 clazz[i].array_max = 0; \
768 clazz[i].count_offset = 0; \
772 #define CFF_FIELD( code_, name_, id_, kind_ ) \
773 clazz[i].kind = kind_; \
774 clazz[i].code = code_ | CFFCODE; \
775 clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
776 clazz[i].size = FT_FIELD_SIZE( name_ ); \
777 clazz[i].reader = 0; \
778 clazz[i].array_max = 0; \
779 clazz[i].count_offset = 0; \
782 #undef CFF_FIELD_DELTA
783 #define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \
784 clazz[i].kind = cff_kind_delta; \
785 clazz[i].code = code_ | CFFCODE; \
786 clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
787 clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
788 clazz[i].reader = 0; \
789 clazz[i].array_max = max_; \
790 clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
807 #undef CFF_FIELD_CALLBACK
808 #define CFF_FIELD_CALLBACK( code_, name_, id_ ) \
809 clazz[i].kind = cff_kind_callback; \
810 clazz[i].code = code_ | CFFCODE; \
811 clazz[i].offset = 0; \
813 clazz[i].reader = cff_parse_ ## name_; \
814 clazz[i].array_max = 0; \
815 clazz[i].count_offset = 0; \
820 #define CFF_FIELD( code_, name_, id_, kind_ ) \
821 clazz[i].kind = kind_; \
822 clazz[i].code = code_ | CFFCODE; \
823 clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
824 clazz[i].size = FT_FIELD_SIZE( name_ ); \
825 clazz[i].reader = 0; \
826 clazz[i].array_max = 0; \
827 clazz[i].count_offset = 0; \
831 #undef CFF_FIELD_DELTA
832 #define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \
833 clazz[i].kind = cff_kind_delta; \
834 clazz[i].code = code_ | CFFCODE; \
835 clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
836 clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
837 clazz[i].reader = 0; \
838 clazz[i].array_max = max_; \
839 clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
858 *output_class = clazz;
878 parser->top = parser->stack;
879 parser->start =
start;
880 parser->limit =
limit;
881 parser->cursor =
start;
888 if ( v >= 27 && v != 31 )
930 ( parser->top - parser->stack );
945 code = code | parser->object_code;
956 #ifdef FT_DEBUG_LEVEL_TRACE
963 goto Stack_Underflow;
965 switch ( field->
kind )
981 switch ( field->
size )
999 #ifdef FT_DEBUG_LEVEL_TRACE
1000 switch ( field->
kind )
1003 FT_TRACE4((
" %s\n", val ?
"true" :
"false" ));
1015 FT_TRACE4((
" %f\n", (
double)val / 65536 ));
1019 FT_TRACE4((
" %f\n", (
double)val / 65536 / 1000 ));
1045 while ( num_args > 0 )
1048 switch ( field->
size )
1077 error = field->
reader( parser );
1090 parser->top = parser->stack;
1099 error = CFF_Err_Invalid_Argument;
1103 error = CFF_Err_Invalid_Argument;
1107 error = CFF_Err_Invalid_Argument;
#define FT_ALLOC(ptr, size)
static FT_Fixed cff_parse_fixed_dynamic(FT_Byte **d, FT_Long *scaling)
static FT_Fixed cff_parse_real(FT_Byte *start, FT_Byte *limit, FT_Long power_ten, FT_Long *scaling)
FT_Byte * stack[CFF_MAX_STACK_DEPTH+1]
FT_DivFix(FT_Long a, FT_Long b)
GLuint const GLfloat * val
#define FT_MEM_ZERO(dest, count)
static FT_Error cff_parse_font_matrix(CFF_Parser parser)
cff_parser_init(CFF_Parser parser, FT_UInt code, void *object, FT_Library library)
struct CFF_FontRecDictRec_ * CFF_FontRecDict
return Display return Display Bool Bool int d
#define FT_TRACE1(varformat)
#define FT_ASSERT(condition)
#define FT_TRACE4(varformat)
#define CFF_MAX_STACK_DEPTH
static FT_Error cff_parse_cid_ros(CFF_Parser parser)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
#define FT_CFF_FIELD_HANDLERS_GET
cff_parser_run(CFF_Parser parser, FT_Byte *start, FT_Byte *limit)
static FT_Long cff_parse_num(FT_Byte **d)
static FT_Error cff_parse_font_bbox(CFF_Parser parser)
static FT_Error cff_parse_private_dict(CFF_Parser parser)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
static FT_Long cff_parse_integer(FT_Byte *start, FT_Byte *limit)
static const CFF_Field_Handler cff_field_handlers[]
GLdouble GLdouble GLdouble GLdouble q
static FT_Fixed cff_parse_fixed(FT_Byte **d)
static FT_Fixed cff_parse_fixed_scaled(FT_Byte **d, FT_Long scaling)
static const FT_Long power_tens[]