diff --git a/ChangeLog b/ChangeLog index e26253a75..18a055082 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2003-09-21 David Turner + + * include/freetype/internal/ftserv.h, + include/freetype/internal/service/svpfr.h, + include/freetype/internal/pfr.h, + src/base/ftpfr.c: + + migrating the functions of "ftpfr.h" to the new + service-base internal API + + * src/cff/cffobjs.c, src/cid/cidobjs.c, src/pfr/pfrsbit.c, + src/psaux/psobjs.c, src/sfnt/sfdriver.c, src/sfnt/sfobjs.c, + src/truetype/ttobjs.c, src/type1/t1driver.c, src/type1/t1objs.c, + src/type42/t42objs.c, src/winfonts/winfnt.c: + + removing various compiler warnings + + + 2003-09-19 David Bevan * src/type1/t1parse.c (pfb_tag_fields): Removed. @@ -117,7 +136,7 @@ * src/base/ftbdf.c: Include FT_SERVICE_BDF_H. (test_font_type): Removed. (FT_Get_BDF_Charset_ID, FT_Get_BDF_Property): Use services - provided in `FT_SERVICE_ID_BDF' + provided in `FT_SERVICE_ID_BDF' * src/base/ftmm.c: Include FT_SERVICE_MULTIPLE_MASTERS_H. (ft_face_get_mm_service): New auxiliary function to get services diff --git a/include/freetype/internal/ftserv.h b/include/freetype/internal/ftserv.h index 4e498ad46..f02a1c677 100644 --- a/include/freetype/internal/ftserv.h +++ b/include/freetype/internal/ftserv.h @@ -78,16 +78,16 @@ FT_BEGIN_HEADER /***** *****/ /*************************************************************************/ /*************************************************************************/ - + /* * The following structure is used to _describe_ a given service * to the library. This is useful to build simple static service lists. - */ + */ typedef struct FT_ServiceDescRec_ { const char* serv_id; /* service name */ const void* serv_data; /* service pointer/data */ - + } FT_ServiceDescRec; typedef const FT_ServiceDescRec* FT_ServiceDesc; @@ -114,7 +114,7 @@ FT_BEGIN_HEADER /***** *****/ /*************************************************************************/ /*************************************************************************/ - + /* * This structure is used to store a cache for several frequently used * services. It is the type of `face->internal->services'. You @@ -128,7 +128,8 @@ FT_BEGIN_HEADER FT_Pointer postscript_name; FT_Pointer multi_masters; FT_Pointer glyph_dict; - + FT_Pointer pfr_metrics; + } FT_ServiceCacheRec, *FT_ServiceCache; @@ -196,13 +197,14 @@ FT_BEGIN_HEADER /* * The header files containing the services. */ - + #define FT_SERVICE_MULTIPLE_MASTERS_H -#define FT_SERVICE_POSTSCRIPT_NAME_H +#define FT_SERVICE_POSTSCRIPT_NAME_H #define FT_SERVICE_GLYPH_DICT_H #define FT_SERVICE_BDF_H #define FT_SERVICE_XFREE86_NAME_H #define FT_SERVICE_SFNT_H +#define FT_SERVICE_PFR_H FT_END_HEADER diff --git a/include/freetype/internal/pfr.h b/include/freetype/internal/services/svpfr.h similarity index 88% rename from include/freetype/internal/pfr.h rename to include/freetype/internal/services/svpfr.h index 51be6202c..e47cb6c93 100644 --- a/include/freetype/internal/pfr.h +++ b/include/freetype/internal/services/svpfr.h @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* pfr.h */ +/* svpfr.h */ /* */ /* Internal PFR service functions (specification only). */ /* */ @@ -16,15 +16,15 @@ /***************************************************************************/ -#ifndef __PFR_H__ -#define __PFR_H__ - -#include -#include FT_FREETYPE_H +#ifndef __SVPFR_H__ +#define __SVPFR_H__ +#include FT_INTERNAL_SERVICE_H FT_BEGIN_HEADER +#define FT_SERVICE_ID_PFR_METRICS "pfr-metrics" + typedef FT_Error (*FT_PFR_GetMetricsFunc)( FT_Face face, FT_UInt *aoutline, FT_UInt *ametrics, @@ -41,20 +41,19 @@ FT_BEGIN_HEADER FT_Pos *aadvance ); - typedef struct FT_PFR_ServiceRec_ + FT_DEFINE_SERVICE( PfrMetrics ) { FT_PFR_GetMetricsFunc get_metrics; FT_PFR_GetKerningFunc get_kerning; FT_PFR_GetAdvanceFunc get_advance; - } FT_PFR_ServiceRec, *FT_PFR_Service; - -#define FT_PFR_SERVICE_NAME "pfr" + }; + /* */ FT_END_HEADER -#endif /* __PFR_H__ */ +#endif /* __SVPFR_H__ */ /* END */ diff --git a/src/base/ftpfr.c b/src/base/ftpfr.c index a23dcab0b..57e21eb73 100644 --- a/src/base/ftpfr.c +++ b/src/base/ftpfr.c @@ -16,34 +16,20 @@ /***************************************************************************/ #include -#include FT_INTERNAL_PFR_H #include FT_INTERNAL_OBJECTS_H +#include FT_SERVICE_PFR_H /* check the format */ - static FT_Error - ft_pfr_check( FT_Face face, - FT_PFR_Service *aservice ) + static FT_Service_PfrMetrics + ft_pfr_check( FT_Face face ) { - FT_Error error = FT_Err_Bad_Argument; + FT_Service_PfrMetrics service; + FT_FACE_LOOKUP_SERVICE( face, FT_Service_PfrMetrics, service, + pfr_metrics, FT_SERVICE_ID_PFR_METRICS ); - if ( face && face->driver ) - { - FT_Module module = (FT_Module) face->driver; - const char* name = module->clazz->module_name; - - - if ( name[0] == 'p' && - name[1] == 'f' && - name[2] == 'r' && - name[3] == 0 ) - { - *aservice = (FT_PFR_Service) module->clazz->module_interface; - error = 0; - } - } - return error; + return service; } @@ -54,12 +40,12 @@ FT_Fixed *ametrics_x_scale, FT_Fixed *ametrics_y_scale ) { - FT_Error error; - FT_PFR_Service service; + FT_Error error; + FT_Service_PfrMetrics service; - error = ft_pfr_check( face, &service ); - if ( !error ) + service = ft_pfr_check( face ); + if ( service ) { error = service->get_metrics( face, aoutline_resolution, @@ -67,6 +53,26 @@ ametrics_x_scale, ametrics_y_scale ); } + else if ( face ) + { + FT_Fixed x_scale, y_scale; + + /* this is not a PFR font */ + *aoutline_resolution = face->units_per_EM; + *ametrics_resolution = face->units_per_EM; + + x_scale = y_scale = 0x10000L; + if ( face->size ) + { + x_scale = face->size->metrics.x_scale; + y_scale = face->size->metrics.y_scale; + } + *ametrics_x_scale = x_scale; + *ametrics_y_scale = y_scale; + } + else + error = FT_Err_Invalid_Argument; + return error; } @@ -77,15 +83,22 @@ FT_UInt right, FT_Vector *avector ) { - FT_Error error; - FT_PFR_Service service; + FT_Error error; + FT_Service_PfrMetrics service; - error = ft_pfr_check( face, &service ); - if ( !error ) + service = ft_pfr_check( face ); + if ( service ) { error = service->get_kerning( face, left, right, avector ); } + else if ( face ) + { + error = FT_Get_Kerning( face, left, right, FT_KERNING_UNSCALED, avector ); + } + else + error = FT_Err_Invalid_Argument; + return error; } @@ -95,15 +108,19 @@ FT_UInt gindex, FT_Pos *aadvance ) { - FT_Error error; - FT_PFR_Service service; + FT_Error error; + FT_Service_PfrMetrics service; - error = ft_pfr_check( face, &service ); - if ( !error ) + service = ft_pfr_check( face ); + if ( service ) { error = service->get_advance( face, gindex, aadvance ); } + else + /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */ + error = FT_Err_Invalid_Argument; + return error; } diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index f0700d189..9dad6c3a1 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -396,8 +396,8 @@ else root->units_per_EM = 1000; - root->underline_position = dict->underline_position >> 16; - root->underline_thickness = dict->underline_thickness >> 16; + root->underline_position = (FT_Short) (dict->underline_position >> 16); + root->underline_thickness = (FT_Short) (dict->underline_thickness >> 16); /* retrieve font family & style name */ root->family_name = cff_index_get_name( &cff->name_index, face_index ); diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index 313d31505..79457582e 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -199,12 +199,12 @@ if ( face->subrs ) { FT_Int n; - + for ( n = 0; n < cid->num_dicts; n++ ) { CID_Subrs subr = face->subrs + n; - + if ( subr->code ) { @@ -423,8 +423,8 @@ root->height = (FT_Short)( ( ( root->ascender - root->descender ) * 12 ) / 10 ); - root->underline_position = info->underline_position >> 16; - root->underline_thickness = info->underline_thickness >> 16; + root->underline_position = (FT_Short) (info->underline_position >> 16); + root->underline_thickness = (FT_Short) (info->underline_thickness >> 16); root->internal->max_points = 0; root->internal->max_contours = 0; diff --git a/src/pfr/pfrsbit.c b/src/pfr/pfrsbit.c index 84aeb7a04..949e3ded9 100644 --- a/src/pfr/pfrsbit.c +++ b/src/pfr/pfrsbit.c @@ -654,7 +654,7 @@ error = pfr_load_bitmap_bits( p, stream->limit, format, - face->header.color_flags & 2, + FT_BOOL(face->header.color_flags & 2), &glyph->root.bitmap ); } } diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index fca38baf5..992800f6a 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -589,14 +589,14 @@ /* All white-space charcters are ignored. */ skip_spaces( &cur, limit ); - b = T1Radix( 16, &cur, cur + 1 ); + b = (FT_Byte) T1Radix( 16, &cur, cur + 1 ); if ( cur == cur2 ) break; /* == != <0f> */ - bytes[n / 2] = ( n % 2 ) ? bytes[n / 2] + b - : b * 16; + bytes[n / 2] = (FT_Byte)( ( n % 2 ) ? bytes[n / 2] + b + : b * 16 ); } skip_spaces( &cur, limit ); diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index 8080b810d..cc186a68e 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -89,7 +89,7 @@ * GLYPH DICT SERVICE * */ - + static FT_Error sfnt_get_glyph_name( TT_Face face, FT_UInt glyph_index, @@ -130,7 +130,7 @@ * POSTSCRIPT NAME SERVICE * */ - + static const char* sfnt_get_ps_name( TT_Face face ) { @@ -243,7 +243,7 @@ static const FT_Service_PsNameRec sfnt_service_ps_name = { - (FT_PsName_GetFunc) & sfnt_get_ps_name + (FT_PsName_GetFunc) sfnt_get_ps_name }; @@ -258,10 +258,10 @@ { FT_SERVICE_ID_POSTSCRIPT_NAME, & sfnt_service_ps_name }, #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES { FT_SERVICE_ID_GLYPH_DICT, & sfnt_service_glyph_dict }, -#endif +#endif { NULL, NULL } - }; + }; FT_CALLBACK_DEF( FT_Module_Interface ) diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index 33a71ae3f..64d8afbf9 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -643,14 +643,14 @@ FT_Bitmap_Size* bsize = root->available_sizes + n; TT_SBit_Strike strike = face->sbit_strikes + n; FT_UShort fupem = face->header.Units_Per_EM; - FT_Short height = face->horizontal.Ascender - - face->horizontal.Descender + - face->horizontal.Line_Gap; + FT_Short height = (FT_Short)( face->horizontal.Ascender - + face->horizontal.Descender + + face->horizontal.Line_Gap ); FT_Short avg = face->os2.xAvgCharWidth; /* assume 72dpi */ - bsize->height = + bsize->height = (FT_Short)( ( height * strike->y_ppem + fupem/2 ) / fupem ); bsize->width = (FT_Short)( ( avg * strike->y_ppem + fupem/2 ) / fupem ); diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index e1e69cdf8..3768dd6cb 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -228,7 +228,7 @@ #ifdef TT_CONFIG_OPTION_UNPATENTED_HINTING /* Determine whether unpatented hinting is to be used for this face. */ - face->unpatented_hinting = + face->unpatented_hinting = FT_BOOL ( library->debug_hooks[ FT_DEBUG_HOOK_UNPATENTED_HINTING ] != NULL ); { diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index e920f4344..35cde03d3 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -116,7 +116,7 @@ static const FT_Service_PsNameRec t1_service_ps_name = { - (FT_PsName_GetFunc) &t1_get_ps_name + (FT_PsName_GetFunc) t1_get_ps_name }; @@ -145,10 +145,10 @@ { FT_SERVICE_ID_POSTSCRIPT_NAME, &t1_service_ps_name }, { FT_SERVICE_ID_GLYPH_DICT, &t1_service_glyph_dict }, { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_TYPE_1 }, - -#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT + +#ifndef T1_CONFIG_OPTION_NO_MM_SUPPORT { FT_SERVICE_ID_MULTI_MASTERS, &t1_service_multi_masters }, -#endif +#endif { NULL, NULL } }; diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index c62e72b7e..2207aef45 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -434,8 +434,8 @@ root->max_advance_height = root->height; - root->underline_position = info->underline_position >> 16; - root->underline_thickness = info->underline_thickness >> 16; + root->underline_position = (FT_Short)( info->underline_position >> 16 ); + root->underline_thickness = (FT_Short)( info->underline_thickness >> 16 ); root->internal->max_points = 0; root->internal->max_contours = 0; diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index bb4120571..37a45530f 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -278,8 +278,8 @@ root->max_advance_width = face->ttf_face->max_advance_width; root->max_advance_height = face->ttf_face->max_advance_height; - root->underline_position = info->underline_position >> 16; - root->underline_thickness = info->underline_thickness >> 16; + root->underline_position = (FT_Short)( info->underline_position >> 16 ); + root->underline_thickness = (FT_Short)( info->underline_thickness >> 16 ); root->internal->max_points = 0; root->internal->max_contours = 0; diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c index b2e315f63..ebbabe829 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -453,10 +453,10 @@ bsize->width = font->header.avg_width; - bsize->height = - font->header.pixel_height + font->header.external_leading; + bsize->height = (FT_Short)( + font->header.pixel_height + font->header.external_leading ); bsize->size = font->header.nominal_point_size << 6; - bsize->x_ppem = + bsize->x_ppem = (FT_Pos)( ( font->header.horizontal_resolution * bsize->size + 36 ) / 72 ); bsize->y_ppem =