From afdc4c4c2b996ec48ac9fee27cdaff685cc3c9ee Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 10 Feb 2000 16:08:36 +0000 Subject: [PATCH] Updates to the Type 1 driver Now with a simple AFM parser in order to read the kerning table.. --- src/type1/rules.mk | 1 + src/type1/t1config.h | 9 +++- src/type1/t1driver.c | 102 +++++++++++++++++++++++++++++++++++++++++++ src/type1/type1.c | 9 +++- 4 files changed, 118 insertions(+), 3 deletions(-) diff --git a/src/type1/rules.mk b/src/type1/rules.mk index 3b6355b37..794ea0a9a 100644 --- a/src/type1/rules.mk +++ b/src/type1/rules.mk @@ -103,6 +103,7 @@ T1_DRV_SRC := $(T1_DIR_)t1objs.c \ $(T1_DIR_)t1driver.c \ $(T1_DIR_)t1encode.c \ $(T1_DIR_)t1hinter.c \ + $(T1_DIR_)t1afm.c \ $(T1_DIR_)t1gload.c diff --git a/src/type1/t1config.h b/src/type1/t1config.h index a72b177b2..7b4119bc6 100644 --- a/src/type1/t1config.h +++ b/src/type1/t1config.h @@ -40,6 +40,13 @@ /* Define T1_CONFIG_OPTION_DISABLE_HINTER if you want to generate */ /* a driver with no hinter. This can be useful to debug the parser */ /* */ -#undef T1_CONFIG_OPTION_DISABLE_HINTER +#define T1_CONFIG_OPTION_DISABLE_HINTER + +/* Define this configuration macro if you want to prevent the */ +/* compilation of "t1afm", which is in charge of reading Type1 */ +/* AFM files into an existing face. Note that when set, the T1 */ +/* driver will be unable to produce kerning distances.. */ +/* */ +#define T1_CONFIG_OPTION_NO_AFM #endif /* T1CONFIG_H */ diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index b137ddcf4..0f6ee5447 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -25,6 +26,97 @@ #undef FT_COMPONENT #define FT_COMPONENT trace_t1driver +#ifndef T1_CONFIG_OPTION_NO_AFM + /*************************************************************************/ + /* */ + /* */ + /* Get_Interface */ + /* */ + /* */ + /* Each driver can provide one or more extensions to the base */ + /* FreeType API. These can be used to access format specific */ + /* features (e.g., all TrueType/OpenType resources share a common */ + /* file structure and common tables which can be accessed through the */ + /* `sfnt' interface), or more simply generic ones (e.g., the */ + /* `postscript names' interface which can be used to retrieve the */ + /* PostScript name of a given glyph index). */ + /* */ + /* */ + /* driver :: A handle to a driver object. */ + /* */ + /* */ + /* interface :: A string designing the interface. Examples are */ + /* `sfnt', `post_names', `charmaps', etc. */ + /* */ + /* */ + /* A typeless pointer to the extension's interface (normally a table */ + /* of function pointers). Returns NULL if the requested extension */ + /* isn't available (i.e., wasn't compiled in the driver at build */ + /* time). */ + /* */ + static + void* Get_Interface)( FT_Driver driver, + const FT_String* interface ) + { + if ( strcmp( (const char*)interface, "attach_file" ) == 0 ) + return T1_Read_AFM; + + return 0; + } + + + + /*************************************************************************/ + /* */ + /* */ + /* 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 + T1_Error Get_Kerning( T1_Face face, + T1_UInt left_glyph, + T1_UInt right_glyph, + T1_Vector* kerning ) + { + T1_AFM* afm; + + kerning->x = 0; + kerning->y = 0; + + afm = (T1_AFM*)face->afm_data; + if (afm) + T1_Get_Kerning( afm, left_glyph, right_glyph, kerning ); + + return T1_Err_Ok; + } +#endif + /******************************************************************/ /* */ /* Set_Char_Sizes */ @@ -394,11 +486,21 @@ (FTDriver_initDriver) T1_Init_Driver, (FTDriver_doneDriver) T1_Done_Driver, + +#ifdef T1_CONFIG_OPTION_NO_AFM (FTDriver_getInterface) 0, +#else + (FTDriver_getInterface) Get_Interface, +#endif (FTDriver_initFace) Init_Face, (FTDriver_doneFace) T1_Done_Face, + +#ifdef T1_CONFIG_OPTION_NO_AFM (FTDriver_getKerning) 0, +#else + (FTDriver_getKerning) Get_Kerning, +#endif (FTDriver_initSize) T1_Init_Size, (FTDriver_doneSize) T1_Done_Size, diff --git a/src/type1/type1.c b/src/type1/type1.c index f7058d0b1..2e7c80d7d 100644 --- a/src/type1/type1.c +++ b/src/type1/type1.c @@ -42,9 +42,14 @@ #include #include /* table loader */ #include - #include #include #include -#include +#ifndef T1_CONFIG_OPTION_DISABLE_HINTER +#include +#endif + +#ifndef T1_CONFIG_OPTION_NO_AFM +#include +#endif