* include/freetype/internal/psaux.h (PS_Parser_FuncsRec): New

member function `to_bytes'.

* src/psaux/psauxmod.c (ps_parser_funcs): New member
`ps_parser_to_bytes'.
(psaux_module_class): Increase version to 0x20000L.

* src/psaux/psobjs.c (IS_T1_LINESPACE): Add \f.
(IS_T1_NULLSPACE): New macro.
(IS_T1_SPACE): Add it.
(skip_spaces, skip_alpha): New functions.
(ps_parser_skip_spaces, ps_parser_skip_alpha): Use them.
(ps_tobytes, ps_parser_to_bytes): New functions.
This commit is contained in:
Werner Lemberg 2003-07-24 06:16:21 +00:00
parent acf592e72f
commit 850fee2ccb
4 changed files with 137 additions and 15 deletions

View File

@ -1,3 +1,19 @@
2003-07-23 YAMANO-UCHI Hidetoshi <mer@din.or.jp>
* include/freetype/internal/psaux.h (PS_Parser_FuncsRec): New
member function `to_bytes'.
* src/psaux/psauxmod.c (ps_parser_funcs): New member
`ps_parser_to_bytes'.
(psaux_module_class): Increase version to 0x20000L.
* src/psaux/psobjs.c (IS_T1_LINESPACE): Add \f.
(IS_T1_NULLSPACE): New macro.
(IS_T1_SPACE): Add it.
(skip_spaces, skip_alpha): New functions.
(ps_parser_skip_spaces, ps_parser_skip_alpha): Use them.
(ps_tobytes, ps_parser_to_bytes): New functions.
2003-07-07 Werner Lemberg <wl@gnu.org>
* builds/freetype.mk (DOC_DIR): New variable.

View File

@ -352,6 +352,12 @@ FT_BEGIN_HEADER
FT_Fixed
(*to_fixed)( PS_Parser parser,
FT_Int power_ten );
FT_Error
(*to_bytes)( PS_Parser parser,
FT_Byte* bytes,
FT_Int max_bytes,
FT_Int* pnum_bytes );
FT_Int
(*to_coord_array)( PS_Parser parser,
FT_Int max_coords,

View File

@ -4,7 +4,7 @@
/* */
/* FreeType auxiliary PostScript module implementation (body). */
/* */
/* Copyright 2000-2001, 2002 by */
/* Copyright 2000-2001, 2002, 2003 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -42,6 +42,7 @@
ps_parser_skip_alpha,
ps_parser_to_int,
ps_parser_to_fixed,
ps_parser_to_bytes,
ps_parser_to_coord_array,
ps_parser_to_fixed_array,
ps_parser_to_token,
@ -104,7 +105,7 @@
0,
sizeof( FT_ModuleRec ),
"psaux",
0x10000L,
0x20000L,
0x20000L,
&psaux_interface, /* module-specific interface */

View File

@ -266,18 +266,24 @@
/*************************************************************************/
/*************************************************************************/
/* In the PostScript Language Reference Manual (PLRM) the following */
/* characters are called `white-space characters'. */
#define IS_T1_WHITESPACE( c ) ( (c) == ' ' || (c) == '\t' )
#define IS_T1_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' )
#define IS_T1_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' || (c) == '\f' )
#define IS_T1_NULLSPACE( c ) ( (c) == '\0' )
#define IS_T1_SPACE( c ) ( IS_T1_WHITESPACE( c ) || IS_T1_LINESPACE( c ) )
/* According to the PLRM all white-space characters are equivalent, */
/* except in comments and strings. */
#define IS_T1_SPACE( c ) ( IS_T1_WHITESPACE( c ) || \
IS_T1_LINESPACE( c ) || \
IS_T1_NULLSPACE( c ) )
FT_LOCAL_DEF( void )
ps_parser_skip_spaces( PS_Parser parser )
static void
skip_spaces( FT_Byte** acur,
FT_Byte* limit )
{
FT_Byte* cur = parser->cursor;
FT_Byte* limit = parser->limit;
FT_Byte* cur = *acur;
while ( cur < limit )
@ -289,15 +295,16 @@
break;
cur++;
}
parser->cursor = cur;
*acur = cur;
}
FT_LOCAL_DEF( void )
ps_parser_skip_alpha( PS_Parser parser )
static void
skip_alpha( FT_Byte** acur,
FT_Byte* limit )
{
FT_Byte* cur = parser->cursor;
FT_Byte* limit = parser->limit;
FT_Byte* cur = *acur;
while ( cur < limit )
@ -309,7 +316,22 @@
break;
cur++;
}
parser->cursor = cur;
*acur = cur;
}
FT_LOCAL_DEF( void )
ps_parser_skip_spaces( PS_Parser parser )
{
skip_spaces( &parser->cursor, parser->limit );
}
FT_LOCAL_DEF( void )
ps_parser_skip_alpha( PS_Parser parser )
{
skip_alpha( &parser->cursor, parser->limit );
}
@ -531,6 +553,69 @@
}
/* <...>: hexadecimal string */
static FT_Error
ps_tobytes( FT_Byte** cursor,
FT_Byte* limit,
FT_Int max_bytes,
FT_Byte* bytes,
FT_Int* pnum_bytes )
{
FT_Error error = PSaux_Err_Ok;
FT_Byte* cur = *cursor;
FT_Int n = 0;
FT_Byte b;
skip_spaces( &cur, limit );
if ( *cur != '<' )
{
error = PSaux_Err_Invalid_File_Format;
goto Exit;
}
cur++;
for ( ; cur < limit; n++ )
{
FT_Byte* cur2 = cur;
if ( n + 1 > max_bytes * 2 )
goto Exit;
/* All white-space charcters are ignored. */
skip_spaces( &cur, limit );
b = T1Radix( 16, &cur, cur + 1 );
if ( cur == cur2 )
break;
/* <f> == <f0> != <0f> */
bytes[n / 2] = ( n % 2 ) ? bytes[n / 2] + b
: b * 16;
}
skip_spaces( &cur, limit );
if ( *cur != '>' )
{
error = PSaux_Err_Invalid_File_Format;
goto Exit;
}
*cursor = ++cur;
Exit:
*pnum_bytes = ( n + 1 ) / 2;
return error;
}
static FT_Long
t1_tofixed( FT_Byte** cursor,
FT_Byte* limit,
@ -1171,6 +1256,20 @@
}
FT_LOCAL_DEF( FT_Error )
ps_parser_to_bytes( PS_Parser parser,
FT_Byte* bytes,
FT_Int max_bytes,
FT_Int* pnum_bytes )
{
return ps_tobytes( &parser->cursor,
parser->limit,
max_bytes,
bytes,
pnum_bytes );
}
FT_LOCAL_DEF( FT_Fixed )
ps_parser_to_fixed( PS_Parser parser,
FT_Int power_ten )