include/freetype/tttables.h, include/freetype/config/ftconfig.h, include/freetype/internal/ftobjs.h, include/freetype/internal/ftserv.h, include/freetype/internal/internal.h, include/freetype/internal/sfnt.h, include/freetype/internal/tttypes.h, include/freetype/internal/services/bdf.h, include/freetype/internal/services/glyfdict.h, include/freetype/internal/services/multmast.h, include/freetype/internal/services/postname.h, include/freetype/internal/services/sfnt.h, include/freetype/internal/services/xf86name.h, src/base/ftbdf.c, src/base/ftmm.c, src/base/ftobjs.c, src/base/ftxf86.c, src/bdf/bdfdrivr.c, src/cff/cffdrivr.c, src/cid/cidriver.c, src/pcf/pcfdrivr.c, src/sfnt/sfdriver.c, src/truetype/ttdriver.c, src/type1/t1driver.c, src/type42/t42drivr.c: heavy internal modifications to introduce the concept of "module services". This is the first step towards a massive simplification of the engine's internals, in order to get rid of various numbers of hacks. Note that this changes will break source & binary compatibility for authors of external font drivers. Maybe 2.1.6 will be called 2.2.0 after all :-)LAYOUT
parent
b0b1ea3fea
commit
5e03dd4ed4
28 changed files with 838 additions and 427 deletions
@ -0,0 +1,139 @@ |
||||
#ifndef __FT_SERVICE_H__ |
||||
#define __FT_SERVICE_H__ |
||||
|
||||
/*
|
||||
* each module can export one or more 'services'. Each service is |
||||
* identified by a constant string, and modeled by a pointer, which |
||||
* generally corresponds to a structure containing function pointers. |
||||
* |
||||
* note that a service's data cannot be a mere function |
||||
* pointer. that's because in C, function pointers might be implemented |
||||
* differently than data pointers (e.g. 48 bits instead of 32) |
||||
*/ |
||||
|
||||
/* this macro is used to lookup a service from a face's driver module
|
||||
* |
||||
* ptr :: variable that receives the service pointer. will be NULL |
||||
* if not found |
||||
* |
||||
* id :: a string describing the service. the list of valid service |
||||
* identifiers is below |
||||
* |
||||
* face :: the source face handle |
||||
*/ |
||||
#define FT_FACE_FIND_SERVICE(ptr,face,id) \ |
||||
FT_BEGIN_STMNT \
|
||||
FT_Module module = FT_MODULE(FT_FACE(face)->driver); \
|
||||
\
|
||||
(ptr) = NULL; \
|
||||
if ( module->clazz->get_interface ) \
|
||||
(ptr) = module->clazz->get_interface( module, id ); \
|
||||
FT_END_STMNT |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/*************************************************************************/ |
||||
/***** *****/ |
||||
/***** S E R V I C E D E S C R I P T O R S *****/ |
||||
/***** *****/ |
||||
/*************************************************************************/ |
||||
/*************************************************************************/ |
||||
|
||||
/* 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; |
||||
|
||||
|
||||
/* parse a list of FT_ServiceDescRec descriptors and look for
|
||||
* a specific service by id. Note that the last element in the |
||||
* array must be { NULL, NULL }, and that the function should |
||||
* return NULL if the service isn't available |
||||
* |
||||
* this function can be used by modules to implement their "get_service" |
||||
* method |
||||
*/ |
||||
FT_BASE( FT_Pointer ) |
||||
ft_service_list_lookup( FT_ServiceDesc service_descriptors, |
||||
const char* service_id ); |
||||
|
||||
|
||||
/*************************************************************************/ |
||||
/*************************************************************************/ |
||||
/***** *****/ |
||||
/***** S E R V I C E S C A C H E *****/ |
||||
/***** *****/ |
||||
/*************************************************************************/ |
||||
/*************************************************************************/ |
||||
|
||||
/* this structure is used to store a cache for several often-used
|
||||
* services. It is the type of 'face->internal->services'. You |
||||
* should only use FT_FACE_LOOKUP_SERVICE to access it |
||||
* |
||||
* all fields should have the type FT_Pointer to relax compilation |
||||
* dependencies. We assume the developer isn't completely stupid |
||||
* |
||||
* |
||||
*/ |
||||
typedef struct FT_ServiceCacheRec_ |
||||
{ |
||||
FT_Pointer postscript_name; |
||||
FT_Pointer multi_masters; |
||||
FT_Pointer glyph_dict; |
||||
|
||||
} FT_ServiceCacheRec, *FT_ServiceCache; |
||||
|
||||
/* a magic number used within the services cache
|
||||
*/ |
||||
#define FT_SERVICE_UNAVAILABLE ((FT_Pointer)-2) /* magic number */ |
||||
|
||||
/* this macro is used to lookup a service from a face's driver module
|
||||
* using its cache. |
||||
* |
||||
* ptr :: variable receiving the service data. NULL if not available |
||||
* face :: source face handle containing the cache |
||||
* field :: field name in cache |
||||
* id :: service id |
||||
* |
||||
*/ |
||||
#define FT_FACE_LOOKUP_SERVICE(face,ptr,field,id) \ |
||||
FT_BEGIN_STMNT \
|
||||
(ptr) = FT_FACE(face)->internal->services. field ; \
|
||||
if ( (ptr) == FT_SERVICE_UNAVAILABLE ) \
|
||||
(ptr) = NULL; \
|
||||
else if ( (ptr) == NULL ) \
|
||||
{ \
|
||||
FT_FACE_FIND_SERVICE( ptr, face, id ); \
|
||||
\
|
||||
FT_FACE(face)->internal->services. field = \
|
||||
(FT_Pointer)( (ptr) != NULL \
|
||||
? (ptr) \
|
||||
: FT_SERVICE_UNAVAILABLE ); \
|
||||
} \
|
||||
FT_END_STMNT |
||||
|
||||
|
||||
/* A macro used to define new service structure types
|
||||
*/ |
||||
|
||||
#define FT_DEFINE_SERVICE( name ) \ |
||||
typedef struct FT_Service_ ## name ## Rec_ FT_Service_ ## name ## Rec; \
|
||||
typedef struct FT_Service_ ## name ## Rec_ const * FT_Service_ ## name ; \
|
||||
struct FT_Service_ ## name ## Rec_ |
||||
|
||||
/* */ |
||||
|
||||
#define FT_SERVICE_MULTIPLE_MASTERS_H <freetype/internal/services/multmast.h> |
||||
#define FT_SERVICE_POSTSCRIPT_NAME_H <freetype/internal/services/postname.h> |
||||
#define FT_SERVICE_GLYPH_DICT_H <freetype/internal/services/glyfdict.h> |
||||
#define FT_SERVICE_BDF_H <freetype/internal/services/bdf.h> |
||||
#define FT_SERVICE_XFREE86_NAME_H <freetype/internal/services/xf86name.h> |
||||
|
||||
#endif /* __FT_SERVICE_H__ */ |
@ -0,0 +1,30 @@ |
||||
#ifndef __FT_SERVICE_BDF_H__ |
||||
#define __FT_SERVICE_BDF_H__ |
||||
|
||||
#include FT_INTERNAL_SERVICE_H |
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
#define FT_SERVICE_ID_BDF "bdf" |
||||
|
||||
typedef FT_Error (*FT_BDF_GetCharsetIdFunc) |
||||
( FT_Face face, |
||||
const char* *acharset_encoding, |
||||
const char* *acharset_registry ); |
||||
|
||||
typedef FT_Error (*FT_BDF_GetPropertyFunc) |
||||
( FT_Face face, |
||||
const char* prop_name, |
||||
BDF_PropertyRec *aproperty ); |
||||
|
||||
FT_DEFINE_SERVICE( BDF ) |
||||
{ |
||||
FT_BDF_GetCharsetIdFunc get_charset_id; |
||||
FT_BDF_GetPropertyFunc get_property; |
||||
}; |
||||
|
||||
/* */ |
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FT_SERVICE_BDF_H__ */ |
@ -0,0 +1,36 @@ |
||||
#ifndef __FT_SERVICE_GLYPH_DICT_H__ |
||||
#define __FT_SERVICE_GLYPH_DICT_H__ |
||||
|
||||
#include FT_INTERNAL_SERVICE_H |
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
/*
|
||||
* a service used to retrieve glyph names, as well as to find the |
||||
* index of a given glyph name in a font. |
||||
* |
||||
*/ |
||||
|
||||
#define FT_SERVICE_ID_GLYPH_DICT "glyph-dict" |
||||
|
||||
typedef FT_Error (*FT_GlyphDict_GetNameFunc) |
||||
( FT_Face face, |
||||
FT_UInt glyph_index, |
||||
FT_Pointer buffer, |
||||
FT_UInt buffer_max ); |
||||
|
||||
typedef FT_UInt (*FT_GlyphDict_NameIndexFunc) |
||||
( FT_Face face, |
||||
FT_String* glyph_name ); |
||||
|
||||
FT_DEFINE_SERVICE( GlyphDict ) |
||||
{ |
||||
FT_GlyphDict_GetNameFunc get_name; |
||||
FT_GlyphDict_NameIndexFunc name_index; /* optional */ |
||||
}; |
||||
|
||||
/* */ |
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FT_SERVICE_GLYPH_DICT_H__ */ |
@ -0,0 +1,37 @@ |
||||
#ifndef __FT_SERVICE_MULTIPLE_MASTERS_H__ |
||||
#define __FT_SERVICE_MULTIPLE_MASTERS_H__ |
||||
|
||||
#include FT_INTERNAL_SERVICE_H |
||||
|
||||
/*
|
||||
* a service used to manage multiple-masters data in a given face |
||||
* |
||||
* see the related APIs in "ftmm.h" / FT_MULTIPLE_MASTERS_H |
||||
* |
||||
*/ |
||||
|
||||
|
||||
typedef FT_Error |
||||
(*FT_Get_MM_Func)( FT_Face face, |
||||
FT_Multi_Master* master ); |
||||
|
||||
typedef FT_Error |
||||
(*FT_Set_MM_Design_Func)( FT_Face face, |
||||
FT_UInt num_coords, |
||||
FT_Long* coords ); |
||||
|
||||
typedef FT_Error |
||||
(*FT_Set_MM_Blend_Func)( FT_Face face, |
||||
FT_UInt num_coords, |
||||
FT_Long* coords ); |
||||
|
||||
#define FT_SERVICE_ID_MULTI_MASTERS "multi-masters" |
||||
|
||||
FT_DEFINE_SERVICE( MultiMasters ) |
||||
{ |
||||
FT_Get_MM_Func get_mm; |
||||
FT_Set_MM_Design_Func set_mm_design; |
||||
FT_Set_MM_Blend_Func set_mm_blend; |
||||
}; |
||||
|
||||
#endif /* __FT_SERVICE_MULTIPLE_MASTERS_H__ */ |
@ -0,0 +1,30 @@ |
||||
#ifndef __FT_SERVICE_POSTSCRIPT_NAME_H__ |
||||
#define __FT_SERVICE_POSTSCRIPT_NAME_H__ |
||||
|
||||
#include FT_INTERNAL_SERVICE_H |
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
/*
|
||||
* a trivial service used to retrieve the Postscript name of a given |
||||
* font when available. The "get_name" field should never be NULL |
||||
* |
||||
* the correponding function can return NULL to indicate that the |
||||
* Postscript name is not available. |
||||
* |
||||
* the name is owned by the face and will be destroyed with it |
||||
* |
||||
*/ |
||||
|
||||
#define FT_SERVICE_ID_POSTSCRIPT_NAME "postscript-name" |
||||
|
||||
typedef const char* (*FT_PsName_GetFunc)( FT_Face face ); |
||||
|
||||
FT_DEFINE_SERVICE( PsName ) |
||||
{ |
||||
FT_PsName_GetFunc get_ps_name; |
||||
}; |
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FT_SERVICE_POSTSCRIPT_NAME_H__ */ |
@ -0,0 +1,42 @@ |
||||
#ifndef __FT_SERVICE_SFNT_H__ |
||||
#define __FT_SERVICE_SFNT_H__ |
||||
|
||||
#include FT_INTERNAL_SERVICE_H |
||||
#include FT_TRUETYPE_TABLES_H |
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
/*
|
||||
* SFNT table loading service |
||||
* |
||||
*/ |
||||
|
||||
#define FT_SERVICE_ID_SFNT_TABLE "sfnt-table" |
||||
|
||||
/* used to implement FT_Load_Sfnt_Table()
|
||||
*/ |
||||
typedef FT_Error |
||||
(*FT_SFNT_TableLoadFunc)( FT_Face face, |
||||
FT_ULong tag, |
||||
FT_Long offset, |
||||
FT_Byte* buffer, |
||||
FT_ULong* length ); |
||||
|
||||
/* used to implement FT_Get_Sfnt_Table()
|
||||
*/ |
||||
typedef void* |
||||
(*FT_SFNT_TableGetFunc)( FT_Face face, |
||||
FT_Sfnt_Tag tag ); |
||||
|
||||
|
||||
FT_DEFINE_SERVICE( SFNT_Table ) |
||||
{ |
||||
FT_SFNT_TableLoadFunc load_table; |
||||
FT_SFNT_TableGetFunc get_table; |
||||
}; |
||||
|
||||
/* */ |
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FT_SERVICE_SFNT_H__ */ |
@ -0,0 +1,31 @@ |
||||
#ifndef __FT_SERVICE_XF86_NAME_H__ |
||||
#define __FT_SERVICE_XF86_NAME_H__ |
||||
|
||||
#include FT_INTERNAL_SERVICE_H |
||||
|
||||
FT_BEGIN_HEADER |
||||
|
||||
/*
|
||||
* a trivial service used to return the name of a face's font driver, |
||||
* according to the XFree86 nomenclature. Note that the service data |
||||
* is a simple constant string pointer |
||||
* |
||||
*/ |
||||
|
||||
#define FT_SERVICE_ID_XF86_NAME "xf86-driver-name" |
||||
|
||||
#define FT_XF86_FORMAT_TRUETYPE "TrueType" |
||||
#define FT_XF86_FORMAT_TYPE_1 "Type 1" |
||||
#define FT_XF86_FORMAT_BDF "BDF" |
||||
#define FT_XF86_FORMAT_PCF "PCF" |
||||
#define FT_XF86_FORMAT_TYPE_42 "Type 42" |
||||
#define FT_XF86_FORMAT_CID "CID Type 1" |
||||
#define FT_XF86_FORMAT_CFF "CFF" |
||||
#define FT_XF86_FORMAT_PFR "PFR" |
||||
#define FT_XF86_FORMAT_WINFNT "Windows FNT" |
||||
|
||||
/* */ |
||||
|
||||
FT_END_HEADER |
||||
|
||||
#endif /* __FT_SERVICE_XF86_NAME_H__ */ |
Loading…
Reference in new issue