From 360fe27b55c93c9c6c86895dbbf5db3efc66cc43 Mon Sep 17 00:00:00 2001 From: Mike DePaulo Date: Sat, 28 Feb 2015 07:31:25 -0500 Subject: Updated to freetype 2.5.5 Conflicts: freetype/src/base/ftbdf.c freetype/src/base/fttype1.c freetype/src/pfr/pfrobjs.c --- freetype/src/truetype/ttdriver.c | 8 +- freetype/src/truetype/ttgload.c | 69 ++++++++----- freetype/src/truetype/ttgxvar.c | 6 +- freetype/src/truetype/ttinterp.c | 216 +++++++++++++++++---------------------- freetype/src/truetype/ttinterp.h | 23 +++-- freetype/src/truetype/ttobjs.c | 172 +++++++++++++++---------------- freetype/src/truetype/ttobjs.h | 12 ++- freetype/src/truetype/ttpload.c | 12 ++- freetype/src/truetype/ttsubpix.c | 6 +- 9 files changed, 256 insertions(+), 268 deletions(-) (limited to 'freetype/src/truetype') diff --git a/freetype/src/truetype/ttdriver.c b/freetype/src/truetype/ttdriver.c index ade2505c7..b2925f7d6 100644 --- a/freetype/src/truetype/ttdriver.c +++ b/freetype/src/truetype/ttdriver.c @@ -4,7 +4,7 @@ /* */ /* TrueType font driver implementation (body). */ /* */ -/* Copyright 1996-2013 by */ +/* Copyright 1996-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -267,7 +267,7 @@ /* use the scaled metrics, even when tt_size_reset fails */ FT_Select_Metrics( size->face, strike_index ); - tt_size_reset( ttsize ); + tt_size_reset( ttsize ); /* ignore return value */ } else { @@ -370,7 +370,7 @@ return FT_THROW( Invalid_Size_Handle ); if ( !face ) - return FT_THROW( Invalid_Argument ); + return FT_THROW( Invalid_Face_Handle ); #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( glyph_index >= (FT_UInt)face->num_glyphs && @@ -481,7 +481,7 @@ SFNT_Service sfnt; - /* TT_SERVICES_GET derefers `library' in PIC mode */ + /* TT_SERVICES_GET dereferences `library' in PIC mode */ #ifdef FT_CONFIG_OPTION_PIC if ( !driver ) return NULL; diff --git a/freetype/src/truetype/ttgload.c b/freetype/src/truetype/ttgload.c index 3b4580cd7..8e8f48587 100644 --- a/freetype/src/truetype/ttgload.c +++ b/freetype/src/truetype/ttgload.c @@ -4,7 +4,7 @@ /* */ /* TrueType Glyph Loader (body). */ /* */ -/* Copyright 1996-2013 */ +/* Copyright 1996-2014 */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -99,13 +99,13 @@ else if ( face->os2.version != 0xFFFFU ) { - *tsb = face->os2.sTypoAscender - yMax; + *tsb = (FT_Short)( face->os2.sTypoAscender - yMax ); *ah = face->os2.sTypoAscender - face->os2.sTypoDescender; } else { - *tsb = face->horizontal.Ascender - yMax; + *tsb = (FT_Short)( face->horizontal.Ascender - yMax ); *ah = face->horizontal.Ascender - face->horizontal.Descender; } @@ -801,10 +801,8 @@ FT_Outline current_outline = gloader->current.outline; - error = TT_Set_CodeRange( loader->exec, tt_coderange_glyph, - loader->exec->glyphIns, n_ins ); - if ( error ) - return error; + TT_Set_CodeRange( loader->exec, tt_coderange_glyph, + loader->exec->glyphIns, n_ins ); loader->exec->is_composite = is_composite; loader->exec->pts = *zone; @@ -1789,8 +1787,12 @@ /* (1): exists from the beginning */ /* (2): components that have been loaded so far */ /* (3): the newly loaded component */ - TT_Process_Composite_Component( loader, subglyph, start_point, - num_base_points ); + error = TT_Process_Composite_Component( loader, + subglyph, + start_point, + num_base_points ); + if ( error ) + goto Exit; } loader->stream = old_stream; @@ -1799,16 +1801,17 @@ /* process the glyph */ loader->ins_pos = ins_pos; if ( IS_HINTED( loader->load_flags ) && - #ifdef TT_USE_BYTECODE_INTERPRETER - subglyph->flags & WE_HAVE_INSTR && - #endif - num_points > start_point ) - TT_Process_Composite_Glyph( loader, start_point, start_contour ); - + { + error = TT_Process_Composite_Glyph( loader, + start_point, + start_contour ); + if ( error ) + goto Exit; + } } } else @@ -2083,6 +2086,8 @@ FT_Int32 load_flags, FT_Bool glyf_table_only ) { + FT_Error error; + TT_Face face; FT_Stream stream; #ifdef TT_USE_BYTECODE_INTERPRETER @@ -2120,14 +2125,16 @@ FT_Bool reexecute = FALSE; - if ( !size->cvt_ready ) + if ( size->bytecode_ready < 0 || size->cvt_ready < 0 ) { - FT_Error error = tt_size_ready_bytecode( size, pedantic ); - - + error = tt_size_ready_bytecode( size, pedantic ); if ( error ) return error; } + else if ( size->bytecode_ready ) + return size->bytecode_ready; + else if ( size->cvt_ready ) + return size->cvt_ready; /* query new execution context */ exec = size->debug ? size->context @@ -2191,7 +2198,9 @@ FT_RENDER_MODE_MONO ); } - TT_Load_Context( exec, face, size ); + error = TT_Load_Context( exec, face, size ); + if ( error ) + return error; #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING @@ -2243,7 +2252,9 @@ for ( i = 0; i < size->cvt_size; i++ ) size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); - tt_size_run_prep( size, pedantic ); + error = tt_size_run_prep( size, pedantic ); + if ( error ) + return error; } /* see whether the cvt program has disabled hinting */ @@ -2274,8 +2285,7 @@ #endif { - FT_Error error = face->goto_table( face, TTAG_glyf, stream, 0 ); - + error = face->goto_table( face, TTAG_glyf, stream, 0 ); if ( FT_ERR_EQ( error, Table_Missing ) ) loader->glyf_offset = 0; @@ -2366,15 +2376,18 @@ (void)tt_loader_init( &loader, size, glyph, load_flags, TRUE ); (void)load_truetype_glyph( &loader, glyph_index, 0, TRUE ); glyph->linearHoriAdvance = loader.linear; - glyph->linearVertAdvance = loader.top_bearing + loader.bbox.yMax - - loader.vadvance; + glyph->linearVertAdvance = loader.vadvance; - /* sanity check: if `horiAdvance' in the sbit metric */ - /* structure isn't set, use `linearHoriAdvance' */ + /* sanity checks: if `xxxAdvance' in the sbit metric */ + /* structure isn't set, use `linearXXXAdvance' */ if ( !glyph->metrics.horiAdvance && glyph->linearHoriAdvance ) glyph->metrics.horiAdvance = FT_MulFix( glyph->linearHoriAdvance, size->root.metrics.x_scale ); + if ( !glyph->metrics.vertAdvance && glyph->linearVertAdvance ) + glyph->metrics.vertAdvance = + FT_MulFix( glyph->linearVertAdvance, + size->root.metrics.y_scale ); } return FT_Err_Ok; @@ -2454,7 +2467,7 @@ #endif /* TT_USE_BYTECODE_INTERPRETER */ - compute_glyph_metrics( &loader, glyph_index ); + error = compute_glyph_metrics( &loader, glyph_index ); } /* Set the `high precision' bit flag. */ diff --git a/freetype/src/truetype/ttgxvar.c b/freetype/src/truetype/ttgxvar.c index 50e5f02a7..ea654b878 100644 --- a/freetype/src/truetype/ttgxvar.c +++ b/freetype/src/truetype/ttgxvar.c @@ -4,7 +4,7 @@ /* */ /* TrueType GX Font Variation loader */ /* */ -/* Copyright 2004-2013 by */ +/* Copyright 2004-2014 by */ /* David Turner, Robert Wilhelm, Werner Lemberg, and George Williams. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -938,13 +938,13 @@ FT_FREE( face->cvt ); face->cvt = NULL; - tt_face_load_cvt( face, face->root.stream ); + error = tt_face_load_cvt( face, face->root.stream ); break; case mcvt_modify: /* The original cvt table is in memory. All we need to do is */ /* apply the `cvar' table (if any). */ - tt_face_vary_cvt( face, face->root.stream ); + error = tt_face_vary_cvt( face, face->root.stream ); break; case mcvt_retain: diff --git a/freetype/src/truetype/ttinterp.c b/freetype/src/truetype/ttinterp.c index 828e295a5..24457f4da 100644 --- a/freetype/src/truetype/ttinterp.c +++ b/freetype/src/truetype/ttinterp.c @@ -172,6 +172,9 @@ #define CUR_Func_round( d, c ) \ CUR.func_round( EXEC_ARG_ d, c ) +#define CUR_Func_cur_ppem() \ + CUR.func_cur_ppem( EXEC_ARG ) + #define CUR_Func_read_cvt( index ) \ CUR.func_read_cvt( EXEC_ARG_ index ) @@ -184,12 +187,6 @@ #define CURRENT_Ratio() \ Current_Ratio( EXEC_ARG ) -#define CURRENT_Ppem() \ - Current_Ppem( EXEC_ARG ) - -#define CUR_Ppem() \ - Cur_PPEM( EXEC_ARG ) - #define INS_SxVTL( a, b, c, d ) \ Ins_SxVTL( EXEC_ARG_ a, b, c, d ) @@ -282,10 +279,7 @@ /* */ /* exec :: The target execution context. */ /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL_DEF( void ) TT_Goto_CodeRange( TT_ExecContext exec, FT_Int range, FT_Long IP ) @@ -309,8 +303,6 @@ exec->codeSize = coderange->size; exec->IP = IP; exec->curRange = range; - - return FT_Err_Ok; } @@ -332,10 +324,7 @@ /* */ /* exec :: The target execution context. */ /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL_DEF( void ) TT_Set_CodeRange( TT_ExecContext exec, FT_Int range, void* base, @@ -345,8 +334,6 @@ exec->codeRangeTable[range - 1].base = (FT_Byte*)base; exec->codeRangeTable[range - 1].size = length; - - return FT_Err_Ok; } @@ -364,13 +351,7 @@ /* */ /* exec :: The target execution context. */ /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ - /* */ - /* Does not set the Error variable. */ - /* */ - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL_DEF( void ) TT_Clear_CodeRange( TT_ExecContext exec, FT_Int range ) { @@ -378,8 +359,6 @@ exec->codeRangeTable[range - 1].base = NULL; exec->codeRangeTable[range - 1].size = 0; - - return FT_Err_Ok; } @@ -403,13 +382,10 @@ /* */ /* memory :: A handle to the parent memory object. */ /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ /* */ /* Only the glyph loader and debugger should call this function. */ /* */ - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL_DEF( void ) TT_Done_Context( TT_ExecContext exec ) { FT_Memory memory = exec->memory; @@ -436,8 +412,6 @@ exec->face = NULL; FT_FREE( exec ); - - return FT_Err_Ok; } @@ -664,13 +638,10 @@ /* */ /* size :: A handle to the target size object. */ /* */ - /* */ - /* FreeType error code. 0 means success. */ - /* */ /* */ /* Only the glyph loader and debugger should call this function. */ /* */ - FT_LOCAL_DEF( FT_Error ) + FT_LOCAL_DEF( void ) TT_Save_Context( TT_ExecContext exec, TT_Size size ) { @@ -688,8 +659,6 @@ for ( i = 0; i < TT_MAX_CODE_RANGES; i++ ) size->codeRangeTable[i] = exec->codeRangeTable[i]; - - return FT_Err_Ok; } @@ -721,12 +690,7 @@ TT_Run_Context( TT_ExecContext exec, FT_Bool debug ) { - FT_Error error; - - - if ( ( error = TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ) ) - != FT_Err_Ok ) - return error; + TT_Goto_CodeRange( exec, tt_coderange_glyph, 0 ); exec->zp0 = exec->pts; exec->zp1 = exec->pts; @@ -796,8 +760,13 @@ FT_EXPORT_DEF( TT_ExecContext ) TT_New_Context( TT_Driver driver ) { - FT_Memory memory = driver->root.root.memory; + FT_Memory memory; + + + if ( !driver ) + goto Fail; + memory = driver->root.root.memory; if ( !driver->context ) { @@ -1446,7 +1415,7 @@ TT_MulFix14_arm( FT_Int32 a, FT_Int b ) { - register FT_Int32 t, t2; + FT_Int32 t, t2; #if defined( __CC_ARM ) || defined( __ARMCC__ ) @@ -1706,8 +1675,15 @@ } - static FT_Long + FT_CALLBACK_DEF( FT_Long ) Current_Ppem( EXEC_OP ) + { + return CUR.tt_metrics.ppem; + } + + + FT_CALLBACK_DEF( FT_Long ) + Current_Ppem_Stretched( EXEC_OP ) { return FT_MulFix( CUR.tt_metrics.ppem, CURRENT_Ratio() ); } @@ -2047,7 +2023,7 @@ if ( distance >= 0 ) { val = distance + compensation; - if ( distance && val < 0 ) + if ( val < 0 ) val = 0; } else @@ -2087,10 +2063,8 @@ if ( distance >= 0 ) { - val = distance + compensation + 32; - if ( distance && val > 0 ) - val &= ~63; - else + val = FT_PIX_ROUND( distance + compensation ); + if ( val < 0 ) val = 0; } else @@ -2132,14 +2106,14 @@ if ( distance >= 0 ) { val = FT_PIX_FLOOR( distance + compensation ) + 32; - if ( distance && val < 0 ) - val = 0; + if ( val < 0 ) + val = 32; } else { val = -( FT_PIX_FLOOR( compensation - distance ) + 32 ); if ( val > 0 ) - val = 0; + val = -32; } return val; @@ -2173,15 +2147,13 @@ if ( distance >= 0 ) { - val = distance + compensation; - if ( distance && val > 0 ) - val &= ~63; - else + val = FT_PIX_FLOOR( distance + compensation ); + if ( val < 0 ) val = 0; } else { - val = -( ( compensation - distance ) & -64 ); + val = -FT_PIX_FLOOR( compensation - distance ); if ( val > 0 ) val = 0; } @@ -2217,10 +2189,8 @@ if ( distance >= 0 ) { - val = distance + compensation + 63; - if ( distance && val > 0 ) - val &= ~63; - else + val = FT_PIX_CEIL( distance + compensation ); + if ( val < 0 ) val = 0; } else @@ -2261,10 +2231,8 @@ if ( distance >= 0 ) { - val = distance + compensation + 16; - if ( distance && val > 0 ) - val &= ~31; - else + val = FT_PAD_ROUND( distance + compensation, 32 ); + if ( val < 0 ) val = 0; } else @@ -2311,17 +2279,17 @@ { val = ( distance - CUR.phase + CUR.threshold + compensation ) & -CUR.period; - if ( distance && val < 0 ) - val = 0; val += CUR.phase; + if ( val < 0 ) + val = CUR.phase; } else { val = -( ( CUR.threshold - CUR.phase - distance + compensation ) & -CUR.period ); - if ( val > 0 ) - val = 0; val -= CUR.phase; + if ( val > 0 ) + val = -CUR.phase; } return val; @@ -2359,17 +2327,17 @@ { val = ( ( distance - CUR.phase + CUR.threshold + compensation ) / CUR.period ) * CUR.period; - if ( distance && val < 0 ) - val = 0; val += CUR.phase; + if ( val < 0 ) + val = CUR.phase; } else { val = -( ( ( CUR.threshold - CUR.phase - distance + compensation ) / CUR.period ) * CUR.period ); - if ( val > 0 ) - val = 0; val -= CUR.phase; + if ( val > 0 ) + val = -CUR.phase; } return val; @@ -3077,19 +3045,22 @@ CUR.GS.auto_flip = FALSE; -#define DO_SDB \ - CUR.GS.delta_base = (FT_Short)args[0]; +#define DO_SDB \ + CUR.GS.delta_base = (FT_UShort)args[0]; -#define DO_SDS \ - CUR.GS.delta_shift = (FT_Short)args[0]; +#define DO_SDS \ + if ( (FT_ULong)args[0] > 6UL ) \ + CUR.error = FT_THROW( Bad_Argument ); \ + else \ + CUR.GS.delta_shift = (FT_UShort)args[0]; #define DO_MD /* nothing */ -#define DO_MPPEM \ - args[0] = CURRENT_Ppem(); +#define DO_MPPEM \ + args[0] = CUR_Func_cur_ppem(); /* Note: The pointSize should be irrelevant in a given font program; */ @@ -3101,8 +3072,8 @@ #else -#define DO_MPS \ - args[0] = CURRENT_Ppem(); +#define DO_MPS \ + args[0] = CUR_Func_cur_ppem(); #endif /* 0 */ @@ -5654,7 +5625,7 @@ /*************************************************************************/ /* */ /* INSTCTRL[]: INSTruction ConTRoL */ - /* Opcode range: 0x8e */ + /* Opcode range: 0x8E */ /* Stack: int32 int32 --> */ /* */ static void @@ -7487,9 +7458,9 @@ static void Ins_DELTAP( INS_ARG ) { - FT_ULong k, nump; + FT_ULong nump, k; FT_UShort A; - FT_ULong C; + FT_ULong C, P; FT_Long B; #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING FT_UShort B1, B2; @@ -7523,6 +7494,7 @@ } #endif + P = (FT_ULong)CUR_Func_cur_ppem(); nump = (FT_ULong)args[0]; /* some points theoretically may occur more than once, thus UShort isn't enough */ @@ -7567,12 +7539,12 @@ C += CUR.GS.delta_base; - if ( CURRENT_Ppem() == (FT_Long)C ) + if ( P == C ) { B = ( (FT_ULong)B & 0xF ) - 8; if ( B >= 0 ) B++; - B = B * 64 / ( 1L << CUR.GS.delta_shift ); + B *= 1L << ( 6 - CUR.GS.delta_shift ); #ifdef TT_CONFIG_OPTION_SUBPIXEL_HINTING @@ -7581,42 +7553,33 @@ /* * Allow delta move if * - * - not using ignore_x_mode rendering - * - glyph is specifically set to allow it - * - glyph is composite and freedom vector is not subpixel - * vector + * - not using ignore_x_mode rendering, + * - glyph is specifically set to allow it, or + * - glyph is composite and freedom vector is not in subpixel + * direction. */ if ( !CUR.ignore_x_mode || ( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_DO_DELTAP ) || ( CUR.is_composite && CUR.GS.freeVector.y != 0 ) ) CUR_Func_move( &CUR.zp0, A, B ); - /* Otherwise apply subpixel hinting and */ - /* compatibility mode rules */ - else if ( CUR.ignore_x_mode ) + /* Otherwise, apply subpixel hinting and compatibility mode */ + /* rules, always skipping deltas in subpixel direction. */ + else if ( CUR.ignore_x_mode && CUR.GS.freeVector.y != 0 ) { - if ( CUR.GS.freeVector.y != 0 ) - B1 = CUR.zp0.cur[A].y; - else - B1 = CUR.zp0.cur[A].x; + /* save the y value of the point now; compare after move */ + B1 = (FT_UShort)CUR.zp0.cur[A].y; -#if 0 - /* Standard Subpixel Hinting: Allow y move. */ - /* This messes up dejavu and may not be needed... */ - if ( !CUR.face->sph_compatibility_mode && - CUR.GS.freeVector.y != 0 ) + /* Standard subpixel hinting: Allow y move for y-touched */ + /* points. This messes up DejaVu ... */ + if ( !CUR.face->sph_compatibility_mode && + ( CUR.zp0.tags[A] & FT_CURVE_TAG_TOUCH_Y ) ) CUR_Func_move( &CUR.zp0, A, B ); - else -#endif /* 0 */ - /* Compatibility Mode: Allow x or y move if point touched in */ - /* Y direction. */ - if ( CUR.face->sph_compatibility_mode && - !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) ) + /* compatibility mode */ + else if ( CUR.face->sph_compatibility_mode && + !( CUR.sph_tweak_flags & SPH_TWEAK_ALWAYS_SKIP_DELTAP ) ) { - /* save the y value of the point now; compare after move */ - B1 = CUR.zp0.cur[A].y; - if ( CUR.sph_tweak_flags & SPH_TWEAK_ROUND_NONPIXEL_Y_MOVES ) B = FT_PIX_ROUND( B1 + B ) - B1; @@ -7627,7 +7590,7 @@ CUR_Func_move( &CUR.zp0, A, B ); } - B2 = CUR.zp0.cur[A].y; + B2 = (FT_UShort)CUR.zp0.cur[A].y; /* Reverse this move if it results in a disallowed move */ if ( CUR.GS.freeVector.y != 0 && @@ -7667,7 +7630,7 @@ Ins_DELTAC( INS_ARG ) { FT_ULong nump, k; - FT_ULong A, C; + FT_ULong A, C, P; FT_Long B; @@ -7691,6 +7654,7 @@ } #endif + P = (FT_ULong)CUR_Func_cur_ppem(); nump = (FT_ULong)args[0]; for ( k = 1; k <= nump; k++ ) @@ -7736,12 +7700,12 @@ C += CUR.GS.delta_base; - if ( CURRENT_Ppem() == (FT_Long)C ) + if ( P == C ) { B = ( (FT_ULong)B & 0xF ) - 8; if ( B >= 0 ) B++; - B = B * 64 / ( 1L << CUR.GS.delta_shift ); + B *= 1L << ( 6 - CUR.GS.delta_shift ); CUR_Func_move_cvt( A, B ); } @@ -8262,6 +8226,9 @@ #ifdef TT_CONFIG_OPTION_STATIC_RASTER + if ( !exc ) + return FT_THROW( Invalid_Argument ); + cur = *exc; #endif @@ -8269,11 +8236,12 @@ CUR.iup_called = FALSE; #endif /* TT_CONFIG_OPTION_SUBPIXEL_HINTING */ - /* set CVT functions */ + /* set PPEM and CVT functions */ CUR.tt_metrics.ratio = 0; if ( CUR.metrics.x_ppem != CUR.metrics.y_ppem ) { /* non-square pixels, use the stretched routines */ + CUR.func_cur_ppem = Current_Ppem_Stretched; CUR.func_read_cvt = Read_CVT_Stretched; CUR.func_write_cvt = Write_CVT_Stretched; CUR.func_move_cvt = Move_CVT_Stretched; @@ -8281,6 +8249,7 @@ else { /* square pixels, use normal routines */ + CUR.func_cur_ppem = Current_Ppem; CUR.func_read_cvt = Read_CVT; CUR.func_write_cvt = Write_CVT; CUR.func_move_cvt = Move_CVT; @@ -9035,10 +9004,13 @@ /* If any errors have occurred, function tables may be broken. */ /* Force a re-execution of `prep' and `fpgm' tables if no */ /* bytecode debugger is run. */ - if ( CUR.error && !CUR.instruction_trap ) + if ( CUR.error && + !CUR.instruction_trap && + CUR.curRange == tt_coderange_glyph ) { FT_TRACE1(( " The interpreter returned error 0x%x\n", CUR.error )); - exc->size->cvt_ready = FALSE; + exc->size->bytecode_ready = -1; + exc->size->cvt_ready = -1; } return CUR.error; diff --git a/freetype/src/truetype/ttinterp.h b/freetype/src/truetype/ttinterp.h index 1d8825d3b..333decc6a 100644 --- a/freetype/src/truetype/ttinterp.h +++ b/freetype/src/truetype/ttinterp.h @@ -4,7 +4,7 @@ /* */ /* TrueType bytecode interpreter (specification). */ /* */ -/* Copyright 1996-2007, 2010, 2012-2013 by */ +/* Copyright 1996-2007, 2010, 2012-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -81,6 +81,10 @@ FT_BEGIN_HEADER (*TT_Project_Func)( EXEC_OP_ FT_Pos dx, FT_Pos dy ); + /* getting current ppem. Take care of non-square pixels if necessary */ + typedef FT_Long + (*TT_Cur_Ppem_Func)( EXEC_OP ); + /* reading a cvt value. Take care of non-square pixels if necessary */ typedef FT_F26Dot6 (*TT_Get_CVT_Func)( EXEC_OP_ FT_ULong idx ); @@ -228,11 +232,6 @@ FT_BEGIN_HEADER FT_F26Dot6 phase; /* `SuperRounding' */ FT_F26Dot6 threshold; -#if 0 - /* this seems to be unused */ - FT_Int cur_ppem; /* ppem along the current proj vector */ -#endif - FT_Bool instruction_trap; /* If `True', the interpreter will */ /* exit after each instruction */ @@ -254,6 +253,8 @@ FT_BEGIN_HEADER TT_Move_Func func_move; /* current point move function */ TT_Move_Func func_move_orig; /* move original position function */ + TT_Cur_Ppem_Func func_cur_ppem; /* get current proj. ppem value */ + TT_Get_CVT_Func func_read_cvt; /* read a cvt entry */ TT_Set_CVT_Func func_write_cvt; /* write a cvt entry (in pixels) */ TT_Set_CVT_Func func_move_cvt; /* incr a cvt entry (in pixels) */ @@ -295,18 +296,18 @@ FT_BEGIN_HEADER #ifdef TT_USE_BYTECODE_INTERPRETER - FT_LOCAL( FT_Error ) + FT_LOCAL( void ) TT_Goto_CodeRange( TT_ExecContext exec, FT_Int range, FT_Long IP ); - FT_LOCAL( FT_Error ) + FT_LOCAL( void ) TT_Set_CodeRange( TT_ExecContext exec, FT_Int range, void* base, FT_Long length ); - FT_LOCAL( FT_Error ) + FT_LOCAL( void ) TT_Clear_CodeRange( TT_ExecContext exec, FT_Int range ); @@ -344,7 +345,7 @@ FT_BEGIN_HEADER #ifdef TT_USE_BYTECODE_INTERPRETER - FT_LOCAL( FT_Error ) + FT_LOCAL( void ) TT_Done_Context( TT_ExecContext exec ); FT_LOCAL( FT_Error ) @@ -352,7 +353,7 @@ FT_BEGIN_HEADER TT_Face face, TT_Size size ); - FT_LOCAL( FT_Error ) + FT_LOCAL( void ) TT_Save_Context( TT_ExecContext exec, TT_Size ins ); diff --git a/freetype/src/truetype/ttobjs.c b/freetype/src/truetype/ttobjs.c index ebbf1b058..7357cdf4e 100644 --- a/freetype/src/truetype/ttobjs.c +++ b/freetype/src/truetype/ttobjs.c @@ -256,89 +256,89 @@ #define TRICK_SFNT_ID_prep 2 { /* MingLiU 1995 */ - { 0x05bcf058, 0x000002e4 }, /* cvt */ - { 0x28233bf1, 0x000087c4 }, /* fpgm */ - { 0xa344a1ea, 0x000001e1 } /* prep */ + { 0x05BCF058UL, 0x000002E4UL }, /* cvt */ + { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */ + { 0xA344A1EAUL, 0x000001E1UL } /* prep */ }, { /* MingLiU 1996- */ - { 0x05bcf058, 0x000002e4 }, /* cvt */ - { 0x28233bf1, 0x000087c4 }, /* fpgm */ - { 0xa344a1eb, 0x000001e1 } /* prep */ + { 0x05BCF058UL, 0x000002E4UL }, /* cvt */ + { 0x28233BF1UL, 0x000087C4UL }, /* fpgm */ + { 0xA344A1EBUL, 0x000001E1UL } /* prep */ }, { /* DFKaiShu */ - { 0x11e5ead4, 0x00000350 }, /* cvt */ - { 0x5a30ca3b, 0x00009063 }, /* fpgm */ - { 0x13a42602, 0x0000007e } /* prep */ + { 0x11E5EAD4UL, 0x00000350UL }, /* cvt */ + { 0x5A30CA3BUL, 0x00009063UL }, /* fpgm */ + { 0x13A42602UL, 0x0000007EUL } /* prep */ }, { /* HuaTianKaiTi */ - { 0xfffbfffc, 0x00000008 }, /* cvt */ - { 0x9c9e48b8, 0x0000bea2 }, /* fpgm */ - { 0x70020112, 0x00000008 } /* prep */ + { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */ + { 0x9C9E48B8UL, 0x0000BEA2UL }, /* fpgm */ + { 0x70020112UL, 0x00000008UL } /* prep */ }, { /* HuaTianSongTi */ - { 0xfffbfffc, 0x00000008 }, /* cvt */ - { 0x0a5a0483, 0x00017c39 }, /* fpgm */ - { 0x70020112, 0x00000008 } /* prep */ + { 0xFFFBFFFCUL, 0x00000008UL }, /* cvt */ + { 0x0A5A0483UL, 0x00017C39UL }, /* fpgm */ + { 0x70020112UL, 0x00000008UL } /* prep */ }, { /* NEC fadpop7.ttf */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x40c92555, 0x000000e5 }, /* fpgm */ - { 0xa39b58e3, 0x0000117c } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x40C92555UL, 0x000000E5UL }, /* fpgm */ + { 0xA39B58E3UL, 0x0000117CUL } /* prep */ }, { /* NEC fadrei5.ttf */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x33c41652, 0x000000e5 }, /* fpgm */ - { 0x26d6c52a, 0x00000f6a } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x33C41652UL, 0x000000E5UL }, /* fpgm */ + { 0x26D6C52AUL, 0x00000F6AUL } /* prep */ }, { /* NEC fangot7.ttf */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x6db1651d, 0x0000019d }, /* fpgm */ - { 0x6c6e4b03, 0x00002492 } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x6DB1651DUL, 0x0000019DUL }, /* fpgm */ + { 0x6C6E4B03UL, 0x00002492UL } /* prep */ }, { /* NEC fangyo5.ttf */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x40c92555, 0x000000e5 }, /* fpgm */ - { 0xde51fad0, 0x0000117c } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x40C92555UL, 0x000000E5UL }, /* fpgm */ + { 0xDE51FAD0UL, 0x0000117CUL } /* prep */ }, { /* NEC fankyo5.ttf */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x85e47664, 0x000000e5 }, /* fpgm */ - { 0xa6c62831, 0x00001caa } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x85E47664UL, 0x000000E5UL }, /* fpgm */ + { 0xA6C62831UL, 0x00001CAAUL } /* prep */ }, { /* NEC fanrgo5.ttf */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x2d891cfd, 0x0000019d }, /* fpgm */ - { 0xa0604633, 0x00001de8 } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x2D891CFDUL, 0x0000019DUL }, /* fpgm */ + { 0xA0604633UL, 0x00001DE8UL } /* prep */ }, { /* NEC fangot5.ttc */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x40aa774c, 0x000001cb }, /* fpgm */ - { 0x9b5caa96, 0x00001f9a } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x40AA774CUL, 0x000001CBUL }, /* fpgm */ + { 0x9B5CAA96UL, 0x00001F9AUL } /* prep */ }, { /* NEC fanmin3.ttc */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x0d3de9cb, 0x00000141 }, /* fpgm */ - { 0xd4127766, 0x00002280 } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x0D3DE9CBUL, 0x00000141UL }, /* fpgm */ + { 0xD4127766UL, 0x00002280UL } /* prep */ }, { /* NEC FA-Gothic, 1996 */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x4a692698, 0x000001f0 }, /* fpgm */ - { 0x340d4346, 0x00001fca } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x4A692698UL, 0x000001F0UL }, /* fpgm */ + { 0x340D4346UL, 0x00001FCAUL } /* prep */ }, { /* NEC FA-Minchou, 1996 */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0xcd34c604, 0x00000166 }, /* fpgm */ - { 0x6cf31046, 0x000022b0 } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0xCD34C604UL, 0x00000166UL }, /* fpgm */ + { 0x6CF31046UL, 0x000022B0UL } /* prep */ }, { /* NEC FA-RoundGothicB, 1996 */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0x5da75315, 0x0000019d }, /* fpgm */ - { 0x40745a5f, 0x000022e0 } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0x5DA75315UL, 0x0000019DUL }, /* fpgm */ + { 0x40745A5FUL, 0x000022E0UL } /* prep */ }, { /* NEC FA-RoundGothicM, 1996 */ - { 0x00000000, 0x00000000 }, /* cvt */ - { 0xf055fc48, 0x000001c2 }, /* fpgm */ - { 0x3900ded3, 0x00001e18 } /* prep */ + { 0x00000000UL, 0x00000000UL }, /* cvt */ + { 0xF055FC48UL, 0x000001C2UL }, /* fpgm */ + { 0x3900DED3UL, 0x00001E18UL } /* prep */ } }; @@ -760,7 +760,9 @@ if ( !exec ) return FT_THROW( Could_Not_Find_Context ); - TT_Load_Context( exec, face, size ); + error = TT_Load_Context( exec, face, size ); + if ( error ) + return error; exec->callTop = 0; exec->top = 0; @@ -801,18 +803,16 @@ if ( face->font_program_size > 0 ) { - error = TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); + TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); - if ( !error ) - { - FT_TRACE4(( "Executing `fpgm' table.\n" )); - - error = face->interpreter( exec ); - } + FT_TRACE4(( "Executing `fpgm' table.\n" )); + error = face->interpreter( exec ); } else error = FT_Err_Ok; + size->bytecode_ready = error; + if ( !error ) TT_Save_Context( exec, size ); @@ -854,7 +854,9 @@ if ( !exec ) return FT_THROW( Could_Not_Find_Context ); - TT_Load_Context( exec, face, size ); + error = TT_Load_Context( exec, face, size ); + if ( error ) + return error; exec->callTop = 0; exec->top = 0; @@ -872,9 +874,9 @@ if ( face->cvt_program_size > 0 ) { - error = TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); + TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); - if ( !error && !size->debug ) + if ( !size->debug ) { FT_TRACE4(( "Executing `prep' table.\n" )); @@ -884,6 +886,8 @@ else error = FT_Err_Ok; + size->cvt_ready = error; + /* UNDOCUMENTED! The MS rasterizer doesn't allow the following */ /* graphics state variables to be modified by the CVT program. */ @@ -912,10 +916,6 @@ return error; } -#endif /* TT_USE_BYTECODE_INTERPRETER */ - - -#ifdef TT_USE_BYTECODE_INTERPRETER static void tt_size_done_bytecode( FT_Size ftsize ) @@ -953,8 +953,8 @@ size->max_func = 0; size->max_ins = 0; - size->bytecode_ready = 0; - size->cvt_ready = 0; + size->bytecode_ready = -1; + size->cvt_ready = -1; } @@ -968,14 +968,13 @@ TT_Size size = (TT_Size)ftsize; TT_Face face = (TT_Face)ftsize->face; FT_Memory memory = face->root.memory; - FT_Int i; FT_UShort n_twilight; TT_MaxProfile* maxp = &face->max_profile; - size->bytecode_ready = 1; - size->cvt_ready = 0; + size->bytecode_ready = -1; + size->cvt_ready = -1; size->max_function_defs = maxp->maxFunctionDefs; size->max_instruction_defs = maxp->maxInstructionDefs; @@ -997,9 +996,11 @@ metrics->rotated = FALSE; metrics->stretched = FALSE; - /* set default compensation (all 0) */ - for ( i = 0; i < 4; i++ ) - metrics->compensations[i] = 0; + /* set default engine compensation */ + metrics->compensations[0] = 0; /* gray */ + metrics->compensations[1] = 0; /* black */ + metrics->compensations[2] = 0; /* white */ + metrics->compensations[3] = 0; /* reserved */ } /* allocate function defs, instruction defs, cvt, and storage area */ @@ -1052,15 +1053,14 @@ FT_Error error = FT_Err_Ok; - if ( !size->bytecode_ready ) - { + if ( size->bytecode_ready < 0 ) error = tt_size_init_bytecode( (FT_Size)size, pedantic ); - if ( error ) - goto Exit; - } + + if ( error || size->bytecode_ready ) + goto Exit; /* rescale CVT when needed */ - if ( !size->cvt_ready ) + if ( size->cvt_ready < 0 ) { FT_UInt i; TT_Face face = (TT_Face)size->root.face; @@ -1087,8 +1087,6 @@ size->GS = tt_default_graphics_state; error = tt_size_run_prep( size, pedantic ); - if ( !error ) - size->cvt_ready = 1; } Exit: @@ -1118,9 +1116,10 @@ TT_Size size = (TT_Size)ttsize; FT_Error error = FT_Err_Ok; + #ifdef TT_USE_BYTECODE_INTERPRETER - size->bytecode_ready = 0; - size->cvt_ready = 0; + size->bytecode_ready = -1; + size->cvt_ready = -1; #endif size->ttmetrics.valid = FALSE; @@ -1148,8 +1147,7 @@ #ifdef TT_USE_BYTECODE_INTERPRETER - if ( size->bytecode_ready ) - tt_size_done_bytecode( ttsize ); + tt_size_done_bytecode( ttsize ); #endif size->ttmetrics.valid = FALSE; @@ -1229,7 +1227,7 @@ } #ifdef TT_USE_BYTECODE_INTERPRETER - size->cvt_ready = 0; + size->cvt_ready = -1; #endif /* TT_USE_BYTECODE_INTERPRETER */ if ( !error ) diff --git a/freetype/src/truetype/ttobjs.h b/freetype/src/truetype/ttobjs.h index bcd776532..f029923d3 100644 --- a/freetype/src/truetype/ttobjs.h +++ b/freetype/src/truetype/ttobjs.h @@ -4,7 +4,7 @@ /* */ /* Objects manager (specification). */ /* */ -/* Copyright 1996-2009, 2011-2013 by */ +/* Copyright 1996-2009, 2011-2014 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -95,8 +95,8 @@ FT_BEGIN_HEADER FT_F26Dot6 control_value_cutin; FT_F26Dot6 single_width_cutin; FT_F26Dot6 single_width_value; - FT_Short delta_base; - FT_Short delta_shift; + FT_UShort delta_base; + FT_UShort delta_shift; FT_Byte instruct_control; /* According to Greg Hitchcock from Microsoft, the `scan_control' */ @@ -333,8 +333,10 @@ FT_BEGIN_HEADER FT_Bool debug; TT_ExecContext context; - FT_Bool bytecode_ready; - FT_Bool cvt_ready; + /* if negative, `fpgm' (resp. `prep'), wasn't executed yet; */ + /* otherwise it is the returned error code */ + FT_Error bytecode_ready; + FT_Error cvt_ready; #endif /* TT_USE_BYTECODE_INTERPRETER */ diff --git a/freetype/src/truetype/ttpload.c b/freetype/src/truetype/ttpload.c index 2ee5d38b8..33bca68fe 100644 --- a/freetype/src/truetype/ttpload.c +++ b/freetype/src/truetype/ttpload.c @@ -508,9 +508,9 @@ record_size = FT_NEXT_ULONG( p ); /* The maximum number of bytes in an hdmx device record is the */ - /* maximum number of glyphs + 2; this is 0xFFFF + 2; this is */ - /* the reason why `record_size' is a long (which we read as */ - /* unsigned long for convenience). In practice, two bytes */ + /* maximum number of glyphs + 2; this is 0xFFFF + 2, thus */ + /* explaining why `record_size' is a long (which we read as */ + /* unsigned long for convenience). In practice, two bytes are */ /* sufficient to hold the size value. */ /* */ /* There are at least two fonts, HANNOM-A and HANNOM-B version */ @@ -522,8 +522,10 @@ record_size &= 0xFFFFU; /* The limit for `num_records' is a heuristic value. */ - - if ( version != 0 || num_records > 255 || record_size > 0x10001L ) + if ( version != 0 || + num_records > 255 || + record_size > 0x10001L || + record_size < 4 ) { error = FT_THROW( Invalid_File_Format ); goto Fail; diff --git a/freetype/src/truetype/ttsubpix.c b/freetype/src/truetype/ttsubpix.c index 1f11d8d20..9955021f1 100644 --- a/freetype/src/truetype/ttsubpix.c +++ b/freetype/src/truetype/ttsubpix.c @@ -282,7 +282,7 @@ const SPH_TweakRule COMPATIBILITY_MODE_Rules [COMPATIBILITY_MODE_RULES_SIZE] = { - { "-", 0, "", 0 }, + { "Verdana Clones", 0, "", 0 }, }; @@ -956,7 +956,7 @@ if ( loader->exec->rasterizer_version != TT_INTERPRETER_VERSION_35 ) { loader->exec->rasterizer_version = TT_INTERPRETER_VERSION_35; - loader->exec->size->cvt_ready = FALSE; + loader->exec->size->cvt_ready = -1; tt_size_ready_bytecode( loader->exec->size, @@ -971,7 +971,7 @@ SPH_OPTION_SET_RASTERIZER_VERSION ) { loader->exec->rasterizer_version = SPH_OPTION_SET_RASTERIZER_VERSION; - loader->exec->size->cvt_ready = FALSE; + loader->exec->size->cvt_ready = -1; tt_size_ready_bytecode( loader->exec->size, -- cgit v1.2.3