summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype2/freetype-src/src/cff
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/freetype2/freetype-src/src/cff')
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/Jamfile2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c13
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c205
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cff.c10
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c85
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c49
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffload.c169
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffload.h7
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c117
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h10
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c47
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h12
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h31
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h9
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/module.mk2
-rw-r--r--Build/source/libs/freetype2/freetype-src/src/cff/rules.mk2
24 files changed, 527 insertions, 259 deletions
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile b/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile
index 8067e6b29cb..e6dd05fc15a 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/cff Jamfile
#
-# Copyright 2001-2016 by
+# Copyright 2001-2017 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h b/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h
index 512edd1d21e..d2c770d2974 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cf2error.h
@@ -66,7 +66,7 @@ FT_BEGIN_HEADER
* model our error mechanism on a Java-like exception mechanism.
* When we assign an error code we are thus `throwing' an error.
*
- * The perservation of an error code is done by coding convention.
+ * The preservation of an error code is done by coding convention.
* Upon a function call if the error code is anything other than
* `FT_Err_Ok', which is guaranteed to be zero, we
* will return without altering that error. This will allow the
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c
index c0d067e94ee..eb8472f119a 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cf2ft.c
@@ -340,6 +340,11 @@
CFF_Builder* builder = &decoder->builder;
CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( builder->face );
+ FT_Bool no_stem_darkening_driver =
+ driver->no_stem_darkening;
+ FT_Char no_stem_darkening_font =
+ builder->face->root.internal->no_stem_darkening;
+
/* local error */
FT_Error error2 = FT_Err_Ok;
CF2_BufferRec buf;
@@ -368,12 +373,14 @@
&scaled );
/* copy isCFF2 boolean from TT_Face to CF2_Font */
- font->isCFF2 = builder->face->isCFF2;
+ font->isCFF2 = builder->face->is_cff2;
font->renderingFlags = 0;
if ( hinted )
font->renderingFlags |= CF2_FlagsHinted;
- if ( scaled && !driver->no_stem_darkening )
+ if ( scaled && ( !no_stem_darkening_font ||
+ ( no_stem_darkening_font < 0 &&
+ !no_stem_darkening_driver ) ) )
font->renderingFlags |= CF2_FlagsDarkened;
font->darkenParams[0] = driver->darken_params[0];
@@ -450,7 +457,7 @@
FT_ASSERT( decoder && decoder->builder.face );
FT_ASSERT( vec && len );
- return cff_get_var_blend( decoder->builder.face, len, vec, NULL );
+ return cff_get_var_blend( decoder->builder.face, len, NULL, vec, NULL );
}
#endif
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c b/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c
index 6bf298a4d60..40bd9059a13 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cf2intrp.c
@@ -60,12 +60,6 @@
#define FT_COMPONENT trace_cf2interp
- /* some operators are not implemented yet */
-#define CF2_FIXME FT_TRACE4(( "cf2_interpT2CharString:" \
- " operator not implemented yet\n" ))
-
-
-
FT_LOCAL_DEF( void )
cf2_hintmask_init( CF2_HintMask hintmask,
FT_Error* error )
@@ -339,14 +333,14 @@
FT_Bool doConditionalLastRead )
{
CF2_Fixed vals[14];
- CF2_UInt index;
+ CF2_UInt idx;
FT_Bool isHFlex;
CF2_Int top, i, j;
vals[0] = *curX;
vals[1] = *curY;
- index = 0;
+ idx = 0;
isHFlex = FT_BOOL( readFromStack[9] == FALSE );
top = isHFlex ? 9 : 10;
@@ -354,7 +348,7 @@
{
vals[i + 2] = vals[i];
if ( readFromStack[i] )
- vals[i + 2] += cf2_stack_getReal( opStack, index++ );
+ vals[i + 2] += cf2_stack_getReal( opStack, idx++ );
}
if ( isHFlex )
@@ -364,7 +358,7 @@
{
FT_Bool lastIsX = (FT_Bool)( cf2_fixedAbs( vals[10] - *curX ) >
cf2_fixedAbs( vals[11] - *curY ) );
- CF2_Fixed lastVal = cf2_stack_getReal( opStack, index );
+ CF2_Fixed lastVal = cf2_stack_getReal( opStack, idx );
if ( lastIsX )
@@ -381,12 +375,12 @@
else
{
if ( readFromStack[10] )
- vals[12] = vals[10] + cf2_stack_getReal( opStack, index++ );
+ vals[12] = vals[10] + cf2_stack_getReal( opStack, idx++ );
else
vals[12] = *curX;
if ( readFromStack[11] )
- vals[13] = vals[11] + cf2_stack_getReal( opStack, index );
+ vals[13] = vals[11] + cf2_stack_getReal( opStack, idx );
else
vals[13] = *curY;
}
@@ -781,16 +775,16 @@
case cf2_cmdRLINETO:
{
- CF2_UInt index;
+ CF2_UInt idx;
CF2_UInt count = cf2_stack_count( opStack );
FT_TRACE4(( " rlineto\n" ));
- for ( index = 0; index < count; index += 2 )
+ for ( idx = 0; idx < count; idx += 2 )
{
- curX += cf2_stack_getReal( opStack, index + 0 );
- curY += cf2_stack_getReal( opStack, index + 1 );
+ curX += cf2_stack_getReal( opStack, idx + 0 );
+ curY += cf2_stack_getReal( opStack, idx + 1 );
cf2_glyphpath_lineTo( &glyphPath, curX, curY );
}
@@ -802,7 +796,7 @@
case cf2_cmdHLINETO:
case cf2_cmdVLINETO:
{
- CF2_UInt index;
+ CF2_UInt idx;
CF2_UInt count = cf2_stack_count( opStack );
FT_Bool isX = FT_BOOL( op1 == cf2_cmdHLINETO );
@@ -810,9 +804,9 @@
FT_TRACE4(( isX ? " hlineto\n" : " vlineto\n" ));
- for ( index = 0; index < count; index++ )
+ for ( idx = 0; idx < count; idx++ )
{
- CF2_Fixed v = cf2_stack_getReal( opStack, index );
+ CF2_Fixed v = cf2_stack_getReal( opStack, idx );
if ( isX )
@@ -833,33 +827,33 @@
case cf2_cmdRRCURVETO:
{
CF2_UInt count = cf2_stack_count( opStack );
- CF2_UInt index = 0;
+ CF2_UInt idx = 0;
FT_TRACE4(( op1 == cf2_cmdRCURVELINE ? " rcurveline\n"
: " rrcurveto\n" ));
- while ( index + 6 <= count )
+ while ( idx + 6 <= count )
{
- CF2_Fixed x1 = cf2_stack_getReal( opStack, index + 0 ) + curX;
- CF2_Fixed y1 = cf2_stack_getReal( opStack, index + 1 ) + curY;
- CF2_Fixed x2 = cf2_stack_getReal( opStack, index + 2 ) + x1;
- CF2_Fixed y2 = cf2_stack_getReal( opStack, index + 3 ) + y1;
- CF2_Fixed x3 = cf2_stack_getReal( opStack, index + 4 ) + x2;
- CF2_Fixed y3 = cf2_stack_getReal( opStack, index + 5 ) + y2;
+ CF2_Fixed x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX;
+ CF2_Fixed y1 = cf2_stack_getReal( opStack, idx + 1 ) + curY;
+ CF2_Fixed x2 = cf2_stack_getReal( opStack, idx + 2 ) + x1;
+ CF2_Fixed y2 = cf2_stack_getReal( opStack, idx + 3 ) + y1;
+ CF2_Fixed x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2;
+ CF2_Fixed y3 = cf2_stack_getReal( opStack, idx + 5 ) + y2;
cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
- curX = x3;
- curY = y3;
- index += 6;
+ curX = x3;
+ curY = y3;
+ idx += 6;
}
if ( op1 == cf2_cmdRCURVELINE )
{
- curX += cf2_stack_getReal( opStack, index + 0 );
- curY += cf2_stack_getReal( opStack, index + 1 );
+ curX += cf2_stack_getReal( opStack, idx + 0 );
+ curY += cf2_stack_getReal( opStack, idx + 1 );
cf2_glyphpath_lineTo( &glyphPath, curX, curY );
}
@@ -1268,10 +1262,23 @@
continue; /* do not clear the stack */
case cf2_escRANDOM: /* in spec */
- FT_TRACE4(( " random\n" ));
+ {
+ CF2_F16Dot16 r;
- CF2_FIXME;
- break;
+
+ FT_TRACE4(( " random\n" ));
+
+ /* only use the lower 16 bits of `random' */
+ /* to generate a number in the range (0;1] */
+ r = (CF2_F16Dot16)
+ ( ( decoder->current_subfont->random & 0xFFFF ) + 1 );
+
+ decoder->current_subfont->random =
+ cff_random( decoder->current_subfont->random );
+
+ cf2_stack_pushFixed( opStack, r );
+ }
+ continue; /* do not clear the stack */
case cf2_escMUL:
{
@@ -1593,35 +1600,35 @@
case cf2_cmdRLINECURVE:
{
CF2_UInt count = cf2_stack_count( opStack );
- CF2_UInt index = 0;
+ CF2_UInt idx = 0;
FT_TRACE4(( " rlinecurve\n" ));
- while ( index + 6 < count )
+ while ( idx + 6 < count )
{
- curX += cf2_stack_getReal( opStack, index + 0 );
- curY += cf2_stack_getReal( opStack, index + 1 );
+ curX += cf2_stack_getReal( opStack, idx + 0 );
+ curY += cf2_stack_getReal( opStack, idx + 1 );
cf2_glyphpath_lineTo( &glyphPath, curX, curY );
- index += 2;
+ idx += 2;
}
- while ( index < count )
+ while ( idx < count )
{
- CF2_Fixed x1 = cf2_stack_getReal( opStack, index + 0 ) + curX;
- CF2_Fixed y1 = cf2_stack_getReal( opStack, index + 1 ) + curY;
- CF2_Fixed x2 = cf2_stack_getReal( opStack, index + 2 ) + x1;
- CF2_Fixed y2 = cf2_stack_getReal( opStack, index + 3 ) + y1;
- CF2_Fixed x3 = cf2_stack_getReal( opStack, index + 4 ) + x2;
- CF2_Fixed y3 = cf2_stack_getReal( opStack, index + 5 ) + y2;
+ CF2_Fixed x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX;
+ CF2_Fixed y1 = cf2_stack_getReal( opStack, idx + 1 ) + curY;
+ CF2_Fixed x2 = cf2_stack_getReal( opStack, idx + 2 ) + x1;
+ CF2_Fixed y2 = cf2_stack_getReal( opStack, idx + 3 ) + y1;
+ CF2_Fixed x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2;
+ CF2_Fixed y3 = cf2_stack_getReal( opStack, idx + 5 ) + y2;
cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
- curX = x3;
- curY = y3;
- index += 6;
+ curX = x3;
+ curY = y3;
+ idx += 6;
}
cf2_stack_clear( opStack );
@@ -1631,42 +1638,42 @@
case cf2_cmdVVCURVETO:
{
CF2_UInt count, count1 = cf2_stack_count( opStack );
- CF2_UInt index = 0;
+ CF2_UInt idx = 0;
/* if `cf2_stack_count' isn't of the form 4n or 4n+1, */
/* we enforce it by clearing the second bit */
/* (and sorting the stack indexing to suit) */
- count = count1 & ~2U;
- index += count1 - count;
+ count = count1 & ~2U;
+ idx += count1 - count;
FT_TRACE4(( " vvcurveto\n" ));
- while ( index < count )
+ while ( idx < count )
{
CF2_Fixed x1, y1, x2, y2, x3, y3;
- if ( ( count - index ) & 1 )
+ if ( ( count - idx ) & 1 )
{
- x1 = cf2_stack_getReal( opStack, index ) + curX;
+ x1 = cf2_stack_getReal( opStack, idx ) + curX;
- index++;
+ idx++;
}
else
x1 = curX;
- y1 = cf2_stack_getReal( opStack, index + 0 ) + curY;
- x2 = cf2_stack_getReal( opStack, index + 1 ) + x1;
- y2 = cf2_stack_getReal( opStack, index + 2 ) + y1;
+ y1 = cf2_stack_getReal( opStack, idx + 0 ) + curY;
+ x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1;
+ y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1;
x3 = x2;
- y3 = cf2_stack_getReal( opStack, index + 3 ) + y2;
+ y3 = cf2_stack_getReal( opStack, idx + 3 ) + y2;
cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
- curX = x3;
- curY = y3;
- index += 4;
+ curX = x3;
+ curY = y3;
+ idx += 4;
}
cf2_stack_clear( opStack );
@@ -1676,42 +1683,42 @@
case cf2_cmdHHCURVETO:
{
CF2_UInt count, count1 = cf2_stack_count( opStack );
- CF2_UInt index = 0;
+ CF2_UInt idx = 0;
/* if `cf2_stack_count' isn't of the form 4n or 4n+1, */
/* we enforce it by clearing the second bit */
/* (and sorting the stack indexing to suit) */
- count = count1 & ~2U;
- index += count1 - count;
+ count = count1 & ~2U;
+ idx += count1 - count;
FT_TRACE4(( " hhcurveto\n" ));
- while ( index < count )
+ while ( idx < count )
{
CF2_Fixed x1, y1, x2, y2, x3, y3;
- if ( ( count - index ) & 1 )
+ if ( ( count - idx ) & 1 )
{
- y1 = cf2_stack_getReal( opStack, index ) + curY;
+ y1 = cf2_stack_getReal( opStack, idx ) + curY;
- index++;
+ idx++;
}
else
y1 = curY;
- x1 = cf2_stack_getReal( opStack, index + 0 ) + curX;
- x2 = cf2_stack_getReal( opStack, index + 1 ) + x1;
- y2 = cf2_stack_getReal( opStack, index + 2 ) + y1;
- x3 = cf2_stack_getReal( opStack, index + 3 ) + x2;
+ x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX;
+ x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1;
+ y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1;
+ x3 = cf2_stack_getReal( opStack, idx + 3 ) + x2;
y3 = y2;
cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
- curX = x3;
- curY = y3;
- index += 4;
+ curX = x3;
+ curY = y3;
+ idx += 4;
}
cf2_stack_clear( opStack );
@@ -1722,7 +1729,7 @@
case cf2_cmdHVCURVETO:
{
CF2_UInt count, count1 = cf2_stack_count( opStack );
- CF2_UInt index = 0;
+ CF2_UInt idx = 0;
FT_Bool alternate = FT_BOOL( op1 == cf2_cmdHVCURVETO );
@@ -1731,29 +1738,29 @@
/* 8n+4, or 8n+5, we enforce it by clearing the */
/* second bit */
/* (and sorting the stack indexing to suit) */
- count = count1 & ~2U;
- index += count1 - count;
+ count = count1 & ~2U;
+ idx += count1 - count;
FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" ));
- while ( index < count )
+ while ( idx < count )
{
CF2_Fixed x1, x2, x3, y1, y2, y3;
if ( alternate )
{
- x1 = cf2_stack_getReal( opStack, index + 0 ) + curX;
+ x1 = cf2_stack_getReal( opStack, idx + 0 ) + curX;
y1 = curY;
- x2 = cf2_stack_getReal( opStack, index + 1 ) + x1;
- y2 = cf2_stack_getReal( opStack, index + 2 ) + y1;
- y3 = cf2_stack_getReal( opStack, index + 3 ) + y2;
+ x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1;
+ y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1;
+ y3 = cf2_stack_getReal( opStack, idx + 3 ) + y2;
- if ( count - index == 5 )
+ if ( count - idx == 5 )
{
- x3 = cf2_stack_getReal( opStack, index + 4 ) + x2;
+ x3 = cf2_stack_getReal( opStack, idx + 4 ) + x2;
- index++;
+ idx++;
}
else
x3 = x2;
@@ -1763,16 +1770,16 @@
else
{
x1 = curX;
- y1 = cf2_stack_getReal( opStack, index + 0 ) + curY;
- x2 = cf2_stack_getReal( opStack, index + 1 ) + x1;
- y2 = cf2_stack_getReal( opStack, index + 2 ) + y1;
- x3 = cf2_stack_getReal( opStack, index + 3 ) + x2;
+ y1 = cf2_stack_getReal( opStack, idx + 0 ) + curY;
+ x2 = cf2_stack_getReal( opStack, idx + 1 ) + x1;
+ y2 = cf2_stack_getReal( opStack, idx + 2 ) + y1;
+ x3 = cf2_stack_getReal( opStack, idx + 3 ) + x2;
- if ( count - index == 5 )
+ if ( count - idx == 5 )
{
- y3 = cf2_stack_getReal( opStack, index + 4 ) + y2;
+ y3 = cf2_stack_getReal( opStack, idx + 4 ) + y2;
- index++;
+ idx++;
}
else
y3 = y2;
@@ -1782,9 +1789,9 @@
cf2_glyphpath_curveTo( &glyphPath, x1, y1, x2, y2, x3, y3 );
- curX = x3;
- curY = y3;
- index += 4;
+ curX = x3;
+ curY = y3;
+ idx += 4;
}
cf2_stack_clear( opStack );
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cff.c b/Build/source/libs/freetype2/freetype-src/src/cff/cff.c
index 86ca1be0403..397f6dfafe9 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cff.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cff.c
@@ -4,7 +4,7 @@
/* */
/* FreeType OpenType driver component (body only). */
/* */
-/* 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, */
@@ -17,16 +17,15 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
-
#include <ft2build.h>
-#include "cffpic.c"
+#include "cffcmap.c"
#include "cffdrivr.c"
+#include "cffgload.c"
#include "cffparse.c"
+#include "cffpic.c"
#include "cffload.c"
#include "cffobjs.c"
-#include "cffgload.c"
-#include "cffcmap.c"
#include "cf2arrst.c"
#include "cf2blues.c"
@@ -38,4 +37,5 @@
#include "cf2read.c"
#include "cf2stack.c"
+
/* END */
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c
index 695ba69d946..4adce7a54d9 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.c
@@ -4,7 +4,7 @@
/* */
/* CFF character mapping table (cmap) support (body). */
/* */
-/* Copyright 2002-2016 by */
+/* Copyright 2002-2017 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h
index 23795d50905..7792e042483 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffcmap.h
@@ -4,7 +4,7 @@
/* */
/* CFF character mapping table (cmap) support (specification). */
/* */
-/* Copyright 2002-2016 by */
+/* Copyright 2002-2017 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c
index 31825286e2f..38bfc2ca3dd 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.c
@@ -4,7 +4,7 @@
/* */
/* OpenType font driver implementation (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, */
@@ -34,6 +34,7 @@
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
#include FT_SERVICE_MULTIPLE_MASTERS_H
+#include FT_SERVICE_METRICS_VARIATIONS_H
#endif
#include "cfferrs.h"
@@ -832,6 +833,7 @@
{
FT_UInt* hinting_engine = (FT_UInt*)value;
+
if ( *hinting_engine == FT_CFF_HINTING_ADOBE
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
|| *hinting_engine == FT_CFF_HINTING_FREETYPE
@@ -853,12 +855,10 @@
long nsd = ft_strtol( s, NULL, 10 );
- if ( nsd == 0 )
- driver->no_stem_darkening = 0;
- else if ( nsd == 1 )
- driver->no_stem_darkening = 1;
+ if ( !nsd )
+ driver->no_stem_darkening = FALSE;
else
- return FT_THROW( Invalid_Argument );
+ driver->no_stem_darkening = TRUE;
}
else
#endif
@@ -871,6 +871,30 @@
return error;
}
+ else if ( !ft_strcmp( property_name, "random-seed" ) )
+ {
+ FT_Int32 random_seed;
+
+
+#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+ if ( value_is_string )
+ {
+ const char* s = (const char*)value;
+
+
+ random_seed = (FT_Int32)ft_strtol( s, NULL, 10 );
+ }
+ else
+#endif
+ random_seed = *(FT_Int32*)value;
+
+ if ( random_seed < 0 )
+ random_seed = 0;
+
+ driver->random_seed = random_seed;
+
+ return error;
+ }
FT_TRACE0(( "cff_property_set: missing property `%s'\n",
property_name ));
@@ -1018,6 +1042,49 @@
(FT_Get_Var_Blend_Func) cff_get_var_blend, /* get_var_blend */
(FT_Done_Blend_Func) cff_done_blend /* done_blend */
)
+
+
+ /*
+ * METRICS VARIATIONS SERVICE
+ *
+ */
+
+ static FT_Error
+ cff_hadvance_adjust( CFF_Face face,
+ FT_UInt gindex,
+ FT_Int *avalue )
+ {
+ FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)face->var;
+
+
+ return var->hadvance_adjust( FT_FACE( face ), gindex, avalue );
+ }
+
+
+ static void
+ cff_metrics_adjust( CFF_Face face )
+ {
+ FT_Service_MetricsVariations var = (FT_Service_MetricsVariations)face->var;
+
+
+ var->metrics_adjust( FT_FACE( face ) );
+ }
+
+
+ FT_DEFINE_SERVICE_METRICSVARIATIONSREC(
+ cff_service_metrics_variations,
+
+ (FT_HAdvance_Adjust_Func)cff_hadvance_adjust, /* hadvance_adjust */
+ (FT_LSB_Adjust_Func) NULL, /* lsb_adjust */
+ (FT_RSB_Adjust_Func) NULL, /* rsb_adjust */
+
+ (FT_VAdvance_Adjust_Func)NULL, /* vadvance_adjust */
+ (FT_TSB_Adjust_Func) NULL, /* tsb_adjust */
+ (FT_BSB_Adjust_Func) NULL, /* bsb_adjust */
+ (FT_VOrg_Adjust_Func) NULL, /* vorg_adjust */
+
+ (FT_Metrics_Adjust_Func) cff_metrics_adjust /* metrics_adjust */
+ )
#endif
@@ -1035,11 +1102,12 @@
#if !defined FT_CONFIG_OPTION_NO_GLYPH_NAMES && \
defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_DEFINE_SERVICEDESCREC8(
+ FT_DEFINE_SERVICEDESCREC9(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET,
+ FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_GLYPH_DICT, &CFF_SERVICE_GLYPH_DICT_GET,
@@ -1060,11 +1128,12 @@
FT_SERVICE_ID_PROPERTIES, &CFF_SERVICE_PROPERTIES_GET
)
#elif defined TT_CONFIG_OPTION_GX_VAR_SUPPORT
- FT_DEFINE_SERVICEDESCREC7(
+ FT_DEFINE_SERVICEDESCREC8(
cff_services,
FT_SERVICE_ID_FONT_FORMAT, FT_FONT_FORMAT_CFF,
FT_SERVICE_ID_MULTI_MASTERS, &CFF_SERVICE_MULTI_MASTERS_GET,
+ FT_SERVICE_ID_METRICS_VARIATIONS, &CFF_SERVICE_METRICS_VAR_GET,
FT_SERVICE_ID_POSTSCRIPT_INFO, &CFF_SERVICE_PS_INFO_GET,
FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &CFF_SERVICE_PS_NAME_GET,
FT_SERVICE_ID_TT_CMAP, &CFF_SERVICE_GET_CMAP_INFO_GET,
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h
index d7b05983748..05381e66db9 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffdrivr.h
@@ -4,7 +4,7 @@
/* */
/* High-level OpenType driver interface (specification). */
/* */
-/* 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, */
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h
index e7fc6eb71c8..40808c10513 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cfferrs.h
@@ -4,7 +4,7 @@
/* */
/* CFF error codes (specification only). */
/* */
-/* Copyright 2001-2016 by */
+/* Copyright 2001-2017 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c
index d8084f865ba..940804850e8 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.c
@@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (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, */
@@ -278,11 +278,15 @@
if ( hinting && size )
{
- CFF_Internal internal = (CFF_Internal)size->root.internal;
+ FT_Size ftsize = FT_SIZE( size );
+ CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data;
- builder->hints_globals = (void *)internal->topfont;
- builder->hints_funcs = glyph->root.internal->glyph_hints;
+ if ( internal )
+ {
+ builder->hints_globals = (void *)internal->topfont;
+ builder->hints_funcs = glyph->root.internal->glyph_hints;
+ }
}
}
@@ -440,7 +444,8 @@
if ( builder->hints_funcs && size )
{
- CFF_Internal internal = (CFF_Internal)size->root.internal;
+ FT_Size ftsize = FT_SIZE( size );
+ CFF_Internal internal = (CFF_Internal)ftsize->internal->module_data;
/* for CFFs without subfonts, this value has already been set */
@@ -457,7 +462,7 @@
decoder->glyph_width = sub->private_dict.default_width;
decoder->nominal_width = sub->private_dict.nominal_width;
- decoder->current_subfont = sub; /* for Adobe's CFF handler */
+ decoder->current_subfont = sub;
Exit:
return error;
@@ -913,7 +918,6 @@
FT_Byte* limit;
CFF_Builder* builder = &decoder->builder;
FT_Pos x, y;
- FT_Fixed seed;
FT_Fixed* stack;
FT_Int charstring_type =
decoder->cff->top_font.font_dict.charstring_type;
@@ -929,15 +933,6 @@
decoder->num_hints = 0;
decoder->read_width = 1;
- /* compute random seed from stack address of parameter */
- seed = (FT_Fixed)( ( (FT_Offset)(char*)&seed ^
- (FT_Offset)(char*)&decoder ^
- (FT_Offset)(char*)&charstring_base ) &
- FT_ULONG_MAX );
- seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
- if ( seed == 0 )
- seed = 0x7384;
-
/* initialize the decoder */
decoder->top = decoder->stack;
decoder->zone = decoder->zones;
@@ -2104,22 +2099,16 @@
break;
case cff_op_random:
- {
- FT_Fixed Rand;
-
+ FT_TRACE4(( " random\n" ));
- FT_TRACE4(( " rand\n" ));
-
- Rand = seed;
- if ( Rand >= 0x8000L )
- Rand++;
+ /* only use the lower 16 bits of `random' */
+ /* to generate a number in the range (0;1] */
+ args[0] = (FT_Fixed)
+ ( ( decoder->current_subfont->random & 0xFFFF ) + 1 );
+ args++;
- args[0] = Rand;
- seed = FT_MulFix( seed, 0x10000L - seed );
- if ( seed == 0 )
- seed += 0x2873;
- args++;
- }
+ decoder->current_subfont->random =
+ cff_random( decoder->current_subfont->random );
break;
case cff_op_mul:
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h
index b875fbed907..0fa93b43985 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffgload.h
@@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (specification). */
/* */
-/* 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, */
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c
index c1e6b14dbff..3beaeb1c8e7 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.c
@@ -4,7 +4,7 @@
/* */
/* OpenType and CFF data/program tables loader (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, */
@@ -1113,7 +1113,7 @@
/* convert 2.14 to Fixed */
- #define FT_fdot14ToFixed( x ) ( ( (FT_Fixed)( (FT_Int16)(x) ) ) << 2 )
+ #define FT_fdot14ToFixed( x ) ( (FT_Fixed)( (FT_ULong)(x) << 2 ) )
static FT_Error
@@ -1307,6 +1307,10 @@
size = 5 * numBlends; /* add 5 bytes per entry */
if ( subFont->blend_used + size > subFont->blend_alloc )
{
+ FT_Byte* blend_stack_old = subFont->blend_stack;
+ FT_Byte* blend_top_old = subFont->blend_top;
+
+
/* increase or allocate `blend_stack' and reset `blend_top'; */
/* prepare to append `numBlends' values to the buffer */
if ( FT_REALLOC( subFont->blend_stack,
@@ -1316,6 +1320,22 @@
subFont->blend_top = subFont->blend_stack + subFont->blend_used;
subFont->blend_alloc += size;
+
+ /* iterate over the parser stack and adjust pointers */
+ /* if the reallocated buffer has a different address */
+ if ( blend_stack_old &&
+ subFont->blend_stack != blend_stack_old )
+ {
+ FT_PtrDist offset = subFont->blend_stack - blend_stack_old;
+ FT_Byte** p;
+
+
+ for ( p = parser->stack; p < parser->top; p++ )
+ {
+ if ( *p >= blend_stack_old && *p < blend_top_old )
+ *p += offset;
+ }
+ }
}
subFont->blend_used += size;
@@ -1329,24 +1349,25 @@
/* convert inputs to 16.16 fixed point */
- sum = cff_parse_num( parser, &parser->stack[i + base] ) << 16;
+ sum = cff_parse_num( parser, &parser->stack[i + base] ) * 65536;
for ( j = 1; j < blend->lenBV; j++ )
sum += FT_MulFix( *weight++,
cff_parse_num( parser,
- &parser->stack[delta++] ) << 16 );
+ &parser->stack[delta++] ) * 65536 );
/* point parser stack to new value on blend_stack */
parser->stack[i + base] = subFont->blend_top;
- /* Push blended result as Type 2 5-byte fixed point number (except */
- /* that host byte order is used). This will not conflict with */
- /* actual DICTs because 255 is a reserved opcode in both CFF and */
- /* CFF2 DICTs. See `cff_parse_num' for decode of this, which rounds */
- /* to an integer. */
- *subFont->blend_top++ = 255;
- *((FT_UInt32*)subFont->blend_top) = (FT_UInt32)sum; /* write 4 bytes */
- subFont->blend_top += 4;
+ /* Push blended result as Type 2 5-byte fixed point number. This */
+ /* will not conflict with actual DICTs because 255 is a reserved */
+ /* opcode in both CFF and CFF2 DICTs. See `cff_parse_num' for */
+ /* decode of this, which rounds to an integer. */
+ *subFont->blend_top++ = 255;
+ *subFont->blend_top++ = ( (FT_UInt32)sum & 0xFF000000U ) >> 24;
+ *subFont->blend_top++ = ( (FT_UInt32)sum & 0x00FF0000U ) >> 16;
+ *subFont->blend_top++ = ( (FT_UInt32)sum & 0x0000FF00U ) >> 8;
+ *subFont->blend_top++ = (FT_UInt32)sum & 0x000000FFU;
}
/* leave only numBlends results on parser stack */
@@ -1442,10 +1463,15 @@
/* Note: `lenNDV' could be zero. */
/* In that case, build default blend vector (1,0,0...). */
- /* In the normal case, initialize each component to 1 */
- /* before inner loop. */
- if ( lenNDV != 0 )
- blend->BV[master] = FT_FIXED_ONE; /* default */
+ if ( !lenNDV )
+ {
+ blend->BV[master] = 0;
+ continue;
+ }
+
+ /* In the normal case, initialize each component to 1 */
+ /* before inner loop. */
+ blend->BV[master] = FT_FIXED_ONE; /* default */
/* inner loop steps through axes in this region */
for ( j = 0; j < lenNDV; j++ )
@@ -1508,12 +1534,12 @@
lenNDV * sizeof ( *NDV ) ) )
goto Exit;
- blend->lenNDV = lenNDV;
FT_MEM_COPY( blend->lastNDV,
NDV,
lenNDV * sizeof ( *NDV ) );
}
+ blend->lenNDV = lenNDV;
blend->builtBV = TRUE;
Exit:
@@ -1551,12 +1577,17 @@
cff_get_var_blend( CFF_Face face,
FT_UInt *num_coords,
FT_Fixed* *coords,
+ FT_Fixed* *normalizedcoords,
FT_MM_Var* *mm_var )
{
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
- return mm->get_var_blend( FT_FACE( face ), num_coords, coords, mm_var );
+ return mm->get_var_blend( FT_FACE( face ),
+ num_coords,
+ coords,
+ normalizedcoords,
+ mm_var );
}
@@ -1864,7 +1895,8 @@
subfont->lenNDV = lenNDV;
subfont->NDV = NDV;
- stackSize = font->cff2 ? font->top_font.font_dict.maxstack
+ /* add 1 for the operator */
+ stackSize = font->cff2 ? font->top_font.font_dict.maxstack + 1
: CFF_MAX_STACK_DEPTH + 1;
if ( cff_parser_init( &parser,
@@ -1892,6 +1924,13 @@
/* ensure that `num_blue_values' is even */
priv->num_blue_values &= ~1;
+ /* sanitize `initialRandomSeed' to be a positive value, if necessary; */
+ /* this is not mandated by the specification but by our implementation */
+ if ( priv->initial_random_seed < 0 )
+ priv->initial_random_seed = -priv->initial_random_seed;
+ else if ( priv->initial_random_seed == 0 )
+ priv->initial_random_seed = 987654321;
+
Exit:
/* clean up */
cff_blend_clear( subfont ); /* clear blend stack */
@@ -1903,6 +1942,18 @@
}
+ FT_LOCAL_DEF( FT_UInt32 )
+ cff_random( FT_UInt32 r )
+ {
+ /* a 32bit version of the `xorshift' algorithm */
+ r ^= r << 13;
+ r ^= r >> 17;
+ r ^= r << 5;
+
+ return r;
+ }
+
+
/* There are 3 ways to call this function, distinguished by code. */
/* */
/* . CFF_CODE_TOPDICT for either a CFF Top DICT or a CFF Font DICT */
@@ -1916,7 +1967,8 @@
FT_Stream stream,
FT_ULong base_offset,
FT_UInt code,
- CFF_Font font )
+ CFF_Font font,
+ CFF_Face face )
{
FT_Error error;
CFF_ParserRec parser;
@@ -2013,6 +2065,55 @@
if ( error )
goto Exit;
+ if ( !cff2 )
+ {
+ /*
+ * Initialize the random number generator.
+ *
+ * . If we have a face-specific seed, use it.
+ * If non-zero, update it to a positive value.
+ *
+ * . Otherwise, use the seed from the CFF driver.
+ * If non-zero, update it to a positive value.
+ *
+ * . If the random value is zero, use the seed given by the subfont's
+ * `initialRandomSeed' value.
+ *
+ */
+ if ( face->root.internal->random_seed == -1 )
+ {
+ CFF_Driver driver = (CFF_Driver)FT_FACE_DRIVER( face );
+
+
+ subfont->random = (FT_UInt32)driver->random_seed;
+ if ( driver->random_seed )
+ {
+ do
+ {
+ driver->random_seed =
+ (FT_Int32)cff_random( (FT_UInt32)driver->random_seed );
+
+ } while ( driver->random_seed < 0 );
+ }
+ }
+ else
+ {
+ subfont->random = (FT_UInt32)face->root.internal->random_seed;
+ if ( face->root.internal->random_seed )
+ {
+ do
+ {
+ face->root.internal->random_seed =
+ (FT_Int32)cff_random( (FT_UInt32)face->root.internal->random_seed );
+
+ } while ( face->root.internal->random_seed < 0 );
+ }
+ }
+
+ if ( !subfont->random )
+ subfont->random = (FT_UInt32)priv->initial_random_seed;
+ }
+
/* read the local subrs, if any */
if ( priv->local_subrs_offset )
{
@@ -2058,6 +2159,7 @@
FT_Stream stream,
FT_Int face_index,
CFF_Font font,
+ CFF_Face face,
FT_Bool pure_cff,
FT_Bool cff2 )
{
@@ -2178,6 +2280,18 @@
goto Exit;
}
+ /* if we have an empty font name, */
+ /* it must be the only font in the CFF */
+ if ( font->name_index.count > 1 &&
+ font->name_index.data_size < font->name_index.count )
+ {
+ /* for pure CFFs, we still haven't checked enough bytes */
+ /* to be sure that it is a CFF at all */
+ error = pure_cff ? FT_THROW( Unknown_File_Format )
+ : FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
+
if ( FT_SET_ERROR( cff_index_init( &font->font_dict_index,
stream, 0, cff2 ) ) ||
FT_SET_ERROR( cff_index_init( &string_index,
@@ -2189,6 +2303,15 @@
&font->string_pool,
&font->string_pool_size ) ) )
goto Exit;
+
+ /* there must be a Top DICT index entry for each name index entry */
+ if ( font->name_index.count > font->font_dict_index.count )
+ {
+ FT_ERROR(( "cff_font_load:"
+ " not enough entries in Top DICT index\n" ));
+ error = FT_THROW( Invalid_File_Format );
+ goto Exit;
+ }
}
font->num_strings = string_index.count;
@@ -2236,7 +2359,8 @@
stream,
base_offset,
cff2 ? CFF2_CODE_TOPDICT : CFF_CODE_TOPDICT,
- font );
+ font,
+ face );
if ( error )
goto Exit;
@@ -2303,7 +2427,8 @@
base_offset,
cff2 ? CFF2_CODE_FONTDICT
: CFF_CODE_TOPDICT,
- font );
+ font,
+ face );
if ( error )
goto Fail_CID;
}
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h
index dc3a2c52368..c745e8127b3 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffload.h
@@ -4,7 +4,7 @@
/* */
/* OpenType & CFF data/program tables loader (specification). */
/* */
-/* 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, */
@@ -61,11 +61,15 @@ FT_BEGIN_HEADER
FT_UInt cid );
+ FT_LOCAL( FT_UInt32 )
+ cff_random( FT_UInt32 r );
+
FT_LOCAL( FT_Error )
cff_font_load( FT_Library library,
FT_Stream stream,
FT_Int face_index,
CFF_Font font,
+ CFF_Face face,
FT_Bool pure_cff,
FT_Bool cff2 );
@@ -108,6 +112,7 @@ FT_BEGIN_HEADER
cff_get_var_blend( CFF_Face face,
FT_UInt *num_coords,
FT_Fixed* *coords,
+ FT_Fixed* *normalizedcoords,
FT_MM_Var* *mm_var );
FT_LOCAL( void )
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c
index 926effc5236..61613933ff7 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.c
@@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (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, */
@@ -27,6 +27,11 @@
#include FT_INTERNAL_SFNT_H
#include FT_CFF_DRIVER_H
+#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
+#include FT_MULTIPLE_MASTERS_H
+#include FT_SERVICE_MULTIPLE_MASTERS_H
+#endif
+
#include "cffobjs.h"
#include "cffload.h"
#include "cffcmap.h"
@@ -49,9 +54,6 @@
/* */
/* SIZE FUNCTIONS */
/* */
- /* Note that we store the global hints in the size's `internal' root */
- /* field. */
- /* */
/*************************************************************************/
@@ -75,10 +77,11 @@
FT_LOCAL_DEF( void )
cff_size_done( FT_Size cffsize ) /* CFF_Size */
{
+ FT_Memory memory = cffsize->face->memory;
CFF_Size size = (CFF_Size)cffsize;
CFF_Face face = (CFF_Face)size->root.face;
CFF_Font font = (CFF_Font)face->extra.data;
- CFF_Internal internal = (CFF_Internal)cffsize->internal;
+ CFF_Internal internal = (CFF_Internal)cffsize->internal->module_data;
if ( internal )
@@ -98,7 +101,7 @@
funcs->destroy( internal->subfonts[i - 1] );
}
- /* `internal' is freed by destroy_size (in ftobjs.c) */
+ FT_FREE( internal );
}
}
@@ -194,7 +197,7 @@
goto Exit;
}
- cffsize->internal = (FT_Size_Internal)(void*)internal;
+ cffsize->internal->module_data = internal;
}
size->strike_index = 0xFFFFFFFFUL;
@@ -224,7 +227,7 @@
{
CFF_Face face = (CFF_Face)size->face;
CFF_Font font = (CFF_Font)face->extra.data;
- CFF_Internal internal = (CFF_Internal)size->internal;
+ CFF_Internal internal = (CFF_Internal)size->internal->module_data;
FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em;
FT_UInt i;
@@ -296,7 +299,7 @@
{
CFF_Face cffface = (CFF_Face)size->face;
CFF_Font font = (CFF_Font)cffface->extra.data;
- CFF_Internal internal = (CFF_Internal)size->internal;
+ CFF_Internal internal = (CFF_Internal)size->internal->module_data;
FT_Long top_upm = (FT_Long)font->top_font.font_dict.units_per_em;
FT_UInt i;
@@ -517,6 +520,7 @@
goto Exit;
/* check whether we have a valid OpenType file */
+ FT_TRACE2(( " " ));
error = sfnt->init_face( stream, face, face_index, num_params, params );
if ( !error )
{
@@ -559,8 +563,8 @@
error = face->goto_table( face, TTAG_CFF2, stream, 0 );
if ( !error )
{
- cff2 = 1;
- face->isCFF2 = cff2;
+ cff2 = 1;
+ face->is_cff2 = cff2;
}
if ( FT_ERR_EQ( error, Table_Missing ) )
@@ -594,6 +598,7 @@
stream,
face_index,
cff,
+ face,
pure_cff,
cff2 );
if ( error )
@@ -683,62 +688,56 @@
}
#endif /* FT_DEBUG_LEVEL_TRACE */
-
-
#ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
-
- {
- FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
-
- FT_Int instance_index = face_index >> 16;
-
-
- if ( FT_HAS_MULTIPLE_MASTERS( cffface ) &&
- mm &&
- instance_index > 0 )
{
- FT_MM_Var* mm_var;
-
+ FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
- error = mm->get_mm_var( cffface, NULL );
- if ( error )
- goto Exit;
+ FT_Int instance_index = face_index >> 16;
- mm->get_var_blend( cffface, NULL, NULL, &mm_var );
- if ( mm_var->namedstyle )
+ if ( FT_HAS_MULTIPLE_MASTERS( cffface ) &&
+ mm &&
+ instance_index > 0 )
{
- FT_Var_Named_Style* named_style;
- FT_String* style_name;
+ FT_MM_Var* mm_var;
- /* in `face_index', the instance index starts with value 1 */
- named_style = mm_var->namedstyle + instance_index - 1;
- error = sfnt->get_name( face,
- (FT_UShort)named_style->strid,
- &style_name );
+ error = mm->get_mm_var( cffface, NULL );
if ( error )
goto Exit;
- /* set style name; if already set, replace it */
- if ( face->root.style_name )
- FT_FREE( face->root.style_name );
- face->root.style_name = style_name;
+ mm->get_var_blend( cffface, NULL, NULL, NULL, &mm_var );
- /* finally, select the named instance */
- error = mm->set_var_design( cffface,
- mm_var->num_axis,
- named_style->coords );
- if ( error )
- goto Exit;
+ if ( mm_var->namedstyle )
+ {
+ FT_Var_Named_Style* named_style;
+ FT_String* style_name;
+
+
+ /* in `face_index', the instance index starts with value 1 */
+ named_style = mm_var->namedstyle + instance_index - 1;
+ error = sfnt->get_name( face,
+ (FT_UShort)named_style->strid,
+ &style_name );
+ if ( error )
+ goto Exit;
+
+ /* set style name; if already set, replace it */
+ if ( face->root.style_name )
+ FT_FREE( face->root.style_name );
+ face->root.style_name = style_name;
+
+ /* finally, select the named instance */
+ error = mm->set_var_design( cffface,
+ mm_var->num_axis,
+ named_style->coords );
+ if ( error )
+ goto Exit;
+ }
}
}
- }
-
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
-
-
if ( !dict->has_font_matrix )
dict->units_per_em = pure_cff ? 1000 : face->root.units_per_EM;
@@ -1021,7 +1020,6 @@
cffface->style_flags = flags;
}
-
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
/* CID-keyed CFF fonts don't have glyph names -- the SFNT loader */
/* has unset this flag because of the 3.0 `post' table. */
@@ -1032,7 +1030,6 @@
if ( dict->cid_registry != 0xFFFFU && pure_cff )
cffface->face_flags |= FT_FACE_FLAG_CID_KEYED;
-
/*******************************************************************/
/* */
/* Compute char maps. */
@@ -1164,6 +1161,8 @@
{
CFF_Driver driver = (CFF_Driver)module;
+ FT_UInt32 seed;
+
/* set default property values, cf. `ftcffdrv.h' */
#ifdef CFF_CONFIG_OPTION_OLD_ENGINE
@@ -1183,6 +1182,18 @@
driver->darken_params[6] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4;
driver->darken_params[7] = CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4;
+ /* compute random seed from some memory addresses */
+ seed = (FT_UInt32)( (FT_Offset)(char*)&seed ^
+ (FT_Offset)(char*)&module ^
+ (FT_Offset)(char*)module->memory );
+ seed = seed ^ ( seed >> 10 ) ^ ( seed >> 20 );
+
+ driver->random_seed = (FT_Int32)seed;
+ if ( driver->random_seed < 0 )
+ driver->random_seed = -driver->random_seed;
+ else if ( driver->random_seed == 0 )
+ driver->random_seed = 123456789;
+
return FT_Err_Ok;
}
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h
index 9dc77536bd8..1dba694c532 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffobjs.h
@@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (specification). */
/* */
-/* 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, */
@@ -118,10 +118,10 @@ FT_BEGIN_HEADER
{
FT_DriverRec root;
- FT_UInt hinting_engine;
- FT_Bool no_stem_darkening;
-
- FT_Int darken_params[8];
+ FT_UInt hinting_engine;
+ FT_Bool no_stem_darkening;
+ FT_Int darken_params[8];
+ FT_Int32 random_seed;
} CFF_DriverRec;
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c
index ee538c360d4..e1511bdbd17 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.c
@@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (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, */
@@ -448,9 +448,21 @@
/* 16.16 fixed point is used internally for CFF2 blend results. */
/* Since these are trusted values, a limit check is not needed. */
- /* After the 255, 4 bytes are in host order. */
- /* Blend result is rounded to integer. */
- return (FT_Long)( *( (FT_UInt32 *) ( d[0] + 1 ) ) + 0x8000U ) >> 16;
+ /* After the 255, 4 bytes give the number. */
+ /* The blend value is converted to integer, with rounding; */
+ /* due to the right-shift we don't need the lowest byte. */
+#if 0
+ return (FT_Short)(
+ ( ( ( (FT_UInt32)*( d[0] + 1 ) << 24 ) |
+ ( (FT_UInt32)*( d[0] + 2 ) << 16 ) |
+ ( (FT_UInt32)*( d[0] + 3 ) << 8 ) |
+ (FT_UInt32)*( d[0] + 4 ) ) + 0x8000U ) >> 16 );
+#else
+ return (FT_Short)(
+ ( ( ( (FT_UInt32)*( d[0] + 1 ) << 16 ) |
+ ( (FT_UInt32)*( d[0] + 2 ) << 8 ) |
+ (FT_UInt32)*( d[0] + 3 ) ) + 0x80U ) >> 8 );
+#endif
}
else
@@ -882,8 +894,6 @@
FT_Error error;
- error = FT_ERR( Stack_Underflow );
-
if ( !priv || !priv->subfont )
{
error = FT_THROW( Invalid_File_Format );
@@ -1113,6 +1123,8 @@
#define CFF_FIELD_DELTA( code, name, max, id ) i++;
#undef CFF_FIELD_CALLBACK
#define CFF_FIELD_CALLBACK( code, name, id ) i++;
+#undef CFF_FIELD_BLEND
+#define CFF_FIELD_BLEND( code, id ) i++;
#include "cfftoken.h"
@@ -1160,6 +1172,17 @@
clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
i++;
+#undef CFF_FIELD_BLEND
+#define CFF_FIELD_BLEND( code_, id_ ) \
+ clazz[i].kind = cff_kind_blend; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = 0; \
+ clazz[i].size = 0; \
+ clazz[i].reader = cff_parse_blend; \
+ clazz[i].array_max = 0; \
+ clazz[i].count_offset = 0; \
+ i++;
+
#include "cfftoken.h"
clazz[i].kind = 0;
@@ -1210,6 +1233,18 @@
clazz[i].id = id_; \
i++;
+#undef CFF_FIELD_BLEND
+#define CFF_FIELD_BLEND( code_, id_ ) \
+ clazz[i].kind = cff_kind_blend; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = 0; \
+ clazz[i].size = 0; \
+ clazz[i].reader = cff_parse_blend; \
+ clazz[i].array_max = 0; \
+ clazz[i].count_offset = 0; \
+ clazz[i].id = id_; \
+ i++;
+
#include "cfftoken.h"
clazz[i].kind = 0;
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h
index 6088fec21c5..83d1bba45f2 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffparse.h
@@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (specification) */
/* */
-/* 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, */
@@ -31,8 +31,16 @@ FT_BEGIN_HEADER
/* CFF uses constant parser stack size; */
/* CFF2 can increase from default 193 */
#define CFF_MAX_STACK_DEPTH 96
+
+ /*
+ * There are plans to remove the `maxstack' operator in a forthcoming
+ * revision of the CFF2 specification, increasing the (then static) stack
+ * size to 513. By making the default stack size equal to the maximum
+ * stack size, the operator is essentially disabled, which has the
+ * desired effect in FreeType.
+ */
#define CFF2_MAX_STACK 513
-#define CFF2_DEFAULT_STACK 193
+#define CFF2_DEFAULT_STACK 513
#define CFF_CODE_TOPDICT 0x1000
#define CFF_CODE_PRIVATE 0x2000
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c
index a0bc34fd5f3..4e9ba12b3fe 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for cff module. */
/* */
-/* Copyright 2009-2016 by */
+/* Copyright 2009-2017 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h
index 4737b9e38a8..5db39cd6272 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cffpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for cff module. */
/* */
-/* Copyright 2009-2016 by */
+/* Copyright 2009-2017 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -33,6 +33,7 @@
#define CFF_SERVICE_PROPERTIES_GET cff_service_properties
#define CFF_SERVICES_GET cff_services
#define CFF_SERVICE_MULTI_MASTERS_GET cff_service_multi_masters
+#define CFF_SERVICE_METRICS_VAR_GET cff_service_metrics_variations
#define CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec
#define CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec
#define CFF_FIELD_HANDLERS_GET cff_field_handlers
@@ -46,22 +47,26 @@
#include FT_SERVICE_TT_CMAP_H
#include FT_SERVICE_CID_H
#include FT_SERVICE_PROPERTIES_H
+#include FT_SERVICE_MULTIPLE_MASTERS_H
+#include FT_SERVICE_METRICS_VARIATIONS_H
FT_BEGIN_HEADER
typedef struct CffModulePIC_
{
- FT_ServiceDescRec* cff_services;
- CFF_Field_Handler* cff_field_handlers;
- FT_Service_PsInfoRec cff_service_ps_info;
- FT_Service_GlyphDictRec cff_service_glyph_dict;
- FT_Service_PsFontNameRec cff_service_ps_name;
- FT_Service_TTCMapsRec cff_service_get_cmap_info;
- FT_Service_CIDRec cff_service_cid_info;
- FT_Service_PropertiesRec cff_service_properties;
- FT_CMap_ClassRec cff_cmap_encoding_class_rec;
- FT_CMap_ClassRec cff_cmap_unicode_class_rec;
+ FT_ServiceDescRec* cff_services;
+ CFF_Field_Handler* cff_field_handlers;
+ FT_Service_PsInfoRec cff_service_ps_info;
+ FT_Service_GlyphDictRec cff_service_glyph_dict;
+ FT_Service_PsFontNameRec cff_service_ps_name;
+ FT_Service_TTCMapsRec cff_service_get_cmap_info;
+ FT_Service_CIDRec cff_service_cid_info;
+ FT_Service_PropertiesRec cff_service_properties;
+ FT_Service_MultiMastersRec cff_service_multi_masters;
+ FT_Service_MetricsVariationsRec cff_service_metrics_variations;
+ FT_CMap_ClassRec cff_cmap_encoding_class_rec;
+ FT_CMap_ClassRec cff_cmap_unicode_class_rec;
} CffModulePIC;
@@ -83,6 +88,10 @@ FT_BEGIN_HEADER
( GET_PIC( library )->cff_service_properties )
#define CFF_SERVICES_GET \
( GET_PIC( library )->cff_services )
+#define CFF_SERVICE_MULTI_MASTERS_GET \
+ ( GET_PIC( library )->cff_service_multi_masters )
+#define CFF_SERVICE_METRICS_VAR_GET \
+ ( GET_PIC( library )->cff_service_metrics_variations )
#define CFF_CMAP_ENCODING_CLASS_REC_GET \
( GET_PIC( library )->cff_cmap_encoding_class_rec )
#define CFF_CMAP_UNICODE_CLASS_REC_GET \
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h
index fd41c6c7110..3222e933f1d 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cfftoken.h
@@ -4,7 +4,7 @@
/* */
/* CFF token definitions (specification only). */
/* */
-/* 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, */
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h b/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h
index 4dae0f281e8..74f569f08b8 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/cfftypes.h
@@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
-/* 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, */
@@ -112,8 +112,8 @@ FT_BEGIN_HEADER
FT_UInt shortDeltaCount; /* not used; always zero */
#endif
- FT_UInt regionIdxCount; /* number of regions in this var data */
- FT_UInt* regionIndices; /* array of `regionCount' indices; */
+ FT_UInt regionIdxCount; /* number of region indexes */
+ FT_UInt* regionIndices; /* array of `regionIdxCount' indices; */
/* these index `varRegionList' */
} CFF_VarData;
@@ -321,6 +321,8 @@ FT_BEGIN_HEADER
FT_Byte** local_subrs; /* array of pointers */
/* into Local Subrs INDEX data */
+ FT_UInt32 random;
+
} CFF_SubFontRec;
@@ -389,6 +391,7 @@ FT_BEGIN_HEADER
/* since version 2.4.12 */
FT_Generic cf2_instance;
+ /* since version 2.7.1 */
CFF_VStoreRec vstore; /* parsed vstore structure */
} CFF_FontRec;
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/module.mk b/Build/source/libs/freetype2/freetype-src/src/cff/module.mk
index 1b4781afed7..2975aeed8c7 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/module.mk
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/module.mk
@@ -3,7 +3,7 @@
#
-# 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, modified,
diff --git a/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk b/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk
index 92f68b1edef..86840bfe3c9 100644
--- a/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk
+++ b/Build/source/libs/freetype2/freetype-src/src/cff/rules.mk
@@ -3,7 +3,7 @@
#
-# 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, modified,