From ba13f97fdccf4e0e0bcf28cf6995cb3342372589 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 22 Sep 2003 09:53:56 +0000 Subject: [PATCH] * include/freetype/internal/ftserv.h (FT_FACE_FIND_SERVICE): Fix compilation warning (s/pptr/Pptr/). * include/freetype/internal/internal.h (FT_INTERNAL_PFR_H, FT_INTERNAL_FNT_TYPES_H): Removed. --- ChangeLog | 72 ++++++++++++++----- include/freetype/internal/ftserv.h | 30 ++++---- include/freetype/internal/internal.h | 2 - include/freetype/internal/services/svpfr.h | 36 ++++++---- include/freetype/internal/services/svwinfnt.h | 11 +-- include/freetype/internal/services/svxf86nm.h | 2 +- src/base/ftpfr.c | 10 ++- src/base/ftwinfnt.c | 5 +- src/cff/cffobjs.c | 6 +- src/cid/cidobjs.c | 6 +- src/pfr/pfrsbit.c | 11 +-- src/type1/t1objs.c | 6 +- src/winfonts/winfnt.c | 2 + 13 files changed, 123 insertions(+), 76 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b927fcf7..7445aba6b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,30 +1,64 @@ +2003-09-21 Werner Lemberg + + * include/freetype/internal/ftserv.h (FT_FACE_FIND_SERVICE): + Fix compilation warning (s/pptr/Pptr/). + + * include/freetype/internal/internal.h (FT_INTERNAL_PFR_H, + FT_INTERNAL_FNT_TYPES_H): Removed. + 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 PFR and WINFNT drivers to the new service-based + internal API. - migrating the functions of "ftpfr.h" to the new - service-base internal API + * include/freetype/internal/fnttypes.h: Removed. Most of its data + are moved to winfnt.h and... + * include/freetype/internal/services/svwinfnt.h: New file. - * 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: + * include/freetype/internal/pfr.h: Removed. Most of its data are + moved to... + * include/freetype/internal/services/svpfr.h: New file. - removing various compiler warnings + * include/freetype/internal/ftserv.h (FT_FACE_FIND_SERVICE, + FT_FACE_LOOKUP_SERVICE): Simplify fix of 2003-09-16 by removing + pointer type argument. + Updated all callers. + Update macro names of services header files. + * src/base/ftobjs.c (FT_Get_Name_Index): Simplified code. + + * src/base/ftpfr.c: Include FT_SERVICE_PFR_H instead of + FT_INTERNAL_PFR_H. + (ft_pfr_check, FT_Get_PFR_Metrics, FT_Get_PFR_Kerning, + FT_Get_PFR_Advance): Use services provided in `PFR_METRICS'. + + * src/base/ftwinfnt.c: Include FT_SERVICE_WINFNT_H instead of + FT_INTERNAL_FNT_TYPES_H. + (FT_Get_WinFNT_Header): Use service provided in `WINFNT'. + + * src/pfr/pfrdrivr.c: Include FT_SERVICE_PFR_H and + FT_SERVICE_XFREE86_NAME_H instead of FT_INTERNAL_PFR_H. + (pfr_service_bdf): Updated. + (pfr_services): New services list. + (pfr_get_service): New function. + (pfr_driver_class): Updated. + + * src/winfonts/winfnt.c: Include FT_SERVICE_WINFNT_H and + FT_SERVICE_XFREE86_NAME_H instead of FT_INTERNAL_FNT_TYPES_H. + (winfnt_get_header, winfnt_get_service): New functions. + (winfnt_service_rec): New structure providing WINFNT services. + (winfnt_services): New services list. + (winfnt_driver_class): Updated. + * src/winfonts/winfnt.h: Add most of the removed fnttypes.h data. - * include/freetype/internal/fnttypes.h, - include/freetype/internal/ftserv.h, src/base/ftbdf.c, src/base/ftmm.c, - src/base/ftobjs.c, src/base/ftpfr.c, src/base/ftwinfnt.c, - src/base/ftxf86.c, src/pfr/pfrdrivr.c, src/winfonts/winfnt.c, - src/winfonts/winfnt.h, include/freetype/internal/service/svwinfnt.h,: + * src/sfnt/sfdriver.c (sfnt_service_ps_name): Fix typo. - simplification of service lookup macros, updating the PFR and - WINFNT font drivers to new services + * src/type1/t1driver.c (t1_service_ps_name): Fix typo. + * src/cff/cffobjs.c, src/cid/cidobjs.c, src/pfr/pfrsbit.c, + src/psaux/psobjs.c, src/sfnt/sfobjs.c, src/truetype/ttobjs.c, + src/type1/t1objs.c, src/type42/t42objs.c: Removing various compiler + warnings. 2003-09-19 David Bevan @@ -145,7 +179,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 8faf68189..5819940eb 100644 --- a/include/freetype/internal/ftserv.h +++ b/include/freetype/internal/ftserv.h @@ -46,15 +46,12 @@ FT_BEGIN_HEADER * id :: * A string describing the service as defined in the service's * header files (e.g. FT_SERVICE_ID_MULTI_MASTERS which expands to - * `multi-masters'). It will be prefixed with "FT_SERVICE_ID_" !! + * `multi-masters'). It is automatically prefixed with + * `FT_SERVICE_ID_'. * * face :: * The source face handle. * - * ptrtype :: - * The pointer type of `ptr'. This is needed to make FreeType - * compile cleanly with C++. - * * @output: * ptr :: * A variable that receives the service pointer. Will be NULL @@ -63,14 +60,16 @@ FT_BEGIN_HEADER #define FT_FACE_FIND_SERVICE( ptr, face, id ) \ FT_BEGIN_STMNT \ FT_Module module = FT_MODULE( FT_FACE(face)->driver ); \ - FT_Pointer* pptr = (FT_Pointer*) &(ptr); \ - \ /* the strange cast is to allow C++ compilation */ \ - *pptr = NULL; \ + FT_Pointer* Pptr = (FT_Pointer*)&(ptr); \ + \ + \ + *Pptr = NULL; \ if ( module->clazz->get_interface ) \ - *pptr = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \ + *Pptr = module->clazz->get_interface( module, FT_SERVICE_ID_ ## id ); \ FT_END_STMNT + /*************************************************************************/ /*************************************************************************/ /***** *****/ @@ -123,9 +122,9 @@ FT_BEGIN_HEADER * All fields should have the type FT_Pointer to relax compilation * dependencies. We assume the developer isn't completely stupid. * - * Each field must be named service_XXXX where XXX correspond to - * the correct FT_SERVICE_ID_XXXX macro. see the definition of - * FT_FACE_LOOKUP_SERVICE below to see why + * Each field must be named `service_XXXX' where `XXX' corresponds to + * the correct FT_SERVICE_ID_XXXX macro. See the definition of + * FT_FACE_LOOKUP_SERVICE below how this is implemented. * */ typedef struct FT_ServiceCacheRec_ @@ -163,20 +162,16 @@ FT_BEGIN_HEADER * id :: * The service ID. * - * ptrtype :: - * The pointer type of `ptr'. This is needed to make FreeType - * compile cleanly with C++. - * * @output: * ptr :: * A variable receiving the service data. NULL if not available. */ #define FT_FACE_LOOKUP_SERVICE( face, ptr, id ) \ FT_BEGIN_STMNT \ + /* the strange cast is to allow C++ compilation */ \ FT_Pointer* pptr = (FT_Pointer*)&(ptr); \ FT_Pointer svc; \ \ - /* the strange cast is to allow C++ compilation */ \ \ svc = FT_FACE(face)->internal->services. service_ ## id ; \ if ( svc == FT_SERVICE_UNAVAILABLE ) \ @@ -192,6 +187,7 @@ FT_BEGIN_HEADER } \ FT_END_STMNT + /* * A macro used to define new service structure types. */ diff --git a/include/freetype/internal/internal.h b/include/freetype/internal/internal.h index 40378666f..6ce543c4a 100644 --- a/include/freetype/internal/internal.h +++ b/include/freetype/internal/internal.h @@ -39,9 +39,7 @@ #define FT_INTERNAL_TYPE1_TYPES_H #define FT_INTERNAL_TYPE42_TYPES_H #define FT_INTERNAL_CFF_TYPES_H -#define FT_INTERNAL_FNT_TYPES_H #define FT_INTERNAL_BDF_TYPES_H -#define FT_INTERNAL_PFR_H #define FT_INTERNAL_POSTSCRIPT_NAMES_H #define FT_INTERNAL_POSTSCRIPT_AUX_H diff --git a/include/freetype/internal/services/svpfr.h b/include/freetype/internal/services/svpfr.h index e47cb6c93..b61050543 100644 --- a/include/freetype/internal/services/svpfr.h +++ b/include/freetype/internal/services/svpfr.h @@ -2,9 +2,9 @@ /* */ /* svpfr.h */ /* */ -/* Internal PFR service functions (specification only). */ +/* Internal PFR service functions (specification). */ /* */ -/* Copyright 2002, 2003 by */ +/* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -21,24 +21,30 @@ #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, - FT_Fixed *ax_scale, - FT_Fixed *ay_scale ); +#define FT_SERVICE_ID_PFR_METRICS "pfr-metrics" + + + typedef FT_Error + (*FT_PFR_GetMetricsFunc)( FT_Face face, + FT_UInt *aoutline, + FT_UInt *ametrics, + FT_Fixed *ax_scale, + FT_Fixed *ay_scale ); - typedef FT_Error (*FT_PFR_GetKerningFunc)( FT_Face face, - FT_UInt left, - FT_UInt right, - FT_Vector *avector ); + typedef FT_Error + (*FT_PFR_GetKerningFunc)( FT_Face face, + FT_UInt left, + FT_UInt right, + FT_Vector *avector ); - typedef FT_Error (*FT_PFR_GetAdvanceFunc)( FT_Face face, - FT_UInt gindex, - FT_Pos *aadvance ); + typedef FT_Error + (*FT_PFR_GetAdvanceFunc)( FT_Face face, + FT_UInt gindex, + FT_Pos *aadvance ); FT_DEFINE_SERVICE( PfrMetrics ) diff --git a/include/freetype/internal/services/svwinfnt.h b/include/freetype/internal/services/svwinfnt.h index 3c0b1d259..57f7765d9 100644 --- a/include/freetype/internal/services/svwinfnt.h +++ b/include/freetype/internal/services/svwinfnt.h @@ -2,7 +2,7 @@ /* */ /* svwinfnt.h */ /* */ -/* The FreeType Windows FNT/FONT service */ +/* The FreeType Windows FNT/FONT service (specification). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ @@ -19,17 +19,19 @@ #ifndef __SVWINFNT_H__ #define __SVWINFNT_H__ - #include FT_INTERNAL_SERVICE_H #include FT_WINFONTS_H + FT_BEGIN_HEADER #define FT_SERVICE_ID_WINFNT "winfonts" - typedef FT_Error (*FT_WinFnt_GetHeaderFunc)( FT_Face face, - FT_WinFNT_HeaderRec *aheader ); + typedef FT_Error + (*FT_WinFnt_GetHeaderFunc)( FT_Face face, + FT_WinFNT_HeaderRec *aheader ); + FT_DEFINE_SERVICE( WinFnt ) { @@ -38,6 +40,7 @@ FT_BEGIN_HEADER /* */ + FT_END_HEADER diff --git a/include/freetype/internal/services/svxf86nm.h b/include/freetype/internal/services/svxf86nm.h index f38cbcbef..3a33abcd8 100644 --- a/include/freetype/internal/services/svxf86nm.h +++ b/include/freetype/internal/services/svxf86nm.h @@ -2,7 +2,7 @@ /* */ /* svxf86nm.h */ /* */ -/* The FreeType XFree86 services (specification). */ +/* The FreeType XFree86 services (specification only). */ /* */ /* Copyright 2003 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ diff --git a/src/base/ftpfr.c b/src/base/ftpfr.c index f49fab506..b1cd77372 100644 --- a/src/base/ftpfr.c +++ b/src/base/ftpfr.c @@ -56,6 +56,7 @@ { FT_Fixed x_scale, y_scale; + /* this is not a PFR font */ *aoutline_resolution = face->units_per_EM; *ametrics_resolution = face->units_per_EM; @@ -88,13 +89,10 @@ 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 ); - } + error = FT_Get_Kerning( face, left, right, + FT_KERNING_UNSCALED, avector ); else error = FT_Err_Invalid_Argument; @@ -117,7 +115,7 @@ error = service->get_advance( face, gindex, aadvance ); } else - /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */ + /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */ error = FT_Err_Invalid_Argument; return error; diff --git a/src/base/ftwinfnt.c b/src/base/ftwinfnt.c index b7eda1dc3..46f618c51 100644 --- a/src/base/ftwinfnt.c +++ b/src/base/ftwinfnt.c @@ -29,6 +29,7 @@ FT_Service_WinFnt service; FT_Error error; + error = FT_Err_Invalid_Argument; if ( face != NULL ) @@ -40,7 +41,9 @@ error = service->get_header( face, header ); } } - return error; + + return error; } + /* END */ diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 9dad6c3a1..c0fdc05ea 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -396,8 +396,10 @@ else root->units_per_EM = 1000; - root->underline_position = (FT_Short) (dict->underline_position >> 16); - root->underline_thickness = (FT_Short) (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 79457582e..5834cd834 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -423,8 +423,10 @@ root->height = (FT_Short)( ( ( root->ascender - root->descender ) * 12 ) / 10 ); - root->underline_position = (FT_Short) (info->underline_position >> 16); - root->underline_thickness = (FT_Short) (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 949e3ded9..dfc7eb2d4 100644 --- a/src/pfr/pfrsbit.c +++ b/src/pfr/pfrsbit.c @@ -651,11 +651,12 @@ error = ft_glyphslot_alloc_bitmap( &glyph->root, len ); if ( !error ) { - error = pfr_load_bitmap_bits( p, - stream->limit, - format, - FT_BOOL(face->header.color_flags & 2), - &glyph->root.bitmap ); + error = pfr_load_bitmap_bits( + p, + stream->limit, + format, + FT_BOOL(face->header.color_flags & 2), + &glyph->root.bitmap ); } } } diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 2207aef45..9f3bed621 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -434,8 +434,10 @@ root->max_advance_height = root->height; - root->underline_position = (FT_Short)( info->underline_position >> 16 ); - root->underline_thickness = (FT_Short)( 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 6bc2eacb7..13a5f4773 100644 --- a/src/winfonts/winfnt.c +++ b/src/winfonts/winfnt.c @@ -637,11 +637,13 @@ { FNT_Font font = ((FNT_Face)face)->font; + *aheader = font->header; return 0; } + static const FT_Service_WinFntRec winfnt_service_rec = { winfnt_get_header