21#include FT_INTERNAL_DEBUG_H
22#include FT_INTERNAL_SERVICE_H
23#include FT_SERVICE_CFF_TABLE_LOAD_H
38#define FT_COMPONENT trace_cffdecode
41#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
43 typedef enum CFF_Operator_
114 cff_op_callothersubr,
118 cff_op_setcurrentpoint,
126#define CFF_COUNT_CHECK_WIDTH 0x80
127#define CFF_COUNT_EXACT 0x40
128#define CFF_COUNT_CLEAR_STACK 0x20
136 static const FT_Byte cff_argument_counts[] =
140 2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
141 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
142 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
144 0 | CFF_COUNT_CLEAR_STACK,
145 0 | CFF_COUNT_CLEAR_STACK,
146 0 | CFF_COUNT_CLEAR_STACK,
148 0 | CFF_COUNT_CLEAR_STACK,
149 0 | CFF_COUNT_CLEAR_STACK,
150 0 | CFF_COUNT_CLEAR_STACK,
151 0 | CFF_COUNT_CLEAR_STACK,
152 0 | CFF_COUNT_CLEAR_STACK,
153 0 | CFF_COUNT_CLEAR_STACK,
154 0 | CFF_COUNT_CLEAR_STACK,
161 0 | CFF_COUNT_CHECK_WIDTH,
163 2 | CFF_COUNT_CHECK_WIDTH,
164 2 | CFF_COUNT_CHECK_WIDTH,
165 2 | CFF_COUNT_CHECK_WIDTH,
166 2 | CFF_COUNT_CHECK_WIDTH,
168 0 | CFF_COUNT_CHECK_WIDTH,
169 0 | CFF_COUNT_CHECK_WIDTH,
224 FT_Int bchar_index, achar_index;
234 FT_ERROR((
"cff_operator_seac: invalid nested seac\n" ));
241#ifdef FT_CONFIG_OPTION_INCREMENTAL
244 if (
face->root.internal->incremental_interface )
259 if ( bchar_index < 0 || achar_index < 0 )
262 " invalid seac character code arguments\n" ));
280 subg = loader->current.subglyphs;
283 subg->index = bchar_index;
291 subg->index = achar_index;
293 subg->arg1 = (
FT_Int)( adx >> 16 );
294 subg->arg2 = (
FT_Int)( ady >> 16 );
298 glyph->
subglyphs = loader->base.subglyphs;
299 glyph->
format = FT_GLYPH_FORMAT_COMPOSITE;
301 loader->current.num_subglyphs = 2;
308 &charstring, &charstring_len );
313 error = cff_decoder_parse_charstrings( decoder, charstring,
333 builder->
pos_x = adx - asb;
334 builder->
pos_y = ady;
338 &charstring, &charstring_len );
343 error = cff_decoder_parse_charstrings( decoder, charstring,
405 if ( in_charstring_type == 1 )
407 else if ( num_subrs < 1240 )
409 else if ( num_subrs < 33900U )
425 FT_Service_CFFLoad cffload;
433 if ( charcode < 0 || charcode > 255 )
438 FT_Service_CFFLoad cffload;
444 FT_ERROR((
"cff_lookup_glyph_by_stdcharcode:"
445 " the `cffload' module is not available\n" ));
446 return FT_THROW( Unimplemented_Feature );
453 glyph_sid = cffload->get_standard_encoding( (
FT_UInt)charcode );
465#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
490 cff_decoder_parse_charstrings(
CFF_Decoder* decoder,
526 zone->base = charstring_base;
527 limit =
zone->limit = charstring_base + charstring_len;
551 if (
v >= 32 ||
v == 28 )
569 val = (FT_Int32)
v - 139;
574 val = ( (FT_Int32)
v - 247 ) * 256 + *
ip++ + 108;
580 val = -( (FT_Int32)
v - 251 ) * 256 - *
ip++ - 108;
586 val = (FT_Int32)( ( (FT_UInt32)
ip[0] << 24 ) |
587 ( (FT_UInt32)
ip[1] << 16 ) |
588 ( (FT_UInt32)
ip[2] << 8 ) |
591 if ( charstring_type == 2 )
600#ifdef FT_DEBUG_LEVEL_TRACE
601 if ( !(
val & 0xFFFFL ) )
644 op = cff_op_rrcurveto;
647 op = cff_op_closepath;
650 op = cff_op_callsubr;
663 op = cff_op_dotsection;
711 op = cff_op_callothersubr;
750 op = cff_op_setcurrentpoint;
782 op = cff_op_hintmask;
785 op = cff_op_cntrmask;
797 op = cff_op_rcurveline;
800 op = cff_op_rlinecurve;
803 op = cff_op_vvcurveto;
806 op = cff_op_hhcurveto;
809 op = cff_op_callgsubr;
812 op = cff_op_vhcurveto;
815 op = cff_op_hvcurveto;
822 if (
op == cff_op_unknown )
837 case cff_op_rrcurveto:
839 case cff_op_hintmask:
840 case cff_op_cntrmask:
844 case cff_op_rcurveline:
845 case cff_op_rlinecurve:
846 case cff_op_vvcurveto:
847 case cff_op_hhcurveto:
848 case cff_op_vhcurveto:
849 case cff_op_hvcurveto:
854 case cff_op_callsubr:
855 case cff_op_callgsubr:
864 req_args = cff_argument_counts[
op];
865 if ( req_args & CFF_COUNT_CHECK_WIDTH )
884 set_width_ok = num_args & 2;
892 case cff_op_hintmask:
893 case cff_op_cntrmask:
894 set_width_ok = num_args & 1;
900 set_width_ok = in_dict
902 : ( ( num_args == 5 ) || ( num_args == 1 ) );
931 if ( num_args < req_args )
932 goto Stack_Underflow;
934 num_args -= req_args;
952 op == cff_op_hstem ?
" hstem\n" :
953 (
op == cff_op_vstem ?
" vstem\n" :
954 (
op == cff_op_hstemhm ?
" hstemhm\n" :
" vstemhm\n" ) ) ));
958 (
op == cff_op_hstem ||
op == cff_op_hstemhm ),
960 args - ( num_args & ~1 ) );
966 case cff_op_hintmask:
967 case cff_op_cntrmask:
968 FT_TRACE4((
op == cff_op_hintmask ?
" hintmask" :
" cntrmask" ));
980 args - ( num_args & ~1 ) );
995 if (
op == cff_op_hintmask )
1006#ifdef FT_DEBUG_LEVEL_TRACE
1026 case cff_op_rmoveto:
1036 case cff_op_vmoveto:
1045 case cff_op_hmoveto:
1054 case cff_op_rlineto:
1062 goto Stack_Underflow;
1064 args -= num_args & ~1;
1065 while ( args < decoder->
top )
1075 case cff_op_hlineto:
1076 case cff_op_vlineto:
1078 FT_Int phase = (
op == cff_op_hlineto );
1085 goto Stack_Underflow;
1089 if ( num_args == 0 )
1097 while ( args < decoder->
top )
1114 case cff_op_rrcurveto:
1122 goto Stack_Underflow;
1124 nargs = num_args - num_args % 6;
1131 while ( args < decoder->
top )
1151 case cff_op_vvcurveto:
1159 goto Stack_Underflow;
1164 nargs = num_args & ~2;
1181 while ( args < decoder->
top )
1199 case cff_op_hhcurveto:
1207 goto Stack_Underflow;
1212 nargs = num_args & ~2;
1228 while ( args < decoder->
top )
1246 case cff_op_vhcurveto:
1247 case cff_op_hvcurveto:
1253 FT_TRACE4((
op == cff_op_vhcurveto ?
" vhcurveto\n"
1254 :
" hvcurveto\n" ));
1260 goto Stack_Underflow;
1265 nargs = num_args & ~2;
1269 goto Stack_Underflow;
1271 phase = (
op == cff_op_hvcurveto );
1273 while ( nargs >= 4 )
1311 case cff_op_rlinecurve:
1320 goto Stack_Underflow;
1322 nargs = num_args & ~1;
1359 case cff_op_rcurveline:
1368 goto Stack_Underflow;
1370 nargs = num_args - 2;
1371 nargs = nargs - nargs % 6 + 2;
1372 num_curves = ( nargs - 2 ) / 6;
1381 while ( num_curves > 0 )
1547 horizontal = (
dx >
dy );
1603 error = cff_operator_seac( decoder,
1615 case cff_op_endchar:
1623 if ( num_args >= 4 )
1629 error = cff_operator_seac( decoder,
1739 if ( new_root ==
root )
1779 else if (
idx > num_args - 2 )
1799 goto Stack_Underflow;
1896 if ( reg_idx >= 0 && reg_idx <= 2 &&
1923 if ( num_results < 0 )
1926 if ( num_results * (
FT_Int)num_designs > num_args )
1927 goto Stack_Underflow;
1932 args -= num_results * ( num_designs - 1 );
1933 num_args -= num_results * ( num_designs - 1 );
1937 case cff_op_dotsection:
1942 case cff_op_closepath:
1947 FT_TRACE4((
" closepath (invalid op)\n" ));
1988 case cff_op_setcurrentpoint:
1993 FT_TRACE4((
" setcurrentpoint (invalid op)\n" ));
2000 case cff_op_callothersubr:
2005 FT_TRACE4((
" callothersubr (invalid op)\n" ));
2014 goto Stack_Underflow;
2050 args[0] = cond ? 0x10000L : 0;
2062 args[0] = cond ? 0x10000L : 0;
2074 args[0] = cond ? 0x10000L : 0;
2086 args[0] = cond ? 0x10000L : 0;
2104 case cff_op_callsubr:
2110 FT_TRACE4((
" callsubr (idx %d, entering level %d)\n",
2116 FT_ERROR((
"cff_decoder_parse_charstrings:"
2117 " invalid local subr index\n" ));
2123 FT_ERROR((
"cff_decoder_parse_charstrings:"
2124 " too many nested subrs\n" ));
2137 FT_ERROR((
"cff_decoder_parse_charstrings:"
2138 " invoking empty subrs\n" ));
2148 case cff_op_callgsubr:
2154 FT_TRACE4((
" callgsubr (idx %d, entering level %d)\n",
2160 FT_ERROR((
"cff_decoder_parse_charstrings:"
2161 " invalid global subr index\n" ));
2167 FT_ERROR((
"cff_decoder_parse_charstrings:"
2168 " too many nested subrs\n" ));
2181 FT_ERROR((
"cff_decoder_parse_charstrings:"
2182 " invoking empty subrs\n" ));
2193 FT_TRACE4((
" return (leaving level %d)\n",
2198 FT_ERROR((
"cff_decoder_parse_charstrings:"
2199 " unexpected return\n" ));
2210 FT_ERROR((
"Unimplemented opcode: %d",
ip[-1] ));
2216 return FT_THROW( Unimplemented_Feature );
2222 goto Stack_Overflow;
2234 FT_TRACE4((
"cff_decoder_parse_charstrings:"
2235 " invalid opcode found in top DICT charstring\n"));
2236 return FT_THROW( Invalid_File_Format );
2239 FT_TRACE4((
"cff_decoder_parse_charstrings: syntax error\n" ));
2240 return FT_THROW( Invalid_File_Format );
2243 FT_TRACE4((
"cff_decoder_parse_charstrings: stack underflow\n" ));
2244 return FT_THROW( Too_Few_Arguments );
2247 FT_TRACE4((
"cff_decoder_parse_charstrings: stack overflow\n" ));
2301 decoder->num_globals );
2303 decoder->hint_mode = hint_mode;
2306 decoder->free_glyph_callback = free_callback;
2322 FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)
cff->
cffload;
2334 FT_TRACE4((
"cff_decoder_prepare: invalid CID subfont index\n" ));
2339 FT_TRACE3((
" in subfont %d:\n", fd_index ));
2354 decoder->num_locals = sub->local_subrs_index.count;
2355 decoder->locals = sub->local_subrs;
2357 decoder->cff->top_font.font_dict.charstring_type,
2358 decoder->num_locals );
2360 decoder->glyph_width = sub->private_dict.default_width;
2361 decoder->nominal_width = sub->private_dict.nominal_width;
2363 decoder->current_subfont = sub;
ios_base &_STLP_CALL internal(ios_base &__s)
_STLP_MOVE_TO_STD_NAMESPACE void _STLP_CALL advance(_InputIterator &__i, _Distance __n)
static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback)
cff_decoder_init(CFF_Decoder *decoder, TT_Face face, CFF_Size size, CFF_GlyphSlot slot, FT_Bool hinting, FT_Render_Mode hint_mode, CFF_Decoder_Get_Glyph_Callback get_callback, CFF_Decoder_Free_Glyph_Callback free_callback)
static FT_Int cff_compute_bias(FT_Int in_charstring_type, FT_UInt num_subrs)
cff_decoder_prepare(CFF_Decoder *decoder, CFF_Size size, FT_UInt glyph_index)
cff_lookup_glyph_by_stdcharcode(CFF_Font cff, FT_Int charcode)
struct CFF_InternalRec_ * CFF_Internal
struct CFF_FontRec_ * CFF_Font
enum FT_Render_Mode_ FT_Render_Mode
FT_DivFix(FT_Long a, FT_Long b)
#define FT_SUBGLYPH_FLAG_USE_MY_METRICS
struct FT_GlyphSlotRec_ * FT_GlyphSlot
#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES
FT_MulFix(FT_Long a, FT_Long b)
#define FT_ERROR(varformat)
#define FT_TRACE3(varformat)
#define FT_TRACE4(varformat)
FT_GlyphLoader_Add(FT_GlyphLoader loader)
FT_GlyphLoader_Prepare(FT_GlyphLoader loader)
FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs)
FT_BEGIN_HEADER typedef signed long FT_Pos
#define FT_FACE_FIND_GLOBAL_SERVICE(face, ptr, id)
FT_BEGIN_HEADER typedef unsigned char FT_Bool
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLuint GLuint GLsizei count
GLdouble GLdouble GLdouble GLdouble top
GLenum GLuint GLint GLenum face
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
const struct T2_Hints_FuncsRec_ * T2_Hints_Funcs
typedefFT_BEGIN_HEADER struct PSH_GlobalsRec_ * PSH_Globals
JSAMPARRAY JDIMENSION num_lines
#define CFF_MAX_SUBRS_CALLS
FT_Error(* CFF_Decoder_Get_Glyph_Callback)(TT_Face face, FT_UInt glyph_index, FT_Byte **pointer, FT_ULong *length)
void(* CFF_Decoder_Free_Glyph_Callback)(TT_Face face, FT_Byte **pointer, FT_ULong length)
#define CFF_MAX_TRANS_ELEMENTS
cff_builder_add_point1(CFF_Builder *builder, FT_Pos x, FT_Pos y)
cff_builder_add_point(CFF_Builder *builder, FT_Pos x, FT_Pos y, FT_Byte flag)
cff_check_points(CFF_Builder *builder, FT_Int count)
cff_builder_start_point(CFF_Builder *builder, FT_Pos x, FT_Pos y)
cff_builder_init(CFF_Builder *builder, TT_Face face, CFF_Size size, CFF_GlyphSlot glyph, FT_Bool hinting)
cff_builder_close_contour(CFF_Builder *builder)
CFF_Decoder_Get_Glyph_Callback get_glyph_callback
FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS]
CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS+1]
CFF_Decoder_Free_Glyph_Callback free_glyph_callback
CFF_SubFont current_subfont
FT_Fixed stack[CFF_MAX_OPERANDS+1]
CFF_SubFont subfonts[CFF_MAX_CID_FONTS]
CFF_FDSelectRec fd_select
CFF_IndexRec global_subrs_index
CFF_FontRecDictRec font_dict
FT_Slot_Internal internal
FT_Size_Internal internal
T2_Hints_CounterFunc counter
T2_Hints_MaskFunc hintmask