summaryrefslogtreecommitdiffstats
path: root/src/cff
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2011-08-17 18:21:28 +0200
committerDavid 'Digit' Turner <digit@google.com>2011-08-17 18:25:40 +0200
commitaeb407daf3711a10a27f3bc2223c5eb05158076e (patch)
tree570010914e8c91992ea388f2319611655c7d4b0c /src/cff
parent3053d1b9db55099918843889e4809ce97483ca9f (diff)
downloadandroid_external_freetype-aeb407daf3711a10a27f3bc2223c5eb05158076e.tar.gz
android_external_freetype-aeb407daf3711a10a27f3bc2223c5eb05158076e.tar.bz2
android_external_freetype-aeb407daf3711a10a27f3bc2223c5eb05158076e.zip
Update to FreeType 2.4.6+
This patch updates our copy of the FreeType sources to 2.4.6+. More precisely, it contains source code corresponding to the state of the upstream repository at the following hash submitted on August 16 2001: c3fb981e2ac79acad09d5673352646696472f55e This corresponds to 2.4.6 with 7 more patches applied on top of it to fix bugs in the TrueType interpreter and the CFF parser. Change-Id: I9f3ac736d616020c8d10fd1d4e4be466f35fb6e7
Diffstat (limited to 'src/cff')
-rw-r--r--src/cff/cffdrivr.c2
-rw-r--r--src/cff/cffgload.c19
-rw-r--r--src/cff/cffload.c6
-rw-r--r--src/cff/cffobjs.c60
-rw-r--r--src/cff/cffparse.c33
-rw-r--r--src/cff/cfftypes.h5
6 files changed, 99 insertions, 26 deletions
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index 39f04ee..4fd3436 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -328,7 +328,7 @@
if ( cff && cff->font_info == NULL )
{
CFF_FontRecDict dict = &cff->top_font.font_dict;
- PS_FontInfoRec *font_info;
+ PS_FontInfoRec *font_info = NULL;
FT_Memory memory = face->root.memory;
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index e99ee70..cb06bdf 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -4,8 +4,7 @@
/* */
/* OpenType Glyph Loader (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
-/* 2010 by */
+/* Copyright 1996-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -1159,8 +1158,8 @@
op = cff_op_flex1;
break;
default:
- /* decrement ip for syntax error message */
- ip--;
+ FT_TRACE4(( " unknown op (12, %d)\n", v ));
+ break;
}
}
break;
@@ -1213,11 +1212,12 @@
op = cff_op_hvcurveto;
break;
default:
+ FT_TRACE4(( " unknown op (%d)\n", v ));
break;
}
if ( op == cff_op_unknown )
- goto Syntax_Error;
+ continue;
/* check arguments */
req_args = cff_argument_counts[op];
@@ -1438,9 +1438,14 @@
FT_TRACE4(( op == cff_op_hlineto ? " hlineto\n"
: " vlineto\n" ));
- if ( num_args < 1 )
+ if ( num_args < 0 )
goto Stack_Underflow;
+ /* there exist subsetted fonts (found in PDFs) */
+ /* which call `hlineto' without arguments */
+ if ( num_args == 0 )
+ break;
+
if ( cff_builder_start_point ( builder, x, y ) ||
check_points( builder, num_args ) )
goto Fail;
@@ -2701,7 +2706,7 @@
glyph_index );
if ( fd_index >= cff->num_subfonts )
- fd_index = cff->num_subfonts - 1;
+ fd_index = (FT_Byte)( cff->num_subfonts - 1 );
top_upm = cff->top_font.font_dict.units_per_em;
sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index 000cbe3..629d38e 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -387,7 +387,7 @@
{
FT_Error error = CFF_Err_Ok;
FT_Memory memory = idx->stream->memory;
- FT_Byte** t;
+ FT_Byte** t = NULL;
FT_Byte* new_bytes = NULL;
@@ -1269,7 +1269,7 @@
if ( gid != 0 )
{
encoding->codes[j] = (FT_UShort)gid;
- encoding->count = j + 1;
+ encoding->count = j + 1;
}
else
{
@@ -1514,7 +1514,7 @@
if ( dict->cid_registry != 0xFFFFU )
{
CFF_IndexRec fd_index;
- CFF_SubFont sub;
+ CFF_SubFont sub = NULL;
FT_UInt idx;
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 1cd35c9..cd38676 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -4,8 +4,7 @@
/* */
/* OpenType objects manager (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
-/* 2010 by */
+/* Copyright 1996-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -162,7 +161,7 @@
{
CFF_Face face = (CFF_Face)cffsize->face;
CFF_Font font = (CFF_Font)face->extra.data;
- CFF_Internal internal;
+ CFF_Internal internal = NULL;
PS_PrivateRec priv;
FT_Memory memory = cffsize->face->memory;
@@ -421,6 +420,7 @@
{
for ( idx = 7; idx < length; idx++ )
name[idx - 7] = name[idx];
+ length -= 7;
}
}
else
@@ -429,6 +429,51 @@
}
+ /* Remove the style part from the family name (if present). */
+
+ static void
+ remove_style( FT_String* family_name,
+ const FT_String* style_name )
+ {
+ FT_Int32 family_name_length, style_name_length;
+
+
+ family_name_length = strlen( family_name );
+ style_name_length = strlen( style_name );
+
+ if ( family_name_length > style_name_length )
+ {
+ FT_Int idx;
+
+
+ for ( idx = 1; idx <= style_name_length; ++idx )
+ {
+ if ( family_name[family_name_length - idx] !=
+ style_name[style_name_length - idx] )
+ break;
+ }
+
+ if ( idx > style_name_length )
+ {
+ /* family_name ends with style_name; remove it */
+ idx = family_name_length - style_name_length - 1;
+
+ /* also remove special characters */
+ /* between real family name and style */
+ while ( idx > 0 &&
+ ( family_name[idx] == '-' ||
+ family_name[idx] == ' ' ||
+ family_name[idx] == '_' ||
+ family_name[idx] == '+' ) )
+ --idx;
+
+ if ( idx > 0 )
+ family_name[idx + 1] = '\0';
+ }
+ }
+ }
+
+
FT_LOCAL_DEF( FT_Error )
cff_face_init( FT_Stream stream,
FT_Face cffface, /* CFF_Face */
@@ -436,14 +481,14 @@
FT_Int num_params,
FT_Parameter* params )
{
- CFF_Face face = (CFF_Face)cffface;
+ CFF_Face face = (CFF_Face)cffface;
FT_Error error;
SFNT_Service sfnt;
FT_Service_PsCMaps psnames;
PSHinter_Service pshinter;
FT_Bool pure_cff = 1;
FT_Bool sfnt_format = 0;
- FT_Library library = cffface->driver->root.library;
+ FT_Library library = cffface->driver->root.library;
sfnt = (SFNT_Service)FT_Get_Module_Interface(
@@ -523,7 +568,7 @@
/* now load and parse the CFF table in the file */
{
- CFF_Font cff;
+ CFF_Font cff = NULL;
CFF_FontRecDict dict;
FT_Memory memory = cffface->memory;
FT_Int32 flags;
@@ -758,6 +803,9 @@
/* case, the remaining string in `fullp' will be used as */
/* the style name. */
style_name = cff_strcpy( memory, fullp );
+
+ /* remove the style part from the family name (if present) */
+ remove_style( cffface->family_name, style_name );
}
break;
}
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index 0d11a72..b12a8d3 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -4,7 +4,7 @@
/* */
/* CFF token stream parser (body) */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2007, 2008, 2009, 2010 by */
+/* Copyright 1996-2004, 2007-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -35,8 +35,6 @@
#define FT_COMPONENT trace_cffparse
-
-
FT_LOCAL_DEF( void )
cff_parser_init( CFF_Parser parser,
FT_UInt code,
@@ -475,9 +473,15 @@
if ( scaling < 0 || scaling > 9 )
{
/* Return default matrix in case of unlikely values. */
+
+ FT_TRACE1(( "cff_parse_font_matrix:"
+ " strange scaling value for xx element (%d),\n"
+ " "
+ " using default matrix\n", scaling ));
+
matrix->xx = 0x10000L;
matrix->yx = 0;
- matrix->yx = 0;
+ matrix->xy = 0;
matrix->yy = 0x10000L;
offset->x = 0;
offset->y = 0;
@@ -493,6 +497,12 @@
offset->y = cff_parse_fixed_scaled( data, scaling );
*upm = power_tens[scaling];
+
+ FT_TRACE4(( " font matrix: [%f %f %f %f]\n",
+ (double)matrix->xx / *upm / 65536,
+ (double)matrix->xy / *upm / 65536,
+ (double)matrix->yx / *upm / 65536,
+ (double)matrix->yy / *upm / 65536 ));
}
Exit:
@@ -518,6 +528,12 @@
bbox->xMax = FT_RoundFix( cff_parse_fixed( data++ ) );
bbox->yMax = FT_RoundFix( cff_parse_fixed( data ) );
error = CFF_Err_Ok;
+
+ FT_TRACE4(( " bbox: [%d %d %d %d]\n",
+ bbox->xMin / 65536,
+ bbox->yMin / 65536,
+ bbox->xMax / 65536,
+ bbox->yMax / 65536 ));
}
return error;
@@ -557,8 +573,8 @@
if ( parser->top >= parser->stack + 3 )
{
- dict->cid_registry = (FT_UInt)cff_parse_num ( data++ );
- dict->cid_ordering = (FT_UInt)cff_parse_num ( data++ );
+ dict->cid_registry = (FT_UInt)cff_parse_num( data++ );
+ dict->cid_ordering = (FT_UInt)cff_parse_num( data++ );
if ( **data == 30 )
FT_TRACE1(( "cff_parse_cid_ros: real supplement is rounded\n" ));
dict->cid_supplement = cff_parse_num( data );
@@ -566,6 +582,11 @@
FT_TRACE1(( "cff_parse_cid_ros: negative supplement %d is found\n",
dict->cid_supplement ));
error = CFF_Err_Ok;
+
+ FT_TRACE4(( " ROS: registry sid %d, ordering sid %d, supplement %d\n",
+ dict->cid_registry,
+ dict->cid_ordering,
+ dict->cid_supplement ));
}
return error;
diff --git a/src/cff/cfftypes.h b/src/cff/cfftypes.h
index d405357..665ab6f 100644
--- a/src/cff/cfftypes.h
+++ b/src/cff/cfftypes.h
@@ -5,7 +5,7 @@
/* Basic OpenType/CFF type definitions and interface (specification */
/* only). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2006, 2007, 2008, 2010 by */
+/* Copyright 1996-2003, 2006-2008, 2010-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -212,8 +212,7 @@ FT_BEGIN_HEADER
} CFF_SubFontRec, *CFF_SubFont;
- /* maximum number of sub-fonts in a CID-keyed file */
-#define CFF_MAX_CID_FONTS 32
+#define CFF_MAX_CID_FONTS 256
typedef struct CFF_FontRec_