From 1ee02cd0419021c3d4950af2619da39c6e9c47f0 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 21 Dec 2009 15:22:51 +0000 Subject: Updated to freetype-2.3.11 --- freetype/src/truetype/Jamfile | 2 +- freetype/src/truetype/truetype.c | 1 + freetype/src/truetype/ttdriver.c | 79 +++++++++++++++--------------- freetype/src/truetype/ttdriver.h | 2 +- freetype/src/truetype/ttgload.c | 103 ++++++++++++++++++++++----------------- freetype/src/truetype/ttgxvar.c | 74 +++++++++++++++------------- freetype/src/truetype/ttgxvar.h | 2 +- freetype/src/truetype/ttinterp.c | 54 ++++++++++++-------- freetype/src/truetype/ttobjs.c | 20 +++----- freetype/src/truetype/ttobjs.h | 38 ++------------- freetype/src/truetype/ttpic.c | 79 ++++++++++++++++++++++++++++++ freetype/src/truetype/ttpic.h | 59 ++++++++++++++++++++++ freetype/src/truetype/ttpload.c | 34 ++++++------- 13 files changed, 343 insertions(+), 204 deletions(-) create mode 100644 freetype/src/truetype/ttpic.c create mode 100644 freetype/src/truetype/ttpic.h (limited to 'freetype/src/truetype') diff --git a/freetype/src/truetype/Jamfile b/freetype/src/truetype/Jamfile index a166909f4..a8cccfe13 100644 --- a/freetype/src/truetype/Jamfile +++ b/freetype/src/truetype/Jamfile @@ -16,7 +16,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) truetype ; if $(FT2_MULTI) { - _sources = ttdriver ttobjs ttpload ttgload ttinterp ttgxvar ; + _sources = ttdriver ttobjs ttpload ttgload ttinterp ttgxvar ttpic ; } else { diff --git a/freetype/src/truetype/truetype.c b/freetype/src/truetype/truetype.c index b36473a72..4bd120978 100644 --- a/freetype/src/truetype/truetype.c +++ b/freetype/src/truetype/truetype.c @@ -19,6 +19,7 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT #include +#include "ttpic.c" #include "ttdriver.c" /* driver interface */ #include "ttpload.c" /* tables loader */ #include "ttgload.c" /* glyph loader */ diff --git a/freetype/src/truetype/ttdriver.c b/freetype/src/truetype/ttdriver.c index 42feb05ed..dca009a10 100644 --- a/freetype/src/truetype/ttdriver.c +++ b/freetype/src/truetype/ttdriver.c @@ -4,7 +4,7 @@ /* */ /* TrueType font driver implementation (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,7 +20,6 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H -#include FT_TRUETYPE_IDS_H #include FT_SERVICE_XFREE86_NAME_H #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT @@ -41,6 +40,7 @@ #include "tterrors.h" +#include "ttpic.h" /*************************************************************************/ /* */ @@ -344,14 +344,13 @@ /*************************************************************************/ #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - static const FT_Service_MultiMastersRec tt_service_gx_multi_masters = - { + FT_DEFINE_SERVICE_MULTIMASTERSREC(tt_service_gx_multi_masters, (FT_Get_MM_Func) NULL, (FT_Set_MM_Design_Func) NULL, (FT_Set_MM_Blend_Func) TT_Set_MM_Blend, (FT_Get_MM_Var_Func) TT_Get_MM_Var, (FT_Set_Var_Design_Func)TT_Set_Var_Design - }; + ) #endif static const FT_Service_TrueTypeEngineRec tt_service_truetype_engine = @@ -371,33 +370,36 @@ #endif /* TT_USE_BYTECODE_INTERPRETER */ }; - static const FT_Service_TTGlyfRec tt_service_truetype_glyf = - { + FT_DEFINE_SERVICE_TTGLYFREC(tt_service_truetype_glyf, (TT_Glyf_GetLocationFunc)tt_face_get_location - }; + ) - static const FT_ServiceDescRec tt_services[] = - { - { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE }, #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - { FT_SERVICE_ID_MULTI_MASTERS, &tt_service_gx_multi_masters }, + FT_DEFINE_SERVICEDESCREC4(tt_services, + FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE, + FT_SERVICE_ID_MULTI_MASTERS, &FT_TT_SERVICE_GX_MULTI_MASTERS_GET, + FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, + FT_SERVICE_ID_TT_GLYF, &FT_TT_SERVICE_TRUETYPE_GLYF_GET + ) +#else + FT_DEFINE_SERVICEDESCREC3(tt_services, + FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TRUETYPE, + FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine, + FT_SERVICE_ID_TT_GLYF, &FT_TT_SERVICE_TRUETYPE_GLYF_GET + ) #endif - { FT_SERVICE_ID_TRUETYPE_ENGINE, &tt_service_truetype_engine }, - { FT_SERVICE_ID_TT_GLYF, &tt_service_truetype_glyf }, - { NULL, NULL } - }; - FT_CALLBACK_DEF( FT_Module_Interface ) tt_get_interface( FT_Module driver, /* TT_Driver */ const char* tt_interface ) { + FT_Library library = driver->library; FT_Module_Interface result; FT_Module sfntd; SFNT_Service sfnt; + FT_UNUSED(library); - - result = ft_service_list_lookup( tt_services, tt_interface ); + result = ft_service_list_lookup( FT_TT_SERVICES_GET, tt_interface ); if ( result != NULL ) return result; @@ -416,18 +418,25 @@ /* The FT_DriverInterface structure is defined in ftdriver.h. */ - FT_CALLBACK_TABLE_DEF - const FT_Driver_ClassRec tt_driver_class = - { - { - FT_MODULE_FONT_DRIVER | - FT_MODULE_DRIVER_SCALABLE | #ifdef TT_USE_BYTECODE_INTERPRETER - FT_MODULE_DRIVER_HAS_HINTER, +#define TT_HINTER_FLAG FT_MODULE_DRIVER_HAS_HINTER #else - 0, +#define TT_HINTER_FLAG 0 #endif +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS +#define TT_SIZE_SELECT tt_size_select +#else +#define TT_SIZE_SELECT 0 +#endif + + FT_DEFINE_DRIVER(tt_driver_class, + + + FT_MODULE_FONT_DRIVER | + FT_MODULE_DRIVER_SCALABLE | + TT_HINTER_FLAG, + sizeof ( TT_DriverRec ), "truetype", /* driver name */ @@ -439,7 +448,6 @@ tt_driver_init, tt_driver_done, tt_get_interface, - }, sizeof ( TT_FaceRec ), sizeof ( TT_SizeRec ), @@ -452,10 +460,9 @@ tt_slot_init, 0, /* FT_Slot_DoneFunc */ -#ifdef FT_CONFIG_OPTION_OLD_INTERNALS - ft_stub_set_char_sizes, - ft_stub_set_pixel_sizes, -#endif + ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ + ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ + Load_Glyph, tt_get_kerning, @@ -463,12 +470,8 @@ tt_get_advances, tt_size_request, -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - tt_size_select -#else - 0 /* FT_Size_SelectFunc */ -#endif - }; + TT_SIZE_SELECT + ) /* END */ diff --git a/freetype/src/truetype/ttdriver.h b/freetype/src/truetype/ttdriver.h index f6f26e4b5..aae00f261 100644 --- a/freetype/src/truetype/ttdriver.h +++ b/freetype/src/truetype/ttdriver.h @@ -27,7 +27,7 @@ FT_BEGIN_HEADER - FT_EXPORT_VAR( const FT_Driver_ClassRec ) tt_driver_class; + FT_DECLARE_DRIVER( tt_driver_class ) FT_END_HEADER diff --git a/freetype/src/truetype/ttgload.c b/freetype/src/truetype/ttgload.c index 06e9ccd1d..28ddb9955 100644 --- a/freetype/src/truetype/ttgload.c +++ b/freetype/src/truetype/ttgload.c @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -317,7 +317,7 @@ if ( n_ins > face->max_profile.maxSizeOfInstructions ) { - FT_TRACE0(( "TT_Load_Simple_Glyph: Too many instructions (%d)\n", + FT_TRACE0(( "TT_Load_Simple_Glyph: too many instructions (%d)\n", n_ins )); error = TT_Err_Too_Many_Hints; goto Fail; @@ -325,7 +325,7 @@ if ( ( limit - p ) < n_ins ) { - FT_TRACE0(( "TT_Load_Simple_Glyph: Instruction count mismatch!\n" )); + FT_TRACE0(( "TT_Load_Simple_Glyph: instruction count mismatch\n" )); error = TT_Err_Too_Many_Hints; goto Fail; } @@ -633,7 +633,13 @@ #ifdef TT_USE_BYTECODE_INTERPRETER - n_ins = loader->glyph->control_len; + if ( loader->glyph->control_len > 0xFFFFL ) + { + FT_TRACE1(( "TT_Hint_Glyph: too long instructions " )); + FT_TRACE1(( "(0x%lx byte) is truncated\n", + loader->glyph->control_len )); + } + n_ins = (FT_UInt)( loader->glyph->control_len ); #endif origin = zone->cur[zone->n_points - 4].x; @@ -680,6 +686,9 @@ FT_Bool debug; FT_Error error; + FT_GlyphLoader gloader = loader->gloader; + FT_Outline current_outline = gloader->current.outline; + error = TT_Set_CodeRange( loader->exec, tt_coderange_glyph, loader->exec->glyphIns, n_ins ); @@ -695,6 +704,10 @@ error = TT_Run_Context( loader->exec, debug ); if ( error && loader->exec->pedantic_hinting ) return error; + + /* store drop-out mode in bits 5-7; set bit 2 also as a marker */ + current_outline.tags[0] |= + ( loader->exec->GS.scan_type << 5 ) | FT_CURVE_TAG_HAS_SCANMODE; } #endif @@ -929,15 +942,15 @@ /* This algorithm is a guess and works much better than the above. */ /* */ FT_Fixed mac_xscale = FT_SqrtFixed( - FT_MulFix( subglyph->transform.xx, - subglyph->transform.xx ) + - FT_MulFix( subglyph->transform.xy, - subglyph->transform.xy ) ); + (FT_Int32)FT_MulFix( subglyph->transform.xx, + subglyph->transform.xx ) + + (FT_Int32)FT_MulFix( subglyph->transform.xy, + subglyph->transform.xy ) ); FT_Fixed mac_yscale = FT_SqrtFixed( - FT_MulFix( subglyph->transform.yy, - subglyph->transform.yy ) + - FT_MulFix( subglyph->transform.yx, - subglyph->transform.yx ) ); + (FT_Int32)FT_MulFix( subglyph->transform.yy, + subglyph->transform.yy ) + + (FT_Int32)FT_MulFix( subglyph->transform.yx, + subglyph->transform.yx ) ); x = FT_MulFix( x, mac_xscale ); @@ -1030,7 +1043,7 @@ /* check it */ if ( n_ins > ((TT_Face)loader->face)->max_profile.maxSizeOfInstructions ) { - FT_TRACE0(( "TT_Process_Composite_Glyph: Too many instructions (%d)\n", + FT_TRACE0(( "TT_Process_Composite_Glyph: too many instructions (%d)\n", n_ins )); return TT_Err_Too_Many_Hints; @@ -1053,8 +1066,7 @@ /* Some points are likely touched during execution of */ /* instructions on components. So let's untouch them. */ for ( i = start_point; i < loader->zone.n_points; i++ ) - loader->zone.tags[i] &= ~( FT_CURVE_TAG_TOUCH_X | - FT_CURVE_TAG_TOUCH_Y ); + loader->zone.tags[i] &= ~FT_CURVE_TAG_TOUCH_BOTH; loader->zone.n_points += 4; @@ -1247,7 +1259,7 @@ { if ( !loader->glyf_offset ) { - FT_TRACE2(( "no `glyf' table but non-zero `loca' entry!\n" )); + FT_TRACE2(( "no `glyf' table but non-zero `loca' entry\n" )); error = TT_Err_Invalid_Table; goto Exit; } @@ -1388,8 +1400,11 @@ { if ( subglyph->flags & ARGS_ARE_XY_VALUES ) { - subglyph->arg1 += deltas[i].x; - subglyph->arg2 += deltas[i].y; + /* XXX: overflow check for subglyph->{arg1,arg2}. */ + /* deltas[i].{x,y} must be within signed 16-bit, */ + /* but the restriction of summed delta is not clear */ + subglyph->arg1 += (FT_Int16)deltas[i].x; + subglyph->arg2 += (FT_Int16)deltas[i].y; } } @@ -1579,17 +1594,35 @@ glyph->metrics.horiBearingY = bbox.yMax; glyph->metrics.horiAdvance = loader->pp2.x - loader->pp1.x; - /* Now take care of vertical metrics. In the case where there is */ - /* no vertical information within the font (relatively common), make */ - /* up some metrics by `hand'... */ + /* adjust advance width to the value contained in the hdmx table */ + if ( !face->postscript.isFixedPitch && + IS_HINTED( loader->load_flags ) ) + { + FT_Byte* widthp; + + + widthp = tt_face_get_device_metrics( face, + size->root.metrics.x_ppem, + glyph_index ); + + if ( widthp ) + glyph->metrics.horiAdvance = *widthp << 6; + } + + /* set glyph dimensions */ + glyph->metrics.width = bbox.xMax - bbox.xMin; + glyph->metrics.height = bbox.yMax - bbox.yMin; + /* Now take care of vertical metrics. In the case where there is */ + /* no vertical information within the font (relatively common), */ + /* create some metrics manually */ { FT_Pos top; /* scaled vertical top side bearing */ FT_Pos advance; /* scaled vertical advance height */ /* Get the unscaled top bearing and advance height. */ - if ( face->vertical_info && + if ( face->vertical_info && face->vertical.number_Of_VMetrics > 0 ) { top = (FT_Short)FT_DivFix( loader->pp3.y - bbox.yMax, @@ -1671,30 +1704,12 @@ /* XXX: for now, we have no better algorithm for the lsb, but it */ /* should work fine. */ /* */ - glyph->metrics.vertBearingX = ( bbox.xMin - bbox.xMax ) / 2; + glyph->metrics.vertBearingX = glyph->metrics.horiBearingX - + glyph->metrics.horiAdvance / 2; glyph->metrics.vertBearingY = top; glyph->metrics.vertAdvance = advance; } - /* adjust advance width to the value contained in the hdmx table */ - if ( !face->postscript.isFixedPitch && - IS_HINTED( loader->load_flags ) ) - { - FT_Byte* widthp; - - - widthp = tt_face_get_device_metrics( face, - size->root.metrics.x_ppem, - glyph_index ); - - if ( widthp ) - glyph->metrics.horiAdvance = *widthp << 6; - } - - /* set glyph dimensions */ - glyph->metrics.width = bbox.xMax - bbox.xMin; - glyph->metrics.height = bbox.yMax - bbox.yMin; - return 0; } @@ -1851,7 +1866,7 @@ loader->glyf_offset = 0; else if ( error ) { - FT_ERROR(( "TT_Load_Glyph: could not access glyph table\n" )); + FT_ERROR(( "tt_loader_init: could not access glyph table\n" )); return error; } else @@ -1998,7 +2013,7 @@ break; } } - else + else glyph->outline.flags |= FT_OUTLINE_IGNORE_DROPOUTS; } diff --git a/freetype/src/truetype/ttgxvar.c b/freetype/src/truetype/ttgxvar.c index 515e734b8..1456a8cc0 100644 --- a/freetype/src/truetype/ttgxvar.c +++ b/freetype/src/truetype/ttgxvar.c @@ -4,7 +4,7 @@ /* */ /* TrueType GX Font Variation loader */ /* */ -/* Copyright 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 2004, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -16,30 +16,31 @@ /***************************************************************************/ -/***************************************************************************/ -/* */ -/* Apple documents the `fvar', `gvar', `cvar', and `avar' tables at */ -/* */ -/* http://developer.apple.com/fonts/TTRefMan/RM06/Chap6[fgca]var.html */ -/* */ -/* The documentation for `fvar' is inconsistent. At one point it says */ -/* that `countSizePairs' should be 3, at another point 2. It should be 2. */ -/* */ -/* The documentation for `gvar' is not intelligible; `cvar' refers you to */ -/* `gvar' and is thus also incomprehensible. */ -/* */ -/* The documentation for `avar' appears correct, but Apple has no fonts */ -/* with an `avar' table, so it is hard to test. */ -/* */ -/* Many thanks to John Jenkins (at Apple) in figuring this out. */ -/* */ -/* */ -/* Apple's `kern' table has some references to tuple indices, but as there */ -/* is no indication where these indices are defined, nor how to */ -/* interpolate the kerning values (different tuples have different */ -/* classes) this issue is ignored. */ -/* */ -/***************************************************************************/ + /*************************************************************************/ + /* */ + /* Apple documents the `fvar', `gvar', `cvar', and `avar' tables at */ + /* */ + /* http://developer.apple.com/fonts/TTRefMan/RM06/Chap6[fgca]var.html */ + /* */ + /* The documentation for `fvar' is inconsistent. At one point it says */ + /* that `countSizePairs' should be 3, at another point 2. It should */ + /* be 2. */ + /* */ + /* The documentation for `gvar' is not intelligible; `cvar' refers you */ + /* to `gvar' and is thus also incomprehensible. */ + /* */ + /* The documentation for `avar' appears correct, but Apple has no fonts */ + /* with an `avar' table, so it is hard to test. */ + /* */ + /* Many thanks to John Jenkins (at Apple) in figuring this out. */ + /* */ + /* */ + /* Apple's `kern' table has some references to tuple indices, but as */ + /* there is no indication where these indices are defined, nor how to */ + /* interpolate the kerning values (different tuples have different */ + /* classes) this issue is ignored. */ + /* */ + /*************************************************************************/ #include @@ -47,11 +48,9 @@ #include FT_CONFIG_CONFIG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H -#include FT_TRUETYPE_IDS_H #include FT_TRUETYPE_TAGS_H #include FT_MULTIPLE_MASTERS_H -#include "ttdriver.h" #include "ttpload.h" #include "ttgxvar.h" @@ -158,6 +157,9 @@ runcnt = runcnt & GX_PT_POINT_RUN_COUNT_MASK; first = points[i++] = FT_GET_USHORT(); + if ( runcnt < 1 ) + goto Exit; + /* first point not included in runcount */ for ( j = 0; j < runcnt; ++j ) points[i++] = (FT_UShort)( first += FT_GET_USHORT() ); @@ -166,11 +168,15 @@ { first = points[i++] = FT_GET_BYTE(); + if ( runcnt < 1 ) + goto Exit; + for ( j = 0; j < runcnt; ++j ) points[i++] = (FT_UShort)( first += FT_GET_BYTE() ); } } + Exit: return points; } @@ -205,12 +211,12 @@ /* */ static FT_Short* ft_var_readpackeddeltas( FT_Stream stream, - FT_Int delta_cnt ) + FT_Offset delta_cnt ) { FT_Short *deltas; FT_Int runcnt; - FT_Int i; - FT_Int j; + FT_Offset i; + FT_Offset j; FT_Memory memory = stream->memory; FT_Error error = TT_Err_Ok; @@ -1132,7 +1138,7 @@ if ( blend == NULL ) { - FT_TRACE2(( "no blend specified!\n" )); + FT_TRACE2(( "tt_face_vary_cvt: no blend specified\n" )); error = TT_Err_Ok; goto Exit; @@ -1140,7 +1146,7 @@ if ( face->cvt == NULL ) { - FT_TRACE2(( "no `cvt ' table!\n" )); + FT_TRACE2(( "tt_face_vary_cvt: no `cvt ' table\n" )); error = TT_Err_Ok; goto Exit; @@ -1149,7 +1155,7 @@ error = face->goto_table( face, TTAG_cvar, stream, &table_len ); if ( error ) { - FT_TRACE2(( "is missing!\n" )); + FT_TRACE2(( "is missing\n" )); error = TT_Err_Ok; goto Exit; @@ -1164,7 +1170,7 @@ table_start = FT_Stream_FTell( stream ); if ( FT_GET_LONG() != 0x00010000L ) { - FT_TRACE2(( "bad table version!\n" )); + FT_TRACE2(( "bad table version\n" )); error = TT_Err_Ok; goto FExit; diff --git a/freetype/src/truetype/ttgxvar.h b/freetype/src/truetype/ttgxvar.h index 706cb4d36..82dfc4431 100644 --- a/freetype/src/truetype/ttgxvar.h +++ b/freetype/src/truetype/ttgxvar.h @@ -84,7 +84,7 @@ FT_BEGIN_HEADER FT_Fixed* normalizedcoords; FT_MM_Var* mmvar; - FT_Int mmvar_len; + FT_Offset mmvar_len; FT_Bool avar_checked; GX_AVarSegment avar_segment; diff --git a/freetype/src/truetype/ttinterp.c b/freetype/src/truetype/ttinterp.c index 2279a62cb..13aa9a27c 100644 --- a/freetype/src/truetype/ttinterp.c +++ b/freetype/src/truetype/ttinterp.c @@ -791,9 +791,9 @@ /* allocate object */ if ( FT_NEW( exec ) ) - goto Exit; + goto Fail; - /* initialize it */ + /* initialize it; in case of error this deallocates `exec' too */ error = Init_Context( exec, memory ); if ( error ) goto Fail; @@ -802,13 +802,10 @@ driver->context = exec; } - Exit: return driver->context; Fail: - FT_FREE( exec ); - - return 0; + return NULL; } @@ -2197,7 +2194,7 @@ FT_ASSERT( !CUR.face->unpatented_hinting ); #endif - return TT_DotFix14( dx, dy, + return TT_DotFix14( (FT_UInt32)dx, (FT_UInt32)dy, CUR.GS.projVector.x, CUR.GS.projVector.y ); } @@ -2223,7 +2220,7 @@ Dual_Project( EXEC_OP_ FT_Pos dx, FT_Pos dy ) { - return TT_DotFix14( dx, dy, + return TT_DotFix14( (FT_UInt32)dx, (FT_UInt32)dy, CUR.GS.dualVector.x, CUR.GS.dualVector.y ); } @@ -4293,13 +4290,21 @@ CUR.numFDefs++; } + /* Although FDEF takes unsigned 32-bit integer, */ + /* func # must be within unsigned 16-bit integer */ + if ( n > 0xFFFFU ) + { + CUR.error = TT_Err_Too_Many_Function_Defs; + return; + } + rec->range = CUR.curRange; - rec->opc = n; + rec->opc = (FT_UInt16)n; rec->start = CUR.IP + 1; rec->active = TRUE; if ( n > CUR.maxFunc ) - CUR.maxFunc = n; + CUR.maxFunc = (FT_UInt16)n; /* Now skip the whole function definition. */ /* We don't allow nested IDEFS & FDEFs. */ @@ -4556,13 +4561,20 @@ CUR.numIDefs++; } - def->opc = args[0]; + /* opcode must be unsigned 8-bit integer */ + if ( 0 > args[0] || args[0] > 0x00FF ) + { + CUR.error = TT_Err_Too_Many_Instruction_Defs; + return; + } + + def->opc = (FT_Byte)args[0]; def->start = CUR.IP+1; def->range = CUR.curRange; def->active = TRUE; if ( (FT_ULong)args[0] > CUR.maxIns ) - CUR.maxIns = args[0]; + CUR.maxIns = (FT_Byte)args[0]; /* Now skip the whole function definition. */ /* We don't allow nested IDEFs & FDEFs. */ @@ -5530,20 +5542,20 @@ { if ( CUR.GS.both_x_axis ) { - dx = TT_MulFix14( args[0], 0x4000 ); + dx = TT_MulFix14( (FT_UInt32)args[0], 0x4000 ); dy = 0; } else { dx = 0; - dy = TT_MulFix14( args[0], 0x4000 ); + dy = TT_MulFix14( (FT_UInt32)args[0], 0x4000 ); } } else #endif { - dx = TT_MulFix14( args[0], CUR.GS.freeVector.x ); - dy = TT_MulFix14( args[0], CUR.GS.freeVector.y ); + dx = TT_MulFix14( (FT_UInt32)args[0], CUR.GS.freeVector.x ); + dy = TT_MulFix14( (FT_UInt32)args[0], CUR.GS.freeVector.y ); } while ( CUR.GS.loop > 0 ) @@ -5709,8 +5721,8 @@ if ( CUR.GS.gep0 == 0 ) /* If in twilight zone */ { - CUR.zp0.org[point].x = TT_MulFix14( distance, CUR.GS.freeVector.x ); - CUR.zp0.org[point].y = TT_MulFix14( distance, CUR.GS.freeVector.y ), + CUR.zp0.org[point].x = TT_MulFix14( (FT_UInt32)distance, CUR.GS.freeVector.x ); + CUR.zp0.org[point].y = TT_MulFix14( (FT_UInt32)distance, CUR.GS.freeVector.y ), CUR.zp0.cur[point] = CUR.zp0.org[point]; } @@ -5897,10 +5909,12 @@ if ( CUR.GS.gep1 == 0 ) { CUR.zp1.org[point].x = CUR.zp0.org[CUR.GS.rp0].x + - TT_MulFix14( cvt_dist, CUR.GS.freeVector.x ); + TT_MulFix14( (FT_UInt32)cvt_dist, + CUR.GS.freeVector.x ); CUR.zp1.org[point].y = CUR.zp0.org[CUR.GS.rp0].y + - TT_MulFix14( cvt_dist, CUR.GS.freeVector.y ); + TT_MulFix14( (FT_UInt32)cvt_dist, + CUR.GS.freeVector.y ); CUR.zp1.cur[point] = CUR.zp0.cur[point]; } diff --git a/freetype/src/truetype/ttobjs.c b/freetype/src/truetype/ttobjs.c index 2649a670d..11d662d2d 100644 --- a/freetype/src/truetype/ttobjs.c +++ b/freetype/src/truetype/ttobjs.c @@ -18,9 +18,7 @@ #include #include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_CALC_H #include FT_INTERNAL_STREAM_H -#include FT_TRUETYPE_IDS_H #include FT_TRUETYPE_TAGS_H #include FT_INTERNAL_SFNT_H @@ -150,7 +148,9 @@ static FT_Bool tt_check_trickyness( FT_String* name ) { - static const char* const trick_names[] = +#define TRICK_NAMES_MAX_CHARACTERS 16 +#define TRICK_NAMES_COUNT 7 + static const char trick_names[TRICK_NAMES_COUNT][TRICK_NAMES_MAX_CHARACTERS+1] = { "DFKaiSho-SB", /* dfkaisb.ttf */ "DFKaiShu", @@ -159,7 +159,6 @@ "MingLiU", /* mingliu.ttf & mingliu.ttc */ "PMingLiU", /* mingliu.ttc */ "MingLi43", /* mingli.ttf */ - NULL }; int nn; @@ -169,7 +168,7 @@ /* Note that we only check the face name at the moment; it might */ /* be worth to do more checks for a few special cases. */ - for ( nn = 0; trick_names[nn] != NULL; nn++ ) + for ( nn = 0; nn < TRICK_NAMES_COUNT; nn++ ) if ( ft_strstr( name, trick_names[nn] ) ) return TRUE; @@ -612,18 +611,15 @@ /* Set default metrics */ { - FT_Size_Metrics* metrics = &size->metrics; - TT_Size_Metrics* metrics2 = &size->ttmetrics; + TT_Size_Metrics* metrics = &size->ttmetrics; - metrics->x_ppem = 0; - metrics->y_ppem = 0; - metrics2->rotated = FALSE; - metrics2->stretched = FALSE; + metrics->rotated = FALSE; + metrics->stretched = FALSE; /* set default compensation (all 0) */ for ( i = 0; i < 4; i++ ) - metrics2->compensations[i] = 0; + metrics->compensations[i] = 0; } /* allocate function defs, instruction defs, cvt, and storage area */ diff --git a/freetype/src/truetype/ttobjs.h b/freetype/src/truetype/ttobjs.h index d4b82285e..30c8669cb 100644 --- a/freetype/src/truetype/ttobjs.h +++ b/freetype/src/truetype/ttobjs.h @@ -4,7 +4,7 @@ /* */ /* Objects manager (specification). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -194,45 +194,13 @@ FT_BEGIN_HEADER } TT_Transform; - /*************************************************************************/ - /* */ - /* Subglyph loading record. Used to load composite components. */ - /* */ - typedef struct TT_SubglyphRec_ - { - FT_Long index; /* subglyph index; initialized with -1 */ - FT_Bool is_scaled; /* is the subglyph scaled? */ - FT_Bool is_hinted; /* should it be hinted? */ - FT_Bool preserve_pps; /* preserve phantom points? */ - - FT_Long file_offset; - - FT_BBox bbox; - FT_Pos left_bearing; - FT_Pos advance; - - TT_GlyphZoneRec zone; - - FT_Long arg1; /* first argument */ - FT_Long arg2; /* second argument */ - - FT_UShort element_flag; /* current load element flag */ - - TT_Transform transform; /* transformation matrix */ - - FT_Vector pp1, pp2; /* phantom points (horizontal) */ - FT_Vector pp3, pp4; /* phantom points (vertical) */ - - } TT_SubGlyphRec, *TT_SubGlyph_Stack; - - /*************************************************************************/ /* */ /* A note regarding non-squared pixels: */ /* */ /* (This text will probably go into some docs at some time; for now, it */ - /* is kept here to explain some definitions in the TIns_Metrics */ - /* record). */ + /* is kept here to explain some definitions in the TT_Size_Metrics */ + /* record). */ /* */ /* The CVT is a one-dimensional array containing values that control */ /* certain important characteristics in a font, like the height of all */ diff --git a/freetype/src/truetype/ttpic.c b/freetype/src/truetype/ttpic.c new file mode 100644 index 000000000..27ec4a1d5 --- /dev/null +++ b/freetype/src/truetype/ttpic.c @@ -0,0 +1,79 @@ +/***************************************************************************/ +/* */ +/* ttpic.c */ +/* */ +/* The FreeType position independent code services for truetype module. */ +/* */ +/* Copyright 2009 by */ +/* Oran Agra and Mickey Gabel. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#include +#include FT_FREETYPE_H +#include FT_INTERNAL_OBJECTS_H +#include "ttpic.h" + +#ifdef FT_CONFIG_OPTION_PIC + + /* forward declaration of PIC init functions from ttdriver.c */ + FT_Error FT_Create_Class_tt_services( FT_Library, FT_ServiceDescRec**); + void FT_Destroy_Class_tt_services( FT_Library, FT_ServiceDescRec*); + void FT_Init_Class_tt_service_gx_multi_masters(FT_Service_MultiMastersRec*); + void FT_Init_Class_tt_service_truetype_glyf(FT_Service_TTGlyfRec*); + + void + tt_driver_class_pic_free( FT_Library library ) + { + FT_PIC_Container* pic_container = &library->pic_container; + FT_Memory memory = library->memory; + if ( pic_container->truetype ) + { + TTModulePIC* container = (TTModulePIC*)pic_container->truetype; + if(container->tt_services) + FT_Destroy_Class_tt_services(library, container->tt_services); + container->tt_services = NULL; + FT_FREE( container ); + pic_container->truetype = NULL; + } + } + + FT_Error + tt_driver_class_pic_init( FT_Library library ) + { + FT_PIC_Container* pic_container = &library->pic_container; + FT_Error error = FT_Err_Ok; + TTModulePIC* container; + FT_Memory memory = library->memory; + + /* allocate pointer, clear and set global container pointer */ + if ( FT_ALLOC ( container, sizeof ( *container ) ) ) + return error; + FT_MEM_SET( container, 0, sizeof(*container) ); + pic_container->truetype = container; + + /* initialize pointer table - this is how the module usually expects this data */ + error = FT_Create_Class_tt_services(library, &container->tt_services); + if(error) + goto Exit; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Init_Class_tt_service_gx_multi_masters(&container->tt_service_gx_multi_masters); +#endif + FT_Init_Class_tt_service_truetype_glyf(&container->tt_service_truetype_glyf); +Exit: + if(error) + tt_driver_class_pic_free(library); + return error; + } + +#endif /* FT_CONFIG_OPTION_PIC */ + + +/* END */ diff --git a/freetype/src/truetype/ttpic.h b/freetype/src/truetype/ttpic.h new file mode 100644 index 000000000..84de0fee9 --- /dev/null +++ b/freetype/src/truetype/ttpic.h @@ -0,0 +1,59 @@ +/***************************************************************************/ +/* */ +/* ttpic.h */ +/* */ +/* The FreeType position independent code services for truetype module. */ +/* */ +/* Copyright 2009 by */ +/* Oran Agra and Mickey Gabel. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __TTPIC_H__ +#define __TTPIC_H__ + + +FT_BEGIN_HEADER + +#ifndef FT_CONFIG_OPTION_PIC +#define FT_TT_SERVICES_GET tt_services +#define FT_TT_SERVICE_GX_MULTI_MASTERS_GET tt_service_gx_multi_masters +#define FT_TT_SERVICE_TRUETYPE_GLYF_GET tt_service_truetype_glyf + +#else /* FT_CONFIG_OPTION_PIC */ + +#include FT_MULTIPLE_MASTERS_H +#include FT_SERVICE_MULTIPLE_MASTERS_H +#include FT_SERVICE_TRUETYPE_GLYF_H + + typedef struct TTModulePIC_ + { + FT_ServiceDescRec* tt_services; +#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Service_MultiMastersRec tt_service_gx_multi_masters; +#endif + FT_Service_TTGlyfRec tt_service_truetype_glyf; + } TTModulePIC; + +#define GET_PIC(lib) ((TTModulePIC*)((lib)->pic_container.truetype)) +#define FT_TT_SERVICES_GET (GET_PIC(library)->tt_services) +#define FT_TT_SERVICE_GX_MULTI_MASTERS_GET (GET_PIC(library)->tt_service_gx_multi_masters) +#define FT_TT_SERVICE_TRUETYPE_GLYF_GET (GET_PIC(library)->tt_service_truetype_glyf) + +#endif /* FT_CONFIG_OPTION_PIC */ + + /* */ + +FT_END_HEADER + +#endif /* __TTPIC_H__ */ + + +/* END */ diff --git a/freetype/src/truetype/ttpload.c b/freetype/src/truetype/ttpload.c index dc538fb08..a311b03c0 100644 --- a/freetype/src/truetype/ttpload.c +++ b/freetype/src/truetype/ttpload.c @@ -4,7 +4,7 @@ /* */ /* TrueType-specific tables loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007, 2008 by */ +/* Copyright 1996-2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -58,7 +58,6 @@ /* */ /* FreeType error code. 0 means success. */ /* */ - FT_LOCAL_DEF( FT_Error ) tt_face_load_loca( TT_Face face, FT_Stream stream ) @@ -92,11 +91,11 @@ if ( table_len >= 0x40000L ) { - FT_TRACE2(( "table too large!\n" )); + FT_TRACE2(( "table too large\n" )); error = TT_Err_Invalid_Table; goto Exit; } - face->num_locations = (FT_UInt)( table_len >> shift ); + face->num_locations = table_len >> shift; } else { @@ -104,20 +103,20 @@ if ( table_len >= 0x20000L ) { - FT_TRACE2(( "table too large!\n" )); + FT_TRACE2(( "table too large\n" )); error = TT_Err_Invalid_Table; goto Exit; } - face->num_locations = (FT_UInt)( table_len >> shift ); + face->num_locations = table_len >> shift; } - if ( face->num_locations != (FT_UInt)face->root.num_glyphs ) + if ( face->num_locations != (FT_ULong)face->root.num_glyphs ) { FT_TRACE2(( "glyph count mismatch! loca: %d, maxp: %d\n", face->num_locations, face->root.num_glyphs )); /* we only handle the case where `maxp' gives a larger value */ - if ( face->num_locations < (FT_UInt)face->root.num_glyphs ) + if ( face->num_locations < (FT_ULong)face->root.num_glyphs ) { FT_Long new_loca_len = (FT_Long)face->root.num_glyphs << shift; @@ -140,7 +139,7 @@ if ( new_loca_len <= dist ) { - face->num_locations = (FT_Long)face->root.num_glyphs; + face->num_locations = face->root.num_glyphs; table_len = new_loca_len; FT_TRACE2(( "adjusting num_locations to %d\n", @@ -204,12 +203,11 @@ } } - /* It isn't mentioned explicitly that the `loca' table must be */ - /* ordered, but implicitly it refers to the length of an entry */ - /* as the difference between the current and the next position. */ - /* Anyway, there do exist (malformed) fonts which don't obey */ - /* this rule, so we are only able to provide an upper bound for */ - /* the size. */ + /* The `loca' table must be ordered; it refers to the length of */ + /* an entry as the difference between the current and the next */ + /* position. However, there do exist (malformed) fonts which */ + /* don't obey this rule, so we are only able to provide an */ + /* upper bound for the size. */ /* */ /* We get (intentionally) a wrong, non-zero result in case the */ /* `glyf' table is missing. */ @@ -267,7 +265,7 @@ error = face->goto_table( face, TTAG_cvt, stream, &table_len ); if ( error ) { - FT_TRACE2(( "is missing!\n" )); + FT_TRACE2(( "is missing\n" )); face->cvt_size = 0; face->cvt = NULL; @@ -352,7 +350,7 @@ face->font_program_size = 0; error = TT_Err_Ok; - FT_TRACE2(( "is missing!\n" )); + FT_TRACE2(( "is missing\n" )); } else { @@ -413,7 +411,7 @@ face->cvt_program_size = 0; error = TT_Err_Ok; - FT_TRACE2(( "is missing!\n" )); + FT_TRACE2(( "is missing\n" )); } else { -- cgit v1.2.3