Formatting; fixing documentation.

This commit is contained in:
Werner Lemberg 2000-07-03 16:45:15 +00:00
parent d18388e44b
commit d0c36e3b5a
5 changed files with 791 additions and 810 deletions

View File

@ -27,6 +27,7 @@
#include <string.h> /* for strncpy(), strncmp(), strlen() */
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */

View File

@ -1,19 +1,20 @@
/*******************************************************************
*
* t1objs.c 1.0
*
* Type1 Objects manager.
*
* Copyright 1996-1998 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.
*
******************************************************************/
/***************************************************************************/
/* */
/* t1objs.c */
/* */
/* Type 1 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 <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
@ -28,116 +29,122 @@
#include <freetype/internal/psnames.h>
/* Required by tracing mode */
#undef FT_COMPONENT
#define FT_COMPONENT trace_t1objs
/*******************************************************************
* *
* SIZE FUNCTIONS *
* *
* *
*******************************************************************/
/*******************************************************************
*
* <Function> T1_Done_Size
*
* <Description>
* The TrueDoc instance object destructor. Used to discard
* a given instance object..
*
* <Input>
* instance :: handle to the target instance object
*
* <Return>
* TrueDoc error code. 0 means success
*
******************************************************************/
/*************************************************************************/
/* */
/* 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_t1objs
/*************************************************************************/
/* */
/* SIZE FUNCTIONS */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* T1_Done_Size */
/* */
/* <Description> */
/* The Type 1 size object destructor. Used to discard a given size */
/* object. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
LOCAL_FUNC
void T1_Done_Size( T1_Size size )
{
if (size)
if ( size )
{
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
T1_Done_Size_Hinter( size );
#endif
size->valid = 0;
}
}
/*******************************************************************
*
* <Function> T1_Init_Size
*
* <Description>
* The instance object constructor
*
* <Input>
* instance : handle to new instance object
* face : pointer to parent face object
*
* <Return>
* TrueDoc error code. 0 means success.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* T1_Init_Size */
/* */
/* <Description> */
/* The size object initializer. */
/* */
/* <Input> */
/* size :: A handle to the target size object. */
/* */
/* <Return> */
/* FreeTrue error code. 0 means success. */
/* */
LOCAL_DEF
FT_Error T1_Init_Size( T1_Size size )
{
FT_Error error;
FT_Error error;
size->valid = 0;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
error = T1_New_Size_Hinter( size );
return error;
#else
(void)error;
UNUSED( error );
return T1_Err_Ok;
#endif
}
/*******************************************************************
*
* <Function> T1_Reset_Size
*
* <Description>
* Resets an instance to a new pointsize/transform.
* This function is in charge of resetting the blue zones,
* As well as the stem snap tables for a given size..
*
* <Input>
* instance the instance object to destroy
*
* <Output>
* Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* T1_Reset_Size */
/* */
/* <Description> */
/* Resets an instance to a new pointsize/transform. This function is */
/* in charge of resetting the blue zones,a s well as the stem snap */
/* tables for a given size. */
/* */
/* <Input> */
/* size :: The target size object. */
/* */
/* <Output> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Reset_Size( T1_Size size )
{
/* recompute ascender, descender, etc.. */
/* recompute ascender, descender, etc. */
T1_Face face = (T1_Face)size->root.face;
FT_Size_Metrics* metrics = &size->root.metrics;
if ( metrics->x_ppem < 1 || metrics->y_ppem < 1 )
return FT_Err_Invalid_Argument;
/* Compute root ascender, descender, test height, and max_advance */
metrics->ascender = ( FT_MulFix( face->root.ascender,
metrics->y_scale ) + 32 ) & -64;
metrics->descender = ( FT_MulFix( face->root.descender,
metrics->y_scale ) + 32 ) & -64;
metrics->height = ( FT_MulFix( face->root.height,
metrics->y_scale ) + 32 ) & -64;
metrics->ascender = ( FT_MulFix( face->root.ascender,
metrics->y_scale ) + 32 ) & -64;
metrics->descender = ( FT_MulFix( face->root.descender,
metrics->y_scale ) + 32 ) & -64;
metrics->height = ( FT_MulFix( face->root.height,
metrics->y_scale ) + 32 ) & -64;
metrics->max_advance = ( FT_MulFix( face->root.max_advance_width,
metrics->x_scale ) + 32 ) & -64;
@ -149,35 +156,33 @@
}
/*******************************************************************
* *
* FACE FUNCTIONS *
* *
* *
*******************************************************************/
/*************************************************************************/
/* */
/* FACE FUNCTIONS */
/* */
/* */
/*************************************************************************/
/*******************************************************************
*
* <Function> T1_Done_Face
*
* <Description>
* The face object destructor.
*
* <Input>
* face :: typeless pointer to the face object to destroy
*
* <Return>
* Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* T1_Done_Face */
/* */
/* <Description> */
/* The face object destructor. */
/* */
/* <Input> */
/* face :: A typeless pointer to the face object to destroy. */
/* */
LOCAL_FUNC
void T1_Done_Face( T1_Face face )
{
FT_Memory memory;
T1_Font* type1 = &face->type1;
if (face)
if ( face )
{
memory = face->root.memory;
@ -185,6 +190,7 @@
{
T1_FontInfo* info = &type1->font_info;
FREE( info->version );
FREE( info->notice );
FREE( info->full_name );
@ -209,7 +215,7 @@
#ifndef T1_CONFIG_OPTION_NO_AFM
/* release afm data if present */
if ( face->afm_data)
if ( face->afm_data )
T1_Done_AFM( memory, (T1_AFM*)face->afm_data );
#endif
@ -222,22 +228,29 @@
}
}
/*******************************************************************
*
* <Function> T1_Init_Face
*
* <Description>
* The face object constructor.
*
* <Input>
* face :: face record to build
* Input :: input stream where to load font data
*
* <Return>
* Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> T1_Init_Face */
/* */
/* <Description> */
/* The face object constructor. */
/* */
/* <Input> */
/* stream :: input stream where to load font data. */
/* */
/* face_index :: The index of the font face in the resource. */
/* */
/* num_params :: Number of additional generic parameters. Ignored. */
/* */
/* params :: Additional generic parameters. Ignored. */
/* */
/* <InOut> */
/* face :: The face record to build. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_Init_Face( FT_Stream stream,
T1_Face face,
@ -249,34 +262,37 @@
FT_Error error;
PSNames_Interface* psnames;
UNUSED(num_params);
UNUSED(params);
UNUSED(face_index);
UNUSED(face);
UNUSED( num_params );
UNUSED( params );
UNUSED( face_index );
UNUSED( face );
face->root.num_faces = 1;
psnames = (PSNames_Interface*)face->psnames;
if (!psnames)
if ( !psnames )
{
psnames = (PSNames_Interface*)
FT_Get_Module_Interface( FT_FACE_LIBRARY(face), "psnames" );
FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psnames" );
face->psnames = psnames;
}
/* open the tokenizer, this will also check the font format */
error = New_Tokenizer( stream, &tokenizer );
if (error) goto Fail;
if ( error )
goto Fail;
/* if we just wanted to check the format, leave successfully now */
if (face_index < 0)
if ( face_index < 0 )
goto Leave;
/* check the face index */
if ( face_index != 0 )
{
FT_ERROR(( "T1.Init_Face : invalid face index\n" ));
FT_ERROR(( "T1_Init_Face: invalid face index\n" ));
error = T1_Err_Invalid_Argument;
goto Leave;
}
@ -285,15 +301,18 @@
{
T1_Parser parser;
Init_T1_Parser( &parser, face, tokenizer );
error = Parse_T1_FontProgram( &parser );
if (error) goto Leave;
if ( error )
goto Leave;
/* Init the face object fields */
/* Now set up root face fields */
{
FT_Face root = (FT_Face)&face->root;
T1_Font* type1 = &face->type1;
FT_Face root = (FT_Face)&face->root;
T1_Font* type1 = &face->type1;
root->num_glyphs = type1->num_glyphs;
root->num_charmaps = 1;
@ -306,27 +325,28 @@
if ( type1->font_info.is_fixed_pitch )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
/* XXX : TO DO - add kerning with .afm support */
/* XXX: TODO -- add kerning with .afm support */
/* get style name - be careful, some broken fonts only */
/* have a /FontName dictionary entry .. !! */
/* have a `/FontName' dictionary entry! */
root->family_name = type1->font_info.family_name;
if (root->family_name)
if ( root->family_name )
{
char* full = type1->font_info.full_name;
char* family = root->family_name;
while ( *family && *full == *family )
{
family++;
full++;
}
root->style_name = ( *full == ' ' ? full+1 : "Regular" );
root->style_name = ( *full == ' ' ? full + 1 : "Regular" );
}
else
{
/* do we have a /FontName ?? */
/* do we have a `/FontName'? */
if (type1->font_name)
{
root->family_name = type1->font_name;
@ -342,21 +362,23 @@
root->units_per_EM = 1000;
root->ascender = (FT_Short)type1->font_bbox.yMax;
root->descender = -(FT_Short)type1->font_bbox.yMin;
root->height = ((root->ascender + root->descender)*12)/10;
root->height = ( ( root->ascender + root->descender) * 12 )
/ 10;
/* now compute the maximum advance width */
root->max_advance_width = type1->private_dict.standard_width[0];
/* compute max advance width for proportional fonts */
if (!type1->font_info.is_fixed_pitch)
if ( !type1->font_info.is_fixed_pitch )
{
FT_Int max_advance;
error = T1_Compute_Max_Advance( face, &max_advance );
/* in case of error, keep the standard width */
if (!error)
if ( !error )
root->max_advance_width = max_advance;
else
error = 0; /* clear error */
@ -374,21 +396,25 @@
/* charmap support - synthetize unicode charmap when possible */
{
FT_Face root = &face->root;
FT_CharMap charmap = face->charmaprecs;
FT_Face root = &face->root;
FT_CharMap charmap = face->charmaprecs;
/* synthesize a Unicode charmap if there is support in the "psnames" */
/* synthesize a Unicode charmap if there is support in the `PSNames' */
/* module.. */
if (face->psnames)
if ( face->psnames )
{
PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
if (psnames->unicode_value)
if ( psnames->unicode_value )
{
error = psnames->build_unicodes( root->memory,
face->type1.num_glyphs,
(const char**)face->type1.glyph_names,
&face->unicode_map );
if (!error)
error = psnames->build_unicodes(
root->memory,
face->type1.num_glyphs,
(const char**)face->type1.glyph_names,
&face->unicode_map );
if ( !error )
{
root->charmap = charmap;
charmap->face = (FT_Face)face;
@ -408,28 +434,28 @@
charmap->face = (FT_Face)face;
charmap->platform_id = 7; /* a new platform id for Adobe fonts ?? */
switch (face->type1.encoding_type)
switch ( face->type1.encoding_type )
{
case t1_encoding_standard:
charmap->encoding = ft_encoding_adobe_standard;
charmap->encoding_id = 0;
break;
case t1_encoding_standard:
charmap->encoding = ft_encoding_adobe_standard;
charmap->encoding_id = 0;
break;
case t1_encoding_expert:
charmap->encoding = ft_encoding_adobe_expert;
charmap->encoding_id = 1;
break;
case t1_encoding_expert:
charmap->encoding = ft_encoding_adobe_expert;
charmap->encoding_id = 1;
break;
default:
charmap->encoding = ft_encoding_adobe_custom;
charmap->encoding_id = 2;
break;
default:
charmap->encoding = ft_encoding_adobe_custom;
charmap->encoding_id = 2;
break;
}
root->charmaps = face->charmaps;
root->charmaps = face->charmaps;
root->num_charmaps = charmap - face->charmaprecs + 1;
face->charmaps[0] = &face->charmaprecs[0];
face->charmaps[1] = &face->charmaprecs[1];
face->charmaps[0] = &face->charmaprecs[0];
face->charmaps[1] = &face->charmaprecs[1];
}
Leave:
@ -440,51 +466,57 @@
}
/*******************************************************************
*
* Function : Glyph_Destroy
*
* Description : The glyph object destructor.
*
* Input : _glyph typeless pointer to the glyph record to destroy
*
* Output : Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* T1_Done_GlyphSlot */
/* */
/* <Description> */
/* The glyph slot object destructor. */
/* */
/* <Input> */
/* glyph :: The glyph slot handle to destroy. */
/* */
LOCAL_FUNC
void T1_Done_GlyphSlot( T1_GlyphSlot glyph )
{
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
T1_Done_Glyph_Hinter( glyph );
#else
UNUSED(glyph)
UNUSED( glyph );
#endif
}
/*******************************************************************
*
* Function : Glyph_Create
*
* Description : The glyph object constructor.
*
* Input : glyph glyph record to build.
* face the glyph's parent face.
*
* Output : Error code.
*
******************************************************************/
/*************************************************************************/
/* */
/* <Function> */
/* T1_Init_GlyphSlot */
/* */
/* <Description> */
/* The glyph slot object constructor. */
/* */
/* <Input> */
/* glyph :: The glyph slot handle to initialize. */
/* */
LOCAL_FUNC
FT_Error T1_Init_GlyphSlot( T1_GlyphSlot glyph )
{
FT_Error error = FT_Err_Ok;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
error = T1_New_Glyph_Hinter( glyph );
#else
UNUSED(glyph);
UNUSED( glyph );
#endif
return error;

View File

@ -1,19 +1,20 @@
/*******************************************************************
*
* t1objs.h 1.0
*
* Type1 objects definition.
*
* Copyright 1996-1999 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.
*
******************************************************************/
/***************************************************************************/
/* */
/* t1objs.h */
/* */
/* Type 1 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 T1OBJS_H
#define T1OBJS_H
@ -28,90 +29,96 @@
extern "C" {
#endif
/* The following structures must be defined by the hinter */
typedef struct T1_Size_Hints_ T1_Size_Hints;
typedef struct T1_Glyph_Hints_ T1_Glyph_Hints;
/***********************************************************************/
/* */
/* <Type> T1_Driver */
/* */
/* <Description> */
/* A handle to a Type 1 driver object. */
/* */
typedef struct T1_DriverRec_ *T1_Driver;
/*************************************************************************/
/* */
/* <Type> */
/* T1_Driver */
/* */
/* <Description> */
/* A handle to a Type 1 driver object. */
/* */
typedef struct T1_DriverRec_* T1_Driver;
/***********************************************************************/
/* */
/* <Type> T1_Size */
/* */
/* <Description> */
/* A handle to a Type 1 size object. */
/* */
/*************************************************************************/
/* */
/* <Type> */
/* T1_Size */
/* */
/* <Description> */
/* A handle to a Type 1 size object. */
/* */
typedef struct T1_SizeRec_* T1_Size;
/***********************************************************************/
/* */
/* <Type> T1_GlyphSlot */
/* */
/* <Description> */
/* A handle to a Type 1 glyph slot object. */
/* */
/*************************************************************************/
/* */
/* <Type> */
/* T1_GlyphSlot */
/* */
/* <Description> */
/* A handle to a Type 1 glyph slot object. */
/* */
typedef struct T1_GlyphSlotRec_* T1_GlyphSlot;
/***********************************************************************/
/* */
/* <Type> T1_CharMap */
/* */
/* <Description> */
/* A handle to a Type 1 character mapping object. */
/* */
/* <Note> */
/* The Type 1 format doesn't use a charmap but an encoding table. */
/* The driver is responsible for making up charmap objects */
/* corresponding to these tables.. */
/* */
typedef struct T1_CharMapRec_* T1_CharMap;
/*************************************************************************/
/* */
/* <Type> */
/* T1_CharMap */
/* */
/* <Description> */
/* A handle to a Type 1 character mapping object. */
/* */
/* <Note> */
/* The Type 1 format doesn't use a charmap but an encoding table. */
/* The driver is responsible for making up charmap objects */
/* corresponding to these tables. */
/* */
typedef struct T1_CharMapRec_* T1_CharMap;
/**************************************************************************/
/* */
/* NOW BEGINS THE TYPE1 SPECIFIC STUFF .............................. */
/* */
/**************************************************************************/
/*************************************************************************/
/* */
/* HERE BEGINS THE TYPE1 SPECIFIC STUFF */
/* */
/*************************************************************************/
/***************************************************/
/* */
/* T1_Size : */
/* */
/* Type 1 size record.. */
/* */
typedef struct T1_SizeRec_
/*************************************************************************/
/* */
/* <Type> */
/* T1_SizeRec */
/* */
/* <Description> */
/* Type 1 size record. */
/* */
typedef struct T1_SizeRec_
{
FT_SizeRec root;
FT_Bool valid;
T1_Size_Hints* hints; /* defined in the hinter. This allows */
/* us to experiment with different */
/* hinting schemes without having to */
/* change 't1objs' each time.. */
/* change `t1objs' each time. */
} T1_SizeRec;
/***************************************************/
/* */
/* T1_GlyphSlot : */
/* */
/* TrueDoc glyph record.. */
/* */
typedef struct T1_GlyphSlotRec_
/*************************************************************************/
/* */
/* <Type> */
/* T1_GlyphSlotRec */
/* */
/* <Description> */
/* Type 1 glyph slot record. */
/* */
typedef struct T1_GlyphSlotRec_
{
FT_GlyphSlotRec root;
@ -129,138 +136,32 @@
} T1_GlyphSlotRec;
/*******************************************************************
*
* <Function> T1_Init_Face
*
* <Description>
* Initialise a given Type 1 face object
*
* <Input>
* face_index :: index of font face in resource
* resource :: source font resource
* face :: face record to build
*
* <Return>
* Error code.
*
******************************************************************/
LOCAL_DEF
FT_Error T1_Init_Face( FT_Stream stream,
T1_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
/*******************************************************************
*
* <Function> T1_Done_Face
*
* <Description>
* Finalise a given face object
*
* <Input>
* face :: handle to the face object to destroy
*
******************************************************************/
FT_Error T1_Init_Face( FT_Stream stream,
T1_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
LOCAL_DEF
void T1_Done_Face( T1_Face face );
/*******************************************************************
*
* <Function> T1_Init_Size
*
* <Description>
* Initialise a new Type 1 size object
*
* <Input>
* size :: handle to size object
*
* <Return>
* Type 1 error code. 0 means success.
*
******************************************************************/
LOCAL_DEF
FT_Error T1_Init_Size( T1_Size size );
/*******************************************************************
*
* <Function> T1_Done_Size
*
* <Description>
* The Type 1 size object finaliser.
*
* <Input>
* size :: handle to the target size object.
*
******************************************************************/
LOCAL_DEF
void T1_Done_Size( T1_Size size );
/*******************************************************************
*
* <Function> T1_Reset_Size
*
* <Description>
* Reset a Type 1 size when resolutions and character dimensions
* have been changed..
*
* <Input>
* size :: handle to the target size object.
*
******************************************************************/
LOCAL_DEF
FT_Error T1_Reset_Size( T1_Size size );
/*******************************************************************
*
* <Function> T1_Init_GlyphSlot
*
* <Description> The TrueType glyph slot initialiser
*
* <Input> glyph :: glyph record to build.
*
* <Output> Error code.
*
******************************************************************/
LOCAL_DEF
FT_Error T1_Init_GlyphSlot( T1_GlyphSlot slot );
/*******************************************************************
*
* <Function> T1_Done_GlyphSlot
*
* <Description> The Type 1 glyph slot finaliser
*
* <Input> glyph :: handle to glyph slot object
*
* <Output> Error code.
*
******************************************************************/
LOCAL_DEF
void T1_Done_GlyphSlot( T1_GlyphSlot slot );
#ifdef __cplusplus
}
#endif

View File

@ -1,25 +1,48 @@
/***************************************************************************/
/* */
/* t1parse.c */
/* */
/* Type 1 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 <freetype/internal/ftdebug.h>
#include <freetype/internal/t1types.h>
#include <t1parse.h>
#include <stdio.h> /* for sscanf */
#include <stdio.h> /* for sscanf() */
#include <string.h> /* for strncpy() */
/*************************************************************************/
/* */
/* <Function> T1_New_Table */
/* */
/* <Description> */
/* Initialise a T1_Table. */
/* */
/* <Input> */
/* table :: address of target table */
/* count :: table size = maximum number of elements */
/* memory :: memory object to use for all subsequent reallocations */
/* */
/* <Return> */
/* Error code. 0 means success */
/* */
/*************************************************************************/
/* */
/* <Function> */
/* T1_New_Table */
/* */
/* <Description> */
/* Initializes a T1_Table structure. */
/* */
/* <InOut> */
/* table :: The address of the target table. */
/* */
/* <Input> */
/* count :: The table size (i.e. maximum number of elements). */
/* memory :: The memory object to use for all subsequent */
/* reallocations. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_New_Table( T1_Table* table,
FT_Int count,
@ -27,7 +50,9 @@
{
FT_Error error;
table->memory = memory;
if ( ALLOC_ARRAY( table->elements, count, FT_Byte* ) )
return error;
@ -48,64 +73,69 @@
}
/*************************************************************************/
/* */
/* <Function> T1_Add_Table */
/* */
/* <Description> */
/* Adds an object to a T1_Table, possibly growing its memory block */
/* */
/* <Input> */
/* table :: target table */
/* index :: index of object in table */
/* object :: address of object to copy in memory */
/* length :: length in bytes of source object */
/* */
/* <Return> */
/* Error code. 0 means success. An error is returned when a */
/* realloc failed.. */
/* */
static
FT_Error reallocate_t1_table( T1_Table* table,
FT_Int new_size )
{
FT_Memory memory = table->memory;
FT_Byte* old_base = table->block;
FT_Error error;
/* realloc the base block */
if ( REALLOC( table->block, table->capacity, new_size ) )
return error;
table->capacity = new_size;
/* shift all offsets when needed */
if (old_base)
{
FT_Long delta = table->block - old_base;
FT_Byte** offset = table->elements;
FT_Byte** limit = offset + table->max_elems;
if (delta)
for ( ; offset < limit; offset ++ )
if (offset[0])
offset[0] += delta;
}
return T1_Err_Ok;
}
static
FT_Error reallocate_t1_table( T1_Table* table,
FT_Int new_size )
{
FT_Memory memory = table->memory;
FT_Byte* old_base = table->block;
FT_Error error;
/* reallocate the base block */
if ( REALLOC( table->block, table->capacity, new_size ) )
return error;
table->capacity = new_size;
/* shift all offsets if necessary */
if ( old_base )
{
FT_Long delta = table->block - old_base;
FT_Byte** offset = table->elements;
FT_Byte** limit = offset + table->max_elems;
if ( delta )
for ( ; offset < limit; offset ++ )
if (offset[0])
offset[0] += delta;
}
return T1_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> */
/* T1_Add_Table */
/* */
/* <Description> */
/* Adds an object to a T1_Table, possibly growing its memory block. */
/* */
/* <InOut> */
/* table :: The target table. */
/* */
/* <Input> */
/* index :: The index of the object in the table. */
/* */
/* object :: The address of the object to copy in memory. */
/* */
/* length :: The length in bytes of the source object. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. An error is returned if a */
/* reallocation failed. */
/* */
LOCAL_FUNC
FT_Error T1_Add_Table( T1_Table* table,
FT_Int index,
void* object,
FT_Int length )
{
if (index < 0 || index > table->max_elems)
if ( index < 0 || index > table->max_elems )
{
FT_ERROR(( "T1.Add_Table: invalid index\n" ));
FT_ERROR(( "T1_Add_Table: invalid index\n" ));
return T1_Err_Syntax_Error;
}
@ -115,37 +145,41 @@
FT_Error error;
FT_Int new_size = table->capacity;
while ( new_size < table->cursor+length )
while ( new_size < table->cursor + length )
new_size += 1024;
error = reallocate_t1_table( table, new_size );
if (error) return error;
if ( error )
return error;
}
/* add the object to the base block and adjust offset */
table->elements[ index ] = table->block + table->cursor;
table->lengths [ index ] = length;
table->elements[index] = table->block + table->cursor;
table->lengths [index] = length;
MEM_Copy( table->block + table->cursor, object, length );
table->cursor += length;
return T1_Err_Ok;
}
/*************************************************************************/
/* */
/* <Function> T1_Done_Table */
/* */
/* <Description> */
/* Finalise a T1_Table. (realloc it to its current cursor). */
/* */
/* <Input> */
/* table :: target table */
/* */
/* <Note> */
/* This function does NOT release the heap's memory block. It is up */
/* to the caller to clean it, or reference it in its own structures. */
/* */
/*************************************************************************/
/* */
/* <Function> */
/* T1_Done_Table */
/* */
/* <Description> */
/* Finalize a T1_Table (reallocate it to its current cursor). */
/* */
/* <Input> */
/* table :: The target table. */
/* */
/* <Note> */
/* This function does NOT release the heap's memory block. It is up */
/* to the caller to clean it, or reference it in its own structures. */
/* */
LOCAL_FUNC
void T1_Done_Table( T1_Table* table )
{
@ -153,60 +187,64 @@
FT_Error error;
FT_Byte* old_base;
/* should never fail, as rec.cursor <= rec.size */
old_base = table->block;
if (!old_base)
if ( !old_base )
return;
(void)REALLOC( table->block, table->capacity, table->cursor );
table->capacity = table->cursor;
if (old_base != table->block)
if ( old_base != table->block )
{
FT_Long delta = table->block - old_base;
FT_Byte** element = table->elements;
FT_Byte** limit = element + table->max_elems;
FT_Long delta = table->block - old_base;
FT_Byte** element = table->elements;
FT_Byte** limit = element + table->max_elems;
for ( ; element < limit; element++ )
if (element[0])
if ( element[0] )
element[0] += delta;
}
}
LOCAL_FUNC
FT_String* CopyString( T1_Parser* parser )
FT_String* CopyString( T1_Parser* parser )
{
FT_String* string = NULL;
T1_Token* token = parser->args++;
FT_Memory memory = parser->tokenizer->memory;
FT_Error error;
if ( token->kind == tok_string )
{
int len = token->len-2;
FT_Int len = token->len - 2;
if ( ALLOC( string, len+1 ) )
if ( ALLOC( string, len + 1 ) )
{
parser->error = error;
return 0;
}
MEM_Copy( string, parser->tokenizer->base + token->start+1, len );
MEM_Copy( string, parser->tokenizer->base + token->start + 1, len );
string[len] = '\0';
parser->error = T1_Err_Ok;
}
else
{
FT_ERROR(( "T1.CopyString : syntax error, string token expected !\n" ));
FT_ERROR(( "T1_CopyString: syntax error, string token expected!\n" ));
parser->error = T1_Err_Syntax_Error;
}
return string;
}
static
FT_Error parse_int( FT_Byte* base,
FT_Byte* limit,
@ -215,7 +253,8 @@
FT_Bool sign = 0;
FT_Long sum = 0;
if (base >= limit)
if ( base >= limit )
goto Fail;
/* check sign */
@ -234,148 +273,158 @@
do
{
sum = ( 10*sum + (*base++ - '0') );
sum = ( 10 * sum + ( *base++ - '0' ) );
} while (base < limit);
} while ( base < limit );
if (sign)
if ( sign )
sum = -sum;
*result = sum;
return T1_Err_Ok;
Fail:
FT_ERROR(( "T1.parse_integer : integer expected\n" ));
FT_ERROR(( "parse_int: integer expected\n" ));
*result = 0;
return T1_Err_Syntax_Error;
}
static
FT_Error parse_float( FT_Byte* base,
FT_Byte* limit,
FT_Int scale,
FT_Long scale,
FT_Long* result )
{
#if 1
/* XXX : We're simply much too lazy to code this function */
/* properly for now.. We'll do that when the rest of */
/* the driver works properly.. */
/* XXX: We are simply much too lazy to code this function */
/* properly for now. We will do that when the rest of */
/* the driver works properly. */
char temp[32];
int len = limit-base;
int len = limit - base;
double value;
if (len > 31) goto Fail;
if ( len > 31 )
goto Fail;
strncpy( temp, (char*)base, len );
temp[len] = '\0';
if ( sscanf( temp, "%lf", &value ) != 1 )
goto Fail;
*result = (FT_Long)(scale*value);
*result = (FT_Long)( scale * value );
return 0;
#else
FT_Byte* cur;
FT_Bool sign = 0; /* sign */
FT_Long number_int = 0; /* integer part */
FT_Long number_frac = 0; /* fractional part */
FT_Long exponent = 0; /* exponent value */
FT_Int num_frac = 0; /* number of fractional digits */
/* check sign */
if (*base == '+')
base++;
FT_Byte* cur;
FT_Bool sign = 0; /* sign */
FT_Long number_int = 0; /* integer part */
FT_Long number_frac = 0; /* fractional part */
FT_Long exponent = 0; /* exponent value */
FT_Int num_frac = 0; /* number of fractional digits */
else if (*base == '-')
{
sign++;
base++;
}
/* find integer part */
cur = base;
while ( cur < limit )
{
FT_Byte c = *cur;
if ( c == '.' || c == 'e' || c == 'E' )
break;
/* check sign */
if ( *base == '+' )
base++;
cur++;
}
else if ( *base == '-' )
{
sign++;
base++;
}
if ( cur > base )
{
error = parse_integer( base, cur, &number_int );
if (error) goto Fail;
}
/* read fractional part, if any */
if ( *cur == '.' )
{
cur++;
base = cur;
/* find integer part */
cur = base;
while ( cur < limit )
{
FT_Byte c = *cur;
if ( c == 'e' || c == 'E' )
if ( c == '.' || c == 'e' || c == 'E' )
break;
cur++;
}
num_frac = cur - base;
if ( cur > base )
{
error = parse_integer( base, cur, &number_frac );
if (error) goto Fail;
base = cur;
error = parse_integer( base, cur, &number_int );
if ( error )
goto Fail;
}
}
/* read exponent, if any */
if ( *cur == 'e' || *cur == 'E' )
{
cur++;
base = cur;
error = parse_integer( base, limit, &exponent );
if (error) goto Fail;
/* read fractional part, if any */
if ( *cur == '.' )
{
cur++;
base = cur;
while ( cur < limit )
{
FT_Byte c = *cur;
/* now check that exponent is within 'correct bounds' */
/* i.e. between -6 and 6 */
if ( exponent < -6 || exponent > 6 )
goto Fail;
}
/* now adjust integer value and exponent for fractional part */
while ( num_frac > 0 )
{
number_int *= 10;
exponent --;
num_frac--;
}
if ( c == 'e' || c == 'E' )
break;
cur++;
}
number_int += num_frac;
num_frac = cur - base;
/* skip point if any, read fractional part */
if ( cur+1 < limit )
{
if (*cur
}
if ( cur > base )
{
error = parse_integer( base, cur, &number_frac );
if ( error )
goto Fail;
base = cur;
}
}
/* now compute scaled float value */
/* XXXXX : incomplete !!! */
#endif
/* read exponent, if any */
if ( *cur == 'e' || *cur == 'E' )
{
cur++;
base = cur;
error = parse_integer( base, limit, &exponent );
if ( error )
goto Fail;
/* now check that exponent is within `correct bounds' */
/* i.e. between -6 and 6 */
if ( exponent < -6 || exponent > 6 )
goto Fail;
}
/* now adjust integer value and exponent for fractional part */
while ( num_frac > 0 )
{
number_int *= 10;
exponent--;
num_frac--;
}
number_int += num_frac;
/* skip point if any, read fractional part */
if ( cur + 1 < limit )
{
if (*cur..
}
/* now compute scaled float value */
/* XXX: incomplete! */
#endif /* 1 */
Fail:
FT_ERROR(( "T1.parse_float : syntax error !\n" ));
FT_ERROR(( "parse_float: syntax error!\n" ));
return T1_Err_Syntax_Error;
}
static
FT_Error parse_integer( FT_Byte* base,
FT_Byte* limit,
@ -383,13 +432,15 @@
{
FT_Byte* cur;
/* the lexical analyser accepts floats as well as integers */
/* now, check that we really have an int in this token */
/* now; check that we really have an int in this token */
cur = base;
while ( cur < limit )
{
FT_Byte c = *cur++;
if ( c == '.' || c == 'e' || c == 'E' )
goto Float_Number;
}
@ -398,16 +449,19 @@
return parse_int( base, limit, result );
Float_Number:
/* We really have a float there, simply call parse_float in this */
/* case with a scale of '10' to perform round.. */
/* we really have a float there; simply call parse_float in this */
/* case with a scale of `10' to perform round */
{
FT_Error error;
error = parse_float( base, limit, 10, result );
if (!error)
if ( !error )
{
if (*result >= 0) *result = (*result+5)/10; /* round value */
else *result = -((5-*result)/10);
if ( *result >= 0 )
*result = ( *result + 5 ) / 10; /* round value */
else
*result = -( ( 5 - *result ) / 10 );
}
return error;
}
@ -417,33 +471,35 @@
LOCAL_FUNC
FT_Long CopyInteger( T1_Parser* parser )
{
FT_Long sum = 0;
T1_Token* token = parser->args++;
FT_Long sum = 0;
T1_Token* token = parser->args++;
if ( token->kind == tok_number )
{
FT_Byte* base = parser->tokenizer->base + token->start;
FT_Byte* limit = base + token->len;
/* now read the number's value */
parser->error = parse_integer( base, limit, &sum );
return sum;
}
FT_ERROR(( "T1.CopyInteger : number expected\n" ));
FT_ERROR(( "CopyInteger: number expected\n" ));
parser->args--;
parser->error = T1_Err_Syntax_Error;
return 0;
}
LOCAL_FUNC
FT_Bool CopyBoolean( T1_Parser* parser )
{
FT_Error error = T1_Err_Ok;
FT_Bool result = 0;
T1_Token* token = parser->args++;
FT_Error error = T1_Err_Ok;
FT_Bool result = 0;
T1_Token* token = parser->args++;
if ( token->kind == tok_keyword )
{
@ -459,7 +515,8 @@
else
{
Fail:
FT_ERROR(( "T1.CopyBoolean : syntax error, 'false' or 'true' expected\n" ));
FT_ERROR(( "CopyBoolean:" ));
FT_ERROR(( " syntax error; `false' or `true' expected\n" ));
error = T1_Err_Syntax_Error;
}
parser->error = error;
@ -467,92 +524,100 @@
}
LOCAL_FUNC
FT_Long CopyFloat( T1_Parser* parser,
FT_Int scale )
{
FT_Error error;
FT_Long sum = 0;
T1_Token* token = parser->args++;
FT_Error error;
FT_Long sum = 0;
T1_Token* token = parser->args++;
if ( token->kind == tok_number )
{
FT_Byte* base = parser->tokenizer->base + token->start;
FT_Byte* limit = base + token->len;
error = parser->error = parse_float( base, limit, scale, &sum );
if (error) goto Fail;
if ( error )
goto Fail;
return sum;
}
Fail:
FT_ERROR(( "T1.CopyFloat : syntax error !\n" ));
FT_ERROR(( "CopyFloat: syntax error!\n" ));
parser->error = T1_Err_Syntax_Error;
return 0;
}
LOCAL_FUNC
void CopyBBox( T1_Parser* parser,
FT_BBox* bbox )
{
T1_Token* token = parser->args++;
FT_Int n;
FT_Error error;
T1_Token* token = parser->args++;
FT_Int n;
FT_Error error;
if ( token->kind == tok_program ||
token->kind == tok_array )
{
/* get rid of '['/']', or '{'/'}' */
/* get rid of `['/`]', or `{'/`}' */
FT_Byte* base = parser->tokenizer->base + token->start + 1;
FT_Byte* limit = base + token->len - 2;
FT_Byte* cur;
FT_Byte* start;
/* read each parameter independently */
cur = base;
for ( n = 0; n < 4; n++ )
{
FT_Long* result;
/* skip whitespace */
while (cur < limit && *cur == ' ') cur++;
while ( cur < limit && *cur == ' ' )
cur++;
/* skip numbers */
start = cur;
while (cur < limit && *cur != ' ') cur++;
while ( cur < limit && *cur != ' ' )
cur++;
/* compute result address */
switch (n)
switch ( n )
{
case 0 : result = &bbox->xMin; break;
case 1 : result = &bbox->yMin; break;
case 2 : result = &bbox->xMax; break;
default: result = &bbox->yMax;
case 0:
result = &bbox->xMin;
break;
case 1:
result = &bbox->yMin;
break;
case 2:
result = &bbox->xMax;
break;
default:
result = &bbox->yMax;
}
error = parse_integer( start, cur, result );
if (error) goto Fail;
if ( error )
goto Fail;
}
parser->error = 0;
return;
}
Fail:
FT_ERROR(( "T1.CopyBBox : syntax error !\n" ));
FT_ERROR(( "CopyBBox: syntax error!\n" ));
parser->error = T1_Err_Syntax_Error;
}
LOCAL_FUNC
void CopyMatrix( T1_Parser* parser,
FT_Matrix* matrix )
@ -560,51 +625,63 @@
T1_Token* token = parser->args++;
FT_Error error;
if ( token->kind == tok_array )
{
/* get rid of '[' and ']' */
/* get rid of `[' and `]' */
FT_Byte* base = parser->tokenizer->base + token->start + 1;
FT_Byte* limit = base + token->len - 2;
FT_Byte* cur;
FT_Byte* start;
FT_Int n;
/* read each parameter independently */
cur = base;
for ( n = 0; n < 4; n++ )
{
FT_Long* result;
/* skip whitespace */
while (cur < limit && *cur == ' ') cur++;
while ( cur < limit && *cur == ' ' )
cur++;
/* skip numbers */
start = cur;
while (cur < limit && *cur != ' ') cur++;
while ( cur < limit && *cur != ' ')
cur++;
/* compute result address */
switch (n)
switch ( n )
{
case 0 : result = &matrix->xx; break;
case 1 : result = &matrix->yx; break;
case 2 : result = &matrix->xy; break;
default: result = &matrix->yy;
case 0:
result = &matrix->xx;
break;
case 1:
result = &matrix->yx;
break;
case 2:
result = &matrix->xy;
break;
default:
result = &matrix->yy;
}
error = parse_float( start, cur, 65536000, result );
if (error) goto Fail;
error = parse_float( start, cur, 65536000L, result );
if ( error )
goto Fail;
}
parser->error = 0;
return;
}
Fail:
FT_ERROR(( "T1.CopyMatrix : syntax error !\n" ));
FT_ERROR(( "CopyMatrix: syntax error!\n" ));
parser->error = T1_Err_Syntax_Error;
}
LOCAL_FUNC
void CopyArray( T1_Parser* parser,
FT_Byte* num_elements,
@ -614,44 +691,50 @@
T1_Token* token = parser->args++;
FT_Error error;
if ( token->kind == tok_array ||
token->kind == tok_program ) /* in the case of MinFeature */
{
/* get rid of '['/']', or '{'/'}' */
/* get rid of `['/`]', or `{'/`}' */
FT_Byte* base = parser->tokenizer->base + token->start + 1;
FT_Byte* limit = base + token->len - 2;
FT_Byte* cur;
FT_Byte* start;
FT_Int n;
/* read each parameter independently */
cur = base;
for ( n = 0; n < max_elements; n++ )
{
FT_Long result;
/* test end of string */
if (cur >= limit)
if ( cur >= limit )
break;
/* skip whitespace */
while (cur < limit && *cur == ' ') cur++;
while ( cur < limit && *cur == ' ' )
cur++;
/* end of list ? */
if (cur >= limit)
/* end of list? */
if ( cur >= limit )
break;
/* skip numbers */
start = cur;
while (cur < limit && *cur != ' ') cur++;
while ( cur < limit && *cur != ' ' )
cur++;
error = parse_integer( start, cur, &result );
if (error) goto Fail;
if ( error )
goto Fail;
*elements ++ = (FT_Short)result;
*elements++ = (FT_Short)result;
}
if (num_elements)
if ( num_elements )
*num_elements = (FT_Byte)n;
parser->error = 0;
@ -659,7 +742,9 @@
}
Fail:
FT_ERROR(( "T1.CopyArray : syntax error !\n" ));
FT_ERROR(( "CopyArray: syntax error!\n" ));
parser->error = T1_Err_Syntax_Error;
}
/* END */

View File

@ -1,26 +1,31 @@
/*******************************************************************
*
* t1parse.h 1.0
*
* Type1 parser.
*
* Copyright 1996-1998 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.
*
*
* The Type1 parser component is in charge of simply parsing
* the font input stream and convert simple tokens and elements
* into integers, floats, matrices, strings, etc..
*
* It is used by the Type1 loader..
*
******************************************************************/
/***************************************************************************/
/* */
/* t1parse.h */
/* */
/* Type 1 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. */
/* */
/***************************************************************************/
/*************************************************************************/
/* */
/* The Type1 parser component is in charge of simply parsing the font */
/* input stream and convert simple tokens and elements into integers, */
/* floats, matrices, strings, etc. */
/* */
/* It is used by the Type1 loader. */
/* */
/*************************************************************************/
#ifndef T1PARSE_H
#define T1PARSE_H
@ -32,16 +37,17 @@
extern "C" {
#endif
/*************************************************************************
*
* <Enum> T1_DictState
*
* <Description>
* An enumeration used to describe the Type 1 parser's state, i.e.
* which dictionary (or array) it is scanning and processing at the
* current moment..
*
*/
/*************************************************************************/
/* */
/* <Enum> */
/* T1_DictState */
/* */
/* <Description> */
/* An enumeration used to describe the Type 1 parser's state, i.e. */
/* which dictionary (or array) it is scanning and processing at the */
/* current moment. */
/* */
typedef enum T1_DictState_
{
dict_none = 0,
@ -61,33 +67,37 @@
} T1_DictState;
/*************************************************************************
*
* <Struct> T1_Table
*
* <Description>
* A T1_Table is a simple object used to store an array of objects
* in a single memory block.
*
* <Fields>
* block :: address in memory of the growheap's block. This
* can change between two object adds, due to the use
* of 'realloc'.
*
* cursor :: current top of the grow heap within its block
*
* capacity :: current size of the heap block. Increments by 1 Kb
*
* max_elems :: maximum number of elements in table
* num_elems :: current number of elements in table
*
* elements :: table of element addresses within the block
* lengths :: table of element sizes within the block
*
* system :: system object used for memory operations (alloc/realloc)
*/
typedef struct T1_Table_
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Table */
/* */
/* <Description> */
/* A T1_Table is a simple object used to store an array of objects in */
/* a single memory block. */
/* */
/* <Fields> */
/* block :: The address in memory of the growheap's block. This */
/* can change between two object adds, due to */
/* reallocation. */
/* */
/* cursor :: The current top of the grow heap within its block. */
/* */
/* capacity :: The current size of the heap block. Increments by */
/* 1kByte chunks. */
/* */
/* max_elems :: The maximum number of elements in table. */
/* */
/* num_elems :: The current number of elements in table. */
/* */
/* elements :: A table of element addresses within the block. */
/* */
/* lengths :: A table of element sizes within the block. */
/* */
/* memory :: The object used for memory operations */
/* (alloc/realloc). */
/* */
typedef struct T1_Table_
{
FT_Byte* block; /* current memory block */
FT_Int cursor; /* current cursor in memory block */
@ -103,173 +113,125 @@
} T1_Table;
/*************************************************************************/
/* */
/* <Struct> T1_Parser */
/* */
/* <Description> */
/* A Type 1 parser. This object is in charge of parsing Type 1 */
/* ASCII streams and builds dictionaries for a T1_Face object. */
/* */
/* <Fields> */
/* error :: */
/* current error code. 0 means success */
/* */
/* face :: */
/* the target T1_Face object being built */
/* */
/* tokenizer :: */
/* the tokenizer (lexical analyser) used for processing the */
/* input stream. */
/* */
/* stack :: */
/* the current token stack. Note that we don't use intermediate */
/* Postscript objects here ! */
/* */
/* top :: */
/* current top of token stack */
/* */
/* limit :: */
/* current upper bound of the token stack. Used for overflow */
/* checks.. */
/* */
/* args :: */
/* arguments of a given operator. used and increased by the */
/* Copy.... functions.. */
/* */
/* state_index :: */
/* index of top of the dictionary state stack */
/* */
/* state_stack :: */
/* dictionary states stack */
/* */
/* table :: */
/* a T1_Table object used to record various kinds of */
/* dictionaries or arrays (like /Encoding, /Subrs, /CharStrings) */
/* */
/* */
/*************************************************************************/
/* */
/* <Struct> */
/* T1_Parser */
/* */
/* <Description> */
/* A Type 1 parser. This object is in charge of parsing Type 1 ASCII */
/* streams and builds dictionaries for a T1_Face object. */
/* */
/* <Fields> */
/* error :: The current error code. 0 means success. */
/* */
/* face :: The target T1_Face object being built. */
/* */
/* tokenizer :: The tokenizer (lexical analyser) used for */
/* processing the input stream. */
/* */
/* dump_tokens :: XXX */
/* */
/* stack :: The current token stack. Note that we don't */
/* use intermediate Postscript objects here! */
/* */
/* top :: The current top of token stack. */
/* */
/* limit :: The current upper bound of the token stack. */
/* Used for overflow checks. */
/* */
/* args :: The arguments of a given operator. Used and */
/* increased by the various CopyXXX() functions. */
/* */
/* state_index :: The index of the top of the dictionary state */
/* stack. */
/* */
/* state_stack :: The dictionary states stack. */
/* */
/* table :: A T1_Table object used to record various kinds */
/* of dictionaries or arrays (like `/Encoding', */
/* `/Subrs', `/CharStrings'). */
/* */
/* cur_name :: XXX */
/* */
/* encoding_type :: XXX */
/* */
/* encoding_names :: XXX */
/* */
/* encoding_lengths :: XXX */
/* */
/* encoding_offsets :: XXX */
/* */
/* subrs :: XXX */
/* */
/* charstrings :: XXX */
/* */
typedef struct T1_Parser_
{
FT_Error error;
T1_Face face;
FT_Error error;
T1_Face face;
T1_Tokenizer tokenizer;
FT_Bool dump_tokens;
T1_Tokenizer tokenizer;
FT_Bool dump_tokens;
T1_Token stack[ T1_MAX_STACK_DEPTH ];
T1_Token* top;
T1_Token* limit;
T1_Token* args;
T1_Token stack[T1_MAX_STACK_DEPTH];
T1_Token* top;
T1_Token* limit;
T1_Token* args;
FT_Int state_index;
T1_DictState state_stack[ T1_MAX_DICT_DEPTH ];
FT_Int state_index;
T1_DictState state_stack[T1_MAX_DICT_DEPTH];
T1_Table table;
T1_Table table;
FT_Int cur_name;
FT_Int cur_name;
T1_EncodingType encoding_type;
FT_Byte* encoding_names;
FT_Int* encoding_lengths;
FT_Byte** encoding_offsets;
FT_Byte* subrs;
FT_Byte* charstrings;
FT_Byte* subrs;
FT_Byte* charstrings;
} T1_Parser;
/*************************************************************************/
/* */
/* <Function> T1_New_Table */
/* */
/* <Description> */
/* Initialise a T1_Table. */
/* */
/* <Input> */
/* table :: address of target table */
/* count :: table size = maximum number of elements */
/* system :: system object to use for all subsequent reallocations */
/* */
/* <Return> */
/* Error code. 0 means success */
/* */
LOCAL_DEF
FT_Error T1_New_Table( T1_Table* table,
FT_Int count,
FT_Memory memory );
/*************************************************************************/
/* */
/* <Function> T1_Add_Table */
/* */
/* <Description> */
/* Adds an object to a T1_Table, possibly growing its memory block */
/* */
/* <Input> */
/* table :: target table */
/* index :: index of object in table */
/* object :: address of object to copy in memory */
/* length :: length in bytes of source object */
/* */
/* <Return> */
/* Error code. 0 means success. An error is returned when a */
/* realloc failed.. */
/* */
LOCAL_DEF
FT_Error T1_Add_Table( T1_Table* table,
FT_Int index,
void* object,
FT_Int length );
/*************************************************************************/
/* */
/* <Function> T1_Done_Table */
/* */
/* <Description> */
/* Finalise a T1_Table. (realloc it to its current cursor). */
/* */
/* <Input> */
/* table :: target table */
/* */
/* <Note> */
/* This function does NOT release the heap's memory block. It is up */
/* to the caller to clean it, or reference it in its own structures. */
/* */
LOCAL_DEF
void T1_Done_Table( T1_Table* table );
LOCAL_DEF
FT_String* CopyString( T1_Parser* parser );
LOCAL_DEF
FT_String* CopyString( T1_Parser* parser );
FT_Long CopyInteger( T1_Parser* parser );
LOCAL_DEF
FT_Long CopyInteger( T1_Parser* parser );
FT_Bool CopyBoolean( T1_Parser* parser );
LOCAL_DEF
FT_Bool CopyBoolean( T1_Parser* parser );
FT_Long CopyFloat( T1_Parser* parser,
FT_Int scale );
LOCAL_DEF
FT_Long CopyFloat( T1_Parser* parser,
FT_Int scale );
void CopyBBox( T1_Parser* parser,
FT_BBox* bbox );
LOCAL_DEF
void CopyBBox( T1_Parser* parser,
FT_BBox* bbox );
LOCAL_DEF
void CopyMatrix( T1_Parser* parser,
FT_Matrix* matrix );
void CopyMatrix( T1_Parser* parser,
FT_Matrix* matrix );
LOCAL_DEF
void CopyArray( T1_Parser* parser,
@ -277,6 +239,7 @@
FT_Short* elements,
FT_Int max_elements );
#ifdef __cplusplus
}
#endif
@ -285,4 +248,3 @@
/* END */