From 19ed8afe60bbc5becf0fbbe3987a91b35a36aad4 Mon Sep 17 00:00:00 2001 From: David Turner Date: Fri, 8 Dec 2000 02:42:29 +0000 Subject: [PATCH] - updated all source files to adhere to the new inclusion scheme - the CFF loader now loads the encodings and charset tables though doesn't use them for now --- ChangeLog | 6 + include/freetype/config/ft2build.h | 6 +- include/freetype/internal/internal.h | 1 + include/freetype/internal/t2types.h | 31 +- src/autohint/ahglobal.c | 15 +- src/autohint/ahglobal.h | 35 +- src/autohint/ahglyph.c | 22 +- src/autohint/ahglyph.h | 23 +- src/autohint/ahhint.c | 21 +- src/autohint/ahhint.h | 24 +- src/autohint/ahloader.h | 14 +- src/autohint/ahmodule.c | 16 +- src/autohint/ahmodule.h | 13 +- src/autohint/ahoptim.c | 17 +- src/autohint/ahoptim.h | 22 +- src/autohint/ahtypes.h | 38 +- src/autohint/autohint.c | 24 +- src/base/ftbase.c | 29 +- src/base/ftbbox.c | 8 +- src/base/ftcalc.c | 8 +- src/base/ftdebug.c | 4 +- src/base/ftextend.c | 8 +- src/base/ftglyph.c | 8 +- src/base/ftinit.c | 10 +- src/base/ftlist.c | 7 +- src/base/ftmac.c | 11 +- src/base/ftmm.c | 6 +- src/base/ftnames.c | 6 +- src/base/ftobjs.c | 13 +- src/base/ftoutln.c | 6 +- src/base/ftstream.c | 6 +- src/base/ftsynth.c | 8 +- src/base/ftsystem.c | 12 +- src/cache/ftcache.c | 26 +- src/cache/ftcchunk.c | 12 +- src/cache/ftcglyph.c | 13 +- src/cache/ftcimage.c | 6 +- src/cache/ftcmanag.c | 11 +- src/cache/ftcsbits.c | 11 +- src/cache/ftlru.c | 9 +- src/cff/cff.c | 24 +- src/cff/cffdrivr.c | 366 ++++++++++ src/cff/cffdrivr.h | 36 + src/cff/cffload.c | 952 +++++++++++++++++++++++++++ src/cff/cffload.h | 70 ++ src/cff/cffobjs.c | 589 +++++++++++++++++ src/cff/cffobjs.h | 141 ++++ src/cff/cffparse.c | 645 ++++++++++++++++++ src/cff/cffparse.h | 67 ++ src/cff/cfftoken.h | 97 +++ src/cff/rules.mk | 48 +- src/cff/t2gload.c | 45 +- src/cff/t2gload.h | 69 +- src/cid/cidafm.c | 27 +- src/cid/cidafm.h | 47 +- src/cid/cidgload.c | 23 +- src/cid/cidgload.h | 24 +- src/cid/cidload.c | 31 +- src/cid/cidload.h | 26 +- src/cid/cidobjs.c | 27 +- src/cid/cidobjs.h | 20 +- src/cid/cidparse.c | 28 +- src/cid/cidparse.h | 31 +- src/cid/cidriver.c | 26 +- src/cid/cidriver.h | 13 +- src/cid/type1cid.c | 24 +- src/psaux/psaux.c | 18 +- src/psaux/psauxmod.c | 19 +- src/psaux/psauxmod.h | 11 +- src/psaux/psobjs.c | 19 +- src/psaux/psobjs.h | 14 +- src/psaux/t1decode.c | 25 +- src/psaux/t1decode.h | 18 +- src/psnames/psmodule.c | 23 +- src/psnames/psmodule.h | 14 +- src/psnames/psnames.c | 10 +- src/raster/ftraster.c | 9 +- src/raster/ftraster.h | 18 +- src/raster/ftrend1.c | 21 +- src/raster/ftrend1.h | 16 +- src/raster/raster.c | 15 +- src/sfnt/sfdriver.c | 39 +- src/sfnt/sfdriver.h | 14 +- src/sfnt/sfnt.c | 36 +- src/sfnt/sfobjs.c | 27 +- src/sfnt/sfobjs.h | 16 +- src/sfnt/ttcmap.c | 21 +- src/sfnt/ttload.c | 26 +- src/sfnt/ttload.h | 16 +- src/sfnt/ttpost.c | 23 +- src/sfnt/ttpost.h | 15 +- src/sfnt/ttsbit.c | 23 +- src/sfnt/ttsbit.h | 22 +- src/smooth/ftgrays.c | 20 +- src/smooth/ftgrays.h | 3 +- src/smooth/ftsmooth.c | 22 +- src/smooth/ftsmooth.h | 13 +- src/smooth/smooth.c | 16 +- src/truetype/truetype.c | 28 +- src/truetype/ttdriver.c | 25 +- src/truetype/ttdriver.h | 14 +- src/truetype/ttgload.c | 25 +- src/truetype/ttgload.h | 28 +- src/truetype/ttinterp.c | 24 +- src/truetype/ttinterp.h | 38 +- src/truetype/ttobjs.c | 42 +- src/truetype/ttobjs.h | 17 +- src/truetype/ttpload.c | 22 +- src/truetype/ttpload.h | 15 +- src/type1/t1afm.c | 19 +- src/type1/t1afm.h | 24 +- src/type1/t1driver.c | 31 +- src/type1/t1driver.h | 13 +- src/type1/t1gload.c | 24 +- src/type1/t1gload.h | 23 +- src/type1/t1load.c | 36 +- src/type1/t1load.h | 27 +- src/type1/t1objs.c | 32 +- src/type1/t1objs.h | 17 +- src/type1/t1parse.c | 26 +- src/type1/t1parse.h | 15 +- src/type1/type1.c | 31 +- 122 files changed, 3657 insertions(+), 1603 deletions(-) create mode 100644 src/cff/cffdrivr.c create mode 100644 src/cff/cffdrivr.h create mode 100644 src/cff/cffload.c create mode 100644 src/cff/cffload.h create mode 100644 src/cff/cffobjs.c create mode 100644 src/cff/cffobjs.h create mode 100644 src/cff/cffparse.c create mode 100644 src/cff/cffparse.h create mode 100644 src/cff/cfftoken.h diff --git a/ChangeLog b/ChangeLog index aa2ff2210..f3f1a3e81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-12-07 David Turnre + + * many, many files: changed source files to adhere to the new + header inclusion scheme. Not completely tested but works for + now here.. + 2000-12-06 David Turner * src/cache/ftlru.c (FT_Lru_Done): fixed a small memory leak diff --git a/include/freetype/config/ft2build.h b/include/freetype/config/ft2build.h index 672e3eff8..33129a644 100644 --- a/include/freetype/config/ft2build.h +++ b/include/freetype/config/ft2build.h @@ -101,7 +101,7 @@ /*************************************************************************/ /* */ - /* The macro FT2_SOURCE_FILE is used to include a given FreeType 2 */ + /* The macro FT_SOURCE_FILE is used to include a given FreeType 2 */ /* component source file (be it a header, a C source file, or an */ /* included file). */ /* */ @@ -114,9 +114,9 @@ /* FT_FLAT_COMPILATION. */ /* */ #ifdef FT_FLAT_COMPILATION -#define FT_SOURCE_FILE( d, x ) +# define FT_SOURCE_FILE( d, x ) #x #else -#define FT_SOURCE_FILE( d, x ) #x +# define FT_SOURCE_FILE( d, x ) #endif diff --git a/include/freetype/internal/internal.h b/include/freetype/internal/internal.h index 7a1a3d915..9895ea2dc 100644 --- a/include/freetype/internal/internal.h +++ b/include/freetype/internal/internal.h @@ -33,6 +33,7 @@ #define FT_INTERNAL_DEBUG_H FT2_INTERNAL_FILE(ftdebug.h) #define FT_INTERNAL_CALC_H FT2_INTERNAL_FILE(ftcalc.h) #define FT_INTERNAL_DRIVER_H FT2_INTERNAL_FILE(ftdriver.h) +#define FT_INTERNAL_EXTEND_H FT2_INTERNAL_FILE(ftextend.h) #define FT_INTERNAL_SFNT_H FT2_INTERNAL_FILE(sfnt.h) diff --git a/include/freetype/internal/t2types.h b/include/freetype/internal/t2types.h index c2cef41da..485303a04 100644 --- a/include/freetype/internal/t2types.h +++ b/include/freetype/internal/t2types.h @@ -61,6 +61,32 @@ FT_BEGIN_HEADER } CFF_Index; + typedef struct CFF_Encoding_ + { + FT_Stream stream; + + FT_UInt format; + FT_ULong offset; + FT_UInt size; + + FT_Byte* bytes; + + } CFF_Encoding; + + + typedef struct CFF_Charset_ + { + FT_Stream stream; + + FT_UInt format; + FT_ULong offset; + FT_UInt size; + + FT_Byte* bytes; + + } CFF_Charset; + + typedef struct CFF_Font_Dict_ { FT_UInt version; @@ -195,8 +221,9 @@ FT_BEGIN_HEADER CFF_Index string_index; CFF_Index global_subrs_index; - /* we don't load the Encoding and CharSet tables */ - + CFF_Encoding encoding; + CFF_Charset charset; + CFF_Index charstrings_index; CFF_Index font_dict_index; CFF_Index private_index; diff --git a/src/autohint/ahglobal.c b/src/autohint/ahglobal.c index f44c075e9..d35cc4d32 100644 --- a/src/autohint/ahglobal.c +++ b/src/autohint/ahglobal.c @@ -18,18 +18,9 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "ahglobal.h" -#include "ahglyph.h" - -#else - -#include -#include - -#endif +#include +#include FT_SOURCE_FILE(autohint,ahglobal.h) +#include FT_SOURCE_FILE(autohint,ahglyph.h) #define MAX_TEST_CHARACTERS 12 diff --git a/src/autohint/ahglobal.h b/src/autohint/ahglobal.h index 705a0c70a..57457efec 100644 --- a/src/autohint/ahglobal.h +++ b/src/autohint/ahglobal.h @@ -20,26 +20,14 @@ /***************************************************************************/ -#ifndef AHGLOBAL_H -#define AHGLOBAL_H +#ifndef __AHGLOBAL_H__ +#define __AHGLOBAL_H__ -#ifdef FT_FLAT_COMPILE +#include +#include FT_SOURCE_FILE(autohint,ahtypes.h) +#include FT_INTERNAL_OBJECTS_H -#include "ahtypes.h" - -#else - -#include - -#endif - - -#include /* for FT_LOCAL/FT_LOCAL_DEF */ - - -#ifdef __cplusplus - extern "C" { -#endif +FT_BEGIN_HEADER #define AH_IS_TOP_BLUE( b ) ( (b) == ah_blue_capital_top || \ @@ -47,16 +35,13 @@ /* compute global metrics automatically */ - FT_LOCAL - FT_Error ah_hinter_compute_globals( AH_Hinter* hinter ); + FT_LOCAL FT_Error + ah_hinter_compute_globals( AH_Hinter* hinter ); -#ifdef __cplusplus - } -#endif +FT_END_HEADER - -#endif /* AHGLOBAL_H */ +#endif /* __AHGLOBAL_H__ */ /* END */ diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c index d3b981799..2027e5520 100644 --- a/src/autohint/ahglyph.c +++ b/src/autohint/ahglyph.c @@ -19,23 +19,11 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "ahglyph.h" -#include "ahangles.h" -#include "ahglobal.h" - -#else - -#include -#include -#include - -#endif - - -#include +#include +#include FT_SOURCE_FILE(autohint,ahglyph.h) +#include FT_SOURCE_FILE(autohint,ahangles.h) +#include FT_SOURCE_FILE(autohint,ahglobal.h) +#include #define xxxAH_DEBUG_GLYPH diff --git a/src/autohint/ahglyph.h b/src/autohint/ahglyph.h index e40753bae..e5bcb0157 100644 --- a/src/autohint/ahglyph.h +++ b/src/autohint/ahglyph.h @@ -23,21 +23,10 @@ #ifndef AHGLYPH_H #define AHGLYPH_H -#ifdef FT_FLAT_COMPILE - -#include "ahtypes.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_SOURCE_FILE(autohint,ahtypes.h) +FT_BEGIN_HEADER typedef enum AH_UV_ { @@ -91,11 +80,7 @@ FT_LOCAL void ah_outline_done( AH_Outline* outline ); - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* AHGLYPH_H */ diff --git a/src/autohint/ahhint.c b/src/autohint/ahhint.c index 0d2b475ab..90b47fe7d 100644 --- a/src/autohint/ahhint.c +++ b/src/autohint/ahhint.c @@ -18,22 +18,11 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "ahhint.h" -#include "ahglyph.h" -#include "ahangles.h" - -#else - -#include -#include -#include - -#endif - -#include +#include +#include FT_SOURCE_FILE(autohint,ahhint.h) +#include FT_SOURCE_FILE(autohint,ahglyph.h) +#include FT_SOURCE_FILE(autohint,ahangles.h) +#include FT_OUTLINE_H #define FACE_GLOBALS( face ) ((AH_Face_Globals*)(face)->autohint.data) diff --git a/src/autohint/ahhint.h b/src/autohint/ahhint.h index e9d5323af..744c33604 100644 --- a/src/autohint/ahhint.h +++ b/src/autohint/ahhint.h @@ -22,22 +22,10 @@ #ifndef AHHINT_H #define AHHINT_H +#include +#include FT_SOURCE_FILE(autohint,ahglobal.h) -#ifdef FT_FLAT_COMPILE - -#include "ahglobal.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER #define AH_HINT_DEFAULT 0 #define AH_HINT_NO_ALIGNMENT 1 @@ -75,11 +63,7 @@ void ah_hinter_done_global_hints( AH_Hinter* hinter, void* global_hints ); - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* AHHINT_H */ diff --git a/src/autohint/ahloader.h b/src/autohint/ahloader.h index 78b1f1624..a03a87cbb 100644 --- a/src/autohint/ahloader.h +++ b/src/autohint/ahloader.h @@ -35,11 +35,9 @@ #ifndef AHLOADER_H #define AHLOADER_H +#include -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER #ifdef _STANDALONE_ @@ -105,7 +103,7 @@ #else /* _STANDALONE */ -#include +#include FT_INTERNAL_OBJECTS_H #define AH_Load FT_GlyphLoad #define AH_Loader FT_GlyphLoader @@ -123,11 +121,7 @@ #endif /* _STANDALONE_ */ - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* AHLOADER_H */ diff --git a/src/autohint/ahmodule.c b/src/autohint/ahmodule.c index 67d96ede8..3c9bd96a7 100644 --- a/src/autohint/ahmodule.c +++ b/src/autohint/ahmodule.c @@ -18,19 +18,9 @@ /* */ /***************************************************************************/ - -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ahhint.h" - -#else - -#include - -#endif +#include +#include FT_MODULE_H +#include FT_SOURCE_FILE(autohint,ahhint.h) typedef struct FT_AutoHinterRec_ diff --git a/src/autohint/ahmodule.h b/src/autohint/ahmodule.h index b631049d5..0789c6499 100644 --- a/src/autohint/ahmodule.h +++ b/src/autohint/ahmodule.h @@ -22,20 +22,15 @@ #ifndef AHMODULE_H #define AHMODULE_H -#include +#include +#include FT_MODULE_H - -#ifdef __cplusplus - extern "C" { -#endif +FT_BEGIN_HEADER FT_CALLBACK_TABLE const FT_Module_Class autohint_module_class; -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* AHMODULE_H */ diff --git a/src/autohint/ahoptim.c b/src/autohint/ahoptim.c index deb440d49..4d0421cd5 100644 --- a/src/autohint/ahoptim.c +++ b/src/autohint/ahoptim.c @@ -30,20 +30,9 @@ /* */ /*************************************************************************/ - -#include /* for ALLOC_ARRAY() and FREE() */ - - -#ifdef FT_FLAT_COMPILE - -#include "ahoptim.h" - -#else - -#include - -#endif - +#include +#include FT_INTERNAL_OBJECTS_H /* for ALLOC_ARRAY() and FREE() */ +#include FT_SOURCE_FILE(autohint,ahoptim.h) /* define this macro to use brute force optimisation -- this is slow, */ /* but a good way to perfect the distortion function `by hand' through */ diff --git a/src/autohint/ahoptim.h b/src/autohint/ahoptim.h index 24f5a5263..01c7ee60d 100644 --- a/src/autohint/ahoptim.h +++ b/src/autohint/ahoptim.h @@ -22,21 +22,10 @@ #ifndef AHOPTIM_H #define AHOPTIM_H +#include +#include FT_SOURCE_FILE(autohint,ahtypes.h) -#ifdef FT_FLAT_COMPILE - -#include "ahtypes.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif +FT_BEGIN_HEADER /* the maximal number of stem configurations to record */ @@ -135,10 +124,7 @@ void AH_Optimizer_Done( AH_Optimizer* optimizer ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* AHOPTIM_H */ diff --git a/src/autohint/ahtypes.h b/src/autohint/ahtypes.h index 66cb2f676..1477ee0b4 100644 --- a/src/autohint/ahtypes.h +++ b/src/autohint/ahtypes.h @@ -23,41 +23,22 @@ #ifndef AHTYPES_H #define AHTYPES_H - -#include /* for freetype.h + FT_LOCAL etc. */ - - -#ifdef FT_FLAT_COMPILE - -#include "ahloader.h" - -#else - -#include - -#endif +#include +#include FT_INTERNAL_OBJECTS_H +#include FT_SOURCE_FILE(autohint,ahloader.h) #define xxAH_DEBUG #ifdef AH_DEBUG - -#include - -#define AH_LOG( x ) printf##x - +# include +# define AH_LOG( x ) printf##x #else - -#define AH_LOG( x ) do ; while ( 0 ) /* nothing */ - -#endif - - -#ifdef __cplusplus - extern "C" { +# define AH_LOG( x ) do ; while ( 0 ) /* nothing */ #endif +FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ @@ -495,10 +476,7 @@ } AH_Hinter; -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* AHTYPES_H */ diff --git a/src/autohint/autohint.c b/src/autohint/autohint.c index 5916b6330..d2f4df693 100644 --- a/src/autohint/autohint.c +++ b/src/autohint/autohint.c @@ -21,23 +21,11 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT -#ifdef FT_FLAT_COMPILE - -#include "ahangles.c" -#include "ahglyph.c" -#include "ahglobal.c" -#include "ahhint.c" -#include "ahmodule.c" - -#else - -#include -#include -#include -#include -#include - -#endif - +#include +#include FT_SOURCE_FILE(autohint,ahangles.c) +#include FT_SOURCE_FILE(autohint,ahglyph.c) +#include FT_SOURCE_FILE(autohint,ahglobal.c) +#include FT_SOURCE_FILE(autohint,ahhint.c) +#include FT_SOURCE_FILE(autohint,ahmodule.c) /* END */ diff --git a/src/base/ftbase.c b/src/base/ftbase.c index a110af42b..82d0b1406 100644 --- a/src/base/ftbase.c +++ b/src/base/ftbase.c @@ -16,27 +16,14 @@ /***************************************************************************/ -#ifdef FT_FLAT_COMPILE - -#include "ftcalc.c" -#include "ftobjs.c" -#include "ftstream.c" -#include "ftlist.c" -#include "ftoutln.c" -#include "ftextend.c" -#include "ftnames.c" - -#else /* FT_FLAT_COMPILE */ - -#include -#include -#include -#include -#include -#include -#include - -#endif /* FT_FLAT_COMPILE */ +#include +#include FT_SOURCE_FILE(base,ftcalc.c) +#include FT_SOURCE_FILE(base,ftobjs.c) +#include FT_SOURCE_FILE(base,ftstream.c) +#include FT_SOURCE_FILE(base,ftlist.c) +#include FT_SOURCE_FILE(base,ftoutln.c) +#include FT_SOURCE_FILE(base,ftextend.c) +#include FT_SOURCE_FILE(base,ftnames.c) /* END */ diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c index 192902953..f6ebb0793 100644 --- a/src/base/ftbbox.c +++ b/src/base/ftbbox.c @@ -23,10 +23,10 @@ /* */ /*************************************************************************/ - -#include -#include -#include +#include +#include FT_BBOX_H +#include FT_IMAGE_H +#include FT_OUTLINE_H typedef struct TBBox_Rec_ diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index d42d6021f..e95577923 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -30,10 +30,10 @@ /* */ /*************************************************************************/ - -#include -#include -#include /* for ABS() */ +#include +#include FT_INTERNAL_CALC_H +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_OBJECTS_H /*************************************************************************/ diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c index f291579af..3032b4fd9 100644 --- a/src/base/ftdebug.c +++ b/src/base/ftdebug.c @@ -40,8 +40,8 @@ /* */ /*************************************************************************/ - -#include +#include +#include FT_INTERNAL_DEBUG_H #ifdef FT_DEBUG_LEVEL_TRACE char ft_trace_levels[trace_max]; diff --git a/src/base/ftextend.c b/src/base/ftextend.c index 7fd23c3d8..18c39f7e0 100644 --- a/src/base/ftextend.c +++ b/src/base/ftextend.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* ftextend.h */ +/* ftextend.c */ /* */ /* FreeType extensions implementation (body). */ /* */ @@ -24,9 +24,9 @@ /* */ /*************************************************************************/ - -#include -#include +#include +#include FT_INTERNAL_EXTEND_H +#include FT_INTERNAL_DEBUG_H /*************************************************************************/ diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c index 8ec96a7ea..d1b52634e 100644 --- a/src/base/ftglyph.c +++ b/src/base/ftglyph.c @@ -27,10 +27,10 @@ /* */ /*************************************************************************/ - -#include -#include -#include +#include +#include FT_GLYPH_H +#include FT_OUTLINE_H +#include FT_INTERNAL_OBJECTS_H /*************************************************************************/ diff --git a/src/base/ftinit.c b/src/base/ftinit.c index 79f751c89..ed6150468 100644 --- a/src/base/ftinit.c +++ b/src/base/ftinit.c @@ -36,11 +36,11 @@ /* */ /*************************************************************************/ - -#include -#include -#include -#include +#include +#include FT_CONFIG_CONFIG_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_DEBUG_H +#include FT_MODULE_H /*************************************************************************/ diff --git a/src/base/ftlist.c b/src/base/ftlist.c index b2688b0af..f72db2445 100644 --- a/src/base/ftlist.c +++ b/src/base/ftlist.c @@ -23,9 +23,10 @@ /*************************************************************************/ -#include -#include -#include +#include +#include FT_LIST_H +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_OBJECTS_H /*************************************************************************/ diff --git a/src/base/ftmac.c b/src/base/ftmac.c index 6feaa31e6..55ba30afb 100644 --- a/src/base/ftmac.c +++ b/src/base/ftmac.c @@ -56,10 +56,11 @@ and delegate the rest of the work to it, by calling FT_Open_Face(). */ -#include -#include -#include -#include +#include +#include FT_FREETYPE_H +#include FT_INTERNAL_STREAM_H +#include FT_SOURCE_FILE(truetype/ttobjs.h) +#include FT_SOURCE_FILE(type1/t1objs.h) #include #include @@ -67,7 +68,7 @@ #include /* for isupper() and isalnum() */ -#include +#include FT_MAC_H diff --git a/src/base/ftmm.c b/src/base/ftmm.c index d6c06050d..24479efd0 100644 --- a/src/base/ftmm.c +++ b/src/base/ftmm.c @@ -15,9 +15,9 @@ /* */ /***************************************************************************/ - -#include -#include +#include +#include FT_MULTIPLE_MASTERS_H +#include FT_INTERNAL_OBJECTS_H /*************************************************************************/ diff --git a/src/base/ftnames.c b/src/base/ftnames.c index 36af8cfca..de030db89 100644 --- a/src/base/ftnames.c +++ b/src/base/ftnames.c @@ -18,9 +18,9 @@ /* */ /***************************************************************************/ - -#include -#include +#include +#include FT_NAMES_H +#include FT_INTERNAL_TRUETYPE_TYPES_H #ifdef TT_CONFIG_OPTION_SFNT_NAMES diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 636a765bb..58e796dcd 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -15,13 +15,12 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include - -#include +#include +#include FT_LIST_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TABLES_H #include /* for strcmp() */ diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c index fdd0098d7..1cf7e54be 100644 --- a/src/base/ftoutln.c +++ b/src/base/ftoutln.c @@ -22,9 +22,9 @@ /* */ /*************************************************************************/ - -#include -#include +#include +#include FT_OUTLINE_H +#include FT_INTERNAL_OBJECTS_H /*************************************************************************/ diff --git a/src/base/ftstream.c b/src/base/ftstream.c index 5b4e1dc99..999ae70cb 100644 --- a/src/base/ftstream.c +++ b/src/base/ftstream.c @@ -15,9 +15,9 @@ /* */ /***************************************************************************/ - -#include -#include +#include +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_DEBUG_H /*************************************************************************/ diff --git a/src/base/ftsynth.c b/src/base/ftsynth.c index 4858649d1..c9cb59bdb 100644 --- a/src/base/ftsynth.c +++ b/src/base/ftsynth.c @@ -15,10 +15,10 @@ /* */ /***************************************************************************/ - -#include -#include -#include +#include +#include FT_INTERNAL_OBJECTS_H +#include FT_OUTLINE_H +#include FT_SYNTHESIS_H #define FT_BOLD_THRESHOLD 0x0100 diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c index 96c4fb28e..e1eb9f2d2 100644 --- a/src/base/ftsystem.c +++ b/src/base/ftsystem.c @@ -24,12 +24,12 @@ /* */ /*************************************************************************/ - -#include -#include -#include -#include -#include +#include +#include FT_CONFIG_CONFIG_H +#include FT_INTERNAL_DEBUG_H +#include FT_SYSTEM_H +#include FT_ERRORS_H +#include FT_TYPES_H #include #include diff --git a/src/cache/ftcache.c b/src/cache/ftcache.c index f5cf47bd5..f3d49fe1b 100644 --- a/src/cache/ftcache.c +++ b/src/cache/ftcache.c @@ -18,25 +18,13 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT -#ifdef FT_FLAT_COMPILE - -#include "ftlru.c" -#include "ftcmanag.c" -#include "ftcglyph.c" -#include "ftcchunk.c" -#include "ftcimage.c" -#include "ftcsbits.c" - -#else - -#include -#include -#include -#include -#include -#include - -#endif +#include +#include FT_SOURCE_FILE(cache,ftlru.c) +#include FT_SOURCE_FILE(cache,ftcmanag.c) +#include FT_SOURCE_FILE(cache,ftcglyph.c) +#include FT_SOURCE_FILE(cache,ftcchunk.c) +#include FT_SOURCE_FILE(cache,ftcimage.c) +#include FT_SOURCE_FILE(cache,ftcsbits.c) /* END */ diff --git a/src/cache/ftcchunk.c b/src/cache/ftcchunk.c index 4689cfb70..183ee0de3 100644 --- a/src/cache/ftcchunk.c +++ b/src/cache/ftcchunk.c @@ -15,12 +15,12 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include -#include +#include +#include FT_CACHE_H +#include FT_CACHE_INTERNAL_CHUNK_H +#include FT_LIST_H +#include FT_ERRORS_H +#include FT_INTERNAL_OBJECTS_H /*************************************************************************/ diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c index b378132ee..9c76e5ea7 100644 --- a/src/cache/ftcglyph.c +++ b/src/cache/ftcglyph.c @@ -15,12 +15,13 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include -#include +#include +#include FT_CACHE_H +#include FT_CACHE_INTERNAL_GLYPH_H +#include FT_ERRORS_H +#include FT_LIST_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_DEBUG_H /*************************************************************************/ diff --git a/src/cache/ftcimage.c b/src/cache/ftcimage.c index 770338dc3..98103fcfe 100644 --- a/src/cache/ftcimage.c +++ b/src/cache/ftcimage.c @@ -16,8 +16,10 @@ /***************************************************************************/ -#include -#include +#include +#include FT_CACHE_H +#include FT_CACHE_IMAGE_H +#include FT_INTERNAL_MEMORY_H #include /* memcmp() */ #include /* labs() */ diff --git a/src/cache/ftcmanag.c b/src/cache/ftcmanag.c index 9b83c7176..0e9ecdd60 100644 --- a/src/cache/ftcmanag.c +++ b/src/cache/ftcmanag.c @@ -15,11 +15,12 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include +#include +#include FT_CACHE_H +#include FT_CACHE_MANAGER_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_DEBUG_H +#include FT_LIST_H #undef FT_COMPONENT diff --git a/src/cache/ftcsbits.c b/src/cache/ftcsbits.c index fcb73fde8..75347b42c 100644 --- a/src/cache/ftcsbits.c +++ b/src/cache/ftcsbits.c @@ -15,11 +15,12 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include +#include +#include FT_CACHE_H +#include FT_CACHE_SMALL_BITMAPS_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_DEBUG_H +#include FT_ERRORS_H #include /* memcmp() */ diff --git a/src/cache/ftlru.c b/src/cache/ftlru.c index 76bae6607..295348075 100644 --- a/src/cache/ftlru.c +++ b/src/cache/ftlru.c @@ -15,10 +15,11 @@ /* */ /***************************************************************************/ - -#include -#include -#include +#include +#include FT_CACHE_H +#include FT_CACHE_INTERNAL_LRU_H +#include FT_LIST_H +#include FT_INTERNAL_OBJECTS_H static diff --git a/src/cff/cff.c b/src/cff/cff.c index 5a987f1cd..d99cb1c30 100644 --- a/src/cff/cff.c +++ b/src/cff/cff.c @@ -18,23 +18,11 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT -#ifdef FT_FLAT_COMPILE - -#include "t2driver.c" /* driver interface */ -#include "t2parse.c" /* token parser */ -#include "t2load.c" /* tables loader */ -#include "t2objs.c" /* object management */ -#include "t2gload.c" /* glyph loader */ - -#else - -#include /* driver interface */ -#include /* token parser */ -#include /* tables loader */ -#include /* object management */ -#include /* glyph loader */ - -#endif - +#include +#include FT_SOURCE_FILE(cff,cffdrivr.c) +#include FT_SOURCE_FILE(cff,cffparse.c) +#include FT_SOURCE_FILE(cff,cffload.c) +#include FT_SOURCE_FILE(cff,cffobjs.c) +#include FT_SOURCE_FILE(cff,t2gload.c) /* END */ diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c new file mode 100644 index 000000000..6066e44f3 --- /dev/null +++ b/src/cff/cffdrivr.c @@ -0,0 +1,366 @@ +/***************************************************************************/ +/* */ +/* cffdrivr.c */ +/* */ +/* OpenType font driver implementation (body). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include +#include FT_FREETYPE_H +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_SFNT_H +#include FT_TRUETYPE_NAMES_H +#include FT_INTERNAL_CFF_ERRORS_H + +#include FT_SOURCE_FILE(cff,cffdrivr.h) +#include FT_SOURCE_FILE(cff,t2gload.h) + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_t2driver + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** F A C E S ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + +#undef PAIR_TAG +#define PAIR_TAG( left, right ) ( ( (FT_ULong)left << 16 ) | \ + (FT_ULong)right ) + + + /*************************************************************************/ + /* */ + /* */ + /* Get_Kerning */ + /* */ + /* */ + /* A driver method used to return the kerning vector between two */ + /* glyphs of the same face. */ + /* */ + /* */ + /* face :: A handle to the source face object. */ + /* */ + /* left_glyph :: The index of the left glyph in the kern pair. */ + /* */ + /* right_glyph :: The index of the right glyph in the kern pair. */ + /* */ + /* */ + /* kerning :: The kerning vector. This is in font units for */ + /* scalable formats, and in pixels for fixed-sizes */ + /* formats. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + /* */ + /* Only horizontal layouts (left-to-right & right-to-left) are */ + /* supported by this function. Other layouts, or more sophisticated */ + /* kernings, are out of scope of this method (the basic driver */ + /* interface is meant to be simple). */ + /* */ + /* They can be implemented by format-specific interfaces. */ + /* */ + static + FT_Error Get_Kerning( TT_Face face, + FT_UInt left_glyph, + FT_UInt right_glyph, + FT_Vector* kerning ) + { + TT_Kern_0_Pair* pair; + + + if ( !face ) + return T2_Err_Invalid_Face_Handle; + + kerning->x = 0; + kerning->y = 0; + + if ( face->kern_pairs ) + { + /* there are some kerning pairs in this font file! */ + FT_ULong search_tag = PAIR_TAG( left_glyph, right_glyph ); + FT_Long left, right; + + + left = 0; + right = face->num_kern_pairs - 1; + + while ( left <= right ) + { + FT_Int middle = left + ( ( right - left ) >> 1 ); + FT_ULong cur_pair; + + + pair = face->kern_pairs + middle; + cur_pair = PAIR_TAG( pair->left, pair->right ); + + if ( cur_pair == search_tag ) + goto Found; + + if ( cur_pair < search_tag ) + left = middle + 1; + else + right = middle - 1; + } + } + + Exit: + return T2_Err_Ok; + + Found: + kerning->x = pair->value; + goto Exit; + } + + +#undef PAIR_TAG + + + /*************************************************************************/ + /* */ + /* */ + /* Load_Glyph */ + /* */ + /* */ + /* A driver method used to load a glyph within a given glyph slot. */ + /* */ + /* */ + /* slot :: A handle to the target slot object where the glyph */ + /* will be loaded. */ + /* */ + /* size :: A handle to the source face size at which the glyph */ + /* must be scaled, loaded, etc. */ + /* */ + /* glyph_index :: The index of the glyph in the font file. */ + /* */ + /* load_flags :: A flag indicating what to load for this glyph. The */ + /* FTLOAD_??? constants can be used to control the */ + /* glyph loading process (e.g., whether the outline */ + /* should be scaled, whether to load bitmaps or not, */ + /* whether to hint the outline, etc). */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + static + FT_Error Load_Glyph( T2_GlyphSlot slot, + T2_Size size, + FT_UShort glyph_index, + FT_UInt load_flags ) + { + FT_Error error; + + + if ( !slot ) + return T2_Err_Invalid_Glyph_Handle; + + /* check whether we want a scaled outline or bitmap */ + if ( !size ) + load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; + + if ( load_flags & FT_LOAD_NO_SCALE ) + size = NULL; + + /* reset the size object if necessary */ + if ( size ) + { + /* these two object must have the same parent */ + if ( size->face != slot->root.face ) + return T2_Err_Invalid_Face_Handle; + } + + /* now load the glyph outline if necessary */ + error = T2_Load_Glyph( slot, size, glyph_index, load_flags ); + + /* force drop-out mode to 2 - irrelevant now */ + /* slot->outline.dropout_mode = 2; */ + + return error; + } + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** C H A R A C T E R M A P P I N G S ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + /*************************************************************************/ + /* */ + /* */ + /* Get_Char_Index */ + /* */ + /* */ + /* Uses a charmap to return a given character code's glyph index. */ + /* */ + /* */ + /* charmap :: A handle to the source charmap object. */ + /* charcode :: The character code. */ + /* */ + /* */ + /* Glyph index. 0 means `undefined character code'. */ + /* */ + static + FT_UInt t2_get_char_index( TT_CharMap charmap, + FT_Long charcode ) + { + FT_Error error; + T2_Face face; + TT_CMapTable* cmap; + + + cmap = &charmap->cmap; + face = (T2_Face)charmap->root.face; + + /* Load table if needed */ + if ( !cmap->loaded ) + { + SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; + + + error = sfnt->load_charmap( face, cmap, face->root.stream ); + if ( error ) + return 0; + + cmap->loaded = TRUE; + } + + return ( cmap->get_index ? cmap->get_index( cmap, charcode ) : 0 ); + } + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /**** ****/ + /**** ****/ + /**** D R I V E R I N T E R F A C E ****/ + /**** ****/ + /**** ****/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + + + static + FT_Module_Interface t2_get_interface( T2_Driver driver, + const char* interface ) + { + FT_Module sfnt; + + + /* we simply pass our request to the `sfnt' module */ + sfnt = FT_Get_Module( driver->root.root.library, "sfnt" ); + + return sfnt ? sfnt->clazz->get_interface( sfnt, interface ) : 0; + } + + + /* The FT_DriverInterface structure is defined in ftdriver.h. */ + + FT_CALLBACK_TABLE_DEF + const FT_Driver_Class cff_driver_class = + { + /* begin with the FT_Module_Class fields */ + { + ft_module_font_driver | ft_module_driver_scalable, + sizeof( T2_DriverRec ), + "cff", + 0x10000L, + 0x20000L, + + 0, /* module-specific interface */ + + (FT_Module_Constructor)T2_Init_Driver, + (FT_Module_Destructor) T2_Done_Driver, + (FT_Module_Requester) t2_get_interface, + }, + + /* now the specific driver fields */ + sizeof( TT_FaceRec ), + sizeof( FT_SizeRec ), + sizeof( T2_GlyphSlotRec ), + + (FTDriver_initFace) T2_Init_Face, + (FTDriver_doneFace) T2_Done_Face, + (FTDriver_initSize) 0, + (FTDriver_doneSize) 0, + (FTDriver_initGlyphSlot)0, + (FTDriver_doneGlyphSlot)0, + + (FTDriver_setCharSizes) 0, + (FTDriver_setPixelSizes)0, + + (FTDriver_loadGlyph) Load_Glyph, + (FTDriver_getCharIndex) t2_get_char_index, + + (FTDriver_getKerning) Get_Kerning, + (FTDriver_attachFile) 0, + (FTDriver_getAdvances) 0 + }; + + +#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS + + + /*************************************************************************/ + /* */ + /* */ + /* getDriverClass */ + /* */ + /* */ + /* This function is used when compiling the TrueType driver as a */ + /* shared library (`.DLL' or `.so'). It will be used by the */ + /* high-level library of FreeType to retrieve the address of the */ + /* driver's generic interface. */ + /* */ + /* It shouldn't be implemented in a static build, as each driver must */ + /* have the same function as an exported entry point. */ + /* */ + /* */ + /* The address of the TrueType's driver generic interface. The */ + /* format-specific interface can then be retrieved through the method */ + /* interface->get_format_interface. */ + /* */ + FT_EXPORT_DEF( const FT_Driver_Class* ) getDriverClass( void ) + { + return &cff_driver_class; + } + + +#endif /* CONFIG_OPTION_DYNAMIC_DRIVERS */ + + +/* END */ diff --git a/src/cff/cffdrivr.h b/src/cff/cffdrivr.h new file mode 100644 index 000000000..f2b934ca1 --- /dev/null +++ b/src/cff/cffdrivr.h @@ -0,0 +1,36 @@ +/***************************************************************************/ +/* */ +/* cffdrivr.h */ +/* */ +/* High-level OpenType driver interface (specification). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef CFFDRIVER_H +#define CFFDRIVER_H + +#include +#include FT_INTERNAL_DRIVER_H + +FT_BEGIN_HEADER + + FT_CALLBACK_TABLE + const FT_Driver_Class cff_driver_class; + + +FT_END_HEADER + +#endif /* CFFDRIVER_H */ + + +/* END */ diff --git a/src/cff/cffload.c b/src/cff/cffload.c new file mode 100644 index 000000000..5aa4cca51 --- /dev/null +++ b/src/cff/cffload.c @@ -0,0 +1,952 @@ +/***************************************************************************/ +/* */ +/* cffload.c */ +/* */ +/* OpenType and CFF data/program tables loader (body) */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_INTERNAL_CFF_ERRORS_H +#include FT_TRUETYPE_TAGS_H + +#include FT_SOURCE_FILE(cff,cffload.h) +#include FT_SOURCE_FILE(cff,cffparse.h) + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_t2load + + + /* read a CFF offset from memory */ + static FT_ULong + cff_get_offset( FT_Byte* p, + FT_Byte off_size ) + { + FT_ULong result; + + + for ( result = 0; off_size > 0; off_size-- ) + { + result <<= 8; + result |= *p++; + } + + return result; + } + + + static FT_Error + cff_new_index( CFF_Index* index, + FT_Stream stream, + FT_Bool load ) + { + FT_Error error; + FT_Memory memory = stream->memory; + FT_UShort count; + + + MEM_Set( index, 0, sizeof ( *index ) ); + + index->stream = stream; + if ( !READ_UShort( count ) && + count > 0 ) + { + FT_Byte* p; + FT_Byte offsize; + FT_ULong data_size; + FT_ULong* poff; + + + /* there is at least one element; read the offset size, */ + /* then access the offset table to compute the index's total size */ + if ( READ_Byte( offsize ) ) + goto Exit; + + index->stream = stream; + index->count = count; + index->off_size = offsize; + data_size = (FT_ULong)( count + 1 ) * offsize; + + if ( ALLOC_ARRAY( index->offsets, count + 1, FT_ULong ) || + ACCESS_Frame( data_size ) ) + goto Exit; + + poff = index->offsets; + p = (FT_Byte*)stream->cursor; + + for ( ; (FT_Short)count >= 0; count-- ) + { + poff[0] = cff_get_offset( p, offsize ); + poff++; + p += offsize; + } + + FORGET_Frame(); + + index->data_offset = FILE_Pos(); + data_size = poff[-1] - 1; + + if ( load ) + { + /* load the data */ + if ( EXTRACT_Frame( data_size, index->bytes ) ) + goto Exit; + } + else + { + /* skip the data */ + if ( FILE_Skip( data_size ) ) + goto Exit; + } + } + + Exit: + if ( error ) + FREE( index->offsets ); + + return error; + } + + + static void + cff_done_index( CFF_Index* index ) + { + if ( index->stream ) + { + FT_Stream stream = index->stream; + FT_Memory memory = stream->memory; + + + if ( index->bytes ) + RELEASE_Frame( index->bytes ); + + FREE( index->offsets ); + MEM_Set( index, 0, sizeof ( *index ) ); + } + } + + + static FT_Error + cff_explicit_index( CFF_Index* index, + FT_Byte*** table ) + { + FT_Error error = 0; + FT_Memory memory = index->stream->memory; + FT_UInt n, offset, old_offset; + FT_Byte** t; + + + *table = 0; + + if ( index->count > 0 && !ALLOC_ARRAY( t, index->count + 1, FT_Byte* ) ) + { + old_offset = 1; + for ( n = 0; n <= index->count; n++ ) + { + offset = index->offsets[n]; + if ( !offset ) + offset = old_offset; + + t[n] = index->bytes + offset - 1; + + old_offset = offset; + } + *table = t; + } + + return error; + } + + + FT_LOCAL_DEF FT_Error + CFF_Access_Element( CFF_Index* index, + FT_UInt element, + FT_Byte** pbytes, + FT_ULong* pbyte_len ) + { + FT_Error error = 0; + + + if ( index && index->count > element ) + { + /* compute start and end offsets */ + FT_ULong off1, off2 = 0; + + + off1 = index->offsets[element]; + if ( off1 ) + { + do + { + element++; + off2 = index->offsets[element]; + + } while ( off2 == 0 && element < index->count ); + + if ( !off2 ) + off1 = 0; + } + + /* access element */ + if ( off1 ) + { + *pbyte_len = off2 - off1; + + if ( index->bytes ) + { + /* this index was completely loaded in memory, that's easy */ + *pbytes = index->bytes + off1 - 1; + } + else + { + /* this index is still on disk/file, access it through a frame */ + FT_Stream stream = index->stream; + + + if ( FILE_Seek( index->data_offset + off1 - 1 ) || + EXTRACT_Frame( off2 - off1, *pbytes ) ) + goto Exit; + } + } + else + { + /* empty index element */ + *pbytes = 0; + *pbyte_len = 0; + } + } + else + error = T2_Err_Invalid_Argument; + + Exit: + return error; + } + + + FT_LOCAL_DEF void + CFF_Forget_Element( CFF_Index* index, + FT_Byte** pbytes ) + { + if ( index->bytes == 0 ) + { + FT_Stream stream = index->stream; + + + RELEASE_Frame( *pbytes ); + } + } + + + FT_LOCAL_DEF FT_String* + CFF_Get_Name( CFF_Index* index, + FT_UInt element ) + { + FT_Memory memory = index->stream->memory; + FT_Byte* bytes; + FT_ULong byte_len; + FT_Error error; + FT_String* name = 0; + + + error = CFF_Access_Element( index, element, &bytes, &byte_len ); + if ( error ) + goto Exit; + + if ( !ALLOC( name, byte_len + 1 ) ) + { + MEM_Copy( name, bytes, byte_len ); + name[byte_len] = 0; + } + CFF_Forget_Element( index, &bytes ); + + Exit: + return name; + } + + + FT_LOCAL_DEF FT_String* + CFF_Get_String( CFF_Index* index, + FT_UInt sid, + PSNames_Interface* interface ) + { + /* if it is not a standard string, return it */ + if ( sid > 390 ) + return CFF_Get_Name( index, sid - 391 ); + + /* that's a standard string, fetch a copy from the PSName module */ + { + FT_String* name = 0; + const char* adobe_name = interface->adobe_std_strings( sid ); + FT_UInt len; + + + if ( adobe_name ) + { + FT_Memory memory = index->stream->memory; + FT_Error error; + + + len = (FT_UInt)strlen( adobe_name ); + if ( !ALLOC( name, len + 1 ) ) + { + MEM_Copy( name, adobe_name, len ); + name[len] = 0; + } + } + + return name; + } + } + + + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** FD Select table support ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + + + static void + CFF_Done_FD_Select( CFF_FD_Select* select, + FT_Stream stream ) + { + if ( select->data ) + RELEASE_Frame( select->data ); + + select->data_size = 0; + select->format = 0; + select->range_count = 0; + } + + + static FT_Error + CFF_Load_FD_Select( CFF_FD_Select* select, + FT_UInt num_glyphs, + FT_Stream stream, + FT_ULong offset ) + { + FT_Error error; + FT_Byte format; + FT_UInt num_ranges; + + + /* read format */ + if ( FILE_Seek( offset ) || READ_Byte( format ) ) + goto Exit; + + select->format = format; + select->cache_count = 0; /* clear cache */ + + switch ( format ) + { + case 0: /* format 0, that's simple */ + select->data_size = num_glyphs; + goto Load_Data; + + case 3: /* format 3, a tad more complex */ + if ( READ_UShort( num_ranges ) ) + goto Exit; + + select->data_size = num_ranges * 3 + 2; + + Load_Data: + if ( EXTRACT_Frame( select->data_size, select->data ) ) + goto Exit; + break; + + default: /* hmm... that's wrong */ + error = T2_Err_Invalid_File_Format; + } + + Exit: + return error; + } + + + FT_LOCAL_DEF FT_Byte + CFF_Get_FD( CFF_FD_Select* select, + FT_UInt glyph_index ) + { + FT_Byte fd = 0; + + + switch ( select->format ) + { + case 0: + fd = select->data[glyph_index]; + break; + + case 3: + /* first, compare to cache */ + if ( (FT_UInt)(glyph_index-select->cache_first) < select->cache_count ) + { + fd = select->cache_fd; + break; + } + + /* then, lookup the ranges array */ + { + FT_Byte* p = select->data; + FT_Byte* p_limit = p + select->data_size; + FT_Byte fd2; + FT_UInt first, limit; + + + first = NEXT_UShort( p ); + do + { + if ( glyph_index < first ) + break; + + fd2 = *p++; + limit = NEXT_UShort( p ); + + if ( glyph_index < limit ) + { + fd = fd2; + + /* update cache */ + select->cache_first = first; + select->cache_count = limit-first; + select->cache_fd = fd2; + break; + } + first = limit; + + } while ( p < p_limit ); + } + break; + + default: + ; + } + + return fd; + } + + + /*************************************************************************/ + /*************************************************************************/ + /*** ***/ + /*** CFF font support ***/ + /*** ***/ + /*************************************************************************/ + /*************************************************************************/ + + static void + CFF_Done_Encoding( CFF_Encoding* encoding, + FT_Stream stream ) + { + FT_Memory memory = stream->memory; + + FREE( encoding->bytes ); + encoding->format = 0; + encoding->size = 0; + encoding->offset = 0; + } + + + static void + CFF_Done_Charset( CFF_Charset* charset, + FT_Stream stream ) + { + FT_Memory memory = stream->memory; + + FREE( charset->bytes ); + charset->format = 0; + charset->offset = 0; + charset->size = 0; + } + + + static FT_Error + CFF_Load_Charset( CFF_Charset* charset, + FT_UInt num_glyphs, + FT_Stream stream, + FT_ULong base_offset, + FT_ULong offset ) + { + FT_Error error = 0; + FT_Memory memory = stream->memory; + + if ( offset > 2 ) + { + FT_ULong size = 1; + + charset->offset = base_offset + offset; + + /* we need to parse the table to determine its size */ + if ( FILE_Seek( charset->offset ) || + READ_Byte( charset->format ) ) + goto Exit; + + switch (charset->format) + { + case 0: + { + size += 2*(num_glyphs-1); + break; + } + + case 1: + { + FT_UInt glyph, nleft; + + num_glyphs--; + while (num_glyphs > 0) + { + if ( READ_UShort(glyph) || + READ_Byte(nleft) ) + goto Exit; + + size += 3; + num_glyphs -= 1 + nleft; + } + break; + } + + case 2: + { + FT_UInt glyph, nleft; + + num_glyphs--; + while (num_glyphs > 0) + { + if ( READ_UShort(glyph) || + READ_UShort(nleft) ) + goto Exit; + + size += 4; + num_glyphs -= 1 + nleft; + } + break; + } + + default: + FT_ERROR(( "CFF.Load_Charset: invalid table format !!\n" )); + error = FT_Err_Invalid_File_Format; + goto Exit; + } + + charset->size = size; + + if ( ALLOC( charset->bytes, size ) || + FILE_Seek( charset->offset ) || + FILE_Read( charset->bytes, size ) ) + goto Exit; + } + else + charset->offset = offset; + + Exit: + return error; + } + + + static FT_Error + CFF_Load_Encoding( CFF_Encoding* encoding, + FT_UInt num_glyphs, + FT_Stream stream, + FT_ULong base_offset, + FT_ULong offset ) + { + FT_Error error = 0; + FT_Memory memory = stream->memory; + FT_UInt count; + + FT_UNUSED(num_glyphs); + + if ( offset > 2 ) + { + FT_ULong size = 1; + + encoding->offset = base_offset + offset; + + /* we need to parse the table to determine its size */ + if ( FILE_Seek( encoding->offset ) || + READ_Byte( encoding->format ) || + READ_Byte( count ) ) + goto Exit; + + switch (encoding->format & 0x7F) + { + case 0: + { + size = 2+count; + break; + } + + case 1: + { + size = 2+count*2; + break; + } + + case 2: + { + size = 2+count*3; + break; + } + + default: + FT_ERROR(( "CFF.Load_Encoding: invalid table format !!\n" )); + error = FT_Err_Invalid_File_Format; + goto Exit; + } + + if (encoding->format & 0x80) + { + /* count supplements.. */ + if ( FILE_Seek( encoding->offset + size ) || + READ_Byte( count ) ) + goto Exit; + + size += 1+3*count; + } + + encoding->size = size; + + if ( ALLOC( encoding->bytes, size ) || + FILE_Seek( encoding->offset ) || + FILE_Read( encoding->bytes, size ) ) + goto Exit; + } + else + encoding->offset = offset; + + Exit: + return error; + } + + + + static FT_Error + CFF_Load_SubFont( CFF_SubFont* font, + CFF_Index* index, + FT_UInt font_index, + FT_Stream stream, + FT_ULong base_offset ) + { + FT_Error error; + CFF_Parser parser; + FT_Byte* dict; + FT_ULong dict_len; + CFF_Font_Dict* top = &font->font_dict; + CFF_Private* priv = &font->private_dict; + + + CFF_Parser_Init( &parser, CFF_CODE_TOPDICT, &font->font_dict ); + + /* set defaults */ + MEM_Set( top, 0, sizeof ( *top ) ); + + top->underline_position = -100; + top->underline_thickness = 50; + top->charstring_type = 2; + top->font_matrix.xx = 0x10000L; + top->font_matrix.yy = 0x10000L; + top->cid_count = 8720; + + error = CFF_Access_Element( index, font_index, &dict, &dict_len ) || + CFF_Parser_Run( &parser, dict, dict + dict_len ); + + CFF_Forget_Element( index, &dict ); + + if ( error ) + goto Exit; + + /* if it is a CID font, we stop there */ + if ( top->cid_registry ) + goto Exit; + + /* parse the private dictionary, if any */ + if ( top->private_offset && top->private_size ) + { + /* set defaults */ + MEM_Set( priv, 0, sizeof ( *priv ) ); + + priv->blue_shift = 7; + priv->blue_fuzz = 1; + priv->lenIV = -1; + priv->expansion_factor = (FT_Fixed)0.06 * 0x10000L; + priv->blue_scale = (FT_Fixed)0.039625 * 0x10000L; + + CFF_Parser_Init( &parser, CFF_CODE_PRIVATE, priv ); + + if ( FILE_Seek( base_offset + font->font_dict.private_offset ) || + ACCESS_Frame( font->font_dict.private_size ) ) + goto Exit; + + error = CFF_Parser_Run( &parser, + (FT_Byte*)stream->cursor, + (FT_Byte*)stream->limit ); + FORGET_Frame(); + if ( error ) + goto Exit; + } + + /* read the local subrs, if any */ + if ( priv->local_subrs_offset ) + { + if ( FILE_Seek( base_offset + top->private_offset + + priv->local_subrs_offset ) ) + goto Exit; + + error = cff_new_index( &font->local_subrs_index, stream, 1 ); + if ( error ) + goto Exit; + + font->num_local_subrs = font->local_subrs_index.count; + error = cff_explicit_index( &font->local_subrs_index, + &font->local_subrs ); + if (error) + goto Exit; + } + + Exit: + return error; + } + + + static void + CFF_Done_SubFont( FT_Memory memory, + CFF_SubFont* subfont ) + { + if ( subfont ) + { + cff_done_index( &subfont->local_subrs_index ); + FREE( subfont->local_subrs ); + } + } + + + FT_LOCAL_DEF FT_Error + CFF_Load_Font( FT_Stream stream, + FT_Int face_index, + CFF_Font* font ) + { + static const FT_Frame_Field cff_header_fields[] = + { +#undef FT_STRUCTURE +#define FT_STRUCTURE CFF_Font + + FT_FRAME_START( 4 ), + FT_FRAME_BYTE( version_major ), + FT_FRAME_BYTE( version_minor ), + FT_FRAME_BYTE( header_size ), + FT_FRAME_BYTE( absolute_offsize ), + FT_FRAME_END + }; + + FT_Error error; + FT_Memory memory = stream->memory; + FT_ULong base_offset; + CFF_Font_Dict* dict; + + + MEM_Set( font, 0, sizeof ( *font ) ); + + font->stream = stream; + font->memory = memory; + dict = &font->top_font.font_dict; + base_offset = FILE_Pos(); + + /* read CFF font header */ + if ( READ_Fields( cff_header_fields, font ) ) + goto Exit; + + /* check format */ + if ( font->version_major != 1 || + font->header_size < 4 || + font->absolute_offsize > 4 ) + { + FT_TRACE2(( "[not a CFF font header!]\n" )); + error = FT_Err_Unknown_File_Format; + goto Exit; + } + + /* skip the rest of the header */ + if ( FILE_Skip( font->header_size - 4 ) ) + goto Exit; + + /* read the name, top dict, string and global subrs index */ + if ( FT_SET_ERROR(cff_new_index( &font->name_index, stream, 0 )) || + FT_SET_ERROR(cff_new_index( &font->font_dict_index, stream, 0 )) || + FT_SET_ERROR(cff_new_index( &font->string_index, stream, 0 )) || + FT_SET_ERROR(cff_new_index( &font->global_subrs_index, stream, 1 )) ) + goto Exit; + + /* well, we don't really forget the `disabled' fonts... */ + font->num_faces = font->name_index.count; + if ( face_index >= (FT_Int)font->num_faces ) + { + FT_ERROR(( "CFF_Load_Font: incorrect face index = %d\n", + face_index )); + error = T2_Err_Invalid_Argument; + } + + /* in case of a font format check, simply exit now */ + if ( face_index < 0 ) + goto Exit; + + /* now, parse the top-level font dictionary */ + error = CFF_Load_SubFont( &font->top_font, + &font->font_dict_index, + face_index, + stream, + base_offset ); + if ( error ) + goto Exit; + + /* now, check for a CID font */ + if ( dict->cid_registry ) + { + CFF_Index fd_index; + CFF_SubFont* sub; + FT_UInt index; + + + /* this is a CID-keyed font, we must now allocate a table of */ + /* sub-fonts, then load each of them separately */ + if ( FILE_Seek( base_offset + dict->cid_fd_array_offset ) ) + goto Exit; + + error = cff_new_index( &fd_index, stream, 0 ); + if ( error ) + goto Exit; + + if ( fd_index.count > CFF_MAX_CID_FONTS ) + { + FT_ERROR(( "CFF_Load_Font: FD array too large in CID font\n" )); + goto Fail_CID; + } + + /* allocate & read each font dict independently */ + font->num_subfonts = fd_index.count; + if ( ALLOC_ARRAY( sub, fd_index.count, CFF_SubFont ) ) + goto Fail_CID; + + /* setup pointer table */ + for ( index = 0; index < fd_index.count; index++ ) + font->subfonts[index] = sub + index; + + /* now load each sub font independently */ + for ( index = 0; index < fd_index.count; index++ ) + { + sub = font->subfonts[index]; + error = CFF_Load_SubFont( sub, &fd_index, index, + stream, base_offset ); + if ( error ) + goto Fail_CID; + } + + /* now load the FD Select array */ + error = CFF_Load_FD_Select( &font->fd_select, + dict->cid_count, + stream, + base_offset + dict->cid_fd_select_offset ); + + Fail_CID: + cff_done_index( &fd_index ); + + if ( error ) + goto Exit; + } + else + font->num_subfonts = 0; + + /* read the charstrings index now */ + if ( dict->charstrings_offset == 0 ) + { + FT_ERROR(( "CFF_Load_Font: no charstrings offset!\n" )); + error = FT_Err_Unknown_File_Format; + goto Exit; + } + + if ( FILE_Seek( base_offset + dict->charstrings_offset ) ) + goto Exit; + + error = cff_new_index( &font->charstrings_index, stream, 0 ); + if ( error ) + goto Exit; + + /* explicit the global subrs */ + font->num_global_subrs = font->global_subrs_index.count; + font->num_glyphs = font->charstrings_index.count; + + error = cff_explicit_index( &font->global_subrs_index, + &font->global_subrs ) ; + + if ( error ) + goto Exit; + + /* read the Charset and Encoding tables when available */ + error = CFF_Load_Charset( &font->charset, font->num_glyphs, stream, + base_offset, dict->charset_offset ); + if (error) + goto Exit; + + error = CFF_Load_Encoding( &font->encoding, font->num_glyphs, stream, + base_offset, dict->encoding_offset ); + if (error) + goto Exit; + + /* get the font name */ + font->font_name = CFF_Get_Name( &font->name_index, face_index ); + + Exit: + return error; + } + + + FT_LOCAL_DEF void + CFF_Done_Font( CFF_Font* font ) + { + FT_Memory memory = font->memory; + FT_UInt index; + + + cff_done_index( &font->global_subrs_index ); + cff_done_index( &font->string_index ); + cff_done_index( &font->font_dict_index ); + cff_done_index( &font->name_index ); + cff_done_index( &font->charstrings_index ); + + /* release font dictionaries */ + for ( index = 0; index < font->num_subfonts; index++ ) + CFF_Done_SubFont( memory, font->subfonts[index] ); + + CFF_Done_Encoding( &font->encoding, font->stream ); + CFF_Done_Charset( &font->charset, font->stream ); + + CFF_Done_SubFont( memory, &font->top_font ); + + CFF_Done_FD_Select( &font->fd_select, font->stream ); + + FREE( font->global_subrs ); + FREE( font->font_name ); + } + + +/* END */ diff --git a/src/cff/cffload.h b/src/cff/cffload.h new file mode 100644 index 000000000..ce3bfe086 --- /dev/null +++ b/src/cff/cffload.h @@ -0,0 +1,70 @@ +/***************************************************************************/ +/* */ +/* cffload.h */ +/* */ +/* OpenType & CFF data/program tables loader (specification). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef CFFLOAD_H +#define CFFLOAD_H + +#include +#include FT_INTERNAL_CFF_TYPES_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H + +FT_BEGIN_HEADER + + FT_LOCAL FT_String* + CFF_Get_Name( CFF_Index* index, + FT_UInt element ); + + + FT_LOCAL FT_String* + CFF_Get_String( CFF_Index* index, + FT_UInt sid, + PSNames_Interface* interface ); + + + FT_LOCAL FT_Error + CFF_Access_Element( CFF_Index* index, + FT_UInt element, + FT_Byte** pbytes, + FT_ULong* pbyte_len ); + + + FT_LOCAL void + CFF_Forget_Element( CFF_Index* index, + FT_Byte** pbytes ); + + + FT_LOCAL FT_Error + CFF_Load_Font( FT_Stream stream, + FT_Int face_index, + CFF_Font* font ); + + + FT_LOCAL void + CFF_Done_Font( CFF_Font* font ); + + + FT_LOCAL FT_Byte + CFF_Get_FD( CFF_FD_Select* select, + FT_UInt glyph_index ); + +FT_END_HEADER + +#endif /* CFFLOAD_H */ + + +/* END */ diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c new file mode 100644 index 000000000..7d543f3fb --- /dev/null +++ b/src/cff/cffobjs.c @@ -0,0 +1,589 @@ +/***************************************************************************/ +/* */ +/* cffobjs.c */ +/* */ +/* OpenType objects manager (body). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H +#include FT_INTERNAL_STREAM_H +#include FT_ERRORS_H +#include FT_TRUETYPE_NAMES_H +#include FT_TRUETYPE_TAGS_H +#include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_SOURCE_FILE(cff,cffobjs.h) +#include FT_SOURCE_FILE(cff,cffload.h) +#include FT_INTERNAL_CFF_ERRORS_H +#include /* for strlen() */ + + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_t2objs + + + /*************************************************************************/ + /* */ + /* FACE FUNCTIONS */ + /* */ + /*************************************************************************/ + + static + FT_String* T2_StrCopy( FT_Memory memory, + const FT_String* source ) + { + FT_Error error; + FT_String* result = 0; + FT_Int len = (FT_Int)strlen( source ); + + + if ( !ALLOC( result, len + 1 ) ) + { + MEM_Copy( result, source, len ); + result[len] = 0; + } + return result; + } + + +#if 0 + + /* this function is used to build a Unicode charmap from the glyph names */ + /* in a file */ + static + FT_Error CFF_Build_Unicode_Charmap( T2_Face face, + FT_ULong base_offset, + PSNames_Interface* psnames ) + { + CFF_Font* font = (CFF_Font*)face->extra.data; + FT_Memory memory = FT_FACE_MEMORY(face); + FT_UInt n, num_glyphs = face->root.num_glyphs; + const char** glyph_names; + FT_Error error; + CFF_Font_Dict* dict = &font->top_font.font_dict; + FT_ULong charset_offset; + FT_Byte format; + FT_Stream stream = face->root.stream; + + + charset_offset = dict->charset_offset; + if ( !charset_offset ) + { + FT_ERROR(( "CFF.Build_Unicode_Charmap: charset table is missing\n" )); + error = T2_Err_Invalid_File_Format; + goto Exit; + } + + /* allocate the charmap */ + if ( ALLOC( face->charmap, ... + + /* seek to charset table and allocate glyph names table */ + if ( FILE_Seek( base_offset + charset_offset ) || + ALLOC_ARRAY( glyph_names, num_glyphs, const char* ) ) + goto Exit; + + /* now, read each glyph name and store it in the glyph name table */ + if ( READ_Byte( format ) ) + goto Fail; + + switch ( format ) + { + case 0: /* format 0 - one SID per glyph */ + { + const char** gname = glyph_names; + const char** limit = gname + num_glyphs; + + if ( ACCESS_Frame( num_glyphs*2 ) ) + goto Fail; + + for ( ; gname < limit; gname++ ) + gname[0] = T2_Get_String( &font->string_index, + GET_UShort(), + psnames ); + FORGET_Frame(); + break; + } + + case 1: /* format 1 - sequential ranges */ + case 2: /* format 2 - sequential ranges with 16-bit counts */ + { + const char** gname = glyph_names; + const char** limit = gname + num_glyphs; + FT_UInt len = 3; + + if (format == 2) + len++; + + while (gname < limit) + { + FT_UInt first; + FT_UInt count; + + if ( ACCESS_Frame( len ) ) + goto Fail; + + first = GET_UShort(); + if (format == 3) + count = GET_UShort(); + else + count = GET_Byte(); + + FORGET_Frame(); + + for ( ; count > 0; count-- ) + { + gname[0] = T2_Get_String( &font->string_index, + first, + psnames ); + gname++; + first++; + } + } + break; + } + + default: /* unknown charset format! */ + FT_ERROR(( "CFF: unknown charset format!\n" )); + error = T2_Err_Invalid_File_Format; + goto Fail; + } + + /* all right, the glyph names were loaded, we now need to create */ + /* the corresponding unicode charmap.. */ + + Fail: + for ( n = 0; n < num_glyphs; n++ ) + FREE( glyph_names[n] ); + + FREE( glyph_names ); + + Exit: + return error; + } + +#endif /* 0 */ + + + static + FT_Encoding find_encoding( int platform_id, + int encoding_id ) + { + typedef struct TEncoding + { + int platform_id; + int encoding_id; + FT_Encoding encoding; + + } TEncoding; + + static + const TEncoding tt_encodings[] = + { + { TT_PLATFORM_ISO, -1, ft_encoding_unicode }, + + { TT_PLATFORM_APPLE_UNICODE, -1, ft_encoding_unicode }, + + { TT_PLATFORM_MACINTOSH, TT_MAC_ID_ROMAN, ft_encoding_apple_roman }, + + { TT_PLATFORM_MICROSOFT, TT_MS_ID_UNICODE_CS, ft_encoding_unicode }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_SJIS, ft_encoding_sjis }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_GB2312, ft_encoding_gb2312 }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_BIG_5, ft_encoding_big5 }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_WANSUNG, ft_encoding_wansung }, + { TT_PLATFORM_MICROSOFT, TT_MS_ID_JOHAB, ft_encoding_johab } + }; + + const TEncoding *cur, *limit; + + + cur = tt_encodings; + limit = cur + sizeof ( tt_encodings ) / sizeof ( tt_encodings[0] ); + + for ( ; cur < limit; cur++ ) + { + if ( cur->platform_id == platform_id ) + { + if ( cur->encoding_id == encoding_id || + cur->encoding_id == -1 ) + return cur->encoding; + } + } + + return ft_encoding_none; + } + + + /*************************************************************************/ + /* */ + /* */ + /* T2_Init_Face */ + /* */ + /* */ + /* Initializes a given OpenType face object. */ + /* */ + /* */ + /* stream :: The source font stream. */ + /* */ + /* face_index :: The index of the font face in the resource. */ + /* */ + /* num_params :: Number of additional generic parameters. Ignored. */ + /* */ + /* params :: Additional generic parameters. Ignored. */ + /* */ + /* */ + /* face :: The newly built face object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL + FT_Error T2_Init_Face( FT_Stream stream, + T2_Face face, + FT_Int face_index, + FT_Int num_params, + FT_Parameter* params ) + { + FT_Error error; + SFNT_Interface* sfnt; + PSNames_Interface* psnames; + FT_Bool pure_cff = 1; + FT_Bool sfnt_format = 0; + + + sfnt = (SFNT_Interface*)FT_Get_Module_Interface( + face->root.driver->root.library, "sfnt" ); + if ( !sfnt ) + goto Bad_Format; + + psnames = (PSNames_Interface*)FT_Get_Module_Interface( + face->root.driver->root.library, "psnames" ); + + /* create input stream from resource */ + if ( FILE_Seek( 0 ) ) + goto Exit; + + /* check that we have a valid OpenType file */ + error = sfnt->init_face( stream, face, face_index, num_params, params ); + if ( !error ) + { + if ( face->format_tag != 0x4F54544FL ) /* `OTTO'; OpenType/CFF font */ + { + FT_TRACE2(( "[not a valid OpenType/CFF font]\n" )); + goto Bad_Format; + } + + /* If we are performing a simple font format check, exit immediately */ + if ( face_index < 0 ) + return T2_Err_Ok; + + sfnt_format = 1; + + /* now, the font can be either an OpenType/CFF font, or a SVG CEF */ + /* font in the later case; it doesn't have a `head' table */ + error = face->goto_table( face, TTAG_head, stream, 0 ); + if ( !error ) + { + pure_cff = 0; + + /* Load font directory */ + error = sfnt->load_face( stream, face, + face_index, num_params, params ); + if ( error ) + goto Exit; + } + else + { + /* load the `cmap' table by hand */ + error = sfnt->load_charmaps( face, stream ); + if ( error ) + goto Exit; + + /* XXX: for now, we don't load the GPOS table, as OpenType Layout */ + /* support will be added later to FreeType 2 as a separate module */ + } + + /* now, load the CFF part of the file */ + error = face->goto_table( face, TTAG_CFF, stream, 0 ); + if ( error ) + goto Exit; + } + else + { + /* rewind to start of file; we are going to load a pure-CFF font */ + if ( FILE_Seek( 0 ) ) + goto Exit; + error = FT_Err_Ok; + } + + /* now load and parse the CFF table in the file */ + { + CFF_Font* cff; + FT_Memory memory = face->root.memory; + FT_Face root; + FT_UInt flags; + FT_ULong base_offset; + + + if ( ALLOC( cff, sizeof ( *cff ) ) ) + goto Exit; + + base_offset = FILE_Pos(); + + face->extra.data = cff; + error = CFF_Load_Font( stream, face_index, cff ); + if ( error ) + goto Exit; + + /* Complement the root flags with some interesting information. */ + /* Note that this is only necessary for pure CFF and CEF fonts */ + + root = &face->root; + if ( pure_cff ) + { + CFF_Font_Dict* dict = &cff->top_font.font_dict; + + + /* we need the `PSNames' module for pure-CFF and CEF formats */ + if ( !psnames ) + { + FT_ERROR(( "T2_Init_Face:" )); + FT_ERROR(( " cannot open CFF & CEF fonts\n" )); + FT_ERROR(( " " )); + FT_ERROR(( " without the `PSNames' module\n" )); + goto Bad_Format; + } + + /* Set up num_faces. */ + root->num_faces = cff->num_faces; + + /* compute number of glyphs */ + if ( dict->cid_registry ) + root->num_glyphs = dict->cid_count; + else + root->num_glyphs = cff->charstrings_index.count; + + /* set global bbox, as well as EM size */ + root->units_per_EM = 1000; + root->bbox = dict->font_bbox; + root->ascender = (FT_Short)root->bbox.yMax; + root->descender = (FT_Short)root->bbox.yMin; + root->height = ( ( root->ascender - root->descender ) * 12 ) / 10; + + /* retrieve font family & style name */ + root->family_name = CFF_Get_Name( &cff->name_index, face_index ); + if ( dict->cid_registry ) + { + root->style_name = T2_StrCopy( memory, "Regular" ); /* XXXX */ + } + else + { + root->style_name = CFF_Get_String( &cff->string_index, + dict->weight, + psnames ); + } + + /*******************************************************************/ + /* */ + /* Compute face flags. */ + /* */ + flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */ + FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ + + if ( sfnt_format ) + flags |= FT_FACE_FLAG_SFNT; + + /* fixed width font? */ + if ( dict->is_fixed_pitch ) + flags |= FT_FACE_FLAG_FIXED_WIDTH; + +/* XXXX: WE DO NOT SUPPORT KERNING METRICS IN THE GPOS TABLE FOR NOW */ +#if 0 + /* kerning available? */ + if ( face->kern_pairs ) + flags |= FT_FACE_FLAG_KERNING; +#endif + + root->face_flags = flags; + + /*******************************************************************/ + /* */ + /* Compute style flags. */ + /* */ + flags = 0; + + if ( dict->italic_angle ) + flags |= FT_STYLE_FLAG_ITALIC; + + /* XXX: may not be correct */ + if ( cff->top_font.private_dict.force_bold ) + flags |= FT_STYLE_FLAG_BOLD; + + root->style_flags = flags; + + /* set the charmaps if any */ + if ( sfnt_format ) + { + /*****************************************************************/ + /* */ + /* Polish the charmaps. */ + /* */ + /* Try to set the charmap encoding according to the platform & */ + /* encoding ID of each charmap. */ + /* */ + TT_CharMap charmap; + FT_Int n; + + + charmap = face->charmaps; + root->num_charmaps = face->num_charmaps; + + /* allocate table of pointers */ + if ( ALLOC_ARRAY( root->charmaps, root->num_charmaps, FT_CharMap ) ) + goto Exit; + + for ( n = 0; n < root->num_charmaps; n++, charmap++ ) + { + FT_Int platform = charmap->cmap.platformID; + FT_Int encoding = charmap->cmap.platformEncodingID; + + + charmap->root.face = (FT_Face)face; + charmap->root.platform_id = platform; + charmap->root.encoding_id = encoding; + charmap->root.encoding = find_encoding( platform, encoding ); + + /* now, set root->charmap with a unicode charmap */ + /* wherever available */ + if ( !root->charmap && + charmap->root.encoding == ft_encoding_unicode ) + root->charmap = (FT_CharMap)charmap; + + root->charmaps[n] = (FT_CharMap)charmap; + } + } + } + } + + Exit: + return error; + + Bad_Format: + error = FT_Err_Unknown_File_Format; + goto Exit; + } + + + /*************************************************************************/ + /* */ + /* */ + /* T2_Done_Face */ + /* */ + /* */ + /* Finalizes a given face object. */ + /* */ + /* */ + /* face :: A pointer to the face object to destroy. */ + /* */ + FT_LOCAL + void T2_Done_Face( T2_Face face ) + { + FT_Memory memory = face->root.memory; + SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; + + + if ( sfnt ) + sfnt->done_face( face ); + + { + CFF_Font* cff = (CFF_Font*)face->extra.data; + + + if ( cff ) + { + CFF_Done_Font( cff ); + FREE( face->extra.data ); + } + } + } + + + /*************************************************************************/ + /* */ + /* */ + /* T2_Init_Driver */ + /* */ + /* */ + /* Initializes a given OpenType driver object. */ + /* */ + /* */ + /* driver :: A handle to the target driver object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + FT_LOCAL_DEF + FT_Error T2_Init_Driver( T2_Driver driver ) + { + /* init extension registry if needed */ + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + return TT_Init_Extensions( driver ); + +#else + + FT_UNUSED( driver ); + + return T2_Err_Ok; + +#endif + } + + + /*************************************************************************/ + /* */ + /* */ + /* T2_Done_Driver */ + /* */ + /* */ + /* Finalizes a given OpenType driver. */ + /* */ + /* */ + /* driver :: A handle to the target OpenType driver. */ + /* */ + FT_LOCAL_DEF + void T2_Done_Driver( T2_Driver driver ) + { + /* destroy extensions registry if needed */ + +#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE + + TT_Done_Extensions( driver ); + +#else + + FT_UNUSED( driver ); + +#endif + } + + +/* END */ diff --git a/src/cff/cffobjs.h b/src/cff/cffobjs.h new file mode 100644 index 000000000..5838d11ab --- /dev/null +++ b/src/cff/cffobjs.h @@ -0,0 +1,141 @@ +/***************************************************************************/ +/* */ +/* cffobjs.h */ +/* */ +/* OpenType objects manager (specification). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef T2OBJS_H +#define T2OBJS_H + +#include +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_CFF_TYPES_H +#include FT_INTERNAL_CFF_ERRORS_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H + +FT_BEGIN_HEADER + + /*************************************************************************/ + /* */ + /* */ + /* T2_Driver */ + /* */ + /* */ + /* A handle to an OpenType driver object. */ + /* */ + typedef struct T2_DriverRec_* T2_Driver; + + typedef TT_Face T2_Face; + + + /*************************************************************************/ + /* */ + /* */ + /* T2_Size */ + /* */ + /* */ + /* A handle to an OpenType size object. */ + /* */ + typedef FT_Size T2_Size; + + + /*************************************************************************/ + /* */ + /* */ + /* T2_GlyphSlot */ + /* */ + /* */ + /* A handle to an OpenType glyph slot object. */ + /* */ + typedef struct T2_GlyphSlotRec_ + { + FT_GlyphSlotRec root; + + FT_Bool hint; + FT_Bool scaled; + + FT_Fixed x_scale; + FT_Fixed y_scale; + + } T2_GlyphSlotRec, *T2_GlyphSlot; + + + + /*************************************************************************/ + /* */ + /* Subglyph transformation record. */ + /* */ + typedef struct T2_Transform_ + { + FT_Fixed xx, xy; /* transformation matrix coefficients */ + FT_Fixed yx, yy; + FT_F26Dot6 ox, oy; /* offsets */ + + } T2_Transform; + + + /* this is only used in the case of a pure CFF font with no charmap */ + typedef struct T2_CharMapRec_ + { + TT_CharMapRec root; + PS_Unicodes unicodes; + + } T2_CharMapRec, *T2_CharMap; + + + /***********************************************************************/ + /* */ + /* TrueType driver class. */ + /* */ + typedef struct T2_DriverRec_ + { + FT_DriverRec root; + void* extension_component; + + } T2_DriverRec; + + + /*************************************************************************/ + /* */ + /* Face functions */ + /* */ + FT_LOCAL FT_Error + T2_Init_Face( FT_Stream stream, + T2_Face face, + FT_Int face_index, + FT_Int num_params, + FT_Parameter* params ); + + FT_LOCAL void + T2_Done_Face( T2_Face face ); + + + /*************************************************************************/ + /* */ + /* Driver functions */ + /* */ + FT_LOCAL FT_Error + T2_Init_Driver( T2_Driver driver ); + + FT_LOCAL void + T2_Done_Driver( T2_Driver driver ); + + +FT_END_HEADER + +#endif /* T2OBJS_H */ + + +/* END */ diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c new file mode 100644 index 000000000..64a9e55b1 --- /dev/null +++ b/src/cff/cffparse.c @@ -0,0 +1,645 @@ +/***************************************************************************/ +/* */ +/* cffparse.c */ +/* */ +/* CFF token stream parser (body) */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include +#include FT_SOURCE_FILE(cff,cffparse.h) +#include FT_INTERNAL_CFF_ERRORS_H +#include FT_INTERNAL_STREAM_H + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_t2parse + + +#define T2_Err_Stack_Underflow FT_Err_Invalid_Argument +#define T2_Err_Syntax_Error FT_Err_Invalid_Argument + + + enum + { + cff_kind_none = 0, + cff_kind_num, + cff_kind_fixed, + cff_kind_string, + cff_kind_bool, + cff_kind_delta, + cff_kind_callback, + + cff_kind_max /* do not remove */ + }; + + + /* now generate handlers for the most simple fields */ + typedef FT_Error (*CFF_Field_Reader)( CFF_Parser* parser ); + + typedef struct CFF_Field_Handler_ + { + int kind; + int code; + FT_UInt offset; + FT_Byte size; + CFF_Field_Reader reader; + FT_UInt array_max; + FT_UInt count_offset; + + } CFF_Field_Handler; + + + FT_LOCAL_DEF void + CFF_Parser_Init( CFF_Parser* parser, + FT_UInt code, + void* object ) + { + MEM_Set( parser, 0, sizeof ( *parser ) ); + + parser->top = parser->stack; + parser->object_code = code; + parser->object = object; + } + + + /* reads an integer */ + static FT_Long + cff_parse_integer( FT_Byte* start, + FT_Byte* limit ) + { + FT_Byte* p = start; + FT_Int v = *p++; + FT_Long val = 0; + + + if ( v == 28 ) + { + if ( p + 2 > limit ) + goto Bad; + + val = (FT_Short)( ( (FT_Int)p[0] << 8 ) | p[1] ); + p += 2; + } + else if ( v == 29 ) + { + if ( p + 4 > limit ) + goto Bad; + + val = ( (FT_Long)p[0] << 24 ) | + ( (FT_Long)p[1] << 16 ) | + ( (FT_Long)p[2] << 8 ) | + p[3]; + p += 4; + } + else if ( v < 247 ) + { + val = v - 139; + } + else if ( v < 251 ) + { + if ( p + 1 > limit ) + goto Bad; + + val = ( v - 247 ) * 256 + p[0] + 108; + p++; + } + else + { + if ( p + 1 > limit ) + goto Bad; + + val = -( v - 251 ) * 256 - p[0] - 108; + p++; + } + + Exit: + return val; + + Bad: + val = 0; + goto Exit; + } + + + /* read a real */ + static FT_Fixed + cff_parse_real( FT_Byte* start, + FT_Byte* limit, + FT_Int power_ten ) + { + FT_Byte* p = start; + FT_Long num, divider, result, exp; + FT_Int sign = 0, exp_sign = 0; + FT_Byte nib; + FT_Byte phase; + + + result = 0; + num = 0; + divider = 1; + + /* first of all, read the integer part */ + phase = 4; + + for (;;) + { + + /* If we entered this iteration with phase == 4, we need to */ + /* read a new byte. This also skips past the intial 0x1E. */ + if ( phase ) + { + p++; + + /* Make sure we don't read past the end. */ + if ( p >= limit ) + goto Bad; + } + + /* Get the nibble. */ + nib = ( p[0] >> phase ) & 0xF; + phase = 4 - phase; + + if ( nib == 0xE ) + sign = 1; + else if ( nib > 9 ) + break; + else + result = result * 10 + nib; + } + + /* read decimal part, if any */ + if ( nib == 0xa ) + for (;;) + { + + /* If we entered this iteration with phase == 4, we need */ + /* to read a new byte. */ + if ( phase ) + { + p++; + + /* Make sure we don't read past the end. */ + if ( p >= limit ) + goto Bad; + } + + /* Get the nibble. */ + nib = ( p[0] >> phase ) & 0xF; + phase = 4 - phase; + if ( nib >= 10 ) + break; + + if (divider < 10000000L) + { + num = num * 10 + nib; + divider *= 10; + } + } + + /* read exponent, if any */ + if ( nib == 12 ) + { + exp_sign = 1; + nib = 11; + } + + if ( nib == 11 ) + { + exp = 0; + + for (;;) + { + /* If we entered this iteration with phase == 4, we need */ + /* to read a new byte. */ + if ( phase ) + { + p++; + + /* Make sure we don't read past the end. */ + if ( p >= limit ) + goto Bad; + } + + /* Get the nibble. */ + nib = ( p[0] >> phase ) & 0xF; + phase = 4 - phase; + if ( nib >= 10 ) + break; + + exp = exp * 10 + nib; + } + + if ( exp_sign ) + exp = -exp; + + power_ten += exp; + } + + /* raise to power of ten if needed */ + while ( power_ten > 0 ) + { + result = result * 10; + num = num * 10; + + power_ten--; + } + + while ( power_ten < 0 ) + { + result = result / 10; + divider = divider * 10; + + power_ten++; + } + + if ( num ) + result += FT_DivFix( num, divider ); + + if ( sign ) + result = -result; + + Exit: + return result; + + Bad: + result = 0; + goto Exit; + } + + + /* read a number, either integer or real */ + static FT_Long + cff_parse_num( FT_Byte** d ) + { + return ( **d == 30 ? ( cff_parse_real ( d[0], d[1], 0 ) >> 16 ) + : cff_parse_integer( d[0], d[1] ) ); + } + + + /* reads a floating point number, either integer or real */ + static FT_Fixed + cff_parse_fixed( FT_Byte** d ) + { + return ( **d == 30 ? cff_parse_real ( d[0], d[1], 0 ) + : cff_parse_integer( d[0], d[1] ) << 16 ); + } + + + static FT_Error + cff_parse_font_matrix( CFF_Parser* parser ) + { + CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object; + FT_Matrix* matrix = &dict->font_matrix; + FT_Vector* offset = &dict->font_offset; + FT_Byte** data = parser->stack; + FT_Error error; + + + error = T2_Err_Stack_Underflow; + + if ( parser->top >= parser->stack + 6 ) + { + matrix->xx = cff_parse_fixed( data++ ); + matrix->yx = cff_parse_fixed( data++ ); + matrix->xy = cff_parse_fixed( data++ ); + matrix->yy = cff_parse_fixed( data++ ); + offset->x = cff_parse_fixed( data++ ); + offset->y = cff_parse_fixed( data ); + error = T2_Err_Ok; + } + + return error; + } + + + static FT_Error + cff_parse_font_bbox( CFF_Parser* parser ) + { + CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object; + FT_BBox* bbox = &dict->font_bbox; + FT_Byte** data = parser->stack; + FT_Error error; + + + error = T2_Err_Stack_Underflow; + + if ( parser->top >= parser->stack + 4 ) + { + bbox->xMin = cff_parse_num( data++ ); + bbox->yMin = cff_parse_num( data++ ); + bbox->xMax = cff_parse_num( data++ ); + bbox->yMax = cff_parse_num( data ); + error = T2_Err_Ok; + } + + return error; + } + + + static FT_Error + cff_parse_private_dict( CFF_Parser* parser ) + { + CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object; + FT_Byte** data = parser->stack; + FT_Error error; + + + error = T2_Err_Stack_Underflow; + + if ( parser->top >= parser->stack + 2 ) + { + dict->private_size = cff_parse_num( data++ ); + dict->private_offset = cff_parse_num( data ); + error = T2_Err_Ok; + } + + return error; + } + + + static FT_Error + cff_parse_cid_ros( CFF_Parser* parser ) + { + CFF_Font_Dict* dict = (CFF_Font_Dict*)parser->object; + FT_Byte** data = parser->stack; + FT_Error error; + + + error = T2_Err_Stack_Underflow; + + if ( parser->top >= parser->stack + 3 ) + { + dict->cid_registry = (FT_UInt)cff_parse_num ( data++ ); + dict->cid_ordering = (FT_UInt)cff_parse_num ( data++ ); + dict->cid_supplement = (FT_ULong)cff_parse_num( data ); + error = T2_Err_Ok; + } + + return error; + } + + +#define CFF_FIELD_NUM( code, name ) \ + CFF_FIELD( code, name, cff_kind_num ) +#define CFF_FIELD_FIXED( code, name ) \ + CFF_FIELD( code, name, cff_kind_fixed ) +#define CFF_FIELD_STRING( code, name ) \ + CFF_FIELD( code, name, cff_kind_string ) +#define CFF_FIELD_BOOL( code, name ) \ + CFF_FIELD( code, name, cff_kind_bool ) +#define CFF_FIELD_DELTA( code, name, max ) \ + CFF_FIELD( code, name, cff_kind_delta ) + +#define CFF_FIELD_CALLBACK( code, name ) \ + { \ + cff_kind_callback, \ + code | CFFCODE, \ + 0, 0, \ + cff_parse_ ## name, \ + 0, 0 \ + }, + +#undef CFF_FIELD +#define CFF_FIELD( code, name, kind ) \ + { \ + kind, \ + code | CFFCODE, \ + FT_FIELD_OFFSET( name ), \ + FT_FIELD_SIZE( name ), \ + 0, 0, 0 \ + }, + +#undef CFF_FIELD_DELTA +#define CFF_FIELD_DELTA( code, name, max ) \ + { \ + cff_kind_delta, \ + code | CFFCODE, \ + FT_FIELD_OFFSET( name ), \ + FT_FIELD_SIZE_DELTA( name ), \ + 0, \ + max, \ + FT_FIELD_OFFSET( num_ ## name ) \ + }, + +#define CFFCODE_TOPDICT 0x1000 +#define CFFCODE_PRIVATE 0x2000 + + static const CFF_Field_Handler cff_field_handlers[] = + { + +#include FT_SOURCE_FILE(cff,cfftoken.h) + + { 0, 0, 0, 0, 0, 0, 0 } + }; + + + FT_LOCAL_DEF FT_Error + CFF_Parser_Run( CFF_Parser* parser, + FT_Byte* start, + FT_Byte* limit ) + { + FT_Byte* p = start; + FT_Error error = T2_Err_Ok; + + + parser->top = parser->stack; + parser->start = start; + parser->limit = limit; + parser->cursor = start; + + while ( p < limit ) + { + FT_Byte v = *p; + + + if ( v >= 27 && v != 31 ) + { + /* it's a number; we will push its position on the stack */ + if ( parser->top - parser->stack >= CFF_MAX_STACK_DEPTH ) + goto Stack_Overflow; + + *parser->top ++ = p; + + /* now, skip it */ + if ( v == 30 ) + { + /* skip real number */ + p++; + for (;;) + { + if ( p >= limit ) + goto Syntax_Error; + v = p[0] >> 4; + if ( v == 15 ) + break; + v = p[0] & 0xF; + if ( v == 15 ) + break; + p++; + } + } + else if ( v == 28 ) + p += 2; + else if ( v == 29 ) + p += 4; + else if ( v > 246 ) + p += 1; + } + else + { + /* This is not a number, hence it's an operator. Compute its code */ + /* and look for it in our current list. */ + + FT_UInt code; + FT_UInt num_args = (FT_UInt) + ( parser->top - parser->stack ); + const CFF_Field_Handler* field; + + + /* first of all, a trivial check */ + if ( num_args < 1 ) + goto Stack_Underflow; + + *parser->top = p; + code = v; + if ( v == 12 ) + { + /* two byte operator */ + p++; + code = 0x100 | p[0]; + } + code = code | parser->object_code; + + for ( field = cff_field_handlers; field->kind; field++ ) + { + if ( field->code == (FT_Int)code ) + { + /* we found our field's handler; read it */ + FT_Long val; + FT_Byte* q = (FT_Byte*)parser->object + field->offset; + + switch ( field->kind ) + { + case cff_kind_bool: + case cff_kind_string: + case cff_kind_num: + val = cff_parse_num( parser->stack ); + goto Store_Number; + + case cff_kind_fixed: + val = cff_parse_fixed( parser->stack ); + + Store_Number: + switch ( field->size ) + { + case 1: + *(FT_Byte*)q = (FT_Byte)val; + break; + + case 2: + *(FT_Short*)q = (FT_Short)val; + break; + + case 4: + *(FT_Int32*)q = (FT_Int)val; + break; + + default: /* for 64-bit systems where long is 8 bytes */ + *(FT_Long*)q = val; + } + break; + + case cff_kind_delta: + { + FT_Byte* qcount = (FT_Byte*)parser->object + + field->count_offset; + + FT_Byte** data = parser->stack; + + + if ( num_args > field->array_max ) + num_args = field->array_max; + + /* store count */ + *qcount = (FT_Byte)num_args; + + val = 0; + while ( num_args > 0 ) + { + val += cff_parse_num( data++ ); + switch ( field->size ) + { + case 1: + *(FT_Byte*)q = (FT_Byte)val; + break; + + case 2: + *(FT_Short*)q = (FT_Short)val; + break; + + case 4: + *(FT_Int32*)q = (FT_Int)val; + break; + + default: /* for 64-bit systems */ + *(FT_Long*)q = val; + } + + q += field->size; + num_args--; + } + } + break; + + default: /* callback */ + error = field->reader( parser ); + if ( error ) + goto Exit; + } + goto Found; + } + } + + /* this is an unknown operator, or it is unsupported; */ + /* we will ignore it for now. */ + + Found: + /* clear stack */ + parser->top = parser->stack; + } + p++; + } + + Exit: + return error; + + Stack_Overflow: + error = T2_Err_Invalid_Argument; + goto Exit; + + Stack_Underflow: + error = T2_Err_Invalid_Argument; + goto Exit; + + Syntax_Error: + error = T2_Err_Invalid_Argument; + goto Exit; + } + + +/* END */ diff --git a/src/cff/cffparse.h b/src/cff/cffparse.h new file mode 100644 index 000000000..f0941654c --- /dev/null +++ b/src/cff/cffparse.h @@ -0,0 +1,67 @@ +/***************************************************************************/ +/* */ +/* cffparse.h */ +/* */ +/* CFF token stream parser (specification) */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#ifndef __CFF_PARSE_H__ +#define __CFF_PARSE_H__ + +#include +#include FT_INTERNAL_CFF_TYPES_H +#include FT_INTERNAL_OBJECTS_H + +FT_BEGIN_HEADER + +#define CFF_MAX_STACK_DEPTH 96 + +#define CFF_CODE_TOPDICT 0x1000 +#define CFF_CODE_PRIVATE 0x2000 + + + + + typedef struct CFF_Parser_ + { + FT_Byte* start; + FT_Byte* limit; + FT_Byte* cursor; + + FT_Byte* stack[CFF_MAX_STACK_DEPTH + 1]; + FT_Byte** top; + + FT_UInt object_code; + void* object; + + } CFF_Parser; + + + FT_LOCAL void + CFF_Parser_Init( CFF_Parser* parser, + FT_UInt code, + void* object ); + + FT_LOCAL FT_Error + CFF_Parser_Run( CFF_Parser* parser, + FT_Byte* start, + FT_Byte* limit ); + + +FT_END_HEADER + +#endif /* __CFF_PARSE_H__ */ + + +/* END */ diff --git a/src/cff/cfftoken.h b/src/cff/cfftoken.h new file mode 100644 index 000000000..151bae995 --- /dev/null +++ b/src/cff/cfftoken.h @@ -0,0 +1,97 @@ +/***************************************************************************/ +/* */ +/* cfftoken.h */ +/* */ +/* CFF token definitions */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + +#undef FT_STRUCTURE +#define FT_STRUCTURE CFF_Font_Dict + +#undef CFFCODE +#define CFFCODE CFFCODE_TOPDICT + + CFF_FIELD_STRING ( 0, version ) + CFF_FIELD_STRING ( 1, notice ) + CFF_FIELD_STRING ( 0x100, copyright ) + CFF_FIELD_STRING ( 2, full_name ) + CFF_FIELD_STRING ( 3, family_name ) + CFF_FIELD_STRING ( 4, weight ) + CFF_FIELD_BOOL ( 0x101, is_fixed_pitch ) + CFF_FIELD_FIXED ( 0x102, italic_angle ) + CFF_FIELD_NUM ( 0x103, underline_position ) + CFF_FIELD_NUM ( 0x104, underline_thickness ) + CFF_FIELD_NUM ( 0x105, paint_type ) + CFF_FIELD_NUM ( 0x106, charstring_type ) + CFF_FIELD_CALLBACK( 0x107, font_matrix ) + CFF_FIELD_NUM ( 13, unique_id ) + CFF_FIELD_CALLBACK( 5, font_bbox ) + CFF_FIELD_NUM ( 0x108, stroke_width ) + CFF_FIELD_NUM ( 15, charset_offset ) + CFF_FIELD_NUM ( 16, encoding_offset ) + CFF_FIELD_NUM ( 17, charstrings_offset ) + CFF_FIELD_CALLBACK( 18, private_dict ) + CFF_FIELD_NUM ( 0x114, synthetic_base ) + CFF_FIELD_STRING ( 0x115, postscript ) + CFF_FIELD_STRING ( 0x116, base_font_name ) + +#if 0 + CFF_FIELD_DELTA ( 0x117, base_font_blend, 16 ) + CFF_FIELD_CALLBACK( 0x118, multiple_master ) + CFF_FIELD_CALLBACK( 0x119, blend_axit_types ) +#endif + + CFF_FIELD_CALLBACK( 0x11E, cid_ros ) + CFF_FIELD_NUM ( 0x11F, cid_font_version ) + CFF_FIELD_NUM ( 0x120, cid_font_revision ) + CFF_FIELD_NUM ( 0x121, cid_font_type ) + CFF_FIELD_NUM ( 0x122, cid_count ) + CFF_FIELD_NUM ( 0x123, cid_uid_base ) + CFF_FIELD_NUM ( 0x124, cid_fd_array_offset ) + CFF_FIELD_NUM ( 0x125, cid_fd_select_offset ) + CFF_FIELD_STRING ( 0x126, cid_font_name ) + +#if 0 + CFF_FIELD_NUM ( 0x127, chameleon ) +#endif + + +#undef FT_STRUCTURE +#define FT_STRUCTURE CFF_Private +#undef CFFCODE +#define CFFCODE CFFCODE_PRIVATE + + CFF_FIELD_DELTA( 6, blue_values, 14 ) + CFF_FIELD_DELTA( 7, other_blues, 10 ) + CFF_FIELD_DELTA( 8, family_blues, 14 ) + CFF_FIELD_DELTA( 9, family_other_blues, 10 ) + CFF_FIELD_FIXED( 0x109, blue_scale ) + CFF_FIELD_NUM ( 0x10A, blue_shift ) + CFF_FIELD_NUM ( 0x10B, blue_fuzz ) + CFF_FIELD_NUM ( 10, standard_width ) + CFF_FIELD_NUM ( 11, standard_height ) + CFF_FIELD_DELTA( 0x10C, snap_widths, 13 ) + CFF_FIELD_DELTA( 0x10D, snap_heights, 13 ) + CFF_FIELD_BOOL ( 0x10E, force_bold ) + CFF_FIELD_FIXED( 0x10F, force_bold_threshold ) + CFF_FIELD_NUM ( 0x110, lenIV ) + CFF_FIELD_NUM ( 0x111, language_group ) + CFF_FIELD_FIXED( 0x112, expansion_factor ) + CFF_FIELD_NUM ( 0x113, initial_random_seed ) + CFF_FIELD_NUM ( 19, local_subrs_offset ) + CFF_FIELD_NUM ( 20, default_width ) + CFF_FIELD_NUM ( 21, nominal_width ) + + +/* END */ diff --git a/src/cff/rules.mk b/src/cff/rules.mk index ba87af5f1..0ef7ec8ea 100644 --- a/src/cff/rules.mk +++ b/src/cff/rules.mk @@ -15,55 +15,55 @@ # OpenType driver directory # -T2_DIR := $(SRC_)cff -T2_DIR_ := $(T2_DIR)$(SEP) +CFF_DIR := $(SRC_)cff +CFF_DIR_ := $(CFF_DIR)$(SEP) -T2_COMPILE := $(FT_COMPILE) +CFF_COMPILE := $(FT_COMPILE) -# T2 driver sources (i.e., C files) +# CFF driver sources (i.e., C files) # -T2_DRV_SRC := $(T2_DIR_)t2objs.c \ - $(T2_DIR_)t2load.c \ - $(T2_DIR_)t2gload.c \ - $(T2_DIR_)t2parse.c \ - $(T2_DIR_)t2driver.c +CFF_DRV_SRC := $(CFF_DIR_)cffobjs.c \ + $(CFF_DIR_)cffload.c \ + $(CFF_DIR_)t2gload.c \ + $(CFF_DIR_)cffparse.c \ + $(CFF_DIR_)cffdrivr.c -# T2 driver headers +# CFF driver headers # -T2_DRV_H := $(T2_DRV_SRC:%.c=%.h) \ - $(T2_DIR_)t2tokens.h +CFF_DRV_H := $(CFF_DRV_SRC:%.c=%.h) \ + $(CFF_DIR_)cfftoken.h -# T2 driver object(s) +# CFF driver object(s) # -# T2_DRV_OBJ_M is used during `multi' builds -# T2_DRV_OBJ_S is used during `single' builds +# CFF_DRV_OBJ_M is used during `multi' builds +# CFF_DRV_OBJ_S is used during `single' builds # -T2_DRV_OBJ_M := $(T2_DRV_SRC:$(T2_DIR_)%.c=$(OBJ_)%.$O) -T2_DRV_OBJ_S := $(OBJ_)cff.$O +CFF_DRV_OBJ_M := $(CFF_DRV_SRC:$(CFF_DIR_)%.c=$(OBJ_)%.$O) +CFF_DRV_OBJ_S := $(OBJ_)cff.$O # T2 driver source file for single build # -T2_DRV_SRC_S := $(T2_DIR_)cff.c +CFF_DRV_SRC_S := $(CFF_DIR_)cff.c # T2 driver - single object # -$(T2_DRV_OBJ_S): $(T2_DRV_SRC_S) $(T2_DRV_SRC) $(FREETYPE_H) $(T2_DRV_H) - $(T2_COMPILE) $T$@ $(T2_DRV_SRC_S) +$(CFF_DRV_OBJ_S): $(CFF_DRV_SRC_S) $(CFF_DRV_SRC) $(FREETYPE_H) $(CFF_DRV_H) + $(CFF_COMPILE) $T$@ $(CFF_DRV_SRC_S) # T2 driver - multiple objects # -$(OBJ_)%.$O: $(T2_DIR_)%.c $(FREETYPE_H) $(T2_DRV_H) - $(T2_COMPILE) $T$@ $< +$(OBJ_)%.$O: $(CFF_DIR_)%.c $(FREETYPE_H) $(CFF_DRV_H) + $(CFF_COMPILE) $T$@ $< # update main driver object lists # -DRV_OBJS_S += $(T2_DRV_OBJ_S) -DRV_OBJS_M += $(T2_DRV_OBJ_M) +DRV_OBJS_S += $(CFF_DRV_OBJ_S) +DRV_OBJS_M += $(CFF_DRV_OBJ_M) # EOF diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c index 764f9ee95..723a9dcf4 100644 --- a/src/cff/t2gload.c +++ b/src/cff/t2gload.c @@ -15,29 +15,18 @@ /* */ /***************************************************************************/ +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_SFNT_H +#include FT_OUTLINE_H +#include FT_TRUETYPE_TAGS_H -#include -#include -#include -#include -#include -#include +#include FT_SOURCE_FILE(cff,cffload.h) +#include FT_SOURCE_FILE(cff,t2gload.h) - -#ifdef FT_FLAT_COMPILE - -#include "t2load.h" -#include "t2gload.h" - -#else - -#include -#include - -#endif - - -#include +#include FT_INTERNAL_CFF_ERRORS_H /*************************************************************************/ @@ -524,14 +513,6 @@ } -#define USE_ARGS( n ) do \ - { \ - top -= n; \ - if ( top < decoder->stack ) \ - goto Stack_Underflow; \ - } while ( 0 ) - - /*************************************************************************/ /* */ /* */ @@ -1979,14 +1960,14 @@ (FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ); /* now load the unscaled outline */ - error = T2_Access_Element( &cff->charstrings_index, glyph_index, - &charstring, &charstring_len ); + error = CFF_Access_Element( &cff->charstrings_index, glyph_index, + &charstring, &charstring_len ); if ( !error ) { T2_Prepare_Decoder( &decoder, glyph_index ); error = T2_Parse_CharStrings( &decoder, charstring, charstring_len ); - T2_Forget_Element( &cff->charstrings_index, &charstring ); + CFF_Forget_Element( &cff->charstrings_index, &charstring ); } /* save new glyph tables */ diff --git a/src/cff/t2gload.h b/src/cff/t2gload.h index 565c39ca7..d9f23cd25 100644 --- a/src/cff/t2gload.h +++ b/src/cff/t2gload.h @@ -19,24 +19,11 @@ #ifndef T2GLOAD_H #define T2GLOAD_H -#include - - -#ifdef FT_FLAT_COMPILE - -#include "t2objs.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_FREETYPE_H +#include FT_SOURCE_FILE(cff,cffobjs.h) +FT_BEGIN_HEADER #define T2_MAX_OPERANDS 48 #define T2_MAX_SUBRS_CALLS 32 @@ -168,44 +155,44 @@ FT_Byte** locals; FT_Byte** globals; + FT_Byte** glyph_names; /* for pure CFF fonts only */ + FT_UInt num_glyphs; /* number of glyphs in font */ + } T2_Decoder; - FT_LOCAL - void T2_Init_Decoder( T2_Decoder* decoder, - TT_Face face, - T2_Size size, - T2_GlyphSlot slot ); + FT_LOCAL void + T2_Init_Decoder( T2_Decoder* decoder, + TT_Face face, + T2_Size size, + T2_GlyphSlot slot ); - FT_LOCAL - void T2_Prepare_Decoder( T2_Decoder* decoder, - FT_UInt glyph_index ); + FT_LOCAL void + T2_Prepare_Decoder( T2_Decoder* decoder, + FT_UInt glyph_index ); #if 0 /* unused until we support pure CFF fonts */ /* Compute the maximum advance width of a font through quick parsing */ - FT_LOCAL - FT_Error T2_Compute_Max_Advance( TT_Face face, - FT_Int* max_advance ); + FT_LOCAL FT_Error + T2_Compute_Max_Advance( TT_Face face, + FT_Int* max_advance ); #endif /* 0 */ - FT_LOCAL - FT_Error T2_Parse_CharStrings( T2_Decoder* decoder, - FT_Byte* charstring_base, - FT_Int charstring_len ); + FT_LOCAL FT_Error + T2_Parse_CharStrings( T2_Decoder* decoder, + FT_Byte* charstring_base, + FT_Int charstring_len ); - FT_LOCAL - FT_Error T2_Load_Glyph( T2_GlyphSlot glyph, - T2_Size size, - FT_Int glyph_index, - FT_Int load_flags ); + FT_LOCAL FT_Error + T2_Load_Glyph( T2_GlyphSlot glyph, + T2_Size size, + FT_Int glyph_index, + FT_Int load_flags ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* T2GLOAD_H */ diff --git a/src/cid/cidafm.c b/src/cid/cidafm.c index 8381d9472..d28f4b237 100644 --- a/src/cid/cidafm.c +++ b/src/cid/cidafm.c @@ -15,25 +15,14 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "cidafm.h" - -#else - -#include - -#endif - - -#include -#include -#include - -#include /* for qsort() */ -#include /* for strcmp() */ -#include /* for isalnum() */ +#include +#include FT_SOURCE_FILE(cid,cidafm.h) +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_TYPE1_ERRORS_H +#include /* for qsort() */ +#include /* for strcmp() */ +#include /* for isalnum() */ /*************************************************************************/ diff --git a/src/cid/cidafm.h b/src/cid/cidafm.h index 564986f46..b91039193 100644 --- a/src/cid/cidafm.h +++ b/src/cid/cidafm.h @@ -19,22 +19,10 @@ #ifndef CIDAFM_H #define CIDAFM_H +#include +#include FT_SOURCE_FILE(cid,cidobjs.h) -#ifdef FT_FLAT_COMPILE - -#include "cidobjs.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER typedef struct CID_Kern_Pair_ { @@ -44,6 +32,7 @@ } CID_Kern_Pair; + typedef struct CID_AFM_ { FT_UInt num_pairs; @@ -52,25 +41,21 @@ } CID_AFM; - FT_LOCAL - FT_Error CID_Read_AFM( FT_Face cid_face, - FT_Stream stream ); + FT_LOCAL FT_Error + CID_Read_AFM( FT_Face cid_face, + FT_Stream stream ); - FT_LOCAL - void CID_Done_AFM( FT_Memory memory, - CID_AFM* afm ); + FT_LOCAL void + CID_Done_AFM( FT_Memory memory, + CID_AFM* afm ); - FT_LOCAL - void CID_Get_Kerning( CID_AFM* afm, - FT_UInt glyph1, - FT_UInt glyph2, - FT_Vector* kerning ); - - -#ifdef __cplusplus - } -#endif + FT_LOCAL void + CID_Get_Kerning( CID_AFM* afm, + FT_UInt glyph1, + FT_UInt glyph2, + FT_Vector* kerning ); +FT_END_HEADER #endif /* CIDAFM_H */ diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index a86519bb9..62553a689 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -15,23 +15,12 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "cidload.h" -#include "cidgload.h" - -#else - -#include -#include - -#endif - - -#include -#include -#include +#include +#include FT_SOURCE_FILE(cid,cidload.h) +#include FT_SOURCE_FILE(cid,cidgload.h) +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_OUTLINE_H /*************************************************************************/ diff --git a/src/cid/cidgload.h b/src/cid/cidgload.h index 5fadc8fbc..fee9c47e8 100644 --- a/src/cid/cidgload.h +++ b/src/cid/cidgload.h @@ -19,22 +19,10 @@ #ifndef CIDGLOAD_H #define CIDGLOAD_H +#include +#include FT_SOURCE_FILE(cid,cidobjs.h) -#ifdef FT_FLAT_COMPILE - -#include "cidobjs.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER #if 0 @@ -51,11 +39,7 @@ FT_Int glyph_index, FT_Int load_flags ); - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* CIDGLOAD_H */ diff --git a/src/cid/cidload.c b/src/cid/cidload.c index 4c01d4e15..e9acb216c 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -15,28 +15,15 @@ /* */ /***************************************************************************/ - -#include -#include -#include - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "cidload.h" - -#else - -#include - -#endif - - -#include -#include /* for isspace(), isalnum() */ +#include +#include FT_INTERNAL_DEBUG_H +#include FT_CONFIG_CONFIG_H +#include FT_MULTIPLE_MASTERS_H +#include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_TYPE1_ERRORS_H +#include FT_SOURCE_FILE(cid,cidload.h) +#include +#include /* for isspace(), isalnum() */ /*************************************************************************/ diff --git a/src/cid/cidload.h b/src/cid/cidload.h index 2f089d1f6..52697fc77 100644 --- a/src/cid/cidload.h +++ b/src/cid/cidload.h @@ -19,23 +19,11 @@ #ifndef CIDLOAD_H #define CIDLOAD_H -#include - -#ifdef FT_FLAT_COMPILE - -#include "cidparse.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_STREAM_H +#include FT_SOURCE_FILE(cid,cidparse.h) +FT_BEGIN_HEADER typedef struct CID_Loader_ { @@ -57,11 +45,7 @@ FT_LOCAL FT_Error CID_Open_Face( CID_Face face ); - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* CIDLOAD_H */ diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index 9966c8afa..62019af5f 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -15,26 +15,13 @@ /* */ /***************************************************************************/ - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "cidgload.h" -#include "cidload.h" - -#else - -#include -#include - -#endif - - -#include -#include +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_SOURCE_FILE(cid,cidgload.h) +#include FT_SOURCE_FILE(cid,cidload.h) +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H /*************************************************************************/ diff --git a/src/cid/cidobjs.h b/src/cid/cidobjs.h index 5566b1f27..cd1f3429c 100644 --- a/src/cid/cidobjs.h +++ b/src/cid/cidobjs.h @@ -19,16 +19,13 @@ #ifndef CIDOBJS_H #define CIDOBJS_H -#include -#include -#include -#include - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_OBJECTS_H +#include FT_CONFIG_CONFIG_H +#include FT_INTERNAL_TYPE1_ERRORS_H +#include FT_INTERNAL_TYPE1_TYPES_H +FT_BEGIN_HEADER /* The following structures must be defined by the hinter */ typedef struct CID_Size_Hints_ CID_Size_Hints; @@ -130,10 +127,7 @@ void CID_Done_Driver( CID_Driver driver ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* CIDOBJS_H */ diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c index 4a4b5aa0b..2c8749614 100644 --- a/src/cid/cidparse.c +++ b/src/cid/cidparse.c @@ -15,26 +15,14 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "cidparse.h" - -#else - -#include - -#endif - - -#include /* for strncmp() */ +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_TYPE1_ERRORS_H +#include FT_SOURCE_FILE(cid,cidparse.h) +#include /* for strncmp() */ /*************************************************************************/ diff --git a/src/cid/cidparse.h b/src/cid/cidparse.h index d6c06ab50..9805634cb 100644 --- a/src/cid/cidparse.h +++ b/src/cid/cidparse.h @@ -19,14 +19,12 @@ #ifndef CIDPARSE_H #define CIDPARSE_H -#include -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H +FT_BEGIN_HEADER /*************************************************************************/ /* */ @@ -70,14 +68,14 @@ } CID_Parser; - FT_LOCAL - FT_Error CID_New_Parser( CID_Parser* parser, - FT_Stream stream, - FT_Memory memory, - PSAux_Interface* psaux ); + FT_LOCAL FT_Error + CID_New_Parser( CID_Parser* parser, + FT_Stream stream, + FT_Memory memory, + PSAux_Interface* psaux ); - FT_LOCAL - void CID_Done_Parser( CID_Parser* parser ); + FT_LOCAL void + CID_Done_Parser( CID_Parser* parser ); /*************************************************************************/ @@ -107,10 +105,7 @@ (p)->root.funcs.load_field_table( &(p)->root, f, o, 0, 0 ) -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* CIDPARSE_H */ diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c index 8641bf76d..24640d1df 100644 --- a/src/cid/cidriver.c +++ b/src/cid/cidriver.c @@ -15,25 +15,13 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "cidriver.h" -#include "cidgload.h" - -#else - -#include -#include - -#endif - - -#include -#include -#include - -#include /* for strcmp() */ +#include +#include FT_SOURCE_FILE(cid,cidriver.h) +#include FT_SOURCE_FILE(cid,cidgload.h) +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include /* for strcmp() */ /*************************************************************************/ diff --git a/src/cid/cidriver.h b/src/cid/cidriver.h index 2dec2f317..c80318c70 100644 --- a/src/cid/cidriver.h +++ b/src/cid/cidriver.h @@ -19,20 +19,15 @@ #ifndef CIDRIVER_H #define CIDRIVER_H -#include - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_DRIVER_H +FT_BEGIN_HEADER FT_CALLBACK_TABLE const FT_Driver_Class t1cid_driver_class; -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* CIDRIVER_H */ diff --git a/src/cid/type1cid.c b/src/cid/type1cid.c index d26aee26f..f2a91e523 100644 --- a/src/cid/type1cid.c +++ b/src/cid/type1cid.c @@ -18,23 +18,11 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT -#ifdef FT_FLAT_COMPILE - -#include "cidparse.c" -#include "cidload.c" -#include "cidobjs.c" -#include "cidriver.c" -#include "cidgload.c" - -#else - -#include -#include -#include -#include -#include - -#endif - +#include +#include FT_SOURCE_FILE(cid,cidparse.c) +#include FT_SOURCE_FILE(cid,cidload.c) +#include FT_SOURCE_FILE(cid,cidobjs.c) +#include FT_SOURCE_FILE(cid,cidriver.c) +#include FT_SOURCE_FILE(cid,cidgload.c) /* END */ diff --git a/src/psaux/psaux.c b/src/psaux/psaux.c index 74d895e64..c98be56fd 100644 --- a/src/psaux/psaux.c +++ b/src/psaux/psaux.c @@ -18,19 +18,9 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT -#ifdef FT_FLAT_COMPILE - -#include "psobjs.c" -#include "psauxmod.c" -#include "t1decode.c" - -#else - -#include -#include -#include - -#endif - +#include +#include FT_SOURCE_FILE(psaux,psobjs.c) +#include FT_SOURCE_FILE(psaux,psauxmod.c) +#include FT_SOURCE_FILE(psaux,t1decode.c) /* END */ diff --git a/src/psaux/psauxmod.c b/src/psaux/psauxmod.c index 0c8ae9524..722359af1 100644 --- a/src/psaux/psauxmod.c +++ b/src/psaux/psauxmod.c @@ -15,21 +15,10 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "psauxmod.h" -#include "psobjs.h" -#include "t1decode.h" - -#else - -#include -#include -#include - -#endif - +#include +#include FT_SOURCE_FILE(psaux,psauxmod.h) +#include FT_SOURCE_FILE(psaux,psobjs.h) +#include FT_SOURCE_FILE(psaux,t1decode.h) FT_CALLBACK_TABLE_DEF const PS_Table_Funcs ps_table_funcs = diff --git a/src/psaux/psauxmod.h b/src/psaux/psauxmod.h index 3c348cfc3..f6c175251 100644 --- a/src/psaux/psauxmod.h +++ b/src/psaux/psauxmod.h @@ -19,17 +19,14 @@ #ifndef PSAUXMOD_H #define PSAUXMOD_H -#include +#include +#include FT_MODULE_H -#ifdef __cplusplus - extern "C" { -#endif +FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Module_Class ) psaux_driver_class; -#ifdef __cplusplus - } -#endif +FT_END_HEADER #endif /* PSAUXMOD_H */ diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index 589cd68b8..d5e9ac7ea 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -15,20 +15,11 @@ /* */ /***************************************************************************/ - -#include -#include -#include - -#ifdef FT_FLAT_COMPILE - -#include "psobjs.h" - -#else - -#include - -#endif +#include +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_DEBUG_H +#include FT_ERRORS_H +#include FT_SOURCE_FILE(psaux,psobjs.h) /*************************************************************************/ diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h index 8537aecbb..10b550300 100644 --- a/src/psaux/psobjs.h +++ b/src/psaux/psobjs.h @@ -19,13 +19,10 @@ #ifndef PSOBJS_H #define PSOBJS_H -#include - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_POSTSCRIPT_AUX_H +FT_BEGIN_HEADER /*************************************************************************/ /*************************************************************************/ @@ -195,10 +192,7 @@ FT_UShort seed ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* PSOBJS_H */ diff --git a/src/psaux/t1decode.c b/src/psaux/t1decode.c index 40e4f4e29..e2497b12f 100644 --- a/src/psaux/t1decode.c +++ b/src/psaux/t1decode.c @@ -15,25 +15,12 @@ /* */ /***************************************************************************/ - -#include /* for FT_ERROR() */ -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "t1decode.h" -#include "psobjs.h" - -#else - -#include -#include - -#endif - +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_TYPE1_ERRORS_H +#include FT_OUTLINE_H +#include FT_SOURCE_FILE(psaux,t1decode.h) +#include FT_SOURCE_FILE(psaux,psobjs.h) /*************************************************************************/ /* */ diff --git a/src/psaux/t1decode.h b/src/psaux/t1decode.h index b5f0f5d86..6d5c0ff60 100644 --- a/src/psaux/t1decode.h +++ b/src/psaux/t1decode.h @@ -19,15 +19,12 @@ #ifndef T1DECODE_H #define T1DECODE_H -#include -#include -#include - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_INTERNAL_TYPE1_TYPES_H +FT_BEGIN_HEADER FT_CALLBACK_TABLE const T1_Decoder_Funcs t1_decoder_funcs; @@ -55,10 +52,7 @@ void T1_Decoder_Done( T1_Decoder* decoder ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* T1DECODE_H */ diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c index 85dee1064..31d79d9a1 100644 --- a/src/psnames/psmodule.c +++ b/src/psnames/psmodule.c @@ -15,24 +15,11 @@ /* */ /***************************************************************************/ - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "psmodule.h" -#include "pstables.h" - -#else - -#include -#include - -#endif - - +#include +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_INTERNAL_OBJECTS_H +#include FT_SOURCE_FILE(psnames,psmodule.h) +#include FT_SOURCE_FILE(psnames,pstables.h) #include /* for qsort() */ #include /* for strcmp(), strncpy() */ diff --git a/src/psnames/psmodule.h b/src/psnames/psmodule.h index 513c99eb1..3bfcf769e 100644 --- a/src/psnames/psmodule.h +++ b/src/psnames/psmodule.h @@ -19,20 +19,14 @@ #ifndef PSDRIVER_H #define PSDRIVER_H -#include - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_MODULE_H +FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class; -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* PSDRIVER_H */ diff --git a/src/psnames/psnames.c b/src/psnames/psnames.c index cb62304d6..2cd9a793d 100644 --- a/src/psnames/psnames.c +++ b/src/psnames/psnames.c @@ -18,14 +18,8 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - -#ifdef FT_FLAT_COMPILE - -#include "psmodule.c" - -#else - -#include +#include +#include FT_SOURCE_FILE(psnames,psmodule.c) #endif diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c index ee01cb508..41b4d7f87 100644 --- a/src/raster/ftraster.c +++ b/src/raster/ftraster.c @@ -22,12 +22,9 @@ /*************************************************************************/ -#ifdef FT_FLAT_COMPILE -# include "ftraster.h" -#else -# include -#endif -#include /* for FT_MulDiv() only */ +#include +#include FT_SOURCE_FILE(raster,ftraster.h) +#include FT_INTERNAL_CALC_H /* for FT_MulDiv only */ /*************************************************************************/ diff --git a/src/raster/ftraster.h b/src/raster/ftraster.h index 36fa51cd8..36eaf55df 100644 --- a/src/raster/ftraster.h +++ b/src/raster/ftraster.h @@ -19,12 +19,11 @@ #ifndef FTRASTER_H #define FTRASTER_H -#ifdef __cplusplus - extern "C" { -#endif - -#include +#include +#include FT_CONFIG_CONFIG_H +#include FT_IMAGE_H +FT_BEGIN_HEADER /*************************************************************************/ /* */ @@ -33,16 +32,9 @@ /* */ /* #define _STANDALONE_ */ -#ifndef FT_EXPORT_VAR -#define FT_EXPORT_VAR( x ) extern x -#endif - FT_EXPORT_VAR( const FT_Raster_Funcs ) ft_standard_raster; -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* FTRASTER_H */ diff --git a/src/raster/ftrend1.c b/src/raster/ftrend1.c index 8be7e2f9f..5d68d9d86 100644 --- a/src/raster/ftrend1.c +++ b/src/raster/ftrend1.c @@ -16,22 +16,11 @@ /***************************************************************************/ -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ftrend1.h" -#include "ftraster.h" - -#else - -#include -#include - -#endif - +#include +#include FT_INTERNAL_OBJECTS_H +#include FT_OUTLINE_H +#include FT_SOURCE_FILE(raster,ftrend1.h) +#include FT_SOURCE_FILE(raster,ftraster.h) /* initialize renderer -- init its raster */ static diff --git a/src/raster/ftrend1.h b/src/raster/ftrend1.h index 76926ae34..20f0d211c 100644 --- a/src/raster/ftrend1.h +++ b/src/raster/ftrend1.h @@ -19,14 +19,10 @@ #ifndef FTREND1_H #define FTREND1_H +#include +#include FT_RENDER_H -#include - - -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster1_renderer_class; @@ -36,11 +32,7 @@ /* */ FT_EXPORT_VAR( const FT_Renderer_Class ) ft_raster5_renderer_class; - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* FTREND1_H */ diff --git a/src/raster/raster.c b/src/raster/raster.c index ea1080433..32fade414 100644 --- a/src/raster/raster.c +++ b/src/raster/raster.c @@ -18,18 +18,9 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - -#ifdef FT_FLAT_COMPILE - -#include "ftraster.c" -#include "ftrend1.c" - -#else - -#include -#include - -#endif +#include +#include FT_SOURCE_FILE(raster,ftraster.c) +#include FT_SOURCE_FILE(raster,ftrend1.c) /* END */ diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c index 4df3c6963..ec8c75d8a 100644 --- a/src/sfnt/sfdriver.c +++ b/src/sfnt/sfdriver.c @@ -15,44 +15,23 @@ /* */ /***************************************************************************/ +#include +#include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_OBJECTS_H -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "sfdriver.h" -#include "ttload.h" -#include "ttcmap.h" -#include "sfobjs.h" +#include FT_SOURCE_FILE(sfnt,sfdriver.h) +#include FT_SOURCE_FILE(sfnt,ttload.h) +#include FT_SOURCE_FILE(sfnt,ttcmap.h) +#include FT_SOURCE_FILE(sfnt,sfobjs.h) #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS -#include "ttsbit.h" +#include FT_SOURCE_FILE(sfnt,ttsbit.h) #endif #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES -#include "ttpost.h" +#include FT_SOURCE_FILE(sfnt,ttpost.h) #endif -#else - -#include -#include -#include -#include - -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS -#include -#endif - -#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES -#include -#endif - -#endif - - #include /* for strcmp() */ diff --git a/src/sfnt/sfdriver.h b/src/sfnt/sfdriver.h index 72e3e6590..206df4772 100644 --- a/src/sfnt/sfdriver.h +++ b/src/sfnt/sfdriver.h @@ -19,20 +19,14 @@ #ifndef SFDRIVER_H #define SFDRIVER_H -#include - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_MODULE_H +FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Module_Class ) sfnt_module_class; - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* SFDRIVER_H */ diff --git a/src/sfnt/sfnt.c b/src/sfnt/sfnt.c index cca73425c..a933338d9 100644 --- a/src/sfnt/sfnt.c +++ b/src/sfnt/sfnt.c @@ -18,40 +18,18 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - -#ifdef FT_FLAT_COMPILE - -#include "ttload.c" -#include "ttcmap.c" -#include "sfobjs.c" +#include +#include FT_SOURCE_FILE(sfnt,ttload.c) +#include FT_SOURCE_FILE(sfnt,ttcmap.c) +#include FT_SOURCE_FILE(sfnt,sfobjs.c) +#include FT_SOURCE_FILE(sfnt,sfdriver.c) #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS -#include "ttsbit.c" +#include FT_SOURCE_FILE(sfnt,ttsbit.c) #endif #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES -#include "ttpost.c" +#include FT_SOURCE_FILE(sfnt,ttpost.c) #endif -#include "sfdriver.c" - -#else /* FT_FLAT_COMPILE */ - -#include -#include -#include - -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS -#include -#endif - -#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES -#include -#endif - -#include - -#endif /* FT_FLAT_COMPILE */ - - /* END */ diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index f3e0f689d..cee509a15 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -15,25 +15,14 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "sfobjs.h" -#include "ttload.h" - -#else - -#include -#include - -#endif - - -#include -#include -#include -#include -#include +#include +#include FT_SOURCE_FILE(sfnt,sfobjs.h) +#include FT_SOURCE_FILE(sfnt,ttload.h) +#include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_TRUETYPE_NAMES_H +#include FT_TRUETYPE_TAGS_H +#include FT_INTERNAL_TRUETYPE_ERRORS_H /*************************************************************************/ diff --git a/src/sfnt/sfobjs.h b/src/sfnt/sfobjs.h index a334978e1..7e32b1df5 100644 --- a/src/sfnt/sfobjs.h +++ b/src/sfnt/sfobjs.h @@ -19,14 +19,11 @@ #ifndef SFOBJS_H #define SFOBJS_H -#include -#include - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_OBJECTS_H +FT_BEGIN_HEADER FT_LOCAL FT_Error SFNT_Init_Face( FT_Stream stream, @@ -46,10 +43,7 @@ void SFNT_Done_Face( TT_Face face ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* SFDRIVER_H */ diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c index b62ec2c93..6b02b0724 100644 --- a/src/sfnt/ttcmap.c +++ b/src/sfnt/ttcmap.c @@ -15,22 +15,11 @@ /* */ /***************************************************************************/ - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ttload.h" -#include "ttcmap.h" - -#else - -#include -#include - -#endif +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_TRUETYPE_ERRORS_H +#include FT_SOURCE_FILE(sfnt,ttload.h) +#include FT_SOURCE_FILE(sfnt,ttcmap.h) /*************************************************************************/ diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index 3b95d2fdb..d2a19d676 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -16,25 +16,13 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ttload.h" -#include "ttcmap.h" - -#else - -#include -#include - -#endif - +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_TRUETYPE_ERRORS_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include FT_SOURCE_FILE(sfnt,ttload.h) +#include FT_SOURCE_FILE(sfnt,ttcmap.h) /*************************************************************************/ /* */ diff --git a/src/sfnt/ttload.h b/src/sfnt/ttload.h index 181119189..de4d66f7b 100644 --- a/src/sfnt/ttload.h +++ b/src/sfnt/ttload.h @@ -20,15 +20,12 @@ #ifndef TTLOAD_H #define TTLOAD_H - -#include -#include +#include +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_TRUETYPE_TYPES_H -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER FT_LOCAL TT_Table* TT_LookUp_Table( TT_Face face, @@ -129,10 +126,7 @@ #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* TTLOAD_H */ diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c index 6fe7e2b21..d9c529eb5 100644 --- a/src/sfnt/ttpost.c +++ b/src/sfnt/ttpost.c @@ -24,23 +24,12 @@ /* */ /*************************************************************************/ - -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ttpost.h" -#include "ttload.h" - -#else - -#include -#include - -#endif +#include +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_TRUETYPE_ERRORS_H +#include FT_TRUETYPE_TAGS_H +#include FT_SOURCE_FILE(sfnt,ttpost.h) +#include FT_SOURCE_FILE(sfnt,ttload.h) /*************************************************************************/ diff --git a/src/sfnt/ttpost.h b/src/sfnt/ttpost.h index c7a8e94f0..fef0aa32c 100644 --- a/src/sfnt/ttpost.h +++ b/src/sfnt/ttpost.h @@ -20,13 +20,11 @@ #ifndef TTPOST_H #define TTPOST_H -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_CONFIG_CONFIG_H +#include FT_INTERNAL_TRUETYPE_TYPES_H +FT_BEGIN_HEADER #define TT_Err_Invalid_Post_Table_Format 0x0B00 #define TT_Err_Invalid_Post_Table 0x0B01 @@ -41,10 +39,7 @@ void TT_Free_Post_Names( TT_Face face ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* TTPOST_H */ diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index a31f6ed63..b2063571c 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -15,23 +15,12 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ttsbit.h" - -#else - -#include - -#endif - +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_TRUETYPE_ERRORS_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include FT_SOURCE_FILE(sfnt,ttsbit.h) /*************************************************************************/ /* */ diff --git a/src/sfnt/ttsbit.h b/src/sfnt/ttsbit.h index ce941b886..6c00b0cb5 100644 --- a/src/sfnt/ttsbit.h +++ b/src/sfnt/ttsbit.h @@ -19,21 +19,10 @@ #ifndef TTSBIT_H #define TTSBIT_H +#include +#include FT_SOURCE_FILE(sfnt,ttload.h) -#ifdef FT_FLAT_COMPILE - -#include "ttload.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif +FT_BEGIN_HEADER FT_LOCAL @@ -60,10 +49,7 @@ TT_SBit_Metrics *metrics ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* TTSBIT_H */ diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index 6b67705fb..ca863b7ee 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -122,21 +122,11 @@ #else /* _STANDALONE_ */ - -#ifdef FT_FLAT_COMPILE - -#include "ftgrays.h" - -#else - -#include - -#endif - - -#include /* for FT_UNUSED() */ -#include /* for FT_TRACE() and FT_ERROR() */ -#include /* for FT_Outline_Decompose() */ +#include +#include FT_SOURCE_FILE(smooth,ftgrays.h) +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_DEBUG_H +#include FT_OUTLINE_H #define ErrRaster_Invalid_Mode FT_Err_Cannot_Render_Glyph #define ErrRaster_Invalid_Outline FT_Err_Invalid_Outline diff --git a/src/smooth/ftgrays.h b/src/smooth/ftgrays.h index 5055f6d26..cfbd8bbd2 100644 --- a/src/smooth/ftgrays.h +++ b/src/smooth/ftgrays.h @@ -25,7 +25,8 @@ #ifdef _STANDALONE_ #include "ftimage.h" #else -#include +#include +#include FT_IMAGE_H #endif /*************************************************************************/ diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c index 09e1ce7fa..47f201b88 100644 --- a/src/smooth/ftsmooth.c +++ b/src/smooth/ftsmooth.c @@ -15,23 +15,11 @@ /* */ /***************************************************************************/ - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ftsmooth.h" -#include "ftgrays.h" - -#else - -#include -#include - -#endif - +#include +#include FT_INTERNAL_OBJECTS_H +#include FT_OUTLINE_H +#include FT_SOURCE_FILE(smooth,ftsmooth.h) +#include FT_SOURCE_FILE(smooth,ftgrays.h) /* initialize renderer -- init its raster */ static diff --git a/src/smooth/ftsmooth.h b/src/smooth/ftsmooth.h index 723b4141b..332e18e8f 100644 --- a/src/smooth/ftsmooth.h +++ b/src/smooth/ftsmooth.h @@ -19,13 +19,11 @@ #ifndef FTSMOOTH_H #define FTSMOOTH_H -#include +#include +#include FT_RENDER_H -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER #ifndef FT_CONFIG_OPTION_NO_STD_RASTER FT_EXPORT_VAR( const FT_Renderer_Class ) ft_std_renderer_class; @@ -35,10 +33,7 @@ FT_EXPORT_VAR( const FT_Renderer_Class ) ft_smooth_renderer_class; #endif -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* FTSMOOTH_H */ diff --git a/src/smooth/smooth.c b/src/smooth/smooth.c index 41cc4aea5..d9f186e15 100644 --- a/src/smooth/smooth.c +++ b/src/smooth/smooth.c @@ -18,18 +18,8 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - -#ifdef FT_FLAT_COMPILE - -#include "ftgrays.c" -#include "ftsmooth.c" - -#else - -#include -#include - -#endif - +#include +#include FT_SOURCE_FILE(smooth,ftgrays.c) +#include FT_SOURCE_FILE(smooth,ftsmooth.c) /* END */ diff --git a/src/truetype/truetype.c b/src/truetype/truetype.c index 55ba0c9d4..c6ca1fc59 100644 --- a/src/truetype/truetype.c +++ b/src/truetype/truetype.c @@ -18,30 +18,14 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - -#ifdef FT_FLAT_COMPILE - -#include "ttdriver.c" /* driver interface */ -#include "ttpload.c" /* tables loader */ -#include "ttgload.c" /* glyph loader */ -#include "ttobjs.c" /* object manager */ +#include +#include FT_SOURCE_FILE(truetype,ttdriver.c) /* driver interface */ +#include FT_SOURCE_FILE(truetype,ttpload.c) /* tables loader */ +#include FT_SOURCE_FILE(truetype,ttgload.c) /* glyph loader */ +#include FT_SOURCE_FILE(truetype,ttobjs.c) /* object manager */ #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER -#include "ttinterp.c" /* bytecode interpreter */ +#include FT_SOURCE_FILE(truetype,ttinterp.c) #endif -#else /* FT_FLAT_COMPILE */ - -#include /* driver interface */ -#include /* tables loader */ -#include /* glyph loader */ -#include /* object manager */ - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER -#include /* bytecode interpreter */ -#endif - -#endif /* FT_FLAT_COMPILE */ - - /* END */ diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index cddd40794..bbdd67c07 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -15,24 +15,13 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ttdriver.h" -#include "ttgload.h" - -#else - -#include -#include - -#endif +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_SFNT_H +#include FT_TRUETYPE_NAMES_H +#include FT_SOURCE_FILE(truetype,ttdriver.h) +#include FT_SOURCE_FILE(truetype,ttgload.h) /*************************************************************************/ diff --git a/src/truetype/ttdriver.h b/src/truetype/ttdriver.h index a0a275e6e..1c5f305d6 100644 --- a/src/truetype/ttdriver.h +++ b/src/truetype/ttdriver.h @@ -19,21 +19,15 @@ #ifndef TTDRIVER_H #define TTDRIVER_H -#include - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_DRIVER_H +FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Driver_Class ) tt_driver_class; -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* TTDRIVER_H */ diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index 9bb313f87..ac610bb8a 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -15,24 +15,15 @@ /* */ /***************************************************************************/ +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_SFNT_H +#include FT_TRUETYPE_TAGS_H +#include FT_OUTLINE_H -#include -#include -#include -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ttgload.h" - -#else - -#include - -#endif +#include FT_SOURCE_FILE(truetype,ttgload.h) /*************************************************************************/ diff --git a/src/truetype/ttgload.h b/src/truetype/ttgload.h index 990337e6a..0a47f2eb8 100644 --- a/src/truetype/ttgload.h +++ b/src/truetype/ttgload.h @@ -19,30 +19,14 @@ #ifndef TTGLOAD_H #define TTGLOAD_H - -#ifdef FT_FLAT_COMPILE - -#include "ttobjs.h" +#include +#include FT_SOURCE_FILE(truetype,ttobjs.h) #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER -#include "ttinterp.h" -#endif - -#else /* FT_FLAT_COMPILE */ - -#include - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER -#include -#endif - -#endif /* FT_FLAT_COMPILE */ - - -#ifdef __cplusplus - extern "C" { +#include FT_SOURCE_FILE(truetype,ttinterp.h) #endif +FT_BEGIN_HEADER FT_LOCAL void TT_Get_Metrics( TT_HoriHeader* header, @@ -59,9 +43,7 @@ FT_UShort glyph_index, FT_UInt load_flags ); -#ifdef __cplusplus - } -#endif +FT_END_HEADER #endif /* TTGLOAD_H */ diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index e9dd074b1..685db5c23 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -15,24 +15,12 @@ /* */ /***************************************************************************/ - -#include -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ttinterp.h" - -#else - -#include - -#endif - - -#include +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H +#include FT_SYSTEM_H +#include FT_SOURCE_FILE(truetype,ttinterp.h) +#include FT_INTERNAL_TRUETYPE_ERRORS_H #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h index 1094aedac..cd4d6983a 100644 --- a/src/truetype/ttinterp.h +++ b/src/truetype/ttinterp.h @@ -19,36 +19,24 @@ #ifndef TTINTERP_H #define TTINTERP_H +#include +#include FT_SOURCE_FILE(truetype,ttobjs.h) -#ifdef FT_FLAT_COMPILE - -#include "ttobjs.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER #ifndef TT_CONFIG_OPTION_STATIC_INTEPRETER /* indirect implementation */ -#define EXEC_OP_ TT_ExecContext exc, -#define EXEC_OP TT_ExecContext exc -#define EXEC_ARG_ exc, -#define EXEC_ARG exc +# define EXEC_OP_ TT_ExecContext exc, +# define EXEC_OP TT_ExecContext exc +# define EXEC_ARG_ exc, +# define EXEC_ARG exc #else /* static implementation */ -#define EXEC_OP_ /* void */ -#define EXEC_OP /* void */ -#define EXEC_ARG_ /* void */ -#define EXEC_ARG /* void */ +# define EXEC_OP_ /* void */ +# define EXEC_OP /* void */ +# define EXEC_ARG_ /* void */ +# define EXEC_ARG /* void */ #endif /* TT_CONFIG_OPTION_STATIC_INTERPRETER */ @@ -311,9 +299,7 @@ FT_EXPORT( FT_Error ) TT_RunIns( TT_ExecContext exec ); -#ifdef __cplusplus - } -#endif +FT_END_HEADER #endif /* TTINTERP_H */ diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index 0df6a9560..8801b2a34 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -15,41 +15,23 @@ /* */ /***************************************************************************/ +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_NAMES_H +#include FT_TRUETYPE_TAGS_H +#include FT_INTERNAL_SFNT_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_INTERNAL_TRUETYPE_ERRORS_H -#include -#include -#include -#include -#include - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "ttgload.h" -#include "ttpload.h" +#include FT_SOURCE_FILE(truetype,ttgload.h) +#include FT_SOURCE_FILE(truetype,ttpload.h) #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER -#include "ttinterp.h" +#include FT_SOURCE_FILE(truetype,ttinterp.h) #endif -#else /* FT_FLAT_COMPILE */ - -#include -#include - -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER -#include -#endif - -#endif /* FT_FLAT_COMPILE */ - - -#include - - /*************************************************************************/ /* */ diff --git a/src/truetype/ttobjs.h b/src/truetype/ttobjs.h index 9fa331e38..08d4d5890 100644 --- a/src/truetype/ttobjs.h +++ b/src/truetype/ttobjs.h @@ -19,15 +19,12 @@ #ifndef TTOBJS_H #define TTOBJS_H +#include +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_TRUETYPE_TYPES_H +#include FT_INTERNAL_TRUETYPE_ERRORS_H -#include -#include -#include - - -#ifdef __cplusplus - extern "C" { -#endif +FT_BEGIN_HEADER /*************************************************************************/ @@ -416,9 +413,7 @@ void TT_Done_Driver( TT_Driver driver ); -#ifdef __cplusplus - } -#endif +FT_END_HEADER #endif /* TTOBJS_H */ diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c index f7b812cbb..e56e1af71 100644 --- a/src/truetype/ttpload.c +++ b/src/truetype/ttpload.c @@ -1,6 +1,6 @@ /***************************************************************************/ /* */ -/* ttpload.h */ +/* ttpload.c */ /* */ /* TrueType glyph data/program tables loader (body). */ /* */ @@ -15,19 +15,13 @@ /* */ /***************************************************************************/ - -#include -#include -#include -#include - -#ifdef FT_FLAT_COMPILE -#include "ttpload.h" -#else -#include -#endif - -#include +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_OBJECTS_H +#include FT_INTERNAL_STREAM_H +#include FT_TRUETYPE_TAGS_H +#include FT_SOURCE_FILE(truetype,ttpload.h) +#include FT_INTERNAL_TRUETYPE_ERRORS_H /*************************************************************************/ diff --git a/src/truetype/ttpload.h b/src/truetype/ttpload.h index 7d8b8d927..7ee4f8c9c 100644 --- a/src/truetype/ttpload.h +++ b/src/truetype/ttpload.h @@ -19,13 +19,10 @@ #ifndef TTPLOAD_H #define TTPLOAD_H -#include - - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_TRUETYPE_TYPES_H +FT_BEGIN_HEADER FT_LOCAL FT_Error TT_Load_Locations( TT_Face face, @@ -39,11 +36,7 @@ FT_Error TT_Load_Programs( TT_Face face, FT_Stream stream ); - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* TTPLOAD_H */ diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c index d168f82c1..7c4cc2d82 100644 --- a/src/type1/t1afm.c +++ b/src/type1/t1afm.c @@ -15,21 +15,10 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "t1afm.h" - -#else - -#include - -#endif - - -#include -#include - +#include +#include FT_SOURCE_FILE(type1,t1afm.h) +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_TYPE1_TYPES_H #include /* for qsort() */ #include /* for strcmp() */ #include /* for isalnum() */ diff --git a/src/type1/t1afm.h b/src/type1/t1afm.h index 397af573a..a5cc08539 100644 --- a/src/type1/t1afm.h +++ b/src/type1/t1afm.h @@ -19,22 +19,10 @@ #ifndef T1AFM_H #define T1AFM_H +#include +#include FT_SOURCE_FILE(type1,t1objs.h) -#ifdef FT_FLAT_COMPILE - -#include "t1objs.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER typedef struct T1_Kern_Pair_ { @@ -67,11 +55,7 @@ FT_UInt glyph2, FT_Vector* kerning ); - -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* T1AFM_H */ diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index ea8ab911c..dcda8e332 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -15,33 +15,18 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "t1driver.h" -#include "t1gload.h" -#include "t1load.h" +#include +#include FT_SOURCE_FILE(type1,t1driver.h) +#include FT_SOURCE_FILE(type1,t1gload.h) +#include FT_SOURCE_FILE(type1,t1load.h) #ifndef T1_CONFIG_OPTION_NO_AFM -#include "t1afm.h" +#include FT_SOURCE_FILE(type1,t1afm.h) #endif -#else - -#include -#include -#include - -#ifndef T1_CONFIG_OPTION_NO_AFM -#include -#endif - -#endif - - -#include -#include -#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_POSTSCRIPT_NAMES_H #include /* for strcmp() */ diff --git a/src/type1/t1driver.h b/src/type1/t1driver.h index 5354a4fa6..8282d89e3 100644 --- a/src/type1/t1driver.h +++ b/src/type1/t1driver.h @@ -19,19 +19,14 @@ #ifndef T1DRIVER_H #define T1DRIVER_H -#include - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_DRIVER_H +FT_BEGIN_HEADER FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class; -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* T1DRIVER_H */ diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index ef258e15b..d21d7ccd2 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -15,24 +15,12 @@ /* */ /***************************************************************************/ - -#ifdef FT_FLAT_COMPILE - -#include "t1gload.h" - -#else - -#include - -#endif - - -#include -#include -#include -#include - - +#include +#include FT_SOURCE_FILE(type1,t1gload.h) +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H +#include FT_OUTLINE_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H #include /* for strcmp() */ diff --git a/src/type1/t1gload.h b/src/type1/t1gload.h index a0d954294..cc47559cb 100644 --- a/src/type1/t1gload.h +++ b/src/type1/t1gload.h @@ -19,22 +19,10 @@ #ifndef T1GLOAD_H #define T1GLOAD_H +#include +#include FT_SOURCE_FILE(type1,t1objs.h) -#ifdef FT_FLAT_COMPILE - -#include "t1objs.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif - +FT_BEGIN_HEADER FT_LOCAL FT_Error T1_Compute_Max_Advance( T1_Face face, @@ -47,10 +35,7 @@ FT_Int load_flags ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* T1GLOAD_H */ diff --git a/src/type1/t1load.c b/src/type1/t1load.c index 6e5a47a2c..7606ef769 100644 --- a/src/type1/t1load.c +++ b/src/type1/t1load.c @@ -60,26 +60,14 @@ /* */ /*************************************************************************/ +#include +#include FT_INTERNAL_DEBUG_H +#include FT_CONFIG_CONFIG_H +#include FT_MULTIPLE_MASTERS_H +#include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_TYPE1_ERRORS_H -#include -#include -#include - -#include -#include - - -#ifdef FT_FLAT_COMPILE - -#include "t1load.h" - -#else - -#include - -#endif - - +#include FT_SOURCE_FILE(type1,t1load.h) #include /* for strncmp(), strcmp() */ #include /* for isalnum() */ @@ -1382,15 +1370,7 @@ const T1_Field t1_keywords[] = { -#ifdef FT_FLAT_COMPILE - -#include "t1tokens.h" - -#else - -#include - -#endif +#include FT_SOURCE_FILE(type1,t1tokens.h) /* now add the special functions... */ T1_FIELD_CALLBACK( "FontName", parse_font_name ) diff --git a/src/type1/t1load.h b/src/type1/t1load.h index 4d2f4b9e4..6f1dcb86e 100644 --- a/src/type1/t1load.h +++ b/src/type1/t1load.h @@ -19,25 +19,14 @@ #ifndef T1LOAD_H #define T1LOAD_H -#include -#include -#include +#include +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_MULTIPLE_MASTERS_H +#include FT_SOURCE_FILE(type1,t1parse.h) -#ifdef FT_FLAT_COMPILE - -#include "t1parse.h" - -#else - -#include - -#endif - - -#ifdef __cplusplus - extern "C" { -#endif +FT_BEGIN_HEADER typedef struct T1_Loader_ { @@ -83,9 +72,7 @@ #endif /* !T1_CONFIG_OPTION_NO_MM_SUPPORT */ -#ifdef __cplusplus - } -#endif +FT_END_HEADER #endif /* T1LOAD_H */ diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 9f5851ffe..77ee296af 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -15,36 +15,20 @@ /* */ /***************************************************************************/ - -#include -#include - +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_STREAM_H #include /* strcmp() */ - -#ifdef FT_FLAT_COMPILE - -#include "t1gload.h" -#include "t1load.h" +#include FT_SOURCE_FILE(type1,t1gload.h) +#include FT_SOURCE_FILE(type1,t1load.h) #ifndef T1_CONFIG_OPTION_NO_AFM -#include "t1afm.h" +#include FT_SOURCE_FILE(type1,t1afm.h) #endif -#else - -#include -#include - -#ifndef T1_CONFIG_OPTION_NO_AFM -#include -#endif - -#endif - - -#include -#include +#include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H /*************************************************************************/ diff --git a/src/type1/t1objs.h b/src/type1/t1objs.h index 3081b3f7f..3bd1f8477 100644 --- a/src/type1/t1objs.h +++ b/src/type1/t1objs.h @@ -19,14 +19,13 @@ #ifndef T1OBJS_H #define T1OBJS_H -#include -#include -#include -#include +#include +#include FT_INTERNAL_OBJECTS_H +#include FT_CONFIG_CONFIG_H +#include FT_INTERNAL_TYPE1_ERRORS_H +#include FT_INTERNAL_TYPE1_TYPES_H -#ifdef __cplusplus - extern "C" { -#endif +FT_BEGIN_HEADER /* The following structures must be defined by the hinter */ typedef struct T1_Size_Hints_ T1_Size_Hints; @@ -151,9 +150,7 @@ void T1_Done_Driver( T1_Driver driver ); -#ifdef __cplusplus - } -#endif +FT_END_HEADER #endif /* T1OBJS_H */ diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c index 97a14ab2e..b3d5c02b8 100644 --- a/src/type1/t1parse.c +++ b/src/type1/t1parse.c @@ -32,25 +32,13 @@ /* */ /*************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#ifdef FT_FLAT_COMPILE - -#include "t1parse.h" - -#else - -#include - -#endif - - +#include +#include FT_INTERNAL_DEBUG_H +#include FT_INTERNAL_CALC_H +#include FT_INTERNAL_STREAM_H +#include FT_INTERNAL_TYPE1_ERRORS_H +#include FT_INTERNAL_POSTSCRIPT_AUX_H +#include FT_SOURCE_FILE(type1,t1parse.h) #include /* for strncmp() */ diff --git a/src/type1/t1parse.h b/src/type1/t1parse.h index f114e7790..2bb47e26e 100644 --- a/src/type1/t1parse.h +++ b/src/type1/t1parse.h @@ -19,13 +19,11 @@ #ifndef T1PARSE_H #define T1PARSE_H -#include -#include - -#ifdef __cplusplus - extern "C" { -#endif +#include +#include FT_INTERNAL_TYPE1_TYPES_H +#include FT_INTERNAL_STREAM_H +FT_BEGIN_HEADER /*************************************************************************/ /* */ @@ -125,10 +123,7 @@ void T1_Finalize_Parser( T1_ParserRec* parser ); -#ifdef __cplusplus - } -#endif - +FT_END_HEADER #endif /* T1PARSE_H */ diff --git a/src/type1/type1.c b/src/type1/type1.c index d01c1cbde..abcf5abcc 100644 --- a/src/type1/type1.c +++ b/src/type1/type1.c @@ -18,32 +18,15 @@ #define FT_MAKE_OPTION_SINGLE_OBJECT - -#ifdef FT_FLAT_COMPILE - -#include "t1parse.c" -#include "t1load.c" -#include "t1objs.c" -#include "t1driver.c" -#include "t1gload.c" +#include +#include FT_SOURCE_FILE(type1,t1parse.c) +#include FT_SOURCE_FILE(type1,t1load.c) +#include FT_SOURCE_FILE(type1,t1objs.c) +#include FT_SOURCE_FILE(type1,t1driver.c) +#include FT_SOURCE_FILE(type1,t1gload.c) #ifndef T1_CONFIG_OPTION_NO_AFM -#include "t1afm.c" +#include FT_SOURCE_FILE(type1,t1afm.c) #endif -#else /* FT_FLAT_COMPILE */ - -#include -#include -#include -#include -#include - -#ifndef T1_CONFIG_OPTION_NO_AFM -#include -#endif - -#endif /* FT_FLAT_COMPILE */ - - /* END */