summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c')
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c173
1 files changed, 98 insertions, 75 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c
index 4a506ee8163..af31408cbf9 100644
--- a/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c
+++ b/Build/source/libs/freetype2/freetype-src/src/truetype/ttinterp.c
@@ -4,7 +4,7 @@
/* */
/* TrueType bytecode interpreter (body). */
/* */
-/* Copyright 1996-2016 by */
+/* Copyright 1996-2017 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -402,7 +402,7 @@
exec->IDefs = size->instruction_defs;
exec->pointSize = size->point_size;
exec->tt_metrics = size->ttmetrics;
- exec->metrics = size->metrics;
+ exec->metrics = *size->metrics;
exec->maxFunc = size->max_func;
exec->maxIns = size->max_ins;
@@ -1656,7 +1656,7 @@
/* zone :: The affected glyph zone. */
/* */
/* <Note> */
- /* See `ttinterp.h' for details on backwards compatibility mode. */
+ /* See `ttinterp.h' for details on backward compatibility mode. */
/* `Touches' the point. */
/* */
static void
@@ -1684,7 +1684,7 @@
/* Exception to the post-IUP curfew: Allow the x component of */
/* diagonal moves, but only post-IUP. DejaVu tries to adjust */
/* diagonal stems like on `Z' and `z' post-IUP. */
- if ( SUBPIXEL_HINTING_MINIMAL && !exc->backwards_compatibility )
+ if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
zone->cur[point].x += FT_MulDiv( distance, v, exc->F_dot_P );
else
#endif
@@ -1700,10 +1700,10 @@
if ( v != 0 )
{
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( !( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility &&
- exc->iupx_called &&
- exc->iupy_called ) )
+ if ( !( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called ) )
#endif
zone->cur[point].y += FT_MulDiv( distance, v, exc->F_dot_P );
@@ -1756,7 +1756,7 @@
/* */
/* The following versions are used whenever both vectors are both */
/* along one of the coordinate unit vectors, i.e. in 90% of the cases. */
- /* See `ttinterp.h' for details on backwards compatibility mode. */
+ /* See `ttinterp.h' for details on backward compatibility mode. */
/* */
/*************************************************************************/
@@ -1774,7 +1774,7 @@
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( SUBPIXEL_HINTING_MINIMAL && !exc->backwards_compatibility )
+ if ( SUBPIXEL_HINTING_MINIMAL && !exc->backward_compatibility )
zone->cur[point].x += distance;
else
#endif
@@ -1796,7 +1796,7 @@
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
if ( !( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility &&
+ exc->backward_compatibility &&
exc->iupx_called && exc->iupy_called ) )
#endif
zone->cur[point].y += distance;
@@ -3564,6 +3564,13 @@
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
+ /* FDEF is only allowed in `prep' or `fpgm' */
+ if ( exc->curRange == tt_coderange_glyph )
+ {
+ exc->error = FT_THROW( DEF_In_Glyf_Bytecode );
+ return;
+ }
+
/* some font programs are broken enough to redefine functions! */
/* We will then parse the current table. */
@@ -3990,6 +3997,13 @@
TT_DefRecord* limit;
+ /* we enable IDEF only in `prep' or `fpgm' */
+ if ( exc->curRange == tt_coderange_glyph )
+ {
+ exc->error = FT_THROW( DEF_In_Glyf_Bytecode );
+ return;
+ }
+
/* First of all, look for the same function in our table */
def = exc->IDefs;
@@ -5112,11 +5126,11 @@
#endif
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* Native ClearType fonts sign a waiver that turns off all backwards */
+ /* Native ClearType fonts sign a waiver that turns off all backward */
/* compatibility hacks and lets them program points to the grid like */
/* it's 1996. They might sign a waiver for just one glyph, though. */
if ( SUBPIXEL_HINTING_MINIMAL )
- exc->backwards_compatibility = !FT_BOOL( L == 4 );
+ exc->backward_compatibility = !FT_BOOL( L == 4 );
#endif
}
}
@@ -5204,11 +5218,11 @@
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backwards compatibility mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility &&
- exc->iupx_called &&
- exc->iupy_called )
+ /* See `ttinterp.h' for details on backward compatibility mode. */
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called )
goto Fail;
#endif
@@ -5259,11 +5273,11 @@
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backwards compatibility mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility &&
- exc->iupx_called &&
- exc->iupy_called )
+ /* See `ttinterp.h' for details on backward compatibility mode. */
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called )
return;
#endif
@@ -5297,11 +5311,11 @@
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backwards compatibility mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility &&
- exc->iupx_called &&
- exc->iupy_called )
+ /* See `ttinterp.h' for details on backward compatibility mode. */
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called )
return;
#endif
@@ -5364,7 +5378,7 @@
}
- /* See `ttinterp.h' for details on backwards compatibility mode. */
+ /* See `ttinterp.h' for details on backward compatibility mode. */
static void
Move_Zp2_Point( TT_ExecContext exc,
FT_UShort point,
@@ -5375,8 +5389,8 @@
if ( exc->GS.freeVector.x != 0 )
{
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( !( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility ) )
+ if ( !( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility ) )
#endif
exc->zp2.cur[point].x += dx;
@@ -5387,10 +5401,10 @@
if ( exc->GS.freeVector.y != 0 )
{
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( !( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility &&
- exc->iupx_called &&
- exc->iupy_called ) )
+ if ( !( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility &&
+ exc->iupx_called &&
+ exc->iupy_called ) )
#endif
exc->zp2.cur[point].y += dy;
@@ -5687,14 +5701,14 @@
else
#endif
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility )
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility )
{
/* Special case: allow SHPIX to move points in the twilight zone. */
/* Otherwise, treat SHPIX the same as DELTAP. Unbreaks various */
/* fonts such as older versions of Rokkitt and DTL Argo T Light */
- /* that would glitch severly after calling ALIGNRP after a blocked */
- /* SHPIX. */
+ /* that would glitch severely after calling ALIGNRP after a */
+ /* blocked SHPIX. */
if ( in_twilight ||
( !( exc->iupx_called && exc->iupy_called ) &&
( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
@@ -6452,7 +6466,7 @@
R.x = FT_MulDiv( val, dax, discriminant );
R.y = FT_MulDiv( val, day, discriminant );
- /* XXX: Block in backwards_compatibility and/or post-IUP? */
+ /* XXX: Block in backward_compatibility and/or post-IUP? */
exc->zp2.cur[point].x = exc->zp1.cur[a0].x + R.x;
exc->zp2.cur[point].y = exc->zp1.cur[a0].y + R.y;
}
@@ -6460,7 +6474,7 @@
{
/* else, take the middle of the middles of A and B */
- /* XXX: Block in backwards_compatibility and/or post-IUP? */
+ /* XXX: Block in backward_compatibility and/or post-IUP? */
exc->zp2.cur[point].x = ( exc->zp1.cur[a0].x +
exc->zp1.cur[a1].x +
exc->zp0.cur[b0].x +
@@ -6852,11 +6866,11 @@
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backwards compatibility mode. */
+ /* See `ttinterp.h' for details on backward compatibility mode. */
/* Allow IUP until it has been called on both axes. Immediately */
/* return on subsequent ones. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility )
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility )
{
if ( exc->iupx_called && exc->iupy_called )
return;
@@ -7098,10 +7112,10 @@
{
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* See `ttinterp.h' for details on backwards compatibility */
- /* mode. */
- if ( SUBPIXEL_HINTING_MINIMAL &&
- exc->backwards_compatibility )
+ /* See `ttinterp.h' for details on backward compatibility */
+ /* mode. */
+ if ( SUBPIXEL_HINTING_MINIMAL &&
+ exc->backward_compatibility )
{
if ( !( exc->iupx_called && exc->iupy_called ) &&
( ( exc->is_composite && exc->GS.freeVector.y != 0 ) ||
@@ -7245,7 +7259,7 @@
{
if ( exc->ignore_x_mode )
{
- /* if in ClearType backwards compatibility mode, */
+ /* if in ClearType backward compatibility mode, */
/* we sometimes change the TrueType version dynamically */
K = exc->rasterizer_version;
FT_TRACE6(( "Setting rasterizer version %d\n",
@@ -7575,15 +7589,15 @@
#endif /* TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY */
#ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL
- /* Toggle backwards compatibility according to what font says, except */
+ /* Toggle backward compatibility according to what font says, except */
/* when it's a `tricky' font that heavily relies on the interpreter to */
- /* render glyphs correctly, e.g. DFKai-SB. Backwards compatibility */
+ /* render glyphs correctly, e.g. DFKai-SB. Backward compatibility */
/* hacks may break it. */
if ( SUBPIXEL_HINTING_MINIMAL &&
!FT_IS_TRICKY( &exc->face->root ) )
- exc->backwards_compatibility = !( exc->GS.instruct_control & 4 );
+ exc->backward_compatibility = !( exc->GS.instruct_control & 4 );
else
- exc->backwards_compatibility = FALSE;
+ exc->backward_compatibility = FALSE;
exc->iupx_called = FALSE;
exc->iupy_called = FALSE;
@@ -7605,21 +7619,35 @@
exc->twilight.n_points = (FT_UShort)num_twilight_points;
}
- /* Set up loop detectors. We restrict the number of LOOPCALL loops */
- /* and the number of JMPR, JROT, and JROF calls with a negative */
- /* argument to values that depend on the size of the CVT table and */
- /* the number of points in the current glyph (if applicable). */
- /* */
- /* The idea is that in real-world bytecode you either iterate over */
- /* all CVT entries, or over all points (or contours) of a glyph, and */
- /* such iterations don't happen very often. */
+ /* Set up loop detectors. We restrict the number of LOOPCALL loops */
+ /* and the number of JMPR, JROT, and JROF calls with a negative */
+ /* argument to values that depend on various parameters like the */
+ /* size of the CVT table or the number of points in the current */
+ /* glyph (if applicable). */
+ /* */
+ /* The idea is that in real-world bytecode you either iterate over */
+ /* all CVT entries (in the `prep' table), or over all points (or */
+ /* contours, in the `glyf' table) of a glyph, and such iterations */
+ /* don't happen very often. */
exc->loopcall_counter = 0;
exc->neg_jump_counter = 0;
/* The maximum values are heuristic. */
- exc->loopcall_counter_max = FT_MAX( 100,
- 10 * ( exc->pts.n_points +
- exc->cvtSize ) );
+ if ( exc->pts.n_points )
+ exc->loopcall_counter_max = FT_MAX( 50,
+ 10 * exc->pts.n_points ) +
+ FT_MAX( 50,
+ exc->cvtSize / 10 );
+ else
+ exc->loopcall_counter_max = FT_MAX( 100,
+ 10 * exc->cvtSize );
+
+ /* as a protection against an unreasonable number of CVT entries */
+ /* we assume at most 100 control values per glyph for the counter */
+ if ( exc->loopcall_counter_max >
+ 100 * (FT_ULong)exc->face->root.num_glyphs )
+ exc->loopcall_counter_max = 100 * (FT_ULong)exc->face->root.num_glyphs;
+
FT_TRACE5(( "TT_RunIns: Limiting total number of loops in LOOPCALL"
" to %d\n", exc->loopcall_counter_max ));
@@ -8394,23 +8422,18 @@
exc->error = FT_THROW( Code_Overflow );
LErrorLabel_:
- /* 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 ( exc->error &&
- !exc->instruction_trap &&
- exc->curRange == tt_coderange_glyph )
- {
+ if ( exc->error && !exc->instruction_trap )
FT_TRACE1(( " The interpreter returned error 0x%x\n", exc->error ));
- exc->size->bytecode_ready = -1;
- exc->size->cvt_ready = -1;
- }
return exc->error;
}
+#else /* !TT_USE_BYTECODE_INTERPRETER */
+
+ /* ANSI C doesn't like empty source files */
+ typedef int _tt_interp_dummy;
-#endif /* TT_USE_BYTECODE_INTERPRETER */
+#endif /* !TT_USE_BYTECODE_INTERPRETER */
/* END */