20 #include FT_INTERNAL_DEBUG_H 21 #include FT_INTERNAL_STREAM_H 22 #include FT_INTERNAL_SFNT_H 24 #include FT_CFF_DRIVER_H 41 #define FT_COMPONENT trace_cffgload 127 #define CFF_COUNT_CHECK_WIDTH 0x80 128 #define CFF_COUNT_EXACT 0x40 129 #define CFF_COUNT_CLEAR_STACK 0x20 137 static const FT_Byte cff_argument_counts[] =
259 builder->
glyph = glyph;
268 builder->
base = &loader->base.outline;
269 builder->
current = &loader->current.outline;
275 if ( hinting && size )
337 cff_compute_bias(
FT_Int in_charstring_type,
343 if ( in_charstring_type == 1 )
345 else if ( num_subrs < 1240 )
347 else if ( num_subrs < 33900U )
393 cff_builder_init( &decoder->builder, face, size, slot, hinting );
399 decoder->globals_bias = cff_compute_bias(
401 decoder->num_globals );
403 decoder->hint_mode = hint_mode;
428 FT_TRACE4((
"cff_decoder_prepare: invalid CID subfont index\n" ));
433 FT_TRACE3((
"glyph index %d (subfont %d):\n", glyph_index, fd_index ));
443 builder->
hints_globals = (
void *)
internal->subfonts[fd_index];
446 #ifdef FT_DEBUG_LEVEL_TRACE 448 FT_TRACE3((
"glyph index %d:\n", glyph_index ));
451 decoder->num_locals = sub->local_subrs_index.count;
452 decoder->locals = sub->local_subrs;
453 decoder->locals_bias = cff_compute_bias(
454 decoder->cff->top_font.font_dict.charstring_type,
455 decoder->num_locals );
457 decoder->glyph_width = sub->private_dict.default_width;
458 decoder->nominal_width = sub->private_dict.nominal_width;
460 decoder->current_subfont = sub;
570 error = cff_builder_add_contour( builder );
604 if ( p1->
x == p2->
x && p1->
y == p2->
y )
638 if ( charcode < 0 || charcode > 255 )
660 #ifdef FT_CONFIG_OPTION_INCREMENTAL 667 face->
root.
internal->incremental_interface->funcs->get_glyph_data(
669 glyph_index, &data );
695 #ifndef FT_CONFIG_OPTION_INCREMENTAL 699 #ifdef FT_CONFIG_OPTION_INCREMENTAL 710 face->
root.
internal->incremental_interface->funcs->free_glyph_data(
711 face->
root.
internal->incremental_interface->object, &data );
735 FT_Int bchar_index, achar_index;
745 FT_ERROR((
"cff_operator_seac: invalid nested seac\n" ));
752 #ifdef FT_CONFIG_OPTION_INCREMENTAL 770 if ( bchar_index < 0 || achar_index < 0 )
773 " invalid seac character code arguments\n" ));
791 subg = loader->current.subglyphs;
794 subg->index = bchar_index;
802 subg->index = achar_index;
804 subg->arg1 = (
FT_Int)( adx >> 16 );
805 subg->arg2 = (
FT_Int)( ady >> 16 );
809 glyph->
subglyphs = loader->base.subglyphs;
810 glyph->
format = FT_GLYPH_FORMAT_COMPOSITE;
812 loader->current.num_subglyphs = 2;
819 &charstring, &charstring_len );
844 builder->
pos_x = adx - asb;
845 builder->
pos_y = ady;
849 &charstring, &charstring_len );
925 seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
932 zone = decoder->
zones;
933 stack = decoder->
top;
939 zone->
base = charstring_base;
940 limit = zone->
limit = charstring_base + charstring_len;
964 if ( v >= 32 || v == 28 )
976 if ( ip + 1 >=
limit )
987 val = ( (
FT_Int32)v - 247 ) * 256 + *ip++ + 108;
993 val = -( (
FT_Int32)v - 251 ) * 256 - *ip++ - 108;
997 if ( ip + 3 >=
limit )
1004 if ( charstring_type == 2 )
1008 goto Stack_Overflow;
1013 #ifdef FT_DEBUG_LEVEL_TRACE 1014 if ( !( val & 0xFFFFL ) )
1179 FT_TRACE4((
" unknown op (12, %d)\n", v ));
1241 req_args = cff_argument_counts[op];
1261 set_width_ok = num_args & 2;
1271 set_width_ok = num_args & 1;
1277 set_width_ok = ( num_args == 5 ) || ( num_args == 1 );
1306 if ( num_args < req_args )
1307 goto Stack_Underflow;
1309 num_args -= req_args;
1335 args - ( num_args & ~1 ) );
1355 args - ( num_args & ~1 ) );
1381 #ifdef FT_DEBUG_LEVEL_TRACE 1437 goto Stack_Underflow;
1439 args -= num_args & ~1;
1440 while ( args < decoder->
top )
1460 goto Stack_Underflow;
1464 if ( num_args == 0 )
1472 while ( args < decoder->top )
1497 goto Stack_Underflow;
1499 nargs = num_args - num_args % 6;
1506 while ( args < decoder->top )
1531 goto Stack_Underflow;
1536 nargs = num_args & ~2;
1553 while ( args < decoder->top )
1576 goto Stack_Underflow;
1581 nargs = num_args & ~2;
1597 while ( args < decoder->top )
1620 :
" hvcurveto\n" ));
1626 goto Stack_Underflow;
1631 nargs = num_args & ~2;
1635 goto Stack_Underflow;
1639 while ( nargs >= 4 )
1682 goto Stack_Underflow;
1684 nargs = num_args & ~1;
1685 num_lines = ( nargs - 6 ) / 2;
1694 while ( num_lines > 0 )
1726 goto Stack_Underflow;
1728 nargs = num_args - 2;
1729 nargs = nargs - nargs % 6 + 2;
1730 num_curves = ( nargs - 2 ) / 6;
1739 while ( num_curves > 0 )
1888 for ( count = 5; count > 0; count-- )
1901 horizontal = ( dx > dy );
1903 for ( count = 5; count > 0; count-- )
1941 for ( count = 6; count > 0; count-- )
1946 (
FT_Bool)( count == 4 || count == 1 ) );
1957 error = cff_operator_seac( decoder,
1958 args[0], args[1], args[2],
1959 (
FT_Int)( args[3] >> 16 ),
1960 (
FT_Int)( args[4] >> 16 ) );
1973 if ( num_args >= 4 )
1979 error = cff_operator_seac( decoder,
1980 0L, args[-4], args[-3],
1981 (
FT_Int)( args[-2] >> 16 ),
1982 (
FT_Int)( args[-1] >> 16 ) );
2040 args[0] =
FT_DivFix( args[0], args[1] );
2059 if ( Rand >= 0x8000L )
2063 seed =
FT_MulFix( seed, 0x10000L - seed );
2073 args[0] =
FT_MulFix( args[0], args[1] );
2089 new_root = ( root +
FT_DivFix( args[0], root ) + 1 ) >> 1;
2090 if ( new_root == root || count <= 0 )
2130 else if ( idx > num_args - 2 )
2132 args[0] = args[-( idx + 1 )];
2150 goto Stack_Underflow;
2160 for ( i = count - 2; i >= 0; i-- )
2161 args[i + 1] = args[i];
2174 for ( i = 0; i < count - 1; i++ )
2175 args[i] = args[i + 1];
2176 args[count - 1] = tmp;
2240 FT_TRACE4((
" closepath (invalid op)\n" ));
2284 FT_TRACE4((
" setcurrentpoint (invalid op)\n" ));
2296 FT_TRACE4((
" callothersubr (invalid op)\n" ));
2303 args -= 2 + ( args[-2] >> 16 );
2305 goto Stack_Underflow;
2336 FT_Fixed cond = args[0] && args[1];
2341 args[0] = cond ? 0x10000L : 0;
2348 FT_Fixed cond = args[0] || args[1];
2353 args[0] = cond ? 0x10000L : 0;
2365 args[0] = cond ? 0x10000L : 0;
2372 FT_Fixed cond = ( args[2] <= args[3] );
2393 FT_ERROR((
"cff_decoder_parse_charstrings:" 2394 " invalid local subr index\n" ));
2400 FT_ERROR((
"cff_decoder_parse_charstrings:" 2401 " too many nested subrs\n" ));
2414 FT_ERROR((
"cff_decoder_parse_charstrings:" 2415 " invoking empty subrs\n" ));
2419 decoder->
zone = zone;
2435 FT_ERROR((
"cff_decoder_parse_charstrings:" 2436 " invalid global subr index\n" ));
2442 FT_ERROR((
"cff_decoder_parse_charstrings:" 2443 " too many nested subrs\n" ));
2456 FT_ERROR((
"cff_decoder_parse_charstrings:" 2457 " invoking empty subrs\n" ));
2461 decoder->
zone = zone;
2472 FT_ERROR((
"cff_decoder_parse_charstrings:" 2473 " unexpected return\n" ));
2478 zone = decoder->
zone;
2485 FT_ERROR((
"Unimplemented opcode: %d", ip[-1] ));
2491 return FT_THROW( Unimplemented_Feature );
2494 decoder->
top = args;
2497 goto Stack_Overflow;
2509 FT_TRACE4((
"cff_decoder_parse_charstrings: syntax error\n" ));
2510 return FT_THROW( Invalid_File_Format );
2513 FT_TRACE4((
"cff_decoder_parse_charstrings: stack underflow\n" ));
2514 return FT_THROW( Too_Few_Arguments );
2517 FT_TRACE4((
"cff_decoder_parse_charstrings: stack overflow\n" ));
2544 cff_compute_max_advance(
TT_Face face,
2572 &charstring, &charstring_len );
2606 FT_Bool hinting, scaled, force_scaling;
2613 force_scaling =
FALSE;
2622 if ( glyph_index != 0 )
2626 if ( glyph_index == 0 )
2627 return FT_THROW( Invalid_Argument );
2631 return FT_THROW( Invalid_Argument );
2644 #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS 2664 error = sfnt->load_sbit_image( face,
2714 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS 2726 if ( has_vertical_info )
2754 return FT_THROW( Invalid_Argument );
2777 if ( top_upm != sub_upm )
2782 force_scaling =
TRUE;
2799 glyph->
hint = hinting;
2821 &charstring, &charstring_len );
2823 goto Glyph_Build_Finished;
2827 goto Glyph_Build_Finished;
2846 goto Glyph_Build_Finished;
2848 #ifdef FT_CONFIG_OPTION_INCREMENTAL 2866 if ( csindex->offsets )
2869 csindex->offsets[glyph_index] - 1;
2874 Glyph_Build_Finished:
2877 cff_builder_done( &decoder.
builder );
2881 #ifdef FT_CONFIG_OPTION_INCREMENTAL 2886 face->
root.
internal->incremental_interface->funcs->get_glyph_metrics )
2898 glyph_index,
FALSE, &metrics );
2922 internal->glyph_matrix = font_matrix;
2923 internal->glyph_delta = font_offset;
2924 internal->glyph_transformed = 1;
2939 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS 2949 if ( has_vertical_info )
2959 metrics->vertBearingY = vertBearingY;
2960 metrics->vertAdvance = vertAdvance;
2983 if ( !( font_matrix.
xx == 0x10000L &&
2984 font_matrix.
yy == 0x10000L &&
2985 font_matrix.
xy == 0 &&
2986 font_matrix.
yx == 0 ) )
2989 if ( !( font_offset.
x == 0 &&
2990 font_offset.
y == 0 ) )
2992 font_offset.
x, font_offset.
y );
2994 advance.
x = metrics->horiAdvance;
2997 metrics->horiAdvance = advance.
x + font_offset.
x;
3000 advance.
y = metrics->vertAdvance;
3002 metrics->vertAdvance = advance.
y + font_offset.
y;
3016 for ( n = cur->
n_points; n > 0; n--, vec++ )
3023 metrics->horiAdvance =
FT_MulFix( metrics->horiAdvance, x_scale );
3024 metrics->vertAdvance =
FT_MulFix( metrics->vertAdvance, y_scale );
3030 metrics->width = cbox.
xMax - cbox.
xMin;
3031 metrics->height = cbox.
yMax - cbox.
yMin;
3033 metrics->horiBearingX = cbox.
xMin;
3034 metrics->horiBearingY = cbox.
yMax;
3036 if ( has_vertical_info )
3037 metrics->vertBearingX = metrics->horiBearingX -
3038 metrics->horiAdvance / 2;
3043 metrics->vertAdvance );
GLenum GLuint GLenum GLsizei length
cff_builder_close_contour(CFF_Builder *builder)
typedefFT_BEGIN_HEADER struct PSH_GlobalsRec_ * PSH_Globals
cff_get_standard_encoding(FT_UInt charcode)
#define FT_LOAD_VERTICAL_LAYOUT
FT_DivFix(FT_Long a, FT_Long b)
SFNT_Interface * SFNT_Service
#define FT_LOAD_SBITS_ONLY
FT_BEGIN_HEADER typedef signed long FT_Pos
#define CFF_MAX_TRANS_ELEMENTS
ft_synthesize_vertical_metrics(FT_Glyph_Metrics *metrics, FT_Pos advance)
#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES
cff_get_glyph_data(TT_Face face, FT_UInt glyph_index, FT_Byte **pointer, FT_ULong *length)
#define FT_MEM_ZERO(dest, count)
#define FT_SUBGLYPH_FLAG_USE_MY_METRICS
#define CFF_MAX_SUBRS_CALLS
#define FT_CURVE_TAG_CUBIC
GLint GLint GLint GLint GLint GLint y
GLsizei const GLvoid * pointer
enum FT_Render_Mode_ FT_Render_Mode
cff_builder_add_point1(CFF_Builder *builder, FT_Pos x, FT_Pos y)
#define FT_LOAD_NO_HINTING
return FT_THROW(Missing_Property)
FT_Fixed stack[CFF_MAX_OPERANDS+1]
struct CFF_FontRec_ * CFF_Font
JSAMPARRAY JDIMENSION num_lines
cff_lookup_glyph_by_stdcharcode(CFF_Font cff, FT_Int charcode)
#define FT_LOAD_NO_RECURSE
CFF_SubFont subfonts[CFF_MAX_CID_FONTS]
CFF_IndexRec global_subrs_index
FT_Fixed linearHoriAdvance
GLint GLint GLint GLint GLint x
#define FT_LOAD_ADVANCE_ONLY
cff_decoder_parse_charstrings(CFF_Decoder *decoder, FT_Byte *charstring_base, FT_ULong charstring_len)
#define FT_FACE_DRIVER(x)
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FT_Face_Internal internal
GLenum GLuint GLint GLenum face
typedefFT_BEGIN_HEADER struct FT_GlyphLoaderRec_ * FT_GlyphLoader
#define FT_ERROR(varformat)
#define FT_CFF_HINTING_FREETYPE
cff_fd_select_get(CFF_FDSelect fdselect, FT_UInt glyph_index)
cff_index_access_element(CFF_Index idx, FT_UInt element, FT_Byte **pbytes, FT_ULong *pbyte_len)
struct CFF_InternalRec_ * CFF_Internal
FT_Size_Internal internal
#define FT_TRACE4(varformat)
FT_Bool glyph_transformed
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
FT_GlyphLoader_Add(FT_GlyphLoader loader)
CFF_FontRecDictRec font_dict
cff_decoder_prepare(CFF_Decoder *decoder, CFF_Size size, FT_UInt glyph_index)
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
cff_decoder_init(CFF_Decoder *decoder, TT_Face face, CFF_Size size, CFF_GlyphSlot slot, FT_Bool hinting, FT_Render_Mode hint_mode)
struct TT_FaceRec_ * TT_Face
#define CFF_COUNT_CHECK_WIDTH
T2_Hints_CounterFunc counter
CFF_FDSelectRec fd_select
FT_GlyphLoader_CheckSubGlyphs(FT_GlyphLoader loader, FT_UInt n_subs)
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
GLsizei GLsizei GLenum GLenum const GLvoid * data
#define FT_OUTLINE_HIGH_PRECISION
CFF_Decoder_Zone zones[CFF_MAX_SUBRS_CALLS+1]
#define CFF_COUNT_CLEAR_STACK
cff_slot_load(CFF_GlyphSlot glyph, CFF_Size size, FT_UInt glyph_index, FT_Int32 load_flags)
cff_check_points(CFF_Builder *builder, FT_Int count)
FT_MulFix(FT_Long a, FT_Long b)
if(!abbox) return FT_THROW(Invalid_Argument)
FT_Fixed buildchar[CFF_MAX_TRANS_ELEMENTS]
#define FT_TRACE3(varformat)
cff_builder_add_point(CFF_Builder *builder, FT_Pos x, FT_Pos y, FT_Byte flag)
GLdouble GLdouble GLdouble GLdouble top
FT_Vector_Transform(FT_Vector *vec, const FT_Matrix *matrix)
FT_BEGIN_HEADER struct FT_Glyph_Metrics_ FT_Glyph_Metrics
typedefFT_BEGIN_HEADER struct CFF_DriverRec_ * CFF_Driver
struct FT_GlyphSlotRec_ * FT_GlyphSlot
FT_GlyphLoader_Rewind(FT_GlyphLoader loader)
FT_Slot_Internal internal
cff_charset_cid_to_gindex(CFF_Charset charset, FT_UInt cid)
FT_Fixed linearVertAdvance
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
FT_GlyphLoader_Prepare(FT_GlyphLoader loader)
GLuint GLuint GLsizei count
CFF_IndexRec charstrings_index
#define FT_CFF_HINTING_ADOBE
GLsizei GLenum const GLvoid GLuint GLsizei GLfloat * metrics
#define FT_LOAD_NO_BITMAP
png_infop png_uint_32 flag
#define FT_GLYPHLOADER_CHECK_POINTS(_loader, _points, _contours)
enum CFF_Operator_ CFF_Operator
cff_free_glyph_data(TT_Face face, FT_Byte **pointer, FT_ULong length)
cf2_decoder_parse_charstrings(CFF_Decoder *decoder, FT_Byte *charstring_base, FT_ULong charstring_len)
const struct T2_Hints_FuncsRec_ * T2_Hints_Funcs
FT_Module_Constructor FT_GLYPH_FORMAT_OUTLINE
cff_index_forget_element(CFF_Index idx, FT_Byte **pbytes)
T2_Hints_MaskFunc hintmask
cff_builder_start_point(CFF_Builder *builder, FT_Pos x, FT_Pos y)
#define FT_OUTLINE_REVERSE_FILL
FT_BEGIN_HEADER struct CFF_IndexRec_ * CFF_Index
#define FT_LOAD_TARGET_MODE(x)