20 #include FT_INTERNAL_CALC_H
21 #include FT_INTERNAL_DEBUG_H
22 #include FT_INTERNAL_POSTSCRIPT_HINTS_H
31 #define Fix2Int( f ) ( (FT_Int)(FT_Short)( (f) >> 16 ) )
40 #define FT_COMPONENT trace_t1decode
135 FT_Service_PsCMaps psnames = decoder->
psnames;
139 if ( charcode < 0 || charcode > 255 )
142 glyph_name = psnames->adobe_std_strings(
143 psnames->adobe_std_encoding[charcode]);
151 name[0] == glyph_name[0] &&
193 FT_Int bchar_index, achar_index;
200 #ifdef FT_CONFIG_OPTION_INCREMENTAL
207 FT_ERROR((
"t1operator_seac: invalid nested seac\n" ));
208 return PSaux_Err_Syntax_Error;
216 #ifdef FT_CONFIG_OPTION_INCREMENTAL
224 " glyph names table not available in this font\n" ));
225 return PSaux_Err_Syntax_Error;
228 #ifdef FT_CONFIG_OPTION_INCREMENTAL
242 if ( bchar_index < 0 || achar_index < 0 )
245 " invalid seac character code arguments\n" ));
246 return PSaux_Err_Syntax_Error;
263 subg = loader->current.subglyphs;
266 subg->index = bchar_index;
274 subg->index = achar_index;
281 glyph->
subglyphs = loader->base.subglyphs;
282 glyph->
format = FT_GLYPH_FORMAT_COMPOSITE;
284 loader->current.num_subglyphs = 2;
365 FT_Int known_othersubr_result_cnt = 0;
366 FT_Int unknown_othersubr_result_cnt = 0;
372 #ifdef FT_DEBUG_LEVEL_TRACE
382 seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
387 decoder->top = decoder->stack;
388 decoder->zone = decoder->zones;
389 zone = decoder->zones;
397 FT_ASSERT( ( decoder->len_buildchar == 0 ) ==
398 ( decoder->buildchar ==
NULL ) );
400 if ( decoder->buildchar && decoder->len_buildchar > 0 )
403 sizeof ( decoder->buildchar[0] ) * decoder->len_buildchar );
406 "Start charstring\n" ));
408 zone->
base = charstring_base;
409 limit = zone->
limit = charstring_base + charstring_len;
412 error = PSaux_Err_Ok;
414 x = orig_x = builder->
pos_x;
415 y = orig_y = builder->
pos_y;
431 FT_ASSERT( known_othersubr_result_cnt == 0 ||
432 unknown_othersubr_result_cnt == 0 );
434 #ifdef FT_DEBUG_LEVEL_TRACE
437 FT_TRACE5((
" (%d)", decoder->top - decoder->stack ));
511 FT_ERROR((
"t1_decoder_parse_charstrings:"
512 " invalid escape (12+EOF)\n" ));
547 FT_ERROR((
"t1_decoder_parse_charstrings:"
548 " invalid escape (12+%d)\n",
555 if ( ip + 4 > limit )
557 FT_ERROR((
"t1_decoder_parse_charstrings:"
558 " unexpected EOF in integer\n" ));
562 value = (FT_Int32)( ( (
FT_Long)ip[0] << 24 ) |
575 if ( value > 32000 || value < -32000 )
579 FT_ERROR((
"t1_decoder_parse_charstrings:"
580 " no `div' after large integer\n" ));
597 value = (FT_Int32)ip[-1] - 139;
602 FT_ERROR((
"t1_decoder_parse_charstrings:"
603 " unexpected EOF in integer\n" ));
608 value = ( ( (FT_Int32)ip[-2] - 247 ) << 8 ) + ip[-1] + 108;
610 value = -( ( ( (FT_Int32)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 );
618 FT_ERROR((
"t1_decoder_parse_charstrings:"
619 " invalid byte (%d)\n", ip[-1] ));
624 if ( unknown_othersubr_result_cnt > 0 )
636 unknown_othersubr_result_cnt = 0;
643 FT_ERROR((
"t1_decoder_parse_charstrings:"
644 " no `div' after large integer\n" ));
658 FT_ERROR((
"t1_decoder_parse_charstrings: stack overflow\n" ));
662 #ifdef FT_DEBUG_LEVEL_TRACE
678 #ifdef FT_DEBUG_LEVEL_TRACE
683 if ( top - decoder->stack < 2 )
684 goto Stack_Underflow;
702 if ( arg_cnt > top - decoder->stack )
703 goto Stack_Underflow;
707 known_othersubr_result_cnt = 0;
708 unknown_othersubr_result_cnt = 0;
730 goto Unexpected_OtherSubr;
732 if ( decoder->flex_state == 0 ||
733 decoder->num_flex_vectors != 7 )
735 FT_ERROR((
"t1_decoder_parse_charstrings:"
736 " unexpected flex end\n" ));
743 known_othersubr_result_cnt = 2;
748 goto Unexpected_OtherSubr;
750 decoder->flex_state = 1;
751 decoder->num_flex_vectors = 0;
765 goto Unexpected_OtherSubr;
767 if ( decoder->flex_state == 0 )
769 FT_ERROR((
"t1_decoder_parse_charstrings:"
770 " missing flex start\n" ));
777 idx = decoder->num_flex_vectors++;
778 if ( idx > 0 && idx < 7 )
782 (
FT_Byte)( idx == 3 || idx == 6 ) );
788 goto Unexpected_OtherSubr;
790 known_othersubr_result_cnt = 1;
799 top = decoder->stack;
816 FT_ERROR((
"t1_decoder_parse_charstrings:"
817 " unexpected multiple masters operator\n" ));
821 num_points = (
FT_UInt)subr_no - 13 + ( subr_no == 18 );
824 FT_ERROR((
"t1_decoder_parse_charstrings:"
825 " incorrect number of multiple masters arguments\n" ));
845 delta = top + num_points;
847 for ( nn = 0; nn < num_points; nn++ )
858 known_othersubr_result_cnt = num_points;
871 if ( arg_cnt != 1 || blend ==
NULL )
872 goto Unexpected_OtherSubr;
877 idx + blend->
num_designs > decoder->len_buildchar )
878 goto Unexpected_OtherSubr;
891 goto Unexpected_OtherSubr;
895 known_othersubr_result_cnt = 1;
902 goto Unexpected_OtherSubr;
906 known_othersubr_result_cnt = 1;
913 goto Unexpected_OtherSubr;
917 known_othersubr_result_cnt = 1;
923 if ( arg_cnt != 2 || top[1] == 0 )
924 goto Unexpected_OtherSubr;
928 known_othersubr_result_cnt = 1;
939 if ( arg_cnt != 2 || blend ==
NULL )
940 goto Unexpected_OtherSubr;
944 if ( idx < 0 || (
FT_UInt) idx >= decoder->len_buildchar )
945 goto Unexpected_OtherSubr;
947 decoder->buildchar[
idx] = top[0];
960 if ( arg_cnt != 1 || blend ==
NULL )
961 goto Unexpected_OtherSubr;
965 if ( idx < 0 || (
FT_UInt) idx >= decoder->len_buildchar )
966 goto Unexpected_OtherSubr;
968 top[0] = decoder->buildchar[
idx];
971 known_othersubr_result_cnt = 1;
988 goto Unexpected_OtherSubr;
990 if ( top[2] > top[3] )
993 known_othersubr_result_cnt = 1;
1000 goto Unexpected_OtherSubr;
1007 if ( Rand >= 0x8000L )
1012 seed =
FT_MulFix( seed, 0x10000L - seed );
1017 known_othersubr_result_cnt = 1;
1021 if ( arg_cnt >= 0 && subr_no >= 0 )
1023 FT_ERROR((
"t1_decoder_parse_charstrings:"
1024 " unknown othersubr [%d %d], wish me luck\n",
1025 arg_cnt, subr_no ));
1026 unknown_othersubr_result_cnt = arg_cnt;
1031 Unexpected_OtherSubr:
1032 FT_ERROR((
"t1_decoder_parse_charstrings:"
1033 " invalid othersubr [%d %d]\n", arg_cnt, subr_no ));
1037 top += known_othersubr_result_cnt;
1048 if ( top - decoder->stack < num_args )
1049 goto Stack_Underflow;
1057 #ifdef FT_DEBUG_LEVEL_TRACE
1069 if ( top - decoder->stack != num_args )
1070 FT_TRACE0((
"t1_decoder_parse_charstrings:"
1071 " too much operands on the stack"
1072 " (seen %d, expected %d)\n",
1073 top - decoder->stack, num_args ));
1098 decoder->hint_mode );
1106 #ifdef FT_DEBUG_LEVEL_TRACE
1108 if ( decoder->len_buildchar > 0 )
1115 for ( i = 0; i < decoder->len_buildchar; ++
i )
1116 FT_TRACE4((
"%d ", decoder->buildchar[i] ));
1126 return PSaux_Err_Ok;
1137 orig_x = x = builder->
pos_x + top[0];
1138 orig_y = y = builder->
pos_y;
1146 return PSaux_Err_Ok;
1168 x = builder->
pos_x + top[0];
1169 y = builder->
pos_y + top[1];
1175 return PSaux_Err_Ok;
1204 if ( !decoder->flex_state )
1251 if ( !decoder->flex_state )
1313 if ( !decoder->flex_state )
1341 if ( idx < 0 || idx >= (
FT_Int)decoder->num_subrs )
1343 FT_ERROR((
"t1_decoder_parse_charstrings:"
1344 " invalid subrs index\n" ));
1350 FT_ERROR((
"t1_decoder_parse_charstrings:"
1351 " too many nested subrs\n" ));
1362 zone->
base = decoder->subrs[
idx];
1364 if ( decoder->subrs_len )
1370 zone->
base += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 );
1371 zone->
limit = decoder->subrs[idx + 1];
1378 FT_ERROR((
"t1_decoder_parse_charstrings:"
1379 " invoking empty subrs\n" ));
1383 decoder->zone = zone;
1385 limit = zone->
limit;
1392 if ( known_othersubr_result_cnt > 0 )
1394 known_othersubr_result_cnt--;
1399 if ( unknown_othersubr_result_cnt == 0 )
1401 FT_ERROR((
"t1_decoder_parse_charstrings:"
1402 " no more operands for othersubr\n" ));
1406 unknown_othersubr_result_cnt--;
1413 if ( zone <= decoder->zones )
1415 FT_ERROR((
"t1_decoder_parse_charstrings:"
1416 " unexpected return\n" ));
1422 limit = zone->
limit;
1423 decoder->zone = zone;
1494 if ( decoder->flex_state != 1 )
1496 FT_ERROR((
"t1_decoder_parse_charstrings:"
1497 " unexpected `setcurrentpoint'\n" ));
1506 decoder->flex_state = 0;
1515 FT_ERROR((
"t1_decoder_parse_charstrings:"
1516 " unhandled opcode %d\n", op ));
1527 #ifdef FT_DEBUG_LEVEL_TRACE
1542 return PSaux_Err_Syntax_Error;
1545 return PSaux_Err_Stack_Underflow;
1554 return decoder->parse_callback( decoder, glyph );
1574 FT_Service_PsCMaps psnames = 0;
1581 " the `psnames' module is not available\n" ));
1582 return PSaux_Err_Unimplemented_Feature;
1585 decoder->psnames = psnames;
1594 decoder->num_glyphs = (
FT_UInt)face->num_glyphs;
1595 decoder->glyph_names = glyph_names;
1596 decoder->hint_mode = hint_mode;
1597 decoder->blend = blend;
1598 decoder->parse_callback = parse_callback;
1602 return PSaux_Err_Ok;
typedefFT_BEGIN_HEADER struct PSH_GlobalsRec_ * PSH_Globals
FT_DivFix(FT_Long a, FT_Long b)
struct T1_FaceRec_ * T1_Face
FT_BEGIN_HEADER typedef signed long FT_Pos
t1_builder_done(T1_Builder builder)
t1_builder_add_point1(T1_Builder builder, FT_Pos x, FT_Pos y)
#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES
#define FT_MEM_ZERO(dest, count)
#define FT_SUBGLYPH_FLAG_USE_MY_METRICS
enum FT_Render_Mode_ FT_Render_Mode
t1_builder_start_point(T1_Builder builder, FT_Pos x, FT_Pos y)
cannot open resource broken file module version is too low unimplemented feature broken offset within table missing module invalid character code cannot render this glyph format invalid composite glyph invalid pixel size invalid library handle invalid face handle invalid glyph slot handle invalid cache manager handle too many modules out of memory cannot open stream invalid stream skip invalid stream operation nested frame access raster uninitialized raster overflow too many registered caches too few arguments code overflow division by zero found debug opcode nested DEFS execution context too long too many instruction definitions horizontal name table missing horizontal PostScript(post) table missing" ) FT_ERRORDEF_( Invalid_Horiz_Metrics
#define FT_FACE_FIND_GLOBAL_SERVICE(face, ptr, id)
EGLImageKHR EGLint * name
enum T1_Operator_ T1_Operator
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FT_Face_Internal internal
t1_decoder_init(T1_Decoder decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte **glyph_names, PS_Blend blend, FT_Bool hinting, FT_Render_Mode hint_mode, T1_Decoder_Callback parse_callback)
typedefFT_BEGIN_HEADER struct FT_GlyphLoaderRec_ * FT_GlyphLoader
#define FT_ERROR(varformat)
#define FT_ASSERT(condition)
#define FT_TRACE4(varformat)
static const FT_Int t1_args_count[op_max]
FT_GlyphLoader_Add(FT_GlyphLoader loader)
FT_CALLBACK_TABLE_DEF const T1_Decoder_FuncsRec t1_decoder_funcs
T1_Hints_SetStemFunc stem
FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs)
#define FT_TRACE0(varformat)
T1_ParseState parse_state
t1_decoder_parse_charstrings(T1_Decoder decoder, FT_Byte *charstring_base, FT_UInt charstring_len)
FT_Service_PsCMaps psnames
GLfloat GLfloat GLfloat top
t1_builder_close_contour(T1_Builder builder)
#define T1_MAX_CHARSTRINGS_OPERANDS
FT_Error(* T1_Decoder_Callback)(T1_Decoder decoder, FT_UInt glyph_index)
EGLSurface EGLint EGLint y
FT_MulFix(FT_Long a, FT_Long b)
struct T1_Hints_FuncsRec_ * T1_Hints_Funcs
EGLSurface EGLint void ** value
#define T1_MAX_SUBRS_CALLS
t1_decoder_parse_glyph(T1_Decoder decoder, FT_UInt glyph)
struct FT_GlyphSlotRec_ * FT_GlyphSlot
static FT_Int t1_lookup_glyph_by_stdcharcode(T1_Decoder decoder, FT_Int charcode)
FT_Slot_Internal internal
#define FT_TRACE5(varformat)
t1_builder_add_point(T1_Builder builder, FT_Pos x, FT_Pos y, FT_Byte flag)
FT_GlyphLoader_Prepare(FT_GlyphLoader loader)
t1_builder_init(T1_Builder builder, FT_Face face, FT_Size size, FT_GlyphSlot glyph, FT_Bool hinting)
static FT_Error t1operator_seac(T1_Decoder decoder, FT_Pos asb, FT_Pos adx, FT_Pos ady, FT_Int bchar, FT_Int achar)
T1_Hints_SetStem3Func stem3
t1_decoder_done(T1_Decoder decoder)
t1_builder_check_points(T1_Builder builder, FT_Int count)
GLint GLsizei const GLuint64 * values