Formatting, copyright years.

This commit is contained in:
Werner Lemberg 2006-01-16 22:35:33 +00:00
parent 108fdbbbd3
commit ce94c7a9aa
16 changed files with 175 additions and 153 deletions

View File

@ -1,25 +1,29 @@
2006-01-16 Chia-I Wu <b90201047@ntu.edu.tw>
* src/psaux/afmparse.c, src/psaux/afmparse.h: New files which
implement an AFM parser. It is used to parse an AFM file.
implement an AFM parser.
* src/psaux/psconv.c, src/psaux/psconv.h: New files to provide
conversion functions (e.g, PS real number => FT_Fixed) for the
PS_Parser and AFM_Parser. Some of the functions are taken, with some
modifications, from the psobjs.c
conversion functions (e.g., PS real number => FT_Fixed) for the
PS_Parser and AFM_Parser. Some of the functions are taken, with
some modifications, from the file psobjs.c.
* src/psaux/psobjs.c: Use functions from psconv.c.
* include/freetype/internal/psaux.h, src/psaux/psauxmod.c:: Add
* include/freetype/internal/psaux.h, src/psaux/psauxmod.c: Add
`AFM_Parser' to the `psaux' service.
* src/psaux/psaux.c, src/psaux/rules.mk: Include those new files.
* src/psaux/psaux.c, src/psaux/rules.mk (PSAUX_DRV_SRC): Include
those new files.
* src/tools/test_afm.c: A test program for AFM parser.
* include/freetype/internal/services/svkern.h,
include/freetype/internal/ftserv.h: New service `Kerning'. It is
currently only used to get the track kerning information.
* include/freetype/internal/services/svkern.h: New file providing a
`Kerning' service. It is currently only used to get the track
kerning information.
* include/freetype/internal/ftserv.h (FT_SERVICE_KERNING_H): New
macro.
* src/type1/t1driver.c, src/type1/t1objs.c, src/type1/t1afm.c,
src/type1/t1afm.h: Update to use the AFM parser.

View File

@ -2728,7 +2728,7 @@ FT_BEGIN_HEADER
/* degree :: The degree of tightness. */
/* */
/* <Output> */
/* akerning :: The kerning in in 16.16 fractional points. */
/* akerning :: The kerning in 16.16 fractional points. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType services (specification only). */
/* */
/* Copyright 2003, 2004, 2005 by */
/* Copyright 2003, 2004, 2005, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -5,7 +5,7 @@
/* Auxiliary functions and data structures related to PostScript fonts */
/* (specification). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -702,6 +702,7 @@ FT_BEGIN_HEADER
FT_Fixed min_kern;
FT_Fixed max_ptsize;
FT_Fixed max_kern;
} AFM_TrackKernRec, *AFM_TrackKern;
typedef struct AFM_KernPairRec_
@ -710,6 +711,7 @@ FT_BEGIN_HEADER
FT_Int index2;
FT_Int x;
FT_Int y;
} AFM_KernPairRec, *AFM_KernPair;
typedef struct AFM_FontInfoRec_
@ -719,6 +721,7 @@ FT_BEGIN_HEADER
FT_Int NumTrackKern;
AFM_KernPair KernPairs; /* free if non-NULL */
FT_Int NumKernPair;
} AFM_FontInfoRec, *AFM_FontInfo;
typedef struct AFM_Parser_FuncsRec_
@ -739,6 +742,7 @@ FT_BEGIN_HEADER
typedef struct AFM_StreamRec_* AFM_Stream;
/*************************************************************************/
/* */
/* <Struct> */
@ -748,14 +752,14 @@ FT_BEGIN_HEADER
/* An AFM_Parser is a parser for the AFM files. */
/* */
/* <Fields> */
/* memory :: The object used for memory operations */
/* (alloc/realloc). */
/* memory :: The object used for memory operations (alloc and */
/* realloc). */
/* */
/* stream :: This is an opaque object. */
/* */
/* FontInfo :: The result will be stored here. */
/* */
/* get_index :: An user provided function to get glyph index by its */
/* get_index :: A user provided function to get a glyph index by its */
/* name. */
/* */
typedef struct AFM_ParserRec_

View File

@ -4,7 +4,7 @@
/* */
/* The FreeType Kerning service (specification). */
/* */
/* Copyright 2003, 2004 by */
/* Copyright 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -15,6 +15,7 @@
/* */
/***************************************************************************/
#include FT_INTERNAL_POSTSCRIPT_AUX_H
#include FT_INTERNAL_DEBUG_H
@ -23,6 +24,7 @@
#include "psauxerr.h"
/***************************************************************************/
/* */
/* AFM_Stream */
@ -42,11 +44,11 @@
typedef struct AFM_StreamRec_
{
FT_Byte* cursor;
FT_Byte* base;
FT_Byte* limit;
FT_Byte* cursor;
FT_Byte* base;
FT_Byte* limit;
FT_Int status;
FT_Int status;
} AFM_StreamRec;
@ -55,34 +57,35 @@
#define EOF -1
#endif
/* this works because empty lines are ignored */
#define AFM_IS_NEWLINE( ch ) ( ( ch ) == '\r' || ( ch ) == '\n' )
#define AFM_IS_EOF( ch ) ( ( ch ) == EOF || ( ch ) == '\x1a' )
#define AFM_IS_SPACE( ch ) ( ( ch ) == ' ' || ( ch ) == '\t' )
/* this works because empty lines are ignored */
#define AFM_IS_NEWLINE( ch ) ( (ch) == '\r' || (ch) == '\n' )
/* column separator; there is no `column' in the spec actually */
#define AFM_IS_SEP( ch ) ( ( ch ) == ';' )
#define AFM_IS_EOF( ch ) ( (ch) == EOF || (ch) == '\x1a' )
#define AFM_IS_SPACE( ch ) ( (ch) == ' ' || (ch) == '\t' )
#define AFM_GETC() \
( ( ( stream )->cursor < ( stream )->limit ) \
? *( stream )->cursor++ \
: EOF )
/* column separator; there is no `column' in the spec actually */
#define AFM_IS_SEP( ch ) ( (ch) == ';' )
#define AFM_STREAM_KEY_BEGIN( stream ) \
(char*)( ( stream )->cursor - 1 )
#define AFM_GETC() \
( ( (stream)->cursor < (stream)->limit ) ? *(stream)->cursor++ \
: EOF )
#define AFM_STREAM_KEY_LEN( stream, key ) \
( (char*)( stream )->cursor - key - 1 )
#define AFM_STREAM_KEY_BEGIN( stream ) \
(char*)( (stream)->cursor - 1 )
#define AFM_STREAM_KEY_LEN( stream, key ) \
( (char*)(stream)->cursor - key - 1 )
#define AFM_STATUS_EOC( stream ) \
( ( stream )->status >= AFM_STREAM_STATUS_EOC )
( (stream)->status >= AFM_STREAM_STATUS_EOC )
#define AFM_STATUS_EOL( stream ) \
( ( stream )->status >= AFM_STREAM_STATUS_EOL )
( (stream)->status >= AFM_STREAM_STATUS_EOL )
#define AFM_STATUS_EOF( stream ) \
( ( stream )->status >= AFM_STREAM_STATUS_EOF )
( (stream)->status >= AFM_STREAM_STATUS_EOF )
static int
afm_stream_skip_spaces( AFM_Stream stream )
@ -111,7 +114,7 @@
}
/* read a key or val in current column */
/* read a key or value in current column */
static char*
afm_stream_read_one( AFM_Stream stream )
{
@ -133,19 +136,16 @@
else if ( AFM_IS_NEWLINE( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOL;
break;
}
else if ( AFM_IS_SEP( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOC;
break;
}
else if ( AFM_IS_EOF( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOF;
break;
}
}
@ -175,13 +175,11 @@
if ( AFM_IS_NEWLINE( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOL;
break;
}
else if ( AFM_IS_EOF( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOF;
break;
}
}
@ -190,14 +188,14 @@
}
/***************************************************************************/
/* */
/* AFM_Parser */
/* */
/* */
/*************************************************************************/
/* */
/* AFM_Parser */
/* */
/* */
/* all keys defined in Ch. 7-10 of 5004.AFM_Spec.pdf */
typedef enum
typedef enum AFM_Token_
{
AFM_TOKEN_ASCENDER,
AFM_TOKEN_AXISLABEL,
@ -275,6 +273,7 @@
AFM_TOKEN_XHEIGHT,
N_AFM_TOKENS,
AFM_TOKEN_UNKNOWN
} AFM_Token;
@ -357,16 +356,16 @@
};
#define AFM_MAX_ARGUMENTS 5
#define AFM_MAX_ARGUMENTS 5
static AFM_ValueRec shared_vals[AFM_MAX_ARGUMENTS];
/*
* `afm_parser_read_vals' and `afm_parser_next_key' provides
* `afm_parser_read_vals' and `afm_parser_next_key' provide
* high-level operations to an AFM_Stream. The rest of the
* parser functions should use them and should not access
* the AFM_Stream directly.
* parser functions should use them without accessing the
* AFM_Stream directly.
*/
FT_LOCAL_DEF( FT_Int )
@ -399,35 +398,40 @@
switch ( vals[i].type )
{
case AFM_VALUE_TYPE_STRING:
case AFM_VALUE_TYPE_NAME:
if ( !FT_QAlloc( parser->memory, len + 1, (void**)&vals[i].u.s ) )
{
ft_memcpy( vals[i].u.s, str, len );
vals[i].u.s[len] = '\0';
}
break;
case AFM_VALUE_TYPE_FIXED:
vals[i].u.f = PS_Conv_ToFixed( (FT_Byte**)&str,
(FT_Byte*)str + len,
0 );
break;
case AFM_VALUE_TYPE_INTEGER:
vals[i].u.i = PS_Conv_ToInt( (FT_Byte**)&str,
(FT_Byte*)str + len );
break;
case AFM_VALUE_TYPE_BOOL:
vals[i].u.b = ( len == 4 &&
ft_strncmp( str, "true", 4 ) == 0 );
break;
case AFM_VALUE_TYPE_INDEX:
if ( parser->get_index )
vals[i].u.i = parser->get_index( str,
len,
parser->user_data );
else
vals[i].u.i = 0;
break;
case AFM_VALUE_TYPE_STRING:
case AFM_VALUE_TYPE_NAME:
if ( !FT_QAlloc( parser->memory, len + 1,
(void**)&vals[i].u.s ) )
{
ft_memcpy( vals[i].u.s, str, len );
vals[i].u.s[len] = '\0';
}
break;
case AFM_VALUE_TYPE_FIXED:
vals[i].u.f = PS_Conv_ToFixed( (FT_Byte**)&str,
(FT_Byte*)str + len,
0 );
break;
case AFM_VALUE_TYPE_INTEGER:
vals[i].u.i = PS_Conv_ToInt( (FT_Byte**)&str,
(FT_Byte*)str + len );
break;
case AFM_VALUE_TYPE_BOOL:
vals[i].u.b = ( len == 4 &&
ft_strncmp( str, "true", 4 ) == 0 );
break;
case AFM_VALUE_TYPE_INDEX:
if ( parser->get_index )
vals[i].u.i = parser->get_index( str,
len,
parser->user_data );
else
vals[i].u.i = 0;
break;
}
}
@ -458,7 +462,7 @@
/* skip empty line */
if ( !key &&
!AFM_STATUS_EOF( stream ) &&
AFM_STATUS_EOL( stream ) )
AFM_STATUS_EOL( stream ) )
continue;
break;
@ -478,7 +482,7 @@
/* skip empty column */
if ( !key &&
!AFM_STATUS_EOF( stream ) &&
AFM_STATUS_EOC( stream ) )
AFM_STATUS_EOC( stream ) )
continue;
break;
@ -532,11 +536,11 @@
if ( FT_NEW( stream ) )
return error;
stream->cursor = stream->base = base;
stream->limit = limit;
stream->cursor = stream->base = base;
stream->limit = limit;
/* so that the first call won't skip the first line */
stream->status = AFM_STREAM_STATUS_EOL;
/* don't skip the first line during the first call */
stream->status = AFM_STREAM_STATUS_EOL;
parser->memory = memory;
parser->stream = stream;
@ -656,6 +660,7 @@
#undef KERN_INDEX
#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 )
/* compare two kerning pairs */
FT_CALLBACK_DEF( int )
afm_compare_kern_pairs( const void* a,
@ -749,7 +754,6 @@
sizeof( AFM_KernPairRec ),
afm_compare_kern_pairs );
return PSaux_Err_Ok;
break;
case AFM_TOKEN_UNKNOWN:
break;
@ -793,7 +797,6 @@
case AFM_TOKEN_ENDKERNDATA:
case AFM_TOKEN_ENDFONTMETRICS:
return PSaux_Err_Ok;
break;
case AFM_TOKEN_UNKNOWN:
break;
@ -814,8 +817,8 @@
FT_UInt n,
AFM_Token end_section )
{
char* key;
FT_UInt len;
char* key;
FT_UInt len;
while ( n-- > 0 )
@ -901,7 +904,7 @@
error = afm_parse_kern_data( parser );
if ( error )
goto Fail;
/* no break since we only support kern data */
/* fall through since we only support kern data */
case AFM_TOKEN_ENDFONTMETRICS:
return PSaux_Err_Ok;
@ -923,3 +926,6 @@
return error;
}
/* END */

View File

@ -57,11 +57,13 @@ FT_BEGIN_HEADER
{
enum AFM_ValueType_ type;
union {
char* s;
FT_Fixed f;
FT_Int i;
FT_Bool b;
char* s;
FT_Fixed f;
FT_Int i;
FT_Bool b;
} u;
} AFM_ValueRec, *AFM_Value;

View File

@ -4,7 +4,7 @@
/* */
/* FreeType auxiliary PostScript driver component (body only). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -4,7 +4,7 @@
/* */
/* FreeType auxiliary PostScript module implementation (body). */
/* */
/* Copyright 2000-2001, 2002, 2003 by */
/* Copyright 2000-2001, 2002, 2003, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -2,7 +2,7 @@
/* */
/* psconv.c */
/* */
/* Some convenient conversions (body). */
/* Some convenience conversions (body). */
/* */
/* Copyright 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@ -24,8 +24,8 @@
#include "psauxerr.h"
/* The following array is used by various functions to quickly convert */
/* digits (both decimal and non-decimal) into numbers. */
/* The following array is used by various functions to quickly convert */
/* digits (both decimal and non-decimal) into numbers. */
#if 'A' == 65
/* ASCII */
@ -69,6 +69,7 @@
#endif /* 'A' == 193 */
FT_LOCAL_DEF( FT_Int )
PS_Conv_Strtol( FT_Byte** cursor,
FT_Byte* limit,
@ -205,7 +206,7 @@
power_ten += PS_Conv_ToInt( &p, limit );
}
Exit:
Exit:
while ( power_ten > 0 )
{
integral *= 10;
@ -325,7 +326,7 @@ Exit:
return r;
}
#endif
#endif /* 0 */
FT_LOCAL_DEF( FT_UInt )
@ -369,11 +370,11 @@ Exit:
FT_LOCAL_DEF( FT_UInt )
PS_Conv_EexecDecode( FT_Byte** cursor,
FT_Byte* limit,
FT_Byte* buffer,
FT_UInt n,
FT_UShort* seed )
PS_Conv_EexecDecode( FT_Byte** cursor,
FT_Byte* limit,
FT_Byte* buffer,
FT_UInt n,
FT_UShort* seed )
{
FT_Byte* p;
FT_UInt r;
@ -392,3 +393,6 @@ Exit:
return r;
}
/* END */

View File

@ -2,7 +2,7 @@
/* */
/* psconv.h */
/* */
/* Some convenient conversions (specification). */
/* Some convenience conversions (specification). */
/* */
/* Copyright 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
@ -56,40 +56,41 @@ FT_BEGIN_HEADER
FT_UInt n );
FT_LOCAL( FT_UInt )
PS_Conv_EexecDecode( FT_Byte** cursor,
FT_Byte* limit,
FT_Byte* buffer,
FT_UInt n,
FT_UShort* seed );
PS_Conv_EexecDecode( FT_Byte** cursor,
FT_Byte* limit,
FT_Byte* buffer,
FT_UInt n,
FT_UShort* seed );
#define IS_PS_NEWLINE( ch ) \
( ( ch ) == '\r' || \
( ( ch ) == '\r' || \
( ch ) == '\n' )
#define IS_PS_SPACE( ch ) \
( ( ch ) == ' ' || \
IS_PS_NEWLINE( ch ) || \
( ch ) == '\t' || \
( ch ) == '\f' || \
#define IS_PS_SPACE( ch ) \
( ( ch ) == ' ' || \
IS_PS_NEWLINE( ch ) || \
( ch ) == '\t' || \
( ch ) == '\f' || \
( ch ) == '\0' )
#define IS_PS_SPECIAL( ch ) \
( ( ch ) == '/' || \
( ch ) == '(' || \
( ch ) == ')' || \
( ch ) == '<' || \
( ch ) == '>' || \
( ch ) == '[' || \
( ch ) == ']' || \
( ch ) == '{' || \
( ch ) == '}' || \
( ( ch ) == '/' || \
( ch ) == '(' || \
( ch ) == ')' || \
( ch ) == '<' || \
( ch ) == '>' || \
( ch ) == '[' || \
( ch ) == ']' || \
( ch ) == '{' || \
( ch ) == '}' || \
( ch ) == '%' )
#define IS_PS_DELIM( ch ) \
( IS_PS_SPACE( ch ) || \
#define IS_PS_DELIM( ch ) \
( IS_PS_SPACE( ch ) || \
IS_PS_SPECIAL( ch ) )
#define IS_PS_DIGIT( ch ) ( ( ch ) >= '0' && ( ch ) <= '9' )
#define IS_PS_DIGIT( ch ) ( ( ch ) >= '0' && ( ch ) <= '9' )
#define IS_PS_XDIGIT( ch ) \
( IS_PS_DIGIT( ( ch ) ) || \

View File

@ -4,7 +4,7 @@
/* */
/* Auxiliary functions for PostScript fonts (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -1117,7 +1117,7 @@
{
if ( *cur != '<' )
{
FT_ERROR(( "ps_tobytes: Missing starting delimiter `<'\n" ));
FT_ERROR(( "ps_parser_to_bytes: Missing starting delimiter `<'\n" ));
error = PSaux_Err_Invalid_File_Format;
goto Exit;
}

View File

@ -3,7 +3,7 @@
#
# Copyright 1996-2000, 2002, 2003 by
# Copyright 1996-2000, 2002, 2003, 2006 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,

View File

@ -4,7 +4,7 @@
/* */
/* AFM support for Type 1 fonts (body). */
/* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005 by */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -98,16 +98,16 @@
FT_Stream stream,
AFM_FontInfo fi )
{
FT_Error error = T1_Err_Ok;
FT_Memory memory = stream->memory;
FT_Byte* start;
FT_Byte* limit;
FT_Byte* p;
AFM_KernPair kp;
FT_Int width_table_length;
FT_CharMap oldcharmap;
FT_CharMap charmap;
FT_Int n;
FT_Error error = T1_Err_Ok;
FT_Memory memory = stream->memory;
FT_Byte* start;
FT_Byte* limit;
FT_Byte* p;
AFM_KernPair kp;
FT_Int width_table_length;
FT_CharMap oldcharmap;
FT_CharMap charmap;
FT_Int n;
start = (FT_Byte*)stream->cursor;
@ -225,11 +225,11 @@
T1_Read_Metrics( FT_Face t1_face,
FT_Stream stream )
{
PSAux_Service psaux;
FT_Memory memory = stream->memory;
AFM_ParserRec parser;
AFM_FontInfo fi;
FT_Error error = T1_Err_Unknown_File_Format;
PSAux_Service psaux;
FT_Memory memory = stream->memory;
AFM_ParserRec parser;
AFM_FontInfo fi;
FT_Error error = T1_Err_Unknown_File_Format;
if ( FT_FRAME_ENTER( stream->size ) )

View File

@ -4,7 +4,7 @@
/* */
/* AFM support for Type 1 fonts (specification). */
/* */
/* Copyright 1996-2001, 2002 by */
/* Copyright 1996-2001, 2002, 2006 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */

View File

@ -38,6 +38,7 @@
#include FT_SERVICE_POSTSCRIPT_INFO_H
#include FT_SERVICE_KERNING_H
/*************************************************************************/
/* */
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */