From 27a4f9c4ac45ff65f941964f7351b64b1e6a9f35 Mon Sep 17 00:00:00 2001 From: scuri Date: Tue, 20 Oct 2009 17:20:18 +0000 Subject: *** empty log message *** --- src/freetype2/cid/cidgload.c | 59 ++++++++++++----------- src/freetype2/cid/cidload.c | 36 ++++++++++++-- src/freetype2/cid/cidobjs.c | 81 ++++++++++++++++---------------- src/freetype2/cid/cidparse.c | 9 ++-- src/freetype2/cid/cidriver.c | 109 ++++++++++++++++++++++++++++++++++++------- src/freetype2/cid/cidriver.h | 4 ++ src/freetype2/cid/cidtoken.h | 13 +++++- 7 files changed, 217 insertions(+), 94 deletions(-) (limited to 'src/freetype2/cid') diff --git a/src/freetype2/cid/cidgload.c b/src/freetype2/cid/cidgload.c index 8bec6e1..f59035f 100644 --- a/src/freetype2/cid/cidgload.c +++ b/src/freetype2/cid/cidgload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 Glyph Loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -22,6 +22,7 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_OUTLINE_H +#include FT_INTERNAL_CALC_H #include "ciderrs.h" @@ -51,20 +52,23 @@ FT_ULong glyph_length = 0; PSAux_Service psaux = (PSAux_Service)face->psaux; +#ifdef FT_CONFIG_OPTION_INCREMENTAL + FT_Incremental_InterfaceRec *inc = + face->root.internal->incremental_interface; +#endif + #ifdef FT_CONFIG_OPTION_INCREMENTAL /* For incremental fonts get the character data using */ /* the callback function. */ - if ( face->root.internal->incremental_interface ) + if ( inc ) { FT_Data glyph_data; - error = face->root.internal->incremental_interface->funcs->get_glyph_data( - face->root.internal->incremental_interface->object, - glyph_index, - &glyph_data ); + error = inc->funcs->get_glyph_data( inc->object, + glyph_index, &glyph_data ); if ( error ) goto Exit; @@ -74,15 +78,13 @@ if ( glyph_data.length != 0 ) { glyph_length = glyph_data.length - cid->fd_bytes; - FT_ALLOC( charstring, glyph_length ); + (void)FT_ALLOC( charstring, glyph_length ); if ( !error ) ft_memcpy( charstring, glyph_data.pointer + cid->fd_bytes, glyph_length ); } - face->root.internal->incremental_interface->funcs->free_glyph_data( - face->root.internal->incremental_interface->object, - &glyph_data ); + inc->funcs->free_glyph_data( inc->object, &glyph_data ); if ( error ) goto Exit; @@ -163,22 +165,21 @@ #ifdef FT_CONFIG_OPTION_INCREMENTAL /* Incremental fonts can optionally override the metrics. */ - if ( !error && - face->root.internal->incremental_interface && - face->root.internal->incremental_interface->funcs->get_glyph_metrics ) + if ( !error && inc && inc->funcs->get_glyph_metrics ) { FT_Incremental_MetricsRec metrics; - metrics.bearing_x = decoder->builder.left_bearing.x; - metrics.bearing_y = decoder->builder.left_bearing.y; - metrics.advance = decoder->builder.advance.x; - error = face->root.internal->incremental_interface->funcs->get_glyph_metrics( - face->root.internal->incremental_interface->object, - glyph_index, FALSE, &metrics ); - decoder->builder.left_bearing.x = metrics.bearing_x; - decoder->builder.left_bearing.y = metrics.bearing_y; - decoder->builder.advance.x = metrics.advance; + metrics.bearing_x = FIXED_TO_INT( decoder->builder.left_bearing.x ); + metrics.bearing_y = FIXED_TO_INT( decoder->builder.left_bearing.y ); + metrics.advance = FIXED_TO_INT( decoder->builder.advance.x ); + + error = inc->funcs->get_glyph_metrics( inc->object, + glyph_index, FALSE, &metrics ); + + decoder->builder.left_bearing.x = INT_TO_FIXED( metrics.bearing_x ); + decoder->builder.left_bearing.y = INT_TO_FIXED( metrics.bearing_y ); + decoder->builder.advance.x = INT_TO_FIXED( metrics.advance ); decoder->builder.advance.y = 0; } @@ -251,7 +252,7 @@ /* ignore the error if one occurred - skip to next glyph */ } - *max_advance = decoder.builder.advance.x; + *max_advance = FIXED_TO_INT( decoder.builder.advance.x ); psaux->t1_decoder_funcs->done( &decoder ); @@ -342,8 +343,10 @@ FT_Slot_Internal internal = cidglyph->internal; - cidglyph->metrics.horiBearingX = decoder.builder.left_bearing.x; - cidglyph->metrics.horiAdvance = decoder.builder.advance.x; + cidglyph->metrics.horiBearingX = + FIXED_TO_INT( decoder.builder.left_bearing.x ); + cidglyph->metrics.horiAdvance = + FIXED_TO_INT( decoder.builder.advance.x ); internal->glyph_matrix = font_matrix; internal->glyph_delta = font_offset; @@ -357,8 +360,10 @@ /* copy the _unscaled_ advance width */ - metrics->horiAdvance = decoder.builder.advance.x; - cidglyph->linearHoriAdvance = decoder.builder.advance.x; + metrics->horiAdvance = + FIXED_TO_INT( decoder.builder.advance.x ); + cidglyph->linearHoriAdvance = + FIXED_TO_INT( decoder.builder.advance.x ); cidglyph->internal->glyph_transformed = 0; /* make up vertical ones */ diff --git a/src/freetype2/cid/cidload.c b/src/freetype2/cid/cidload.c index 9ed8cee..3bb3594 100644 --- a/src/freetype2/cid/cidload.c +++ b/src/freetype2/cid/cidload.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 font loader (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -97,6 +97,10 @@ object = (FT_Byte*)&cid->font_info; break; + case T1_FIELD_LOCATION_FONT_EXTRA: + object = (FT_Byte*)&face->font_extra; + break; + case T1_FIELD_LOCATION_BBOX: object = (FT_Byte*)&cid->font_bbox; break; @@ -108,7 +112,7 @@ if ( parser->num_dict < 0 ) { - FT_ERROR(( "cid_load_keyword: invalid use of `%s'!\n", + FT_ERROR(( "cid_load_keyword: invalid use of `%s'\n", keyword->ident )); error = CID_Err_Syntax_Error; goto Exit; @@ -234,14 +238,38 @@ } + /* by mistake, `expansion_factor' appears both in PS_PrivateRec */ + /* and CID_FaceDictRec (both are public header files and can't */ + /* changed); we simply copy the value */ + + FT_CALLBACK_DEF( FT_Error ) + parse_expansion_factor( CID_Face face, + CID_Parser* parser ) + { + CID_FaceDict dict; + + + if ( parser->num_dict >= 0 ) + { + dict = face->cid.font_dicts + parser->num_dict; + + dict->expansion_factor = cid_parser_to_fixed( parser, 0 ); + dict->private_dict.expansion_factor = dict->expansion_factor; + } + + return CID_Err_Ok; + } + + static const T1_FieldRec cid_field_records[] = { #include "cidtoken.h" - T1_FIELD_CALLBACK( "FDArray", parse_fd_array, 0 ) - T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix, 0 ) + T1_FIELD_CALLBACK( "FDArray", parse_fd_array, 0 ) + T1_FIELD_CALLBACK( "FontMatrix", parse_font_matrix, 0 ) + T1_FIELD_CALLBACK( "ExpansionFactor", parse_expansion_factor, 0 ) { 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 } }; diff --git a/src/freetype2/cid/cidobjs.c b/src/freetype2/cid/cidobjs.c index 1b3bfbf..9647d87 100644 --- a/src/freetype2/cid/cidobjs.c +++ b/src/freetype2/cid/cidobjs.c @@ -4,7 +4,7 @@ /* */ /* CID objects manager (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -193,61 +193,61 @@ FT_LOCAL_DEF( void ) cid_face_done( FT_Face cidface ) /* CID_Face */ { - CID_Face face = (CID_Face)cidface; - FT_Memory memory; + CID_Face face = (CID_Face)cidface; + FT_Memory memory; + CID_FaceInfo cid; + PS_FontInfo info; - if ( face ) - { - CID_FaceInfo cid = &face->cid; - PS_FontInfo info = &cid->font_info; + if ( !face ) + return; + cid = &face->cid; + info = &cid->font_info; + memory = cidface->memory; - memory = cidface->memory; + /* release subrs */ + if ( face->subrs ) + { + FT_Int n; - /* release subrs */ - if ( face->subrs ) + + for ( n = 0; n < cid->num_dicts; n++ ) { - FT_Int n; + CID_Subrs subr = face->subrs + n; - for ( n = 0; n < cid->num_dicts; n++ ) + if ( subr->code ) { - CID_Subrs subr = face->subrs + n; - - - if ( subr->code ) - { - FT_FREE( subr->code[0] ); - FT_FREE( subr->code ); - } + FT_FREE( subr->code[0] ); + FT_FREE( subr->code ); } - - FT_FREE( face->subrs ); } - /* release FontInfo strings */ - FT_FREE( info->version ); - FT_FREE( info->notice ); - FT_FREE( info->full_name ); - FT_FREE( info->family_name ); - FT_FREE( info->weight ); + FT_FREE( face->subrs ); + } - /* release font dictionaries */ - FT_FREE( cid->font_dicts ); - cid->num_dicts = 0; + /* release FontInfo strings */ + FT_FREE( info->version ); + FT_FREE( info->notice ); + FT_FREE( info->full_name ); + FT_FREE( info->family_name ); + FT_FREE( info->weight ); - /* release other strings */ - FT_FREE( cid->cid_font_name ); - FT_FREE( cid->registry ); - FT_FREE( cid->ordering ); + /* release font dictionaries */ + FT_FREE( cid->font_dicts ); + cid->num_dicts = 0; - cidface->family_name = 0; - cidface->style_name = 0; + /* release other strings */ + FT_FREE( cid->cid_font_name ); + FT_FREE( cid->registry ); + FT_FREE( cid->ordering ); - FT_FREE( face->binary_data ); - FT_FREE( face->cid_stream ); - } + cidface->family_name = 0; + cidface->style_name = 0; + + FT_FREE( face->binary_data ); + FT_FREE( face->cid_stream ); } @@ -324,6 +324,7 @@ goto Exit; /* check the face index */ + /* XXX: handle CID fonts with more than a single face */ if ( face_index != 0 ) { FT_ERROR(( "cid_face_init: invalid face index\n" )); diff --git a/src/freetype2/cid/cidparse.c b/src/freetype2/cid/cidparse.c index bb87afc..efed618 100644 --- a/src/freetype2/cid/cidparse.c +++ b/src/freetype2/cid/cidparse.c @@ -4,7 +4,7 @@ /* */ /* CID-keyed Type1 parser (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -18,7 +18,6 @@ #include #include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_CALC_H #include FT_INTERNAL_OBJECTS_H #include FT_INTERNAL_STREAM_H @@ -87,13 +86,13 @@ /* `StartData' or `/sfnts' */ { FT_Byte buffer[256 + 10]; - FT_Int read_len = 256 + 10; + FT_Long read_len = 256 + 10; /* same as signed FT_Stream->size */ FT_Byte* p = buffer; - for ( offset = (FT_ULong)FT_STREAM_POS(); ; offset += 256 ) + for ( offset = FT_STREAM_POS(); ; offset += 256 ) { - FT_Int stream_len; + FT_Long stream_len; /* same as signed FT_Stream->size */ stream_len = stream->size - FT_STREAM_POS(); diff --git a/src/freetype2/cid/cidriver.c b/src/freetype2/cid/cidriver.c index 5c5a729..3a2d225 100644 --- a/src/freetype2/cid/cidriver.c +++ b/src/freetype2/cid/cidriver.c @@ -4,7 +4,7 @@ /* */ /* CID driver interface (body). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2004, 2006, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -20,13 +20,14 @@ #include "cidriver.h" #include "cidgload.h" #include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_STREAM_H #include "ciderrs.h" #include FT_SERVICE_POSTSCRIPT_NAME_H #include FT_SERVICE_XFREE86_NAME_H #include FT_SERVICE_POSTSCRIPT_INFO_H +#include FT_SERVICE_CID_H + /*************************************************************************/ /* */ @@ -38,10 +39,10 @@ #define FT_COMPONENT trace_ciddriver - /* - * POSTSCRIPT NAME SERVICE - * - */ + /* + * POSTSCRIPT NAME SERVICE + * + */ static const char* cid_get_postscript_name( CID_Face face ) @@ -62,38 +63,114 @@ }; - /* - * POSTSCRIPT INFO SERVICE - * - */ + /* + * POSTSCRIPT INFO SERVICE + * + */ static FT_Error cid_ps_get_font_info( FT_Face face, PS_FontInfoRec* afont_info ) { *afont_info = ((CID_Face)face)->cid.font_info; - return 0; + + return CID_Err_Ok; } + static FT_Error + cid_ps_get_font_extra( FT_Face face, + PS_FontExtraRec* afont_extra ) + { + *afont_extra = ((CID_Face)face)->font_extra; + + return CID_Err_Ok; + } static const FT_Service_PsInfoRec cid_service_ps_info = { (PS_GetFontInfoFunc) cid_ps_get_font_info, + (PS_GetFontExtraFunc) cid_ps_get_font_extra, (PS_HasGlyphNamesFunc) NULL, /* unsupported with CID fonts */ (PS_GetFontPrivateFunc)NULL /* unsupported */ }; - /* - * SERVICE LIST - * - */ + /* + * CID INFO SERVICE + * + */ + static FT_Error + cid_get_ros( CID_Face face, + const char* *registry, + const char* *ordering, + FT_Int *supplement ) + { + CID_FaceInfo cid = &face->cid; + + + if ( registry ) + *registry = cid->registry; + + if ( ordering ) + *ordering = cid->ordering; + + if ( supplement ) + *supplement = cid->supplement; + + return CID_Err_Ok; + } + + + static FT_Error + cid_get_is_cid( CID_Face face, + FT_Bool *is_cid ) + { + FT_Error error = CID_Err_Ok; + FT_UNUSED( face ); + + + if ( is_cid ) + *is_cid = 1; /* cid driver is only used for CID keyed fonts */ + + return error; + } + + + static FT_Error + cid_get_cid_from_glyph_index( CID_Face face, + FT_UInt glyph_index, + FT_UInt *cid ) + { + FT_Error error = CID_Err_Ok; + FT_UNUSED( face ); + + + if ( cid ) + *cid = glyph_index; /* identity mapping */ + + return error; + } + + + static const FT_Service_CIDRec cid_service_cid_info = + { + (FT_CID_GetRegistryOrderingSupplementFunc)cid_get_ros, + (FT_CID_GetIsInternallyCIDKeyedFunc) cid_get_is_cid, + (FT_CID_GetCIDFromGlyphIndexFunc) cid_get_cid_from_glyph_index + }; + + + /* + * SERVICE LIST + * + */ static const FT_ServiceDescRec cid_services[] = { - { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cid_service_ps_name }, { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_CID }, + { FT_SERVICE_ID_POSTSCRIPT_FONT_NAME, &cid_service_ps_name }, { FT_SERVICE_ID_POSTSCRIPT_INFO, &cid_service_ps_info }, + { FT_SERVICE_ID_CID, &cid_service_cid_info }, { NULL, NULL } }; diff --git a/src/freetype2/cid/cidriver.h b/src/freetype2/cid/cidriver.h index d5a80f6..c7f424b 100644 --- a/src/freetype2/cid/cidriver.h +++ b/src/freetype2/cid/cidriver.h @@ -26,6 +26,10 @@ FT_BEGIN_HEADER +#ifdef FT_CONFIG_OPTION_PIC +#error "this module does not support PIC yet" +#endif + FT_CALLBACK_TABLE const FT_Driver_ClassRec t1cid_driver_class; diff --git a/src/freetype2/cid/cidtoken.h b/src/freetype2/cid/cidtoken.h index ad5bbb2..94a3657 100644 --- a/src/freetype2/cid/cidtoken.h +++ b/src/freetype2/cid/cidtoken.h @@ -4,7 +4,7 @@ /* */ /* CID token definitions (specification only). */ /* */ -/* Copyright 1996-2001, 2002, 2003, 2006 by */ +/* Copyright 1996-2001, 2002, 2003, 2006, 2008, 2009 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -49,6 +49,13 @@ T1_FIELD_NUM ( "UnderlinePosition", underline_position, 0 ) T1_FIELD_NUM ( "UnderlineThickness", underline_thickness, 0 ) +#undef FT_STRUCTURE +#define FT_STRUCTURE PS_FontExtraRec +#undef T1CODE +#define T1CODE T1_FIELD_LOCATION_FONT_EXTRA + + T1_FIELD_NUM ( "FSType", fs_type, 0 ) + #undef FT_STRUCTURE #define FT_STRUCTURE CID_FaceDictRec @@ -62,7 +69,6 @@ T1_FIELD_NUM ( "SubrCount", num_subrs, 0 ) T1_FIELD_NUM ( "lenBuildCharArray", len_buildchar, 0 ) T1_FIELD_FIXED( "ForceBoldThreshold", forcebold_threshold, 0 ) - T1_FIELD_FIXED( "ExpansionFactor", expansion_factor, 0 ) T1_FIELD_FIXED( "StrokeWidth", stroke_width, 0 ) @@ -92,6 +98,9 @@ T1_FIELD_NUM_TABLE ( "StemSnapH", snap_widths, 12, 0 ) T1_FIELD_NUM_TABLE ( "StemSnapV", snap_heights, 12, 0 ) + T1_FIELD_BOOL ( "ForceBold", force_bold, 0 ) + + #undef FT_STRUCTURE #define FT_STRUCTURE FT_BBox #undef T1CODE -- cgit v1.2.3