summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2015-05-11 11:41:25 +0100
committerChris Liddell <chris.liddell@artifex.com>2015-05-12 09:16:26 +0100
commite969ca54ec0bda5a5093efe6afb7b72f57583fe7 (patch)
tree3dac293d8a24e20a5a2e0541257eb15e9bd5ce79
parent7c0eec2620be1f8c9774f52848ec7436cf97de28 (diff)
downloadghostpdl-freetype-2.5.5.tar.gz
Fix and reenable new FT CFF code.freetype-2.5.5
1) The incremental interface to Freetype requires the callback method to apply character code mapping via std encoding, rather it being applied internally in Freetype. submitted and applied upstream: http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=d65bf72 2) The VVCURVETO, HHCURVETO, VHCURVETO and HVCURVETO in the old CFF engine were tolerant of extra parameters on the stack, apply a similar thing in the new CFF code. submitted and applied upstream: http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=a87fb8cc
-rw-r--r--gs/base/freetype.mak2
-rw-r--r--gs/freetype/src/cff/cf2ft.c17
-rw-r--r--gs/freetype/src/cff/cf2intrp.c51
3 files changed, 53 insertions, 17 deletions
diff --git a/gs/base/freetype.mak b/gs/base/freetype.mak
index a4a1191e8..f130893b4 100644
--- a/gs/base/freetype.mak
+++ b/gs/base/freetype.mak
@@ -33,7 +33,7 @@ FTO_=$(O_)$(FTOBJ)
# we must define FT2_BUILD_LIBRARY to get internal declarations
# If GS is using the system zlib, freetype should also do so,
# FT_CONFIG_SYSTEM_ZLIB is set by the top makefile.
-FTCC=$(CC_) $(I_)$(FTSRCDIR)$(D)include$(_I) $(D_)FT2_BUILD_LIBRARY$(_D) $(D_)DARWIN_NO_CARBON$(_D) $(D_)CFF_CONFIG_OPTION_OLD_ENGINE$(_D) $(FT_CONFIG_SYSTEM_ZLIB)
+FTCC=$(CC_) $(I_)$(FTSRCDIR)$(D)include$(_I) $(D_)FT2_BUILD_LIBRARY$(_D) $(D_)DARWIN_NO_CARBON$(_D) $(FT_CONFIG_SYSTEM_ZLIB)
# Define the name of this makefile.
FT_MAK=$(GLSRC)freetype.mak
diff --git a/gs/freetype/src/cff/cf2ft.c b/gs/freetype/src/cff/cf2ft.c
index ebba4694c..37515035c 100644
--- a/gs/freetype/src/cff/cf2ft.c
+++ b/gs/freetype/src/cff/cf2ft.c
@@ -582,9 +582,20 @@
FT_ZERO( buf );
- gid = cff_lookup_glyph_by_stdcharcode( decoder->cff, code );
- if ( gid < 0 )
- return FT_THROW( Invalid_Glyph_Format );
+#ifdef FT_CONFIG_OPTION_INCREMENTAL
+ /* Incremental fonts don't necessarily have valid charsets. */
+ /* They use the character code, not the glyph index, in this case. */
+ if ( decoder->builder.face->root.internal->incremental_interface )
+ {
+ gid = code;
+ }
+ else
+#endif /* FT_CONFIG_OPTION_INCREMENTAL */
+ {
+ gid = cff_lookup_glyph_by_stdcharcode( decoder->cff, code );
+ if ( gid < 0 )
+ return FT_THROW( Invalid_Glyph_Format );
+ }
error = cff_get_glyph_data( decoder->builder.face,
gid,
diff --git a/gs/freetype/src/cff/cf2intrp.c b/gs/freetype/src/cff/cf2intrp.c
index a26960669..cf97d68e0 100644
--- a/gs/freetype/src/cff/cf2intrp.c
+++ b/gs/freetype/src/cff/cf2intrp.c
@@ -43,6 +43,7 @@
#include "cf2font.h"
#include "cf2stack.h"
#include "cf2hints.h"
+#include "cf2intrp.h"
#include "cf2error.h"
@@ -760,16 +761,19 @@
/* push our current CFF charstring region on subrStack */
charstring = (CF2_Buffer)
- cf2_arrstack_getPointer( &subrStack,
- charstringIndex + 1 );
+ cf2_arrstack_getPointer(
+ &subrStack,
+ (size_t)charstringIndex + 1 );
/* set up the new CFF region and pointer */
- subrIndex = cf2_stack_popInt( opStack );
+ subrIndex = (CF2_UInt)cf2_stack_popInt( opStack );
switch ( op1 )
{
case cf2_cmdCALLGSUBR:
- FT_TRACE4(( "(%d)\n", subrIndex + decoder->globals_bias ));
+ FT_TRACE4(( " (idx %d, entering level %d)\n",
+ subrIndex + (CF2_UInt)decoder->globals_bias,
+ charstringIndex + 1 ));
if ( cf2_initGlobalRegionBuffer( decoder,
subrIndex,
@@ -782,7 +786,9 @@
default:
/* cf2_cmdCALLSUBR */
- FT_TRACE4(( "(%d)\n", subrIndex + decoder->locals_bias ));
+ FT_TRACE4(( " (idx %d, entering level %d)\n",
+ subrIndex + (CF2_UInt)decoder->locals_bias,
+ charstringIndex + 1 ));
if ( cf2_initLocalRegionBuffer( decoder,
subrIndex,
@@ -798,7 +804,7 @@
continue; /* do not clear the stack */
case cf2_cmdRETURN:
- FT_TRACE4(( " return\n" ));
+ FT_TRACE4(( " return (leaving level %d)\n", charstringIndex ));
if ( charstringIndex < 1 )
{
@@ -809,8 +815,9 @@
/* restore position in previous charstring */
charstring = (CF2_Buffer)
- cf2_arrstack_getPointer( &subrStack,
- --charstringIndex );
+ cf2_arrstack_getPointer(
+ &subrStack,
+ (CF2_UInt)--charstringIndex );
continue; /* do not clear the stack */
case cf2_cmdESC:
@@ -1088,8 +1095,8 @@
/* must be either 4 or 5 -- */
/* this is a (deprecated) implied `seac' operator */
- CF2_UInt achar;
- CF2_UInt bchar;
+ CF2_Int achar;
+ CF2_Int bchar;
CF2_BufferRec component;
CF2_Fixed dummyWidth; /* ignore component width */
FT_Error error2;
@@ -1291,9 +1298,14 @@
case cf2_cmdVVCURVETO:
{
- CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
CF2_UInt index = 0;
+ /* if cf2_stack_count() isn't of the form 4n or 4n+1, */
+ /* we enforce it by clearing the second bit */
+ /* And sort the stack indexing to suit */
+ count = count1 & ~2;
+ index += count1 - count;
FT_TRACE4(( " vvcurveto\n" ));
@@ -1330,9 +1342,14 @@
case cf2_cmdHHCURVETO:
{
- CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
CF2_UInt index = 0;
+ /* if cf2_stack_count() isn't of the form 4n or 4n+1, */
+ /* we enforce it by clearing the second bit */
+ /* And sort the stack indexing to suit */
+ count = count1 & ~2;
+ index += count1 - count;
FT_TRACE4(( " hhcurveto\n" ));
@@ -1370,11 +1387,19 @@
case cf2_cmdVHCURVETO:
case cf2_cmdHVCURVETO:
{
- CF2_UInt count = cf2_stack_count( opStack );
+ CF2_UInt count, count1 = cf2_stack_count( opStack );
CF2_UInt index = 0;
FT_Bool alternate = op1 == cf2_cmdHVCURVETO;
+ /* if cf2_stack_count() isn't of the form 8n, 8n+1, */
+ /* 8n+4, or 8n+5, we enforce it by clearing the */
+ /* second bit */
+ /* And sort the stack indexing to suit */
+ count = count1 & ~2;
+ index += count1 - count;
+
+
FT_TRACE4(( alternate ? " hvcurveto\n" : " vhcurveto\n" ));