21#include FT_INTERNAL_DEBUG_H
22#include FT_INTERNAL_SERVICE_H
23#include FT_SERVICE_CFF_TABLE_LOAD_H
38#define FT_COMPONENT 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,
317 decoder->free_glyph_callback(
face, &charstring, charstring_len );
328 glyph_width =
decoder->glyph_width;
333 builder->
pos_x = adx - asb;
334 builder->
pos_y = ady;
338 &charstring, &charstring_len );
343 error = cff_decoder_parse_charstrings(
decoder, charstring,
347 decoder->free_glyph_callback(
face, &charstring, charstring_len );
357 decoder->glyph_width = glyph_width;
408 if ( in_charstring_type == 1 )
410 else if ( num_subrs < 1240 )
412 else if ( num_subrs < 33900U )
428 FT_Service_CFFLoad cffload;
436 if ( charcode < 0 || charcode > 255 )
441 FT_Service_CFFLoad cffload;
447 FT_ERROR((
"cff_lookup_glyph_by_stdcharcode:"
448 " the `cffload' module is not available\n" ));
449 return FT_THROW( Unimplemented_Feature );
456 glyph_sid = cffload->get_standard_encoding( (
FT_UInt)charcode );
468#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
510 decoder->cff->top_font.font_dict.charstring_type;
512 decoder->cff->top_font.font_dict.num_designs;
514 decoder->cff->top_font.font_dict.num_axes;
533 zone->base = charstring_base;
534 limit =
zone->limit = charstring_base + charstring_len;
558 if (
v >= 32 ||
v == 28 )
576 val = (FT_Int32)
v - 139;
581 val = ( (FT_Int32)
v - 247 ) * 256 + *
ip++ + 108;
587 val = -( (FT_Int32)
v - 251 ) * 256 - *
ip++ - 108;
593 val = (FT_Int32)( ( (FT_UInt32)
ip[0] << 24 ) |
594 ( (FT_UInt32)
ip[1] << 16 ) |
595 ( (FT_UInt32)
ip[2] << 8 ) |
598 if ( charstring_type == 2 )
607#ifdef FT_DEBUG_LEVEL_TRACE
608 if ( !(
val & 0xFFFFL ) )
651 op = cff_op_rrcurveto;
654 op = cff_op_closepath;
657 op = cff_op_callsubr;
670 op = cff_op_dotsection;
718 op = cff_op_callothersubr;
757 op = cff_op_setcurrentpoint;
789 op = cff_op_hintmask;
792 op = cff_op_cntrmask;
804 op = cff_op_rcurveline;
807 op = cff_op_rlinecurve;
810 op = cff_op_vvcurveto;
813 op = cff_op_hhcurveto;
816 op = cff_op_callgsubr;
819 op = cff_op_vhcurveto;
822 op = cff_op_hvcurveto;
829 if (
op == cff_op_unknown )
844 case cff_op_rrcurveto:
846 case cff_op_hintmask:
847 case cff_op_cntrmask:
851 case cff_op_rcurveline:
852 case cff_op_rlinecurve:
853 case cff_op_vvcurveto:
854 case cff_op_hhcurveto:
855 case cff_op_vhcurveto:
856 case cff_op_hvcurveto:
861 case cff_op_callsubr:
862 case cff_op_callgsubr:
864 case cff_op_dotsection:
867 case cff_op_closepath:
868 case cff_op_callothersubr:
871 case cff_op_setcurrentpoint:
880 req_args = cff_argument_counts[
op];
881 if ( req_args & CFF_COUNT_CHECK_WIDTH )
883 if ( num_args > 0 &&
decoder->read_width )
900 set_width_ok = num_args & 2;
908 case cff_op_hintmask:
909 case cff_op_cntrmask:
910 set_width_ok = num_args & 1;
916 set_width_ok = in_dict
918 : ( ( num_args == 5 ) || ( num_args == 1 ) );
947 if ( num_args < req_args )
948 goto Stack_Underflow;
950 num_args -= req_args;
968 op == cff_op_hstem ?
" hstem" :
969 (
op == cff_op_vstem ?
" vstem" :
970 (
op == cff_op_hstemhm ?
" hstemhm" :
" vstemhm" ) ) ));
974 (
op == cff_op_hstem ||
op == cff_op_hstemhm ),
976 args - ( num_args & ~1 ) );
978 decoder->num_hints += num_args / 2;
982 case cff_op_hintmask:
983 case cff_op_cntrmask:
984 FT_TRACE4((
"%s",
op == cff_op_hintmask ?
" hintmask"
997 args - ( num_args & ~1 ) );
999 decoder->num_hints += num_args / 2;
1012 if (
op == cff_op_hintmask )
1023#ifdef FT_DEBUG_LEVEL_TRACE
1043 case cff_op_rmoveto:
1053 case cff_op_vmoveto:
1062 case cff_op_hmoveto:
1071 case cff_op_rlineto:
1079 goto Stack_Underflow;
1081 args -= num_args & ~1;
1082 while ( args < decoder->
top )
1092 case cff_op_hlineto:
1093 case cff_op_vlineto:
1095 FT_Int phase = (
op == cff_op_hlineto );
1098 FT_TRACE4((
"%s\n",
op == cff_op_hlineto ?
" hlineto"
1102 goto Stack_Underflow;
1106 if ( num_args == 0 )
1114 while ( args < decoder->
top )
1131 case cff_op_rrcurveto:
1139 goto Stack_Underflow;
1141 nargs = num_args - num_args % 6;
1148 while ( args < decoder->
top )
1168 case cff_op_vvcurveto:
1176 goto Stack_Underflow;
1181 nargs = num_args & ~2;
1198 while ( args < decoder->
top )
1216 case cff_op_hhcurveto:
1224 goto Stack_Underflow;
1229 nargs = num_args & ~2;
1245 while ( args < decoder->
top )
1263 case cff_op_vhcurveto:
1264 case cff_op_hvcurveto:
1270 FT_TRACE4((
"%s\n",
op == cff_op_vhcurveto ?
" vhcurveto"
1277 goto Stack_Underflow;
1282 nargs = num_args & ~2;
1286 goto Stack_Underflow;
1288 phase = (
op == cff_op_hvcurveto );
1290 while ( nargs >= 4 )
1328 case cff_op_rlinecurve:
1337 goto Stack_Underflow;
1339 nargs = num_args & ~1;
1376 case cff_op_rcurveline:
1385 goto Stack_Underflow;
1387 nargs = num_args - 2;
1388 nargs = nargs - nargs % 6 + 2;
1389 num_curves = ( nargs - 2 ) / 6;
1398 while ( num_curves > 0 )
1564 horizontal = (
dx >
dy );
1632 case cff_op_endchar:
1640 if ( num_args >= 4 )
1651 decoder->glyph_width = glyph_width;
1726 FT_UInt32* randval = in_dict ? &
decoder->cff->top_font.random
1727 : &
decoder->current_subfont->random;
1752 if (
args[0] > 0x7FFFFFFFL )
1754 else if (
args[0] > 0 )
1763 if ( new_root ==
root )
1803 else if (
idx > num_args - 2 )
1823 goto Stack_Underflow;
1925 if ( reg_idx >= 0 && reg_idx <= 2 &&
1953 if ( num_results < 0 )
1956 if ( num_results > num_args ||
1957 num_results * (
FT_Int)num_designs > num_args )
1958 goto Stack_Underflow;
1963 args -= num_results * ( num_designs - 1 );
1964 num_args -= num_results * ( num_designs - 1 );
1970 case cff_op_dotsection:
1975 case cff_op_closepath:
1980 FT_TRACE4((
" closepath (invalid op)\n" ));
1996 decoder->builder.left_bearing.y = 0;
2021 case cff_op_setcurrentpoint:
2026 FT_TRACE4((
" setcurrentpoint (invalid op)\n" ));
2033 case cff_op_callothersubr:
2043 FT_TRACE4((
" callothersubr (invalid op)\n" ));
2053 goto Stack_Underflow;
2057 goto Stack_Underflow;
2094 args[0] = cond ? 0x10000L : 0;
2106 args[0] = cond ? 0x10000L : 0;
2118 args[0] = cond ? 0x10000L : 0;
2130 args[0] = cond ? 0x10000L : 0;
2148 case cff_op_callsubr:
2154 FT_TRACE4((
" callsubr (idx %d, entering level %d)\n",
2160 FT_ERROR((
"cff_decoder_parse_charstrings:"
2161 " invalid local 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" ));
2192 case cff_op_callgsubr:
2198 FT_TRACE4((
" callgsubr (idx %d, entering level %d)\n",
2204 FT_ERROR((
"cff_decoder_parse_charstrings:"
2205 " invalid global subr index\n" ));
2211 FT_ERROR((
"cff_decoder_parse_charstrings:"
2212 " too many nested subrs\n" ));
2225 FT_ERROR((
"cff_decoder_parse_charstrings:"
2226 " invoking empty subrs\n" ));
2237 FT_TRACE4((
" return (leaving level %d)\n",
2242 FT_ERROR((
"cff_decoder_parse_charstrings:"
2243 " unexpected return\n" ));
2254 FT_ERROR((
"Unimplemented opcode: %d",
ip[-1] ));
2260 return FT_THROW( Unimplemented_Feature );
2266 goto Stack_Overflow;
2278 FT_TRACE4((
"cff_decoder_parse_charstrings:"
2279 " invalid opcode found in top DICT charstring\n"));
2280 return FT_THROW( Invalid_File_Format );
2283 FT_TRACE4((
"cff_decoder_parse_charstrings: syntax error\n" ));
2284 return FT_THROW( Invalid_File_Format );
2287 FT_TRACE4((
"cff_decoder_parse_charstrings: stack underflow\n" ));
2288 return FT_THROW( Too_Few_Arguments );
2291 FT_TRACE4((
"cff_decoder_parse_charstrings: stack overflow\n" ));
2353 decoder->hint_mode = hint_mode;
2356 decoder->free_glyph_callback = free_callback;
2372 FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)
cff->
cffload;
2384 FT_TRACE4((
"cff_decoder_prepare: invalid CID subfont index\n" ));
2389 FT_TRACE3((
" in subfont %d:\n", fd_index ));
2404 decoder->num_locals = sub->local_subrs_index.count;
2405 decoder->locals = sub->local_subrs;
2407 decoder->cff->top_font.font_dict.charstring_type,
2410 decoder->glyph_width = sub->private_dict.default_width;
2411 decoder->nominal_width = sub->private_dict.nominal_width;
2413 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