Updates to the Type 1 driver

Now with a simple AFM parser in order
to read the kerning table..
This commit is contained in:
David Turner 2000-02-10 16:08:36 +00:00
parent 51d4e28daf
commit afdc4c4c2b
4 changed files with 118 additions and 3 deletions

View File

@ -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

View File

@ -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 */

View File

@ -17,6 +17,7 @@
#include <t1driver.h>
#include <t1gload.h>
#include <t1afm.h>
#include <ftdebug.h>
#include <ftstream.h>
@ -25,6 +26,97 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_t1driver
#ifndef T1_CONFIG_OPTION_NO_AFM
/*************************************************************************/
/* */
/* <Function> */
/* Get_Interface */
/* */
/* <Description> */
/* 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). */
/* */
/* <InOut> */
/* driver :: A handle to a driver object. */
/* */
/* <Input> */
/* interface :: A string designing the interface. Examples are */
/* `sfnt', `post_names', `charmaps', etc. */
/* */
/* <Return> */
/* 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;
}
/*************************************************************************/
/* */
/* <Function> */
/* Get_Kerning */
/* */
/* <Description> */
/* A driver method used to return the kerning vector between two */
/* glyphs of the same face. */
/* */
/* <Input> */
/* 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. */
/* */
/* <Output> */
/* kerning :: The kerning vector. This is in font units for */
/* scalable formats, and in pixels for fixed-sizes */
/* formats. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* 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
/******************************************************************/
/* */
/* <Function> 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,

View File

@ -42,9 +42,14 @@
#include <t1objs.c>
#include <t1load.c> /* table loader */
#include <t1gload.c>
#include <t1tokens.c>
#include <t1parse.c>
#include <t1encode.c>
#include <t1hinter.c>
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
#include <t1hinter.c>
#endif
#ifndef T1_CONFIG_OPTION_NO_AFM
#include <t1afm.c>
#endif