Commit f9b8dec4 authored by David Turner's avatar David Turner
Browse files

major reformatting of the modules source code in order to get

rid of most of the basic types redefinitions (i.e. FT_Int instead
of "FT_Int", etc..)

The format-specific prefixs like "TT_", "T1_", "T2_" & 'CID_"
are now only used in relevant structures..

fixed Werner's fix to t2gload.c :-)
other small bug fixes
parent e3c11d7f
LATEST_CHANGES
LATEST CHANGES
- reformated all modules source code in order to get rid of the basic
data types redifinitions (i.e. "TT_Int" instead of "FT_Int", "T1_Fixed"
instead of "FT_Fixed"). Hence the format-specific prefixes like "TT_",
"T1_", "T2_" and "CID_" are only used for relevant structures..
============================================================================
OLD CHANGES FOR BETA 7
- bug-fixed the OpenType/CFF parser. It now loads and displays my two
fonts nicely, but I'm pretty certain that more testing is needed :-)
......
......@@ -39,7 +39,7 @@ TT_Face face; /* truetype face */
TT_Size size; /* truetype size */
TT_GlyphSlot glyph; /* truetype glyph slot */
TT_ExecContext exec; /* truetype execution context */
TT_Error error;
FT_Error error;
TT_CodeRange_Tag debug_coderange = tt_coderange_glyph;
......@@ -53,7 +53,7 @@ TT_CodeRange_Tag debug_coderange = tt_coderange_glyph;
#undef PACK
#define PACK( x, y ) ((x << 4) | y)
static const TT_Byte Pop_Push_Count[256] =
static const FT_Byte Pop_Push_Count[256] =
{
/* opcodes are gathered in groups of 16 */
/* please keep the spaces as they are */
......@@ -807,16 +807,16 @@ TT_CodeRange_Tag debug_coderange = tt_coderange_glyph;
static
TT_Error RunIns( TT_ExecContext exc )
FT_Error RunIns( TT_ExecContext exc )
{
FT_Int A, diff, key;
FT_Long next_IP;
FT_Char ch, oldch = '\0', *temp;
TT_Error error = 0;
FT_Error error = 0;
FT_GlyphZone save;
FT_GlyphZone pts;
TT_GlyphZone save;
TT_GlyphZone pts;
const FT_String* round_str[8] =
{
......@@ -831,7 +831,7 @@ TT_CodeRange_Tag debug_coderange = tt_coderange_glyph;
};
/* only debug the requested code range */
if (exc->curRange != (TT_Int)debug_coderange)
if (exc->curRange != (FT_Int)debug_coderange)
return TT_RunIns(exc);
exc->pts.n_points = exc->zp0.n_points;
......@@ -843,11 +843,11 @@ TT_CodeRange_Tag debug_coderange = tt_coderange_glyph;
save.n_points = pts.n_points;
save.n_contours = pts.n_contours;
save.org = (TT_Vector*)malloc( 2 * sizeof( TT_F26Dot6 ) *
save.org = (FT_Vector*)malloc( 2 * sizeof( FT_F26Dot6 ) *
save.n_points );
save.cur = (TT_Vector*)malloc( 2 * sizeof( TT_F26Dot6 ) *
save.cur = (FT_Vector*)malloc( 2 * sizeof( FT_F26Dot6 ) *
save.n_points );
save.tags = (TT_Byte*)malloc( save.n_points );
save.tags = (FT_Byte*)malloc( save.n_points );
exc->instruction_trap = 1;
......@@ -996,8 +996,8 @@ TT_CodeRange_Tag debug_coderange = tt_coderange_glyph;
}
} while ( !key );
MEM_Copy( save.org, pts.org, pts.n_points * sizeof ( TT_Vector ) );
MEM_Copy( save.cur, pts.cur, pts.n_points * sizeof ( TT_Vector ) );
MEM_Copy( save.org, pts.org, pts.n_points * sizeof ( FT_Vector ) );
MEM_Copy( save.cur, pts.cur, pts.n_points * sizeof ( FT_Vector ) );
MEM_Copy( save.tags, pts.tags, pts.n_points );
/* a return indicate the last command */
......
......@@ -164,56 +164,6 @@
/*************************************************************************/
/*************************************************************************/
/************************************************************************
*
* <Struct>
* FT_GlyphZone
*
* <Description>
* A glyph zone is used to load, scale and hint glyph outline
* coordinates.
*
* <Fields>
* memory :: handle to memory manager
* max_points :: max size in points of zone
* max_contours :: max size in contours of zone
* n_points :: current number of points in zone
* n_contours :: current number of contours in zone
* org :: original glyph coordinates (font units/scaled)
* cur :: current glyph coordinates (scaled/hinted)
* tags :: point control tags
* contours :: contour end points
*
***********************************************************************/
typedef struct FT_GlyphZone_
{
FT_Memory memory;
FT_UShort max_points;
FT_UShort max_contours;
FT_UShort n_points; /* number of points in zone */
FT_Short n_contours; /* number of contours */
FT_Vector* org; /* original point coordinates */
FT_Vector* cur; /* current point coordinates */
FT_Byte* tags; /* current touch flags */
FT_UShort* contours; /* contour end points */
} FT_GlyphZone;
BASE_DEF(FT_Error) FT_New_GlyphZone( FT_Memory memory,
FT_UShort maxPoints,
FT_Short maxContours,
FT_GlyphZone* zone );
BASE_DEF(void) FT_Done_GlyphZone( FT_GlyphZone* zone );
BASE_DEF(FT_Error) FT_Update_GlyphZone( FT_GlyphZone* zone,
FT_UShort num_points,
FT_Short num_contours );
/*************************************************************************/
/*************************************************************************/
......
......@@ -140,9 +140,9 @@
/* values of "search_range", "entry_selector" and "range_shift".. */
/* */
typedef
TT_Error (*TT_Load_SFNT_Header_Func)( TT_Face face,
FT_Error (*TT_Load_SFNT_Header_Func)( TT_Face face,
FT_Stream stream,
TT_Long faceIndex,
FT_Long faceIndex,
SFNT_Header* sfnt );
/*************************************************************************/
......@@ -167,7 +167,7 @@
/* TT_Load_Format_Tag */
/* */
typedef
TT_Error (*TT_Load_Directory_Func)( TT_Face face,
FT_Error (*TT_Load_Directory_Func)( TT_Face face,
FT_Stream stream,
SFNT_Header* sfnt );
......@@ -214,11 +214,11 @@
/* TrueType error code. 0 means success. */
/* */
typedef
TT_Error (*TT_Load_Any_Func)( TT_Face face,
TT_ULong tag,
TT_Long offset,
FT_Error (*TT_Load_Any_Func)( TT_Face face,
FT_ULong tag,
FT_Long offset,
void* buffer,
TT_Long* length );
FT_Long* length );
/*************************************************************************/
......@@ -253,11 +253,11 @@
/* The `map.buffer' field is always freed before the glyph is loaded. */
/* */
typedef
TT_Error (*TT_Load_SBit_Image_Func)( TT_Face face,
TT_Int x_ppem,
TT_Int y_ppem,
TT_UInt glyph_index,
TT_UInt load_flags,
FT_Error (*TT_Load_SBit_Image_Func)( TT_Face face,
FT_Int x_ppem,
FT_Int y_ppem,
FT_UInt glyph_index,
FT_UInt load_flags,
FT_Stream stream,
FT_Bitmap* map,
TT_SBit_Metrics* metrics );
......@@ -282,9 +282,9 @@
/* TrueType error code. 0 means success. */
/* */
typedef
TT_Error (*TT_Get_PS_Name_Func)( TT_Face face,
TT_UInt index,
TT_String** PSname );
FT_Error (*TT_Get_PS_Name_Func)( TT_Face face,
FT_UInt index,
FT_String** PSname );
/*************************************************************************/
......@@ -304,9 +304,9 @@
/* TrueType error code. 0 means success. */
/* */
typedef
TT_Error (*TT_Load_Metrics_Func)( TT_Face face,
FT_Error (*TT_Load_Metrics_Func)( TT_Face face,
FT_Stream stream,
TT_Bool vertical );
FT_Bool vertical );
......@@ -334,7 +334,7 @@
/* released. */
/* */
typedef
TT_Error (*TT_CharMap_Load_Func)( TT_Face face,
FT_Error (*TT_CharMap_Load_Func)( TT_Face face,
TT_CMapTable* cmap,
FT_Stream input );
......@@ -355,7 +355,7 @@
/* Error code. 0 means success. */
/* */
typedef
TT_Error (*TT_CharMap_Free_Func)( TT_Face face,
FT_Error (*TT_CharMap_Free_Func)( TT_Face face,
TT_CMapTable* cmap );
......@@ -379,7 +379,7 @@
/* the start of the table */
/* */
typedef
TT_Error (*TT_Load_Table_Func)( TT_Face face,
FT_Error (*TT_Load_Table_Func)( TT_Face face,
FT_Stream stream );
......
......@@ -29,231 +29,6 @@
#endif
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** ***/
/*** DEFINITIONS OF BASIC DATA TYPES ***/
/*** ***/
/*** ***/
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
/* The REDEFINE macro is used to convert a FreeType generic type into */
/* a TrueType-specific one. It simply replaces the "FT_" prefix by "T1_" */
/* in order to define compatible T1_Long, T1_Error, T1_Outline, etc.. */
/* */
#undef REDEFINE
#define REDEFINE( type ) typedef FT_##type T1_##type
/* <Type> T1_Bool */
/* */
/* <Description> */
/* A simple typedef of unsigned char, used for simple booleans. */
/* */
REDEFINE( Bool );
/* <Type> T1_FWord */
/* */
/* <Description> */
/* a signed 16-bit integer used to store a distance in original */
/* font units. */
/* */
REDEFINE( FWord );
/* <Type> T1_UFWord */
/* */
/* <Description> */
/* an unsigned 16-bit integer used to store a distance in original */
/* font units. */
/* */
REDEFINE( UFWord );
/* <Type> T1_Char */
/* */
/* <Description> */
/* a simple typedef for the _signed_ char type. */
/* */
REDEFINE( Char );
/* <Type> T1_Byte */
/* */
/* <Description> */
/* a simple typedef for the _unsigned_ char type. */
/* */
REDEFINE( Byte );
/* <Type> T1_String */
/* */
/* <Description> */
/* a simple typedef for the char type, used for strings usually. */
/* */
REDEFINE( String );
/* <Type> T1_Short */
/* */
/* <Description> */
/* a typedef for signed short */
/* */
REDEFINE( Short );
/* <Type> T1_UShort */
/* */
/* <Description> */
/* a typedef for unsigned short */
/* */
REDEFINE( UShort );
/* <Type> FT_Int */
/* */
/* <Description> */
/* a typedef for the int type */
/* */
REDEFINE( Int );
/* <Type> FT_UInt */
/* */
/* <Description> */
/* a typedef for the unsigned int type */
/* */
REDEFINE( UInt );
/* <Type> T1_Long */
/* */
/* <Description> */
/* a typedef for signed long */
/* */
REDEFINE( Long );
/* <Type> T1_ULong */
/* */
/* <Description> */
/* a typedef for unsigned long */
/* */
REDEFINE( ULong );
/* <Type> T1_F2Dot14 */
/* */
/* <Description> */
/* a signed 2.14 fixed float used for unit vectors */
/* */
REDEFINE( F2Dot14 );
/* <Type> T1_F26Dot6 */
/* */
/* <Description> */
/* a signed 26.6 fixed float used for vectorial pixel coordinates */
/* */
REDEFINE( F26Dot6 );
/* <Type> T1_Fixed */
/* */
/* <Description> */
/* This type is used to store 16.16 fixed float values, like */
/* scales or matrix coefficients.. */
/* */
REDEFINE( Fixed );
/* <Type> T1_Pos */
/* */
/* <Description> */
/* The type T1_Pos is a 32-bits integer used to store vectorial */
/* coordinates. Depending on the context, these can represent */
/* distances in integer font units, or 26.6 fixed float pixel */
/* coordinates.. */
/* */
REDEFINE( Pos );
/* <Struct> T1_Vector */
/* */
/* <Description> */
/* A simple structure used to store a 2d vector, coordinates */
/* are of the T1_Pos type. */
/* */
/* <Fields> */
/* x :: horizontal coordinate */
/* y :: vertical coordinate */
/* */
REDEFINE( Vector );
/* <Struct> T1_UnitVector */
/* */
/* <Description> */
/* A simple structure used to store a 2d vector unit vector. */
/* uses T1_F2Dot14 types. */
/* */
/* <Fields> */
/* x :: horizontal coordinate */
/* y :: vertical coordinate */
/* */
REDEFINE( UnitVector );
/* <Struct> T1_Matrix */
/* */
/* <Description> */
/* A simple structure used to store a 2x2 matrix. Coefficients */
/* are in 16.16 fixed float format. The computation performed */
/* is : */
/* { */
/* x' = x*xx + y*xy */
/* y' = x*yx + y*yy */
/* } */
/* */
/* <Fields> */
/* xx :: matrix coefficient */
/* xy :: matrix coefficient */
/* yx :: matrix coefficient */
/* yy :: matrix coefficient */
/* */
REDEFINE( Matrix );
/* <Struct> T1_BBox */
/* */
/* <Description> */
/* A structure used to hold an outline's bounding box, i.e. */
/* the coordinates of its extrema in the horizontal and vertical */
/* directions. */
/* */
/* <Fields> */
/* xMin :: the horizontal minimum (left-most) */
/* yMin :: the vertical minimum (bottom-most) */
/* xMax :: the horizontal maximum (right-most) */
/* yMax :: the vertical maximum (top-most) */
/* */
REDEFINE( BBox );
/* <Type> T1_Error */
/* */
/* <Description> */
/* The FreeType error code type. A value of 0 is always */
/* interpreted as a succesful operation. */
/* */
REDEFINE( Error );
/*************************************************************************/
/*************************************************************************/
......@@ -285,12 +60,12 @@
/* */
typedef struct T1_Encoding_
{
T1_Int num_chars;
T1_Int code_first;
T1_Int code_last;
FT_Int num_chars;
FT_Int code_first;
FT_Int code_last;
T1_UShort* char_index;
T1_String** char_name;
FT_UShort* char_index;
FT_String** char_name;
} T1_Encoding;
......@@ -320,26 +95,26 @@
T1_EncodingType encoding_type;
T1_Encoding encoding;
T1_Byte* subrs_block;
T1_Byte* charstrings_block;
T1_Byte* glyph_names_block;
FT_Byte* subrs_block;
FT_Byte* charstrings_block;
FT_Byte* glyph_names_block;
T1_Int num_subrs;
T1_Byte** subrs;
T1_Int* subrs_len;
FT_Int num_subrs;
FT_Byte** subrs;
FT_Int* subrs_len;
T1_Int num_glyphs;
T1_String** glyph_names; /* array of glyph names */
T1_Byte** charstrings; /* array of glyph charstrings */
T1_Int* charstrings_len;
FT_Int num_glyphs;
FT_String** glyph_names; /* array of glyph names */
FT_Byte** charstrings; /* array of glyph charstrings */
FT_Int* charstrings_len;
T1_Byte paint_type;
T1_Byte font_type;
T1_Matrix font_matrix;
T1_BBox font_bbox;
T1_Long font_id;
FT_Byte paint_type;
FT_Byte font_type;
FT_Matrix font_matrix;
FT_BBox font_bbox;
FT_Long font_id;
T1_Int stroke_width;
FT_Int stroke_width;
} T1_Font;
......
This diff is collapsed.
......@@ -26,6 +26,8 @@
#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' )
#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' )
#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' )
#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' )
#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' )
#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' )
#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' )
#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' )
......
......@@ -566,135 +566,6 @@
}
/*************************************************************************/
/* */
/* <Function> */
/* FT_Done_GlyphZone */
/* */
/* <Description> */
/* Deallocates a glyph zone. */
/* */
/* <Input> */
/* zone :: A pointer to the target glyph zone. */
/* */
BASE_FUNC( void ) FT_Done_GlyphZone( FT_GlyphZone* zone )
{
FT_Memory memory = zone->memory;
FREE( zone->contours );
FREE( zone->tags );
FREE( zone->cur );
FREE( zone->org );
zone->max_points = zone->n_points = 0;
zone->max_contours = zone->n_contours = 0;
}
/*************************************************************************/
/* */
/* <Function> */
/* FT_New_GlyphZone */
/* */
/* <Description> */
/* Allocates a new glyph zone. */
/* */
/* <Input> */
/* memory :: A handle to the current memory object. */
/* */
/* maxPoints :: The capacity of glyph zone in points. */
/* */
/* maxContours :: The capacity of glyph zone in contours. */
/* */
/* <Output> */
/* zone :: A pointer to the target glyph zone record. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
BASE_FUNC( FT_Error ) FT_New_GlyphZone( FT_Memory memory,
FT_UShort maxPoints,
FT_Short maxContours,
FT_GlyphZone* zone )
{
FT_Error error;
if ( maxPoints > 0 )
maxPoints += 2;
MEM_Set( zone, 0, sizeof ( *zone ) );
zone->memory = memory;
if ( ALLOC_ARRAY( zone->org, maxPoints * 2, FT_F26Dot6 ) ||
ALLOC_ARRAY( zone->cur, maxPoints * 2, FT_F26Dot6 ) ||
ALLOC_ARRAY( zone->tags, maxPoints, FT_Byte ) ||
ALLOC_ARRAY( zone->contours, maxContours, FT_UShort ) )
{
FT_Done_GlyphZone( zone );