diff options
Diffstat (limited to 'freetype/src/cff')
-rw-r--r-- | freetype/src/cff/cffdrivr.c | 59 | ||||
-rw-r--r-- | freetype/src/cff/cfferrs.h | 3 | ||||
-rw-r--r-- | freetype/src/cff/cffgload.c | 25 | ||||
-rw-r--r-- | freetype/src/cff/cffload.c | 4 | ||||
-rw-r--r-- | freetype/src/cff/cffobjs.c | 40 | ||||
-rw-r--r-- | freetype/src/cff/cffpic.c | 113 | ||||
-rw-r--r-- | freetype/src/cff/cffpic.h | 9 |
7 files changed, 162 insertions, 91 deletions
diff --git a/freetype/src/cff/cffdrivr.c b/freetype/src/cff/cffdrivr.c index 1e9797294..e1b2ff237 100644 --- a/freetype/src/cff/cffdrivr.c +++ b/freetype/src/cff/cffdrivr.c @@ -4,7 +4,7 @@ /* */ /* OpenType font driver implementation (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -125,7 +125,7 @@ /*************************************************************************/ /* */ /* <Function> */ - /* Load_Glyph */ + /* cff_glyph_load */ /* */ /* <Description> */ /* A driver method used to load a glyph within a given glyph slot. */ @@ -149,10 +149,10 @@ /* FreeType error code. 0 means success. */ /* */ FT_CALLBACK_DEF( FT_Error ) - Load_Glyph( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ - FT_Size cffsize, /* CFF_Size */ - FT_UInt glyph_index, - FT_Int32 load_flags ) + cff_glyph_load( FT_GlyphSlot cffslot, /* CFF_GlyphSlot */ + FT_Size cffsize, /* CFF_Size */ + FT_UInt glyph_index, + FT_Int32 load_flags ) { FT_Error error; CFF_GlyphSlot slot = (CFF_GlyphSlot)cffslot; @@ -203,7 +203,7 @@ for ( nn = 0; nn < count; nn++ ) { - error = Load_Glyph( slot, face->size, start + nn, flags ); + error = cff_glyph_load( slot, face->size, start + nn, flags ); if ( error ) break; @@ -239,7 +239,7 @@ " cannot get glyph name from CFF & CEF fonts\n" " " " without the `PSNames' module\n" )); - error = CFF_Err_Unknown_File_Format; + error = CFF_Err_Missing_Module; goto Exit; } @@ -466,7 +466,7 @@ dict->cid_registry ); *registry = cff->registry; } - + if ( ordering ) { if ( cff->ordering == NULL ) @@ -489,7 +489,7 @@ *supplement = (FT_Int)dict->cid_supplement; } } - + Fail: return error; } @@ -599,19 +599,35 @@ cff_get_interface( FT_Module driver, /* CFF_Driver */ const char* module_interface ) { + FT_Library library; FT_Module sfnt; FT_Module_Interface result; + /* FT_CFF_SERVICES_GET derefers `library' in PIC mode */ +#ifdef FT_CONFIG_OPTION_PIC + if ( !driver ) + return NULL; + library = driver->library; + if ( !library ) + return NULL; +#endif + result = ft_service_list_lookup( FT_CFF_SERVICES_GET, module_interface ); if ( result != NULL ) - return result; + return result; + /* `driver' is not yet evaluated in non-PIC mode */ +#ifndef FT_CONFIG_OPTION_PIC if ( !driver ) return NULL; + library = driver->library; + if ( !library ) + return NULL; +#endif /* we pass our request to the `sfnt' module */ - sfnt = FT_Get_Module( driver->library, "sfnt" ); + sfnt = FT_Get_Module( library, "sfnt" ); return sfnt ? sfnt->clazz->get_interface( sfnt, module_interface ) : 0; } @@ -625,12 +641,13 @@ #define CFF_SIZE_SELECT 0 #endif - FT_DEFINE_DRIVER(cff_driver_class, + FT_DEFINE_DRIVER( cff_driver_class, + FT_MODULE_FONT_DRIVER | FT_MODULE_DRIVER_SCALABLE | FT_MODULE_DRIVER_HAS_HINTER, - sizeof( CFF_DriverRec ), + sizeof ( CFF_DriverRec ), "cff", 0x10000L, 0x20000L, @@ -642,9 +659,9 @@ cff_get_interface, /* now the specific driver fields */ - sizeof( TT_FaceRec ), - sizeof( CFF_SizeRec ), - sizeof( CFF_GlyphSlotRec ), + sizeof ( TT_FaceRec ), + sizeof ( CFF_SizeRec ), + sizeof ( CFF_GlyphSlotRec ), cff_face_init, cff_face_done, @@ -653,14 +670,14 @@ cff_slot_init, cff_slot_done, - ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ + ft_stub_set_char_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ ft_stub_set_pixel_sizes, /* FT_CONFIG_OPTION_OLD_INTERNALS */ - Load_Glyph, + cff_glyph_load, cff_get_kerning, - 0, /* FT_Face_AttachFunc */ - cff_get_advances, /* FT_Face_GetAdvancesFunc */ + 0, /* FT_Face_AttachFunc */ + cff_get_advances, cff_size_request, diff --git a/freetype/src/cff/cfferrs.h b/freetype/src/cff/cfferrs.h index 1b2a5c95c..801d73ec6 100644 --- a/freetype/src/cff/cfferrs.h +++ b/freetype/src/cff/cfferrs.h @@ -4,7 +4,7 @@ /* */ /* CFF error codes (specification only). */ /* */ -/* Copyright 2001 by */ +/* Copyright 2001, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -29,6 +29,7 @@ #undef __FTERRORS_H__ +#undef FT_ERR_PREFIX #define FT_ERR_PREFIX CFF_Err_ #define FT_ERR_BASE FT_Mod_Err_CFF diff --git a/freetype/src/cff/cffgload.c b/freetype/src/cff/cffgload.c index 1478dee54..7e2a4dac8 100644 --- a/freetype/src/cff/cffgload.c +++ b/freetype/src/cff/cffgload.c @@ -4,7 +4,7 @@ /* */ /* OpenType Glyph Loader (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -1513,11 +1513,9 @@ goto Stack_Underflow; /* if num_args isn't of the form 4n or 4n+1, */ - /* we reduce it to 4n+1 */ + /* we enforce it by clearing the second bit */ - nargs = num_args - num_args % 4; - if ( num_args - nargs > 0 ) - nargs += 1; + nargs = num_args & ~2; if ( cff_builder_start_point( builder, x, y ) ) goto Fail; @@ -1560,11 +1558,9 @@ goto Stack_Underflow; /* if num_args isn't of the form 4n or 4n+1, */ - /* we reduce it to 4n+1 */ + /* we enforce it by clearing the second bit */ - nargs = num_args - num_args % 4; - if ( num_args - nargs > 0 ) - nargs += 1; + nargs = num_args & ~2; if ( cff_builder_start_point( builder, x, y ) ) goto Fail; @@ -1612,11 +1608,9 @@ goto Stack_Underflow; /* if num_args isn't of the form 8n, 8n+1, 8n+4, or 8n+5, */ - /* we reduce it to the largest one which fits */ + /* we enforce it by clearing the second bit */ - nargs = num_args - num_args % 4; - if ( num_args - nargs > 0 ) - nargs += 1; + nargs = num_args & ~2; args -= nargs; if ( check_points( builder, ( nargs / 4 ) * 3 ) ) @@ -1963,6 +1957,7 @@ /* Save glyph width so that the subglyphs don't overwrite it. */ FT_Pos glyph_width = decoder->glyph_width; + error = cff_operator_seac( decoder, 0L, args[-4], args[-3], (FT_Int)( args[-2] >> 16 ), @@ -2705,7 +2700,7 @@ FT_Byte fd_index = cff_fd_select_get( &cff->fd_select, glyph_index ); - if ( fd_index >= cff->num_subfonts ) + if ( fd_index >= cff->num_subfonts ) fd_index = (FT_Byte)( cff->num_subfonts - 1 ); top_upm = cff->top_font.font_dict.units_per_em; @@ -2961,7 +2956,7 @@ if ( has_vertical_info ) metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2; - else + else { if ( load_flags & FT_LOAD_VERTICAL_LAYOUT ) ft_synthesize_vertical_metrics( metrics, diff --git a/freetype/src/cff/cffload.c b/freetype/src/cff/cffload.c index 890015176..744b138a7 100644 --- a/freetype/src/cff/cffload.c +++ b/freetype/src/cff/cffload.c @@ -1458,7 +1458,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; } @@ -1576,7 +1576,7 @@ if ( dict->charstrings_offset == 0 ) { FT_ERROR(( "cff_font_load: no charstrings offset\n" )); - error = CFF_Err_Unknown_File_Format; + error = CFF_Err_Invalid_File_Format; goto Exit; } diff --git a/freetype/src/cff/cffobjs.c b/freetype/src/cff/cffobjs.c index db7272779..bd6e1d7d2 100644 --- a/freetype/src/cff/cffobjs.c +++ b/freetype/src/cff/cffobjs.c @@ -4,7 +4,7 @@ /* */ /* OpenType objects manager (body). */ /* */ -/* Copyright 1996-2011 by */ +/* Copyright 1996-2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -404,7 +404,7 @@ FT_Int32 idx = 0; FT_Int32 length = strlen( name ) + 1; FT_Bool continue_search = 1; - + while ( continue_search ) { @@ -495,13 +495,19 @@ sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) - goto Bad_Format; + { + FT_ERROR(( "cff_face_init: cannot access `sfnt' module\n" )); + error = CFF_Err_Missing_Module; + goto Exit; + } FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); pshinter = (PSHinter_Service)FT_Get_Module_Interface( library, "pshinter" ); + FT_TRACE2(( "CFF driver\n" )); + /* create input stream from resource */ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; @@ -512,8 +518,9 @@ { if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */ { - FT_TRACE2(( "[not a valid OpenType/CFF font]\n" )); - goto Bad_Format; + FT_TRACE2(( " not an OpenType/CFF font\n" )); + error = CFF_Err_Unknown_File_Format; + goto Exit; } /* if we are performing a simple font format check, exit immediately */ @@ -605,7 +612,8 @@ " cannot open CFF & CEF fonts\n" " " " without the `PSNames' module\n" )); - goto Bad_Format; + error = CFF_Err_Missing_Module; + goto Exit; } #ifdef FT_DEBUG_LEVEL_TRACE @@ -773,7 +781,7 @@ char* family_name = NULL; - remove_subset_prefix( cffface->family_name ); + remove_subset_prefix( cffface->family_name ); if ( dict->family_name ) { @@ -820,7 +828,7 @@ style_name = cff_strcpy( memory, fullp ); /* remove the style part from the family name (if present) */ - remove_style( cffface->family_name, style_name ); + remove_style( cffface->family_name, style_name ); } break; } @@ -848,22 +856,22 @@ /* */ /* Compute face flags. */ /* */ - flags = (FT_UInt32)( FT_FACE_FLAG_SCALABLE | /* scalable outlines */ - FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ - FT_FACE_FLAG_HINTER ); /* has native hinter */ + flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ + FT_FACE_FLAG_HORIZONTAL | /* horizontal data */ + FT_FACE_FLAG_HINTER; /* has native hinter */ if ( sfnt_format ) - flags |= (FT_UInt32)FT_FACE_FLAG_SFNT; + flags |= FT_FACE_FLAG_SFNT; /* fixed width font? */ if ( dict->is_fixed_pitch ) - flags |= (FT_UInt32)FT_FACE_FLAG_FIXED_WIDTH; + flags |= 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_UInt32)FT_FACE_FLAG_KERNING; + flags |= FT_FACE_FLAG_KERNING; #endif cffface->face_flags = flags; @@ -1015,10 +1023,6 @@ Exit: return error; - - Bad_Format: - error = CFF_Err_Unknown_File_Format; - goto Exit; } diff --git a/freetype/src/cff/cffpic.c b/freetype/src/cff/cffpic.c index 478aac4ed..c34015ba8 100644 --- a/freetype/src/cff/cffpic.c +++ b/freetype/src/cff/cffpic.c @@ -19,40 +19,78 @@ #include <ft2build.h> #include FT_FREETYPE_H #include <freetype/internal/ftobjs.h> +#include "cffcmap.h" #include "cffpic.h" +#include "cfferrs.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*); + FT_Error + FT_Create_Class_cff_services( + FT_Library library, + FT_ServiceDescRec** output_class ); + + void + FT_Destroy_Class_cff_services( + FT_Library library, + FT_ServiceDescRec* clazz ); + + void + FT_Init_Class_cff_service_ps_info( + FT_Library library, + FT_Service_PsInfoRec* clazz ); + + void + FT_Init_Class_cff_service_glyph_dict( + FT_Library library, + FT_Service_GlyphDictRec* clazz ); + + void + FT_Init_Class_cff_service_ps_name( + FT_Library library, + FT_Service_PsFontNameRec* clazz ); + + void + FT_Init_Class_cff_service_get_cmap_info( + FT_Library library, + FT_Service_TTCMapsRec* clazz ); + + void + FT_Init_Class_cff_service_cid_info( + FT_Library library, + FT_Service_CIDRec* clazz ); /* 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*); + FT_Error + FT_Create_Class_cff_field_handlers( + FT_Library library, + CFF_Field_Handler** output_class ); - /* 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 + FT_Destroy_Class_cff_field_handlers( + FT_Library library, + CFF_Field_Handler* clazz ); void - cff_driver_class_pic_free( FT_Library library ) + cff_driver_class_pic_free( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Memory memory = library->memory; + 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); + 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); + 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; @@ -76,22 +114,31 @@ 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) + 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) + 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); + 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); + if ( error ) + cff_driver_class_pic_free( library ); return error; } diff --git a/freetype/src/cff/cffpic.h b/freetype/src/cff/cffpic.h index 338bc5993..076c220d6 100644 --- a/freetype/src/cff/cffpic.h +++ b/freetype/src/cff/cffpic.h @@ -19,7 +19,7 @@ #ifndef __CFFPIC_H__ #define __CFFPIC_H__ - + FT_BEGIN_HEADER #include <freetype/internal/ftpic.h> @@ -68,6 +68,13 @@ FT_BEGIN_HEADER #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) + /* see cffpic.c for the implementation */ + void + cff_driver_class_pic_free( FT_Library library ); + + FT_Error + cff_driver_class_pic_init( FT_Library library ); + #endif /* FT_CONFIG_OPTION_PIC */ /* */ |