aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/cff
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2009-12-22 14:14:24 +0000
committermarha <marha@users.sourceforge.net>2009-12-22 14:14:24 +0000
commit4284aeba874b9168f2228c59639bec8346a56796 (patch)
treed51ffb4507e0cae24b0875d8bb6b2c037829a684 /freetype/src/cff
parentc438f190eedc71ee8dd14e14fec660e98d3dc0bf (diff)
parent0695dfb71ca6fe132d15a4d0890e8a868183adf9 (diff)
downloadvcxsrv-4284aeba874b9168f2228c59639bec8346a56796.tar.gz
vcxsrv-4284aeba874b9168f2228c59639bec8346a56796.tar.bz2
vcxsrv-4284aeba874b9168f2228c59639bec8346a56796.zip
svn merge ^/branches/released
Diffstat (limited to 'freetype/src/cff')
-rw-r--r--freetype/src/cff/Jamfile2
-rw-r--r--freetype/src/cff/cff.c1
-rw-r--r--freetype/src/cff/cffcmap.c17
-rw-r--r--freetype/src/cff/cffcmap.h6
-rw-r--r--freetype/src/cff/cffdrivr.c120
-rw-r--r--freetype/src/cff/cffdrivr.h3
-rw-r--r--freetype/src/cff/cffgload.c96
-rw-r--r--freetype/src/cff/cffgload.h8
-rw-r--r--freetype/src/cff/cffload.c70
-rw-r--r--freetype/src/cff/cffload.h3
-rw-r--r--freetype/src/cff/cffobjs.c52
-rw-r--r--freetype/src/cff/cffparse.c157
-rw-r--r--freetype/src/cff/cffparse.h35
-rw-r--r--freetype/src/cff/cffpic.c99
-rw-r--r--freetype/src/cff/cffpic.h80
-rw-r--r--freetype/src/cff/cfftypes.h2
16 files changed, 545 insertions, 206 deletions
diff --git a/freetype/src/cff/Jamfile b/freetype/src/cff/Jamfile
index 6d0bb1b86..6705d3cfd 100644
--- a/freetype/src/cff/Jamfile
+++ b/freetype/src/cff/Jamfile
@@ -16,7 +16,7 @@ SubDir FT2_TOP $(FT2_SRC_DIR) cff ;
if $(FT2_MULTI)
{
- _sources = cffdrivr cffgload cffload cffobjs cffparse cffcmap ;
+ _sources = cffdrivr cffgload cffload cffobjs cffparse cffcmap cffpic ;
}
else
{
diff --git a/freetype/src/cff/cff.c b/freetype/src/cff/cff.c
index e6d8954c9..fccfd442f 100644
--- a/freetype/src/cff/cff.c
+++ b/freetype/src/cff/cff.c
@@ -19,6 +19,7 @@
#define FT_MAKE_OPTION_SINGLE_OBJECT
#include <ft2build.h>
+#include "cffpic.c"
#include "cffdrivr.c"
#include "cffparse.c"
#include "cffload.c"
diff --git a/freetype/src/cff/cffcmap.c b/freetype/src/cff/cffcmap.c
index 578d048be..46d603e3a 100644
--- a/freetype/src/cff/cffcmap.c
+++ b/freetype/src/cff/cffcmap.c
@@ -65,7 +65,7 @@
}
- FT_CALLBACK_DEF( FT_UInt )
+ FT_CALLBACK_DEF( FT_UInt32 )
cff_cmap_encoding_char_next( CFF_CMapStd cmap,
FT_UInt32 *pchar_code )
{
@@ -99,9 +99,7 @@
}
- FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
- cff_cmap_encoding_class_rec =
- {
+ FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec,
sizeof ( CFF_CMapStdRec ),
(FT_CMap_InitFunc) cff_cmap_encoding_init,
@@ -110,7 +108,7 @@
(FT_CMap_CharNextFunc) cff_cmap_encoding_char_next,
NULL, NULL, NULL, NULL, NULL
- };
+ )
/*************************************************************************/
@@ -194,7 +192,7 @@
}
- FT_CALLBACK_DEF( FT_UInt )
+ FT_CALLBACK_DEF( FT_UInt32 )
cff_cmap_unicode_char_next( PS_Unicodes unicodes,
FT_UInt32 *pchar_code )
{
@@ -207,9 +205,7 @@
}
- FT_CALLBACK_TABLE_DEF const FT_CMap_ClassRec
- cff_cmap_unicode_class_rec =
- {
+ FT_DEFINE_CMAP_CLASS(cff_cmap_unicode_class_rec,
sizeof ( PS_UnicodesRec ),
(FT_CMap_InitFunc) cff_cmap_unicode_init,
@@ -218,7 +214,6 @@
(FT_CMap_CharNextFunc) cff_cmap_unicode_char_next,
NULL, NULL, NULL, NULL, NULL
- };
-
+ )
/* END */
diff --git a/freetype/src/cff/cffcmap.h b/freetype/src/cff/cffcmap.h
index 3809b8561..3f7f67bbe 100644
--- a/freetype/src/cff/cffcmap.h
+++ b/freetype/src/cff/cffcmap.h
@@ -43,8 +43,7 @@ FT_BEGIN_HEADER
} CFF_CMapStdRec;
- FT_CALLBACK_TABLE const FT_CMap_ClassRec
- cff_cmap_encoding_class_rec;
+ FT_DECLARE_CMAP_CLASS(cff_cmap_encoding_class_rec)
/*************************************************************************/
@@ -57,8 +56,7 @@ FT_BEGIN_HEADER
/* unicode (synthetic) cmaps */
- FT_CALLBACK_TABLE const FT_CMap_ClassRec
- cff_cmap_unicode_class_rec;
+ FT_DECLARE_CMAP_CLASS(cff_cmap_unicode_class_rec)
FT_END_HEADER
diff --git a/freetype/src/cff/cffdrivr.c b/freetype/src/cff/cffdrivr.c
index 29a863678..5d04cd763 100644
--- a/freetype/src/cff/cffdrivr.c
+++ b/freetype/src/cff/cffdrivr.c
@@ -21,7 +21,6 @@
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/sfnt.h>
-#include <freetype/ttnameid.h>
#include <freetype/internal/services/svcid.h>
#include <freetype/internal/services/svpscmap.h>
#include <freetype/internal/services/svpsinfo.h>
@@ -32,8 +31,10 @@
#include "cffgload.h"
#include "cffload.h"
#include "cffcmap.h"
+#include "cffparse.h"
#include "cfferrs.h"
+#include "cffpic.h"
#include FT_SERVICE_XFREE86_NAME_H
#include FT_SERVICE_GLYPH_DICT_H
@@ -199,7 +200,7 @@
FT_GlyphSlot slot = face->glyph;
- flags |= FT_LOAD_ADVANCE_ONLY;
+ flags |= (FT_UInt32)FT_LOAD_ADVANCE_ONLY;
for ( nn = 0; nn < count; nn++ )
{
@@ -238,10 +239,10 @@
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
if ( !psnames )
{
- FT_ERROR(( "cff_get_glyph_name:" ));
- FT_ERROR(( " cannot get glyph name from CFF & CEF fonts\n" ));
- FT_ERROR(( " " ));
- FT_ERROR(( " without the `PSNames' module\n" ));
+ FT_ERROR(( "cff_get_glyph_name:"
+ " cannot get glyph name from CFF & CEF fonts\n"
+ " "
+ " without the `PSNames' module\n" ));
error = CFF_Err_Unknown_File_Format;
goto Exit;
}
@@ -309,11 +310,10 @@
}
- static const FT_Service_GlyphDictRec cff_service_glyph_dict =
- {
+ FT_DEFINE_SERVICE_GLYPHDICTREC(cff_service_glyph_dict,
(FT_GlyphDict_GetNameFunc) cff_get_glyph_name,
- (FT_GlyphDict_NameIndexFunc)cff_get_name_index,
- };
+ (FT_GlyphDict_NameIndexFunc)cff_get_name_index
+ )
/*
@@ -378,13 +378,12 @@
}
- static const FT_Service_PsInfoRec cff_service_ps_info =
- {
+ FT_DEFINE_SERVICE_PSINFOREC(cff_service_ps_info,
(PS_GetFontInfoFunc) cff_ps_get_font_info,
(PS_GetFontExtraFunc) NULL,
(PS_HasGlyphNamesFunc) cff_ps_has_glyph_names,
(PS_GetFontPrivateFunc)NULL /* unsupported with CFF fonts */
- };
+ )
/*
@@ -402,10 +401,9 @@
}
- static const FT_Service_PsFontNameRec cff_service_ps_name =
- {
+ FT_DEFINE_SERVICE_PSFONTNAMEREC(cff_service_ps_name,
(FT_PsName_GetFunc)cff_get_ps_name
- };
+ )
/*
@@ -424,16 +422,16 @@
{
FT_CMap cmap = FT_CMAP( charmap );
FT_Error error = CFF_Err_Ok;
+ FT_Face face = FT_CMAP_FACE( cmap );
+ FT_Library library = FT_FACE_LIBRARY( face );
cmap_info->language = 0;
cmap_info->format = 0;
- if ( cmap->clazz != &cff_cmap_encoding_class_rec &&
- cmap->clazz != &cff_cmap_unicode_class_rec )
+ if ( cmap->clazz != &FT_CFF_CMAP_ENCODING_CLASS_REC_GET &&
+ cmap->clazz != &FT_CFF_CMAP_UNICODE_CLASS_REC_GET )
{
- FT_Face face = FT_CMAP_FACE( cmap );
- FT_Library library = FT_FACE_LIBRARY( face );
FT_Module sfnt = FT_Get_Module( library, "sfnt" );
FT_Service_TTCMaps service =
(FT_Service_TTCMaps)ft_module_get_service( sfnt,
@@ -448,10 +446,9 @@
}
- static const FT_Service_TTCMapsRec cff_service_get_cmap_info =
- {
+ FT_DEFINE_SERVICE_TTCMAPSREC(cff_service_get_cmap_info,
(TT_CMap_Info_GetFunc)cff_get_cmap_info
- };
+ )
/*
@@ -498,8 +495,19 @@
*ordering = cff->ordering;
}
+ /*
+ * XXX: According to Adobe TechNote #5176, the supplement in CFF
+ * can be a real number. We truncate it to fit public API
+ * since freetype-2.3.6.
+ */
if ( supplement )
- *supplement = dict->cid_supplement;
+ {
+ if ( dict->cid_supplement < FT_INT_MIN ||
+ dict->cid_supplement > FT_INT_MAX )
+ FT_TRACE1(( "cff_get_ros: too large supplement %d is truncated\n",
+ dict->cid_supplement ));
+ *supplement = (FT_Int)dict->cid_supplement;
+ }
}
Fail:
@@ -570,12 +578,11 @@
}
- static const FT_Service_CIDRec cff_service_cid_info =
- {
+ FT_DEFINE_SERVICE_CIDREC(cff_service_cid_info,
(FT_CID_GetRegistryOrderingSupplementFunc)cff_get_ros,
(FT_CID_GetIsInternallyCIDKeyedFunc) cff_get_is_cid,
(FT_CID_GetCIDFromGlyphIndexFunc) cff_get_cid_from_glyph_index
- };
+ )
/*************************************************************************/
@@ -589,20 +596,24 @@
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
-
- static const FT_ServiceDescRec cff_services[] =
- {
- { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF },
- { FT_SERVICE_ID_POSTSCRIPT_INFO, &cff_service_ps_info },
- { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cff_service_ps_name },
#ifndef FT_CONFIG_OPTION_NO_GLYPH_NAMES
- { FT_SERVICE_ID_GLYPH_DICT, &cff_service_glyph_dict },
+ FT_DEFINE_SERVICEDESCREC6(cff_services,
+ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF,
+ FT_SERVICE_ID_POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET,
+ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
+ FT_SERVICE_ID_GLYPH_DICT, &FT_CFF_SERVICE_GLYPH_DICT_GET,
+ FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
+ FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_GET
+ )
+#else
+ FT_DEFINE_SERVICEDESCREC5(cff_services,
+ FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CFF,
+ FT_SERVICE_ID_POSTSCRIPT_INFO, &FT_CFF_SERVICE_PS_INFO_GET,
+ FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &FT_CFF_SERVICE_PS_NAME_GET,
+ FT_SERVICE_ID_TT_CMAP, &FT_CFF_SERVICE_GET_CMAP_INFO_GET,
+ FT_SERVICE_ID_CID, &FT_CFF_SERVICE_CID_INFO_GET
+ )
#endif
- { FT_SERVICE_ID_TT_CMAP, &cff_service_get_cmap_info },
- { FT_SERVICE_ID_CID, &cff_service_cid_info },
- { NULL, NULL }
- };
-
FT_CALLBACK_DEF( FT_Module_Interface )
cff_get_interface( FT_Module driver, /* CFF_Driver */
@@ -610,9 +621,11 @@
{
FT_Module sfnt;
FT_Module_Interface result;
+ FT_Library library = driver->library;
+ FT_UNUSED(library);
- result = ft_service_list_lookup( cff_services, module_interface );
+ result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface );
if ( result != NULL )
return result;
@@ -625,11 +638,13 @@
/* The FT_DriverInterface structure is defined in ftdriver.h. */
- FT_CALLBACK_TABLE_DEF
- const FT_Driver_ClassRec cff_driver_class =
- {
- /* begin with the FT_Module_Class fields */
- {
+#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+#define CFF_SIZE_SELECT cff_size_select
+#else
+#define CFF_SIZE_SELECT 0
+#endif
+
+ FT_DEFINE_DRIVER(cff_driver_class,
FT_MODULE_FONT_DRIVER |
FT_MODULE_DRIVER_SCALABLE |
FT_MODULE_DRIVER_HAS_HINTER,
@@ -644,7 +659,6 @@
cff_driver_init,
cff_driver_done,
cff_get_interface,
- },
/* now the specific driver fields */
sizeof( TT_FaceRec ),
@@ -658,10 +672,8 @@
cff_slot_init,
cff_slot_done,
-#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
- ft_stub_set_char_sizes,
- ft_stub_set_pixel_sizes,
-#endif
+ ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
+ ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */
Load_Glyph,
@@ -671,12 +683,8 @@
cff_size_request,
-#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
- cff_size_select
-#else
- 0 /* FT_Size_SelectFunc */
-#endif
- };
+ CFF_SIZE_SELECT
+ )
/* END */
diff --git a/freetype/src/cff/cffdrivr.h b/freetype/src/cff/cffdrivr.h
index ee441253b..3fefafc04 100644
--- a/freetype/src/cff/cffdrivr.h
+++ b/freetype/src/cff/cffdrivr.h
@@ -27,8 +27,7 @@
FT_BEGIN_HEADER
- FT_CALLBACK_TABLE
- const FT_Driver_ClassRec cff_driver_class;
+ FT_DECLARE_DRIVER( cff_driver_class )
FT_END_HEADER
diff --git a/freetype/src/cff/cffgload.c b/freetype/src/cff/cffgload.c
index a66928bb5..8dbc8d9ae 100644
--- a/freetype/src/cff/cffgload.c
+++ b/freetype/src/cff/cffgload.c
@@ -18,11 +18,9 @@
#include <ft2build.h>
#include <freetype/internal/ftdebug.h>
-#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftstream.h>
#include <freetype/internal/sfnt.h>
#include FT_OUTLINE_H
-#include FT_TRUETYPE_TAGS_H
#include <freetype/internal/pshints.h>
#include "cffobjs.h"
@@ -474,8 +472,6 @@
point->x = x >> 16;
point->y = y >> 16;
*control = (FT_Byte)( flag ? FT_CURVE_TAG_ON : FT_CURVE_TAG_CUBIC );
-
- builder->last = *point;
}
outline->n_points++;
@@ -554,27 +550,24 @@
cff_builder_close_contour( CFF_Builder* builder )
{
FT_Outline* outline = builder->current;
+ FT_Int first;
if ( !outline )
return;
- /* XXXX: We must not include the last point in the path if it */
- /* is located on the first point. */
+ first = outline->n_contours <= 1
+ ? 0 : outline->contours[outline->n_contours - 2] + 1;
+
+ /* We must not include the last point in the path if it */
+ /* is located on the first point. */
if ( outline->n_points > 1 )
{
- FT_Int first = 0;
FT_Vector* p1 = outline->points + first;
FT_Vector* p2 = outline->points + outline->n_points - 1;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points - 1;
- if ( outline->n_contours > 1 )
- {
- first = outline->contours[outline->n_contours - 2] + 1;
- p1 = outline->points + first;
- }
-
/* `delete' last point only if it coincides with the first */
/* point and if it is not a control point (which can happen). */
if ( p1->x == p2->x && p1->y == p2->y )
@@ -583,8 +576,18 @@
}
if ( outline->n_contours > 0 )
- outline->contours[outline->n_contours - 1] =
- (short)( outline->n_points - 1 );
+ {
+ /* Don't add contours only consisting of one point, i.e., */
+ /* check whether begin point and last point are the same. */
+ if ( first == outline->n_points - 1 )
+ {
+ outline->n_contours--;
+ outline->n_points--;
+ }
+ else
+ outline->contours[outline->n_contours - 1] =
+ (short)( outline->n_points - 1 );
+ }
}
@@ -704,6 +707,12 @@
FT_ULong charstring_len;
+ if ( decoder->seac )
+ {
+ FT_ERROR(( "cff_operator_seac: invalid nested seac\n" ));
+ return CFF_Err_Syntax_Error;
+ }
+
#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. */
@@ -724,8 +733,8 @@
if ( bchar_index < 0 || achar_index < 0 )
{
- FT_ERROR(( "cff_operator_seac:" ));
- FT_ERROR(( " invalid seac character code arguments\n" ));
+ FT_ERROR(( "cff_operator_seac:"
+ " invalid seac character code arguments\n" ));
return CFF_Err_Syntax_Error;
}
@@ -774,8 +783,11 @@
&charstring, &charstring_len );
if ( !error )
{
+ /* the seac operator must not be nested */
+ decoder->seac = TRUE;
error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len );
+ decoder->seac = FALSE;
if ( error )
goto Exit;
@@ -800,8 +812,11 @@
&charstring, &charstring_len );
if ( !error )
{
+ /* the seac operator must not be nested */
+ decoder->seac = TRUE;
error = cff_decoder_parse_charstrings( decoder, charstring,
charstring_len );
+ decoder->seac = FALSE;
if ( error )
goto Exit;
@@ -863,9 +878,10 @@
decoder->read_width = 1;
/* compute random seed from stack address of parameter */
- seed = (FT_Fixed)(char*)&seed ^
- (FT_Fixed)(char*)&decoder ^
- (FT_Fixed)(char*)&charstring_base;
+ seed = (FT_Fixed)( ( (FT_PtrDist)(char*)&seed ^
+ (FT_PtrDist)(char*)&decoder ^
+ (FT_PtrDist)(char*)&charstring_base ) &
+ FT_ULONG_MAX ) ;
seed = ( seed ^ ( seed >> 10 ) ^ ( seed >> 20 ) ) & 0xFFFFL;
if ( seed == 0 )
seed = 0x7384;
@@ -920,18 +936,18 @@
ip += 2;
}
else if ( v < 247 )
- val = (FT_Long)v - 139;
+ val = (FT_Int32)v - 139;
else if ( v < 251 )
{
if ( ip >= limit )
goto Syntax_Error;
- val = ( (FT_Long)v - 247 ) * 256 + *ip++ + 108;
+ val = ( (FT_Int32)v - 247 ) * 256 + *ip++ + 108;
}
else if ( v < 255 )
{
if ( ip >= limit )
goto Syntax_Error;
- val = -( (FT_Long)v - 251 ) * 256 - *ip++ - 108;
+ val = -( (FT_Int32)v - 251 ) * 256 - *ip++ - 108;
}
else
{
@@ -2241,8 +2257,8 @@
if ( idx >= decoder->num_locals )
{
- FT_ERROR(( "cff_decoder_parse_charstrings:" ));
- FT_ERROR(( " invalid local subr index\n" ));
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " invalid local subr index\n" ));
goto Syntax_Error;
}
@@ -2263,7 +2279,7 @@
if ( !zone->base || zone->limit == zone->base )
{
FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invoking empty subrs!\n" ));
+ " invoking empty subrs\n" ));
goto Syntax_Error;
}
@@ -2283,8 +2299,8 @@
if ( idx >= decoder->num_globals )
{
- FT_ERROR(( "cff_decoder_parse_charstrings:" ));
- FT_ERROR(( " invalid global subr index\n" ));
+ FT_ERROR(( "cff_decoder_parse_charstrings:"
+ " invalid global subr index\n" ));
goto Syntax_Error;
}
@@ -2305,7 +2321,7 @@
if ( !zone->base || zone->limit == zone->base )
{
FT_ERROR(( "cff_decoder_parse_charstrings:"
- " invoking empty subrs!\n" ));
+ " invoking empty subrs\n" ));
goto Syntax_Error;
}
@@ -2354,15 +2370,15 @@
return error;
Syntax_Error:
- FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error!\n" ));
+ FT_TRACE4(( "cff_decoder_parse_charstrings: syntax error\n" ));
return CFF_Err_Invalid_File_Format;
Stack_Underflow:
- FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow!\n" ));
+ FT_TRACE4(( "cff_decoder_parse_charstrings: stack underflow\n" ));
return CFF_Err_Too_Few_Arguments;
Stack_Overflow:
- FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow!\n" ));
+ FT_TRACE4(( "cff_decoder_parse_charstrings: stack overflow\n" ));
return CFF_Err_Stack_Overflow;
}
@@ -2565,8 +2581,8 @@
FT_Byte fd_index = cff_fd_select_get( &cff->fd_select,
glyph_index );
- FT_Int top_upm = cff->top_font.font_dict.units_per_em;
- FT_Int sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
+ FT_ULong top_upm = cff->top_font.font_dict.units_per_em;
+ FT_ULong sub_upm = cff->subfonts[fd_index]->font_dict.units_per_em;
font_matrix = cff->subfonts[fd_index]->font_dict.font_matrix;
@@ -2711,9 +2727,14 @@
glyph->root.linearHoriAdvance = decoder.glyph_width;
glyph->root.internal->glyph_transformed = 0;
+#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
has_vertical_info = FT_BOOL( face->vertical_info &&
face->vertical.number_Of_VMetrics > 0 &&
face->vertical.long_metrics );
+#else
+ has_vertical_info = FT_BOOL( face->vertical_info &&
+ face->vertical.number_Of_VMetrics > 0 );
+#endif
/* get the vertical metrics from the vtmx table if we have one */
if ( has_vertical_info )
@@ -2750,8 +2771,8 @@
glyph->root.outline.flags |= FT_OUTLINE_REVERSE_FILL;
- /* apply the font matrix -- `xx' has already been normalized */
- if ( !( font_matrix.yy == 0x10000L &&
+ if ( !( font_matrix.xx == 0x10000L &&
+ font_matrix.yy == 0x10000L &&
font_matrix.xy == 0 &&
font_matrix.yx == 0 ) )
FT_Outline_Transform( &glyph->root.outline, &font_matrix );
@@ -2804,7 +2825,8 @@
metrics->horiBearingY = cbox.yMax;
if ( has_vertical_info )
- metrics->vertBearingX = -metrics->width / 2;
+ metrics->vertBearingX = metrics->horiBearingX -
+ metrics->horiAdvance / 2;
else
ft_synthesize_vertical_metrics( metrics,
metrics->vertAdvance );
diff --git a/freetype/src/cff/cffgload.h b/freetype/src/cff/cffgload.h
index 85de77f46..5c09ac3c2 100644
--- a/freetype/src/cff/cffgload.h
+++ b/freetype/src/cff/cffgload.h
@@ -4,7 +4,7 @@
/* */
/* OpenType Glyph Loader (specification). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -53,8 +53,6 @@ FT_BEGIN_HEADER
/* */
/* current :: The current glyph outline. */
/* */
- /* last :: The last point position. */
- /* */
/* pos_x :: The horizontal translation (if composite glyph). */
/* */
/* pos_y :: The vertical translation (if composite glyph). */
@@ -88,8 +86,6 @@ FT_BEGIN_HEADER
FT_Outline* base;
FT_Outline* current;
- FT_Vector last;
-
FT_Pos pos_x;
FT_Pos pos_y;
@@ -158,6 +154,8 @@ FT_BEGIN_HEADER
FT_Render_Mode hint_mode;
+ FT_Bool seac;
+
} CFF_Decoder;
diff --git a/freetype/src/cff/cffload.c b/freetype/src/cff/cffload.c
index c0f43fd20..58d933da8 100644
--- a/freetype/src/cff/cffload.c
+++ b/freetype/src/cff/cffload.c
@@ -736,6 +736,7 @@
{
FT_Error error = FT_Err_Ok;
FT_UInt i;
+ FT_Long j;
FT_UShort max_cid = 0;
@@ -750,8 +751,11 @@
if ( FT_NEW_ARRAY( charset->cids, max_cid ) )
goto Exit;
- for ( i = 0; i < num_glyphs; i++ )
- charset->cids[charset->sids[i]] = (FT_UShort)i;
+ /* When multiple GIDs map to the same CID, we choose the lowest */
+ /* GID. This is not described in any spec, but it matches the */
+ /* behaviour of recent Acroread versions. */
+ for ( j = num_glyphs - 1; j >= 0 ; j-- )
+ charset->cids[charset->sids[j]] = (FT_UShort)j;
charset->max_cid = max_cid;
charset->num_glyphs = num_glyphs;
@@ -842,7 +846,20 @@
goto Exit;
for ( j = 1; j < num_glyphs; j++ )
- charset->sids[j] = FT_GET_USHORT();
+ {
+ FT_UShort sid = FT_GET_USHORT();
+
+
+ /* this constant is given in the CFF specification */
+ if ( sid < 65000L )
+ charset->sids[j] = sid;
+ else
+ {
+ FT_TRACE0(( "cff_charset_load:"
+ " invalid SID value %d set to zero\n", sid ));
+ charset->sids[j] = 0;
+ }
+ }
FT_FRAME_EXIT();
}
@@ -875,6 +892,20 @@
goto Exit;
}
+ /* check whether the range contains at least one valid glyph; */
+ /* the constant is given in the CFF specification */
+ if ( glyph_sid >= 65000L ) {
+ FT_ERROR(( "cff_charset_load: invalid SID range\n" ));
+ error = CFF_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
+ /* try to rescue some of the SIDs if `nleft' is too large */
+ if ( nleft > 65000L - 1L || glyph_sid >= 65000L - nleft ) {
+ FT_ERROR(( "cff_charset_load: invalid SID range trimmed\n" ));
+ nleft = ( FT_UInt )( 65000L - 1L - glyph_sid );
+ }
+
/* Fill in the range of sids -- `nleft + 1' glyphs. */
for ( i = 0; j < num_glyphs && i <= nleft; i++, j++, glyph_sid++ )
charset->sids[j] = glyph_sid;
@@ -883,7 +914,7 @@
break;
default:
- FT_ERROR(( "cff_charset_load: invalid table format!\n" ));
+ FT_ERROR(( "cff_charset_load: invalid table format\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -906,7 +937,7 @@
if ( num_glyphs > 229 )
{
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
- "predefined charset (Adobe ISO-Latin)!\n" ));
+ "predefined charset (Adobe ISO-Latin)\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -924,7 +955,7 @@
if ( num_glyphs > 166 )
{
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
- "predefined charset (Adobe Expert)!\n" ));
+ "predefined charset (Adobe Expert)\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -942,7 +973,7 @@
if ( num_glyphs > 87 )
{
FT_ERROR(( "cff_charset_load: implicit charset larger than\n"
- "predefined charset (Adobe Expert Subset)!\n" ));
+ "predefined charset (Adobe Expert Subset)\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -1127,7 +1158,7 @@
break;
default:
- FT_ERROR(( "cff_encoding_load: invalid table format!\n" ));
+ FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -1222,7 +1253,7 @@
break;
default:
- FT_ERROR(( "cff_encoding_load: invalid table format!\n" ));
+ FT_ERROR(( "cff_encoding_load: invalid table format\n" ));
error = CFF_Err_Invalid_File_Format;
goto Exit;
}
@@ -1240,7 +1271,8 @@
CFF_Index idx,
FT_UInt font_index,
FT_Stream stream,
- FT_ULong base_offset )
+ FT_ULong base_offset,
+ FT_Library library )
{
FT_Error error;
CFF_ParserRec parser;
@@ -1250,7 +1282,7 @@
CFF_Private priv = &font->private_dict;
- cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict );
+ cff_parser_init( &parser, CFF_CODE_TOPDICT, &font->font_dict, library );
/* set defaults */
FT_MEM_ZERO( top, sizeof ( *top ) );
@@ -1301,7 +1333,7 @@
priv->expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
priv->blue_scale = (FT_Fixed)( 0.039625 * 0x10000L * 1000 );
- cff_parser_init( &parser, CFF_CODE_PRIVATE, priv );
+ cff_parser_init( &parser, CFF_CODE_PRIVATE, priv, library );
if ( FT_STREAM_SEEK( base_offset + font->font_dict.private_offset ) ||
FT_FRAME_ENTER( font->font_dict.private_size ) )
@@ -1354,7 +1386,8 @@
FT_LOCAL_DEF( FT_Error )
- cff_font_load( FT_Stream stream,
+ cff_font_load( FT_Library library,
+ FT_Stream stream,
FT_Int face_index,
CFF_Font font,
FT_Bool pure_cff )
@@ -1394,7 +1427,7 @@
font->header_size < 4 ||
font->absolute_offsize > 4 )
{
- FT_TRACE2(( "[not a CFF font header!]\n" ));
+ FT_TRACE2(( "[not a CFF font header]\n" ));
error = CFF_Err_Unknown_File_Format;
goto Exit;
}
@@ -1432,7 +1465,8 @@
&font->font_dict_index,
face_index,
stream,
- base_offset );
+ base_offset,
+ library );
if ( error )
goto Exit;
@@ -1462,7 +1496,7 @@
if ( fd_index.count > CFF_MAX_CID_FONTS )
{
- FT_ERROR(( "cff_font_load: FD array too large in CID font\n" ));
+ FT_TRACE0(( "cff_font_load: FD array too large in CID font\n" ));
goto Fail_CID;
}
@@ -1480,7 +1514,7 @@
{
sub = font->subfonts[idx];
error = cff_subfont_load( sub, &fd_index, idx,
- stream, base_offset );
+ stream, base_offset, library );
if ( error )
goto Fail_CID;
}
@@ -1503,7 +1537,7 @@
/* read the charstrings index now */
if ( dict->charstrings_offset == 0 )
{
- FT_ERROR(( "cff_font_load: no charstrings offset!\n" ));
+ FT_ERROR(( "cff_font_load: no charstrings offset\n" ));
error = CFF_Err_Unknown_File_Format;
goto Exit;
}
diff --git a/freetype/src/cff/cffload.h b/freetype/src/cff/cffload.h
index 13697e599..4fafe505c 100644
--- a/freetype/src/cff/cffload.h
+++ b/freetype/src/cff/cffload.h
@@ -58,7 +58,8 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
- cff_font_load( FT_Stream stream,
+ cff_font_load( FT_Library library,
+ FT_Stream stream,
FT_Int face_index,
CFF_Font font,
FT_Bool pure_cff );
diff --git a/freetype/src/cff/cffobjs.c b/freetype/src/cff/cffobjs.c
index 85ef89d97..55fa950f3 100644
--- a/freetype/src/cff/cffobjs.c
+++ b/freetype/src/cff/cffobjs.c
@@ -4,7 +4,7 @@
/* */
/* OpenType objects manager (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by */
+/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -30,6 +30,7 @@
#include "cffload.h"
#include "cffcmap.h"
#include "cfferrs.h"
+#include "cffpic.h"
/*************************************************************************/
@@ -223,8 +224,8 @@
CFF_Font font = (CFF_Font)face->extra.data;
CFF_Internal internal = (CFF_Internal)size->internal;
- FT_Int top_upm = font->top_font.font_dict.units_per_em;
- FT_UInt i;
+ FT_ULong top_upm = font->top_font.font_dict.units_per_em;
+ FT_UInt i;
funcs->set_scale( internal->topfont,
@@ -234,7 +235,7 @@
for ( i = font->num_subfonts; i > 0; i-- )
{
CFF_SubFont sub = font->subfonts[i - 1];
- FT_Int sub_upm = sub->font_dict.units_per_em;
+ FT_ULong sub_upm = sub->font_dict.units_per_em;
FT_Pos x_scale, y_scale;
@@ -295,8 +296,8 @@
CFF_Font font = (CFF_Font)cffface->extra.data;
CFF_Internal internal = (CFF_Internal)size->internal;
- FT_Int top_upm = font->top_font.font_dict.units_per_em;
- FT_UInt i;
+ FT_ULong top_upm = font->top_font.font_dict.units_per_em;
+ FT_UInt i;
funcs->set_scale( internal->topfont,
@@ -306,7 +307,7 @@
for ( i = font->num_subfonts; i > 0; i-- )
{
CFF_SubFont sub = font->subfonts[i - 1];
- FT_Int sub_upm = sub->font_dict.units_per_em;
+ FT_ULong sub_upm = sub->font_dict.units_per_em;
FT_Pos x_scale, y_scale;
@@ -408,6 +409,7 @@
PSHinter_Service pshinter;
FT_Bool pure_cff = 1;
FT_Bool sfnt_format = 0;
+ FT_Library library = cffface->driver->root.library;
#if 0
@@ -419,14 +421,14 @@
goto Bad_Format;
#else
sfnt = (SFNT_Service)FT_Get_Module_Interface(
- cffface->driver->root.library, "sfnt" );
+ library, "sfnt" );
if ( !sfnt )
goto Bad_Format;
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
pshinter = (PSHinter_Service)FT_Get_Module_Interface(
- cffface->driver->root.library, "pshinter" );
+ library, "pshinter" );
#endif
/* create input stream from resource */
@@ -507,7 +509,7 @@
goto Exit;
face->extra.data = cff;
- error = cff_font_load( stream, face_index, cff, pure_cff );
+ error = cff_font_load( library, stream, face_index, cff, pure_cff );
if ( error )
goto Exit;
@@ -528,10 +530,10 @@
/* which aren't CID-keyed */
if ( dict->cid_registry == 0xFFFFU && !psnames )
{
- FT_ERROR(( "cff_face_init:" ));
- FT_ERROR(( " cannot open CFF & CEF fonts\n" ));
- FT_ERROR(( " " ));
- FT_ERROR(( " without the `PSNames' module\n" ));
+ FT_ERROR(( "cff_face_init:"
+ " cannot open CFF & CEF fonts\n"
+ " "
+ " without the `PSNames' module\n" ));
goto Bad_Format;
}
@@ -582,7 +584,7 @@
if ( sub->units_per_em )
{
- FT_Int scaling;
+ FT_Long scaling;
if ( top->units_per_em > 1 && sub->units_per_em > 1 )
@@ -764,22 +766,22 @@
/* */
/* Compute face flags. */
/* */
- flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
- FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
- FT_FACE_FLAG_HINTER; /* has native hinter */
+ flags = (FT_UInt32)( FT_FACE_FLAG_SCALABLE | /* scalable outlines */
+ FT_FACE_FLAG_HORIZONTAL | /* horizontal data */
+ FT_FACE_FLAG_HINTER ); /* has native hinter */
if ( sfnt_format )
- flags |= FT_FACE_FLAG_SFNT;
+ flags |= (FT_UInt32)FT_FACE_FLAG_SFNT;
/* fixed width font? */
if ( dict->is_fixed_pitch )
- flags |= FT_FACE_FLAG_FIXED_WIDTH;
+ flags |= (FT_UInt32)FT_FACE_FLAG_FIXED_WIDTH;
/* XXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */
#if 0
/* kerning available? */
if ( face->kern_pairs )
- flags |= FT_FACE_FLAG_KERNING;
+ flags |= (FT_UInt32)FT_FACE_FLAG_KERNING;
#endif
cffface->face_flags = flags;
@@ -868,7 +870,7 @@
nn = (FT_UInt)cffface->num_charmaps;
- FT_CMap_New( &cff_cmap_unicode_class_rec, NULL, &cmaprec, NULL );
+ FT_CMap_New( &FT_CFF_CMAP_UNICODE_CLASS_REC_GET, NULL, &cmaprec, NULL );
/* if no Unicode charmap was previously selected, select this one */
if ( cffface->charmap == NULL && nn != (FT_UInt)cffface->num_charmaps )
@@ -887,19 +889,19 @@
{
cmaprec.encoding_id = TT_ADOBE_ID_STANDARD;
cmaprec.encoding = FT_ENCODING_ADOBE_STANDARD;
- clazz = &cff_cmap_encoding_class_rec;
+ clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
}
else if ( encoding->offset == 1 )
{
cmaprec.encoding_id = TT_ADOBE_ID_EXPERT;
cmaprec.encoding = FT_ENCODING_ADOBE_EXPERT;
- clazz = &cff_cmap_encoding_class_rec;
+ clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
}
else
{
cmaprec.encoding_id = TT_ADOBE_ID_CUSTOM;
cmaprec.encoding = FT_ENCODING_ADOBE_CUSTOM;
- clazz = &cff_cmap_encoding_class_rec;
+ clazz = &FT_CFF_CMAP_ENCODING_CLASS_REC_GET;
}
FT_CMap_New( clazz, NULL, &cmaprec, NULL );
diff --git a/freetype/src/cff/cffparse.c b/freetype/src/cff/cffparse.c
index 8af93b8e8..8174b8234 100644
--- a/freetype/src/cff/cffparse.c
+++ b/freetype/src/cff/cffparse.c
@@ -22,6 +22,7 @@
#include <freetype/internal/ftdebug.h>
#include "cfferrs.h"
+#include "cffpic.h"
/*************************************************************************/
@@ -34,47 +35,20 @@
#define FT_COMPONENT trace_cffparse
- enum
- {
- cff_kind_none = 0,
- cff_kind_num,
- cff_kind_fixed,
- cff_kind_fixed_thousand,
- cff_kind_string,
- cff_kind_bool,
- cff_kind_delta,
- cff_kind_callback,
-
- cff_kind_max /* do not remove */
- };
-
-
- /* now generate handlers for the most simple fields */
- typedef FT_Error (*CFF_Field_Reader)( CFF_Parser parser );
-
- typedef struct CFF_Field_Handler_
- {
- int kind;
- int code;
- FT_UInt offset;
- FT_Byte size;
- CFF_Field_Reader reader;
- FT_UInt array_max;
- FT_UInt count_offset;
-
- } CFF_Field_Handler;
FT_LOCAL_DEF( void )
cff_parser_init( CFF_Parser parser,
FT_UInt code,
- void* object )
+ void* object,
+ FT_Library library)
{
FT_MEM_ZERO( parser, sizeof ( *parser ) );
parser->top = parser->stack;
parser->object_code = code;
parser->object = object;
+ parser->library = library;
}
@@ -156,8 +130,8 @@
static FT_Fixed
cff_parse_real( FT_Byte* start,
FT_Byte* limit,
- FT_Int power_ten,
- FT_Int* scaling )
+ FT_Long power_ten,
+ FT_Long* scaling )
{
FT_Byte* p = start;
FT_UInt nib;
@@ -165,7 +139,7 @@
FT_Long result, number, rest, exponent;
FT_Int sign = 0, exponent_sign = 0;
- FT_Int exponent_add, integer_length, fraction_length;
+ FT_Long exponent_add, integer_length, fraction_length;
if ( scaling )
@@ -181,6 +155,8 @@
integer_length = 0;
fraction_length = 0;
+ FT_UNUSED( rest );
+
/* First of all, read the integer part. */
phase = 4;
@@ -310,7 +286,7 @@
{
if ( exponent > 0 )
{
- FT_Int new_fraction_length, shift;
+ FT_Long new_fraction_length, shift;
/* Make `scaling' as small as possible. */
@@ -410,7 +386,7 @@
/* but return `10^scaling' times the number read in */
static FT_Fixed
cff_parse_fixed_scaled( FT_Byte** d,
- FT_Int scaling )
+ FT_Long scaling )
{
return **d == 30 ? cff_parse_real( d[0], d[1], scaling, NULL )
: ( cff_parse_integer( d[0], d[1] ) *
@@ -423,7 +399,7 @@
/* the scaling factor (as a power of 10) */
static FT_Fixed
cff_parse_fixed_dynamic( FT_Byte** d,
- FT_Int* scaling )
+ FT_Long* scaling )
{
FT_ASSERT( scaling );
@@ -476,7 +452,7 @@
if ( parser->top >= parser->stack + 6 )
{
- FT_Int scaling;
+ FT_Long scaling;
error = CFF_Err_Ok;
@@ -578,7 +554,12 @@
{
dict->cid_registry = (FT_UInt)cff_parse_num ( data++ );
dict->cid_ordering = (FT_UInt)cff_parse_num ( data++ );
- dict->cid_supplement = (FT_ULong)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 );
+ if ( dict->cid_supplement < 0 )
+ FT_TRACE1(( "cff_parse_cid_ros: negative supplement %d is found\n",
+ dict->cid_supplement ));
error = CFF_Err_Ok;
}
@@ -599,6 +580,11 @@
#define CFF_FIELD_DELTA( code, name, max ) \
CFF_FIELD( code, name, cff_kind_delta )
+#define CFFCODE_TOPDICT 0x1000
+#define CFFCODE_PRIVATE 0x2000
+
+#ifndef FT_CONFIG_OPTION_PIC
+
#define CFF_FIELD_CALLBACK( code, name ) \
{ \
cff_kind_callback, \
@@ -630,9 +616,6 @@
FT_FIELD_OFFSET( num_ ## name ) \
},
-#define CFFCODE_TOPDICT 0x1000
-#define CFFCODE_PRIVATE 0x2000
-
static const CFF_Field_Handler cff_field_handlers[] =
{
@@ -642,13 +625,99 @@
};
+#else /* FT_CONFIG_OPTION_PIC */
+
+ void FT_Destroy_Class_cff_field_handlers(FT_Library library, CFF_Field_Handler* clazz)
+ {
+ FT_Memory memory = library->memory;
+ if ( clazz )
+ FT_FREE( clazz );
+ }
+
+ FT_Error FT_Create_Class_cff_field_handlers(FT_Library library, CFF_Field_Handler** output_class)
+ {
+ CFF_Field_Handler* clazz;
+ FT_Error error;
+ FT_Memory memory = library->memory;
+ int i=0;
+
+#undef CFF_FIELD
+#undef CFF_FIELD_DELTA
+#undef CFF_FIELD_CALLBACK
+#define CFF_FIELD_CALLBACK( code, name ) i++;
+#define CFF_FIELD( code, name, kind ) i++;
+#define CFF_FIELD_DELTA( code, name, max ) i++;
+
+#include "cfftoken.h"
+ i++;/*{ 0, 0, 0, 0, 0, 0, 0 }*/
+
+ if ( FT_ALLOC( clazz, sizeof(CFF_Field_Handler)*i ) )
+ return error;
+
+ i=0;
+#undef CFF_FIELD
+#undef CFF_FIELD_DELTA
+#undef CFF_FIELD_CALLBACK
+
+#define CFF_FIELD_CALLBACK( code_, name_ ) \
+ clazz[i].kind = cff_kind_callback; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = 0; \
+ clazz[i].size = 0; \
+ clazz[i].reader = cff_parse_ ## name_; \
+ clazz[i].array_max = 0; \
+ clazz[i].count_offset = 0; \
+ i++;
+
+#undef CFF_FIELD
+#define CFF_FIELD( code_, name_, kind_ ) \
+ clazz[i].kind = kind_; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
+ clazz[i].size = FT_FIELD_SIZE( name_ ); \
+ clazz[i].reader = 0; \
+ clazz[i].array_max = 0; \
+ clazz[i].count_offset = 0; \
+ i++; \
+
+#undef CFF_FIELD_DELTA
+#define CFF_FIELD_DELTA( code_, name_, max_ ) \
+ clazz[i].kind = cff_kind_delta; \
+ clazz[i].code = code_ | CFFCODE; \
+ clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
+ clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
+ clazz[i].reader = 0; \
+ clazz[i].array_max = max_; \
+ clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
+ i++;
+
+#include "cfftoken.h"
+
+ clazz[i].kind = 0;
+ clazz[i].code = 0;
+ clazz[i].offset = 0;
+ clazz[i].size = 0;
+ clazz[i].reader = 0;
+ clazz[i].array_max = 0;
+ clazz[i].count_offset = 0;
+
+ *output_class = clazz;
+ return FT_Err_Ok;
+ }
+
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+
FT_LOCAL_DEF( FT_Error )
cff_parser_run( CFF_Parser parser,
FT_Byte* start,
FT_Byte* limit )
{
- FT_Byte* p = start;
- FT_Error error = CFF_Err_Ok;
+ FT_Byte* p = start;
+ FT_Error error = CFF_Err_Ok;
+ FT_Library library = parser->library;
+ FT_UNUSED(library);
parser->top = parser->stack;
@@ -718,7 +787,7 @@
}
code = code | parser->object_code;
- for ( field = cff_field_handlers; field->kind; field++ )
+ for ( field = FT_CFF_FIELD_HANDLERS_GET; field->kind; field++ )
{
if ( field->code == (FT_Int)code )
{
diff --git a/freetype/src/cff/cffparse.h b/freetype/src/cff/cffparse.h
index f3ec9adb4..0ee7f0f58 100644
--- a/freetype/src/cff/cffparse.h
+++ b/freetype/src/cff/cffparse.h
@@ -36,6 +36,7 @@ FT_BEGIN_HEADER
typedef struct CFF_ParserRec_
{
+ FT_Library library;
FT_Byte* start;
FT_Byte* limit;
FT_Byte* cursor;
@@ -52,7 +53,8 @@ FT_BEGIN_HEADER
FT_LOCAL( void )
cff_parser_init( CFF_Parser parser,
FT_UInt code,
- void* object );
+ void* object,
+ FT_Library library);
FT_LOCAL( FT_Error )
cff_parser_run( CFF_Parser parser,
@@ -60,6 +62,37 @@ FT_BEGIN_HEADER
FT_Byte* limit );
+ enum
+ {
+ cff_kind_none = 0,
+ cff_kind_num,
+ cff_kind_fixed,
+ cff_kind_fixed_thousand,
+ cff_kind_string,
+ cff_kind_bool,
+ cff_kind_delta,
+ cff_kind_callback,
+
+ cff_kind_max /* do not remove */
+ };
+
+
+ /* now generate handlers for the most simple fields */
+ typedef FT_Error (*CFF_Field_Reader)( CFF_Parser parser );
+
+ typedef struct CFF_Field_Handler_
+ {
+ int kind;
+ int code;
+ FT_UInt offset;
+ FT_Byte size;
+ CFF_Field_Reader reader;
+ FT_UInt array_max;
+ FT_UInt count_offset;
+
+ } CFF_Field_Handler;
+
+
FT_END_HEADER
diff --git a/freetype/src/cff/cffpic.c b/freetype/src/cff/cffpic.c
new file mode 100644
index 000000000..336cf838b
--- /dev/null
+++ b/freetype/src/cff/cffpic.c
@@ -0,0 +1,99 @@
+/***************************************************************************/
+/* */
+/* cffpic.c */
+/* */
+/* The FreeType position independent code services for cff module. */
+/* */
+/* Copyright 2009 by */
+/* Oran Agra and Mickey Gabel. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include <freetype/internal/ftobjs.h>
+#include "cffpic.h"
+
+#ifdef FT_CONFIG_OPTION_PIC
+
+ /* forward declaration of PIC init functions from cffdrivr.c */
+ FT_Error FT_Create_Class_cff_services( FT_Library, FT_ServiceDescRec**);
+ void FT_Destroy_Class_cff_services( FT_Library, FT_ServiceDescRec*);
+ void FT_Init_Class_cff_service_ps_info( FT_Library, FT_Service_PsInfoRec*);
+ void FT_Init_Class_cff_service_glyph_dict( FT_Library, FT_Service_GlyphDictRec*);
+ void FT_Init_Class_cff_service_ps_name( FT_Library, FT_Service_PsFontNameRec*);
+ void FT_Init_Class_cff_service_get_cmap_info( FT_Library, FT_Service_TTCMapsRec*);
+ void FT_Init_Class_cff_service_cid_info( FT_Library, FT_Service_CIDRec*);
+
+ /* forward declaration of PIC init functions from cffparse.c */
+ FT_Error FT_Create_Class_cff_field_handlers( FT_Library, CFF_Field_Handler**);
+ void FT_Destroy_Class_cff_field_handlers( FT_Library, CFF_Field_Handler*);
+
+ /* forward declaration of PIC init functions from cffcmap.c */
+ void FT_Init_Class_cff_cmap_encoding_class_rec( FT_Library, FT_CMap_ClassRec*);
+ void FT_Init_Class_cff_cmap_unicode_class_rec( FT_Library, FT_CMap_ClassRec*);
+
+ void
+ cff_driver_class_pic_free( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Memory memory = library->memory;
+ if ( pic_container->cff )
+ {
+ CffModulePIC* container = (CffModulePIC*)pic_container->cff;
+ if(container->cff_services)
+ FT_Destroy_Class_cff_services(library, container->cff_services);
+ container->cff_services = NULL;
+ if(container->cff_field_handlers)
+ FT_Destroy_Class_cff_field_handlers(library, container->cff_field_handlers);
+ container->cff_field_handlers = NULL;
+ FT_FREE( container );
+ pic_container->cff = NULL;
+ }
+ }
+
+ FT_Error
+ cff_driver_class_pic_init( FT_Library library )
+ {
+ FT_PIC_Container* pic_container = &library->pic_container;
+ FT_Error error = FT_Err_Ok;
+ CffModulePIC* container;
+ FT_Memory memory = library->memory;
+
+ /* allocate pointer, clear and set global container pointer */
+ if ( FT_ALLOC ( container, sizeof ( *container ) ) )
+ return error;
+ FT_MEM_SET( container, 0, sizeof(*container) );
+ pic_container->cff = container;
+
+ /* initialize pointer table - this is how the module usually expects this data */
+ error = FT_Create_Class_cff_services(library, &container->cff_services);
+ if(error)
+ goto Exit;
+ error = FT_Create_Class_cff_field_handlers(library, &container->cff_field_handlers);
+ if(error)
+ goto Exit;
+ FT_Init_Class_cff_service_ps_info(library, &container->cff_service_ps_info);
+ FT_Init_Class_cff_service_glyph_dict(library, &container->cff_service_glyph_dict);
+ FT_Init_Class_cff_service_ps_name(library, &container->cff_service_ps_name);
+ FT_Init_Class_cff_service_get_cmap_info(library, &container->cff_service_get_cmap_info);
+ FT_Init_Class_cff_service_cid_info(library, &container->cff_service_cid_info);
+ FT_Init_Class_cff_cmap_encoding_class_rec(library, &container->cff_cmap_encoding_class_rec);
+ FT_Init_Class_cff_cmap_unicode_class_rec(library, &container->cff_cmap_unicode_class_rec);
+Exit:
+ if(error)
+ cff_driver_class_pic_free(library);
+ return error;
+ }
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+
+/* END */
diff --git a/freetype/src/cff/cffpic.h b/freetype/src/cff/cffpic.h
new file mode 100644
index 000000000..338bc5993
--- /dev/null
+++ b/freetype/src/cff/cffpic.h
@@ -0,0 +1,80 @@
+/***************************************************************************/
+/* */
+/* cffpic.h */
+/* */
+/* The FreeType position independent code services for cff module. */
+/* */
+/* Copyright 2009 by */
+/* Oran Agra and Mickey Gabel. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
+#ifndef __CFFPIC_H__
+#define __CFFPIC_H__
+
+
+FT_BEGIN_HEADER
+
+#include <freetype/internal/ftpic.h>
+
+#ifndef FT_CONFIG_OPTION_PIC
+#define FT_CFF_SERVICE_PS_INFO_GET cff_service_ps_info
+#define FT_CFF_SERVICE_GLYPH_DICT_GET cff_service_glyph_dict
+#define FT_CFF_SERVICE_PS_NAME_GET cff_service_ps_name
+#define FT_CFF_SERVICE_GET_CMAP_INFO_GET cff_service_get_cmap_info
+#define FT_CFF_SERVICE_CID_INFO_GET cff_service_cid_info
+#define FT_CFF_SERVICES_GET cff_services
+#define FT_CFF_CMAP_ENCODING_CLASS_REC_GET cff_cmap_encoding_class_rec
+#define FT_CFF_CMAP_UNICODE_CLASS_REC_GET cff_cmap_unicode_class_rec
+#define FT_CFF_FIELD_HANDLERS_GET cff_field_handlers
+
+#else /* FT_CONFIG_OPTION_PIC */
+
+#include FT_SERVICE_GLYPH_DICT_H
+#include "cffparse.h"
+#include FT_SERVICE_POSTSCRIPT_INFO_H
+#include FT_SERVICE_POSTSCRIPT_NAME_H
+#include FT_SERVICE_TT_CMAP_H
+#include FT_SERVICE_CID_H
+
+ 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_CMap_ClassRec cff_cmap_encoding_class_rec;
+ FT_CMap_ClassRec cff_cmap_unicode_class_rec;
+ } CffModulePIC;
+
+#define GET_PIC(lib) ((CffModulePIC*)((lib)->pic_container.cff))
+#define FT_CFF_SERVICE_PS_INFO_GET (GET_PIC(library)->cff_service_ps_info)
+#define FT_CFF_SERVICE_GLYPH_DICT_GET (GET_PIC(library)->cff_service_glyph_dict)
+#define FT_CFF_SERVICE_PS_NAME_GET (GET_PIC(library)->cff_service_ps_name)
+#define FT_CFF_SERVICE_GET_CMAP_INFO_GET (GET_PIC(library)->cff_service_get_cmap_info)
+#define FT_CFF_SERVICE_CID_INFO_GET (GET_PIC(library)->cff_service_cid_info)
+#define FT_CFF_SERVICES_GET (GET_PIC(library)->cff_services)
+#define FT_CFF_CMAP_ENCODING_CLASS_REC_GET (GET_PIC(library)->cff_cmap_encoding_class_rec)
+#define FT_CFF_CMAP_UNICODE_CLASS_REC_GET (GET_PIC(library)->cff_cmap_unicode_class_rec)
+#define FT_CFF_FIELD_HANDLERS_GET (GET_PIC(library)->cff_field_handlers)
+
+#endif /* FT_CONFIG_OPTION_PIC */
+
+ /* */
+
+FT_END_HEADER
+
+#endif /* __CFFPIC_H__ */
+
+
+/* END */
diff --git a/freetype/src/cff/cfftypes.h b/freetype/src/cff/cfftypes.h
index f23e54c09..2d81e340f 100644
--- a/freetype/src/cff/cfftypes.h
+++ b/freetype/src/cff/cfftypes.h
@@ -130,7 +130,7 @@ FT_BEGIN_HEADER
/* these should only be used for the top-level font dictionary */
FT_UInt cid_registry;
FT_UInt cid_ordering;
- FT_ULong cid_supplement;
+ FT_Long cid_supplement;
FT_Long cid_font_version;
FT_Long cid_font_revision;