37#define FT_COMPONENT cffdecode
40#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
42 typedef enum CFF_Operator_
113 cff_op_callothersubr,
117 cff_op_setcurrentpoint,
125#define CFF_COUNT_CHECK_WIDTH 0x80
126#define CFF_COUNT_EXACT 0x40
127#define CFF_COUNT_CLEAR_STACK 0x20
135 static const FT_Byte cff_argument_counts[] =
139 2 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
140 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
141 1 | CFF_COUNT_CHECK_WIDTH | CFF_COUNT_EXACT,
143 0 | CFF_COUNT_CLEAR_STACK,
144 0 | CFF_COUNT_CLEAR_STACK,
145 0 | CFF_COUNT_CLEAR_STACK,
147 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,
160 0 | CFF_COUNT_CHECK_WIDTH,
162 2 | CFF_COUNT_CHECK_WIDTH,
163 2 | CFF_COUNT_CHECK_WIDTH,
164 2 | CFF_COUNT_CHECK_WIDTH,
165 2 | CFF_COUNT_CHECK_WIDTH,
167 0 | CFF_COUNT_CHECK_WIDTH,
168 0 | CFF_COUNT_CHECK_WIDTH,
223 FT_Int bchar_index, achar_index;
233 FT_ERROR((
"cff_operator_seac: invalid nested seac\n" ));
240#ifdef FT_CONFIG_OPTION_INCREMENTAL
243 if (
face->root.internal->incremental_interface )
258 if ( bchar_index < 0 || achar_index < 0 )
261 " invalid seac character code arguments\n" ));
279 subg = loader->current.subglyphs;
282 subg->index = bchar_index;
290 subg->index = achar_index;
292 subg->arg1 = (
FT_Int)( adx >> 16 );
293 subg->arg2 = (
FT_Int)( ady >> 16 );
297 glyph->
subglyphs = loader->base.subglyphs;
298 glyph->
format = FT_GLYPH_FORMAT_COMPOSITE;
300 loader->current.num_subglyphs = 2;
307 &charstring, &charstring_len );
312 error = cff_decoder_parse_charstrings(
decoder, charstring,
316 decoder->free_glyph_callback(
face, &charstring, charstring_len );
327 glyph_width =
decoder->glyph_width;
333 builder->
pos_y = ady;
337 &charstring, &charstring_len );
342 error = cff_decoder_parse_charstrings(
decoder, charstring,
346 decoder->free_glyph_callback(
face, &charstring, charstring_len );
356 decoder->glyph_width = glyph_width;
407 if ( in_charstring_type == 1 )
409 else if ( num_subrs < 1240 )
411 else if ( num_subrs < 33900U )
427 FT_Service_CFFLoad cffload;
435 if ( charcode < 0 || charcode > 255 )
440 FT_Service_CFFLoad cffload;
446 FT_ERROR((
"cff_lookup_glyph_by_stdcharcode:"
447 " the `cffload' module is not available\n" ));
448 return FT_THROW( Unimplemented_Feature );
455 glyph_sid = cffload->get_standard_encoding( (
FT_UInt)charcode );
467#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
509 decoder->cff->top_font.font_dict.charstring_type;
511 decoder->cff->top_font.font_dict.num_designs;
513 decoder->cff->top_font.font_dict.num_axes;
532 if ( !charstring_base )
535 zone->base = charstring_base;
536 limit =
zone->limit = charstring_base + charstring_len;
560 if (
v >= 32 ||
v == 28 )
578 val = (FT_Int32)
v - 139;
583 val = ( (FT_Int32)
v - 247 ) * 256 + *
ip++ + 108;
589 val = -( (FT_Int32)
v - 251 ) * 256 - *
ip++ - 108;
595 val = (FT_Int32)( ( (FT_UInt32)
ip[0] << 24 ) |
596 ( (FT_UInt32)
ip[1] << 16 ) |
597 ( (FT_UInt32)
ip[2] << 8 ) |
600 if ( charstring_type == 2 )
609#ifdef FT_DEBUG_LEVEL_TRACE
610 if ( !(
val & 0xFFFFL ) )
653 op = cff_op_rrcurveto;
656 op = cff_op_closepath;
659 op = cff_op_callsubr;
672 op = cff_op_dotsection;
720 op = cff_op_callothersubr;
759 op = cff_op_setcurrentpoint;
791 op = cff_op_hintmask;
794 op = cff_op_cntrmask;
806 op = cff_op_rcurveline;
809 op = cff_op_rlinecurve;
812 op = cff_op_vvcurveto;
815 op = cff_op_hhcurveto;
818 op = cff_op_callgsubr;
821 op = cff_op_vhcurveto;
824 op = cff_op_hvcurveto;
831 if (
op == cff_op_unknown )
846 case cff_op_rrcurveto:
848 case cff_op_hintmask:
849 case cff_op_cntrmask:
853 case cff_op_rcurveline:
854 case cff_op_rlinecurve:
855 case cff_op_vvcurveto:
856 case cff_op_hhcurveto:
857 case cff_op_vhcurveto:
858 case cff_op_hvcurveto:
863 case cff_op_callsubr:
864 case cff_op_callgsubr:
866 case cff_op_dotsection:
869 case cff_op_closepath:
870 case cff_op_callothersubr:
873 case cff_op_setcurrentpoint:
882 req_args = cff_argument_counts[
op];
883 if ( req_args & CFF_COUNT_CHECK_WIDTH )
885 if ( num_args > 0 &&
decoder->read_width )
902 set_width_ok = num_args & 2;
910 case cff_op_hintmask:
911 case cff_op_cntrmask:
912 set_width_ok = num_args & 1;
918 set_width_ok = in_dict
920 : ( ( num_args == 5 ) || ( num_args == 1 ) );
949 if ( num_args < req_args )
950 goto Stack_Underflow;
952 num_args -= req_args;
970 op == cff_op_hstem ?
" hstem" :
971 (
op == cff_op_vstem ?
" vstem" :
972 (
op == cff_op_hstemhm ?
" hstemhm" :
" vstemhm" ) ) ));
976 (
op == cff_op_hstem ||
op == cff_op_hstemhm ),
978 args - ( num_args & ~1 ) );
980 decoder->num_hints += num_args / 2;
984 case cff_op_hintmask:
985 case cff_op_cntrmask:
986 FT_TRACE4((
"%s",
op == cff_op_hintmask ?
" hintmask"
999 args - ( num_args & ~1 ) );
1001 decoder->num_hints += num_args / 2;
1014 if (
op == cff_op_hintmask )
1025#ifdef FT_DEBUG_LEVEL_TRACE
1045 case cff_op_rmoveto:
1055 case cff_op_vmoveto:
1064 case cff_op_hmoveto:
1073 case cff_op_rlineto:
1081 goto Stack_Underflow;
1083 args -= num_args & ~1;
1084 while ( args < decoder->
top )
1094 case cff_op_hlineto:
1095 case cff_op_vlineto:
1097 FT_Int phase = (
op == cff_op_hlineto );
1100 FT_TRACE4((
"%s\n",
op == cff_op_hlineto ?
" hlineto"
1104 goto Stack_Underflow;
1108 if ( num_args == 0 )
1116 while ( args < decoder->
top )
1133 case cff_op_rrcurveto:
1141 goto Stack_Underflow;
1143 nargs = num_args - num_args % 6;
1150 while ( args < decoder->
top )
1170 case cff_op_vvcurveto:
1178 goto Stack_Underflow;
1183 nargs = num_args & ~2;
1200 while ( args < decoder->
top )
1218 case cff_op_hhcurveto:
1226 goto Stack_Underflow;
1231 nargs = num_args & ~2;
1247 while ( args < decoder->
top )
1265 case cff_op_vhcurveto:
1266 case cff_op_hvcurveto:
1272 FT_TRACE4((
"%s\n",
op == cff_op_vhcurveto ?
" vhcurveto"
1279 goto Stack_Underflow;
1284 nargs = num_args & ~2;
1288 goto Stack_Underflow;
1290 phase = (
op == cff_op_hvcurveto );
1292 while ( nargs >= 4 )
1330 case cff_op_rlinecurve:
1339 goto Stack_Underflow;
1341 nargs = num_args & ~1;
1378 case cff_op_rcurveline:
1387 goto Stack_Underflow;
1389 nargs = num_args - 2;
1390 nargs = nargs - nargs % 6 + 2;
1391 num_curves = ( nargs - 2 ) / 6;
1400 while ( num_curves > 0 )
1566 horizontal = (
dx >
dy );
1634 case cff_op_endchar:
1642 if ( num_args >= 4 )
1653 decoder->glyph_width = glyph_width;
1728 FT_UInt32* randval = in_dict ? &
decoder->cff->top_font.random
1729 : &
decoder->current_subfont->random;
1754 if (
args[0] > 0x7FFFFFFFL )
1756 else if (
args[0] > 0 )
1765 if ( new_root ==
root )
1805 else if (
idx > num_args - 2 )
1825 goto Stack_Underflow;
1927 if ( reg_idx >= 0 && reg_idx <= 2 &&
1955 if ( num_results < 0 )
1958 if ( num_results > num_args ||
1959 num_results * (
FT_Int)num_designs > num_args )
1960 goto Stack_Underflow;
1965 args -= num_results * ( num_designs - 1 );
1966 num_args -= num_results * ( num_designs - 1 );
1972 case cff_op_dotsection:
1977 case cff_op_closepath:
1982 FT_TRACE4((
" closepath (invalid op)\n" ));
1998 decoder->builder.left_bearing.y = 0;
2023 case cff_op_setcurrentpoint:
2028 FT_TRACE4((
" setcurrentpoint (invalid op)\n" ));
2035 case cff_op_callothersubr:
2045 FT_TRACE4((
" callothersubr (invalid op)\n" ));
2055 goto Stack_Underflow;
2059 goto Stack_Underflow;
2096 args[0] = cond ? 0x10000L : 0;
2108 args[0] = cond ? 0x10000L : 0;
2120 args[0] = cond ? 0x10000L : 0;
2132 args[0] = cond ? 0x10000L : 0;
2150 case cff_op_callsubr:
2156 FT_TRACE4((
" callsubr (idx %d, entering level %d)\n",
2162 FT_ERROR((
"cff_decoder_parse_charstrings:"
2163 " invalid local subr index\n" ));
2169 FT_ERROR((
"cff_decoder_parse_charstrings:"
2170 " too many nested subrs\n" ));
2183 FT_ERROR((
"cff_decoder_parse_charstrings:"
2184 " invoking empty subrs\n" ));
2194 case cff_op_callgsubr:
2200 FT_TRACE4((
" callgsubr (idx %d, entering level %d)\n",
2206 FT_ERROR((
"cff_decoder_parse_charstrings:"
2207 " invalid global subr index\n" ));
2213 FT_ERROR((
"cff_decoder_parse_charstrings:"
2214 " too many nested subrs\n" ));
2227 FT_ERROR((
"cff_decoder_parse_charstrings:"
2228 " invoking empty subrs\n" ));
2239 FT_TRACE4((
" return (leaving level %d)\n",
2244 FT_ERROR((
"cff_decoder_parse_charstrings:"
2245 " unexpected return\n" ));
2256 FT_ERROR((
"Unimplemented opcode: %d",
ip[-1] ));
2262 return FT_THROW( Unimplemented_Feature );
2268 goto Stack_Overflow;
2280 FT_TRACE4((
"cff_decoder_parse_charstrings:"
2281 " invalid opcode found in top DICT charstring\n"));
2282 return FT_THROW( Invalid_File_Format );
2285 FT_TRACE4((
"cff_decoder_parse_charstrings: syntax error\n" ));
2286 return FT_THROW( Invalid_File_Format );
2289 FT_TRACE4((
"cff_decoder_parse_charstrings: stack underflow\n" ));
2290 return FT_THROW( Too_Few_Arguments );
2293 FT_TRACE4((
"cff_decoder_parse_charstrings: stack overflow\n" ));
2355 decoder->hint_mode = hint_mode;
2358 decoder->free_glyph_callback = free_callback;
2374 FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)
cff->
cffload;
2386 FT_TRACE4((
"cff_decoder_prepare: invalid CID subfont index\n" ));
2391 FT_TRACE3((
" in subfont %d:\n", fd_index ));
2406 decoder->num_locals = sub->local_subrs_index.count;
2407 decoder->locals = sub->local_subrs;
2409 decoder->cff->top_font.font_dict.charstring_type,
2412 decoder->glyph_width = sub->private_dict.default_width;
2413 decoder->nominal_width = sub->private_dict.nominal_width;
2415 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
GLuint GLuint GLsizei count
GLint GLint GLint GLint GLint GLint y
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_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