2000-07-08 21:51:42 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* z1parse.c */
|
|
|
|
/* */
|
|
|
|
/* Experimental 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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The Type 1 parser is in charge of the following: */
|
|
|
|
/* */
|
|
|
|
/* - provide an implementation of a growing sequence of objects called */
|
|
|
|
/* a `Z1_Table' (used to build various tables needed by the loader). */
|
|
|
|
/* */
|
|
|
|
/* - opening .pfb and .pfa files to extract their top-level and private */
|
|
|
|
/* dictionaries. */
|
|
|
|
/* */
|
|
|
|
/* - read numbers, arrays & strings from any dictionary. */
|
|
|
|
/* */
|
|
|
|
/* See `z1load.c' to see how data is loaded from the font file. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-05-11 20:23:52 +02:00
|
|
|
#include <freetype/internal/ftdebug.h>
|
|
|
|
#include <freetype/internal/ftcalc.h>
|
|
|
|
#include <freetype/internal/ftobjs.h>
|
|
|
|
#include <freetype/internal/ftstream.h>
|
2000-06-07 06:48:12 +02:00
|
|
|
#include <freetype/internal/t1errors.h>
|
2000-08-23 04:47:57 +02:00
|
|
|
#include <freetype/internal/psaux.h>
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#ifdef FT_FLAT_COMPILE
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#include "z1parse.h"
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#else
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-07-08 02:41:13 +02:00
|
|
|
#include <type1z/z1parse.h>
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
#endif
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
#include <string.h> /* for strncmp() */
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* 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_z1parse
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** INPUT STREAM PARSER *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#define IS_Z1_WHITESPACE( c ) ( (c) == ' ' || (c) == '\t' )
|
|
|
|
#define IS_Z1_LINESPACE( c ) ( (c) == '\r' || (c) == '\n' )
|
|
|
|
|
|
|
|
#define IS_Z1_SPACE( c ) ( IS_Z1_WHITESPACE( c ) || IS_Z1_LINESPACE( c ) )
|
2000-05-24 23:12:02 +02:00
|
|
|
|
|
|
|
|
2000-08-23 04:47:57 +02:00
|
|
|
typedef struct PFB_Tag_
|
2000-05-24 23:12:02 +02:00
|
|
|
{
|
2000-08-23 04:47:57 +02:00
|
|
|
FT_UShort tag;
|
|
|
|
FT_Long size;
|
|
|
|
|
|
|
|
} PFB_Tag;
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
|
2000-08-23 04:47:57 +02:00
|
|
|
#undef FT_STRUCTURE
|
|
|
|
#define FT_STRUCTURE PFB_Tag
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
static
|
2000-08-23 04:47:57 +02:00
|
|
|
const FT_Frame_Field pfb_tag_fields[] =
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-08-23 04:47:57 +02:00
|
|
|
FT_FRAME_START(6),
|
|
|
|
FT_FRAME_USHORT ( tag ),
|
|
|
|
FT_FRAME_LONG_LE( size ),
|
|
|
|
FT_FRAME_END
|
|
|
|
};
|
2000-05-24 00:16:27 +02:00
|
|
|
|
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
static
|
2000-07-08 21:51:42 +02:00
|
|
|
FT_Error read_pfb_tag( FT_Stream stream,
|
|
|
|
FT_UShort* tag,
|
|
|
|
FT_Long* size )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
2000-08-23 04:47:57 +02:00
|
|
|
PFB_Tag head;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-08-23 04:47:57 +02:00
|
|
|
*tag = 0;
|
|
|
|
*size = 0;
|
|
|
|
if ( !READ_Fields( pfb_tag_fields, &head ) )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-08-23 04:47:57 +02:00
|
|
|
if ( head.tag == 0x8001 || head.tag == 0x8002 )
|
|
|
|
{
|
|
|
|
*tag = head.tag;
|
|
|
|
*size = head.size;
|
|
|
|
}
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOCAL_FUNC
|
2000-08-23 04:47:57 +02:00
|
|
|
FT_Error Z1_New_Parser( Z1_Parser* parser,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_Memory memory,
|
|
|
|
PSAux_Interface* psaux )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_UShort tag;
|
|
|
|
FT_Long size;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-08-23 04:47:57 +02:00
|
|
|
psaux->t1_parser_funcs->init( &parser->root,0, 0, memory );
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
parser->stream = stream;
|
|
|
|
parser->base_len = 0;
|
|
|
|
parser->base_dict = 0;
|
|
|
|
parser->private_len = 0;
|
|
|
|
parser->private_dict = 0;
|
|
|
|
parser->in_pfb = 0;
|
|
|
|
parser->in_memory = 0;
|
|
|
|
parser->single_block = 0;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/******************************************************************/
|
|
|
|
/* */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* Here a short summary of what is going on: */
|
2000-01-27 15:02:04 +01:00
|
|
|
/* */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* When creating a new Type 1 parser, we try to locate and load */
|
|
|
|
/* the base dictionary if this is possible (i.e. for PFB */
|
|
|
|
/* files). Otherwise, we load the whole font into memory. */
|
2000-01-27 15:02:04 +01:00
|
|
|
/* */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* When `loading' the base dictionary, we only setup pointers */
|
|
|
|
/* in the case of a memory-based stream. Otherwise, we */
|
|
|
|
/* allocate and load the base dictionary in it. */
|
2000-01-27 15:02:04 +01:00
|
|
|
/* */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* parser->in_pfb is set if we are in a binary (".pfb") font. */
|
|
|
|
/* parser->in_memory is set if we have a memory stream. */
|
2000-01-27 15:02:04 +01:00
|
|
|
/* */
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* try to compute the size of the base dictionary; */
|
2000-01-27 15:02:04 +01:00
|
|
|
/* look for a Postscript binary file tag, i.e 0x8001 */
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( FILE_Seek( 0L ) )
|
2000-01-27 15:02:04 +01:00
|
|
|
goto Exit;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
error = read_pfb_tag( stream, &tag, &size );
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( tag != 0x8001 )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
/* assume that this is a PFA file for now; an error will */
|
2000-01-27 15:02:04 +01:00
|
|
|
/* be produced later when more things are checked */
|
2000-07-31 20:59:02 +02:00
|
|
|
if ( FILE_Seek( 0L ) )
|
|
|
|
goto Exit;
|
2000-01-27 15:02:04 +01:00
|
|
|
size = stream->size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
parser->in_pfb = 1;
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* now, try to load `size' bytes of the `base' dictionary we */
|
|
|
|
/* found previously */
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* if it is a memory-based resource, set up pointers */
|
2000-02-15 13:55:57 +01:00
|
|
|
if ( !stream->read )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
parser->base_dict = (FT_Byte*)stream->base + stream->pos;
|
2000-02-15 13:55:57 +01:00
|
|
|
parser->base_len = size;
|
|
|
|
parser->in_memory = 1;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* check that the `size' field is valid */
|
|
|
|
if ( FILE_Skip( size ) )
|
|
|
|
goto Exit;
|
2000-02-15 13:55:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* read segment in memory */
|
|
|
|
if ( ALLOC( parser->base_dict, size ) ||
|
|
|
|
FILE_Read( parser->base_dict, size ) )
|
|
|
|
goto Exit;
|
|
|
|
parser->base_len = size;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* Now check font format; we must see `%!PS-AdobeFont-1' */
|
|
|
|
/* or `%!FontType' */
|
2000-02-15 13:55:57 +01:00
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( size <= 16 ||
|
|
|
|
( strncmp( (const char*)parser->base_dict,
|
|
|
|
"%!PS-AdobeFont-1", 16 ) &&
|
|
|
|
strncmp( (const char*)parser->base_dict,
|
|
|
|
"%!FontType", 10 ) ) )
|
2000-02-15 13:55:57 +01:00
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
FT_TRACE2(( "[not a Type1 font]\n" ));
|
2000-05-12 12:19:41 +02:00
|
|
|
error = FT_Err_Unknown_File_Format;
|
2000-02-15 13:55:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-08-23 04:47:57 +02:00
|
|
|
parser->root.base = parser->base_dict;
|
|
|
|
parser->root.cursor = parser->base_dict;
|
|
|
|
parser->root.limit = parser->root.cursor + parser->base_len;
|
2000-02-15 13:55:57 +01:00
|
|
|
}
|
|
|
|
}
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
Exit:
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( error && !parser->in_memory )
|
2000-01-27 15:02:04 +01:00
|
|
|
FREE( parser->base_dict );
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOCAL_FUNC
|
2000-06-28 01:21:51 +02:00
|
|
|
void Z1_Done_Parser( Z1_Parser* parser )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-08-23 04:47:57 +02:00
|
|
|
FT_Memory memory = parser->root.memory;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/* always free the private dictionary */
|
|
|
|
FREE( parser->private_dict );
|
|
|
|
|
|
|
|
/* free the base dictionary only when we have a disk stream */
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( !parser->in_memory )
|
2000-01-27 15:02:04 +01:00
|
|
|
FREE( parser->base_dict );
|
2000-08-23 04:47:57 +02:00
|
|
|
|
|
|
|
parser->root.funcs.done( &parser->root );
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* return the value of an hexadecimal digit */
|
|
|
|
static
|
|
|
|
int hexa_value( char c )
|
|
|
|
{
|
2000-01-27 15:02:04 +01:00
|
|
|
unsigned int d;
|
|
|
|
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
d = (unsigned int)( c - '0' );
|
|
|
|
if ( d <= 9 )
|
|
|
|
return (int)d;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
d = (unsigned int)( c - 'a' );
|
|
|
|
if ( d <= 5 )
|
|
|
|
return (int)( d + 10 );
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
d = (unsigned int)( c - 'A' );
|
|
|
|
if ( d <= 5 )
|
|
|
|
return (int)( d + 10 );
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
LOCAL_FUNC
|
2000-06-28 01:21:51 +02:00
|
|
|
void Z1_Decrypt( FT_Byte* buffer,
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Int length,
|
|
|
|
FT_UShort seed )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
|
|
|
while ( length > 0 )
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte plain;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
plain = ( *buffer ^ ( seed >> 8 ) );
|
|
|
|
seed = ( *buffer + seed ) * 52845 + 22719;
|
2000-01-27 15:02:04 +01:00
|
|
|
*buffer++ = plain;
|
|
|
|
length--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LOCAL_FUNC
|
2000-06-28 01:21:51 +02:00
|
|
|
FT_Error Z1_Get_Private_Dict( Z1_Parser* parser )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
|
|
|
FT_Stream stream = parser->stream;
|
2000-08-23 04:47:57 +02:00
|
|
|
FT_Memory memory = parser->root.memory;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Error error = 0;
|
|
|
|
FT_Long size;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
if ( parser->in_pfb )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
|
|
|
/* in the case of the PFB format, the private dictionary can be */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* made of several segments. We thus first read the number of */
|
2000-01-27 15:02:04 +01:00
|
|
|
/* segments to compute the total size of the private dictionary */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* then re-read them into memory. */
|
|
|
|
FT_Long start_pos = FILE_Pos();
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_UShort tag;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
parser->private_len = 0;
|
2000-01-27 15:02:04 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
error = read_pfb_tag( stream, &tag, &size );
|
|
|
|
if ( error )
|
|
|
|
goto Fail;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( tag != 0x8002 )
|
2000-01-27 15:02:04 +01:00
|
|
|
break;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
parser->private_len += size;
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( FILE_Skip( size ) )
|
2000-01-27 15:02:04 +01:00
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check that we have a private dictionary there */
|
|
|
|
/* and allocate private dictionary buffer */
|
|
|
|
if ( parser->private_len == 0 )
|
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
FT_ERROR(( "Z1_Get_Private_Dict:" ));
|
|
|
|
FT_ERROR(( " invalid private dictionary section\n" ));
|
2000-01-27 15:02:04 +01:00
|
|
|
error = T1_Err_Invalid_File_Format;
|
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( FILE_Seek( start_pos ) ||
|
|
|
|
ALLOC( parser->private_dict, parser->private_len ) )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
parser->private_len = 0;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
error = read_pfb_tag( stream, &tag, &size );
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( error || tag != 0x8002 )
|
|
|
|
{
|
|
|
|
error = FT_Err_Ok;
|
|
|
|
break;
|
|
|
|
}
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
if ( FILE_Read( parser->private_dict + parser->private_len, size ) )
|
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
parser->private_len += size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
/* we have already `loaded' the whole PFA font file into memory; */
|
|
|
|
/* if this is a memory resource, allocate a new block to hold */
|
|
|
|
/* the private dict. Otherwise, simply overwrite into the base */
|
|
|
|
/* dictionary block in the heap. */
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* first of all, look at the `eexec' keyword */
|
2000-01-27 15:02:04 +01:00
|
|
|
FT_Byte* cur = parser->base_dict;
|
2000-05-17 01:44:38 +02:00
|
|
|
FT_Byte* limit = cur + parser->base_len;
|
2000-01-27 15:02:04 +01:00
|
|
|
FT_Byte c;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
c = cur[0];
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( c == 'e' && cur + 9 < limit ) /* 9 = 5 letters for `eexec' + */
|
|
|
|
/* newline + 4 chars */
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
|
|
|
if ( cur[1] == 'e' && cur[2] == 'x' &&
|
|
|
|
cur[3] == 'e' && cur[4] == 'c' )
|
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
cur += 6; /* we skip the newling after the `eexec' */
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* XXX: Some fonts use DOS-linefeeds, i.e. \r\n; we need to */
|
|
|
|
/* skip the extra \n if we find it */
|
|
|
|
if ( cur[0] == '\n' )
|
2000-04-14 13:22:17 +02:00
|
|
|
cur++;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cur++;
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( cur >= limit )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
FT_ERROR(( "Z1_Get_Private_Dict:" ));
|
|
|
|
FT_ERROR(( " could not find `eexec' keyword\n" ));
|
A complete revision of FreeType 2's GNU makefiles (of the library):
Tons of unnecessary stuff have been removed; only the essential rules
have been retained.
The source files now depend on all header files in include/freetype,
include/freetype/config, and include/freetype/internal. This is not
optimal, I know, and I'll try to improve this, but it is better than
before (namely no dependencies on `internal').
FTDEBUG_SRC has been added (similar to FTSYS_SRC) -- I don't know
exactly whether this is really useful, but it doesn't harm.
There is now more documentation in the makefiles itself.
io-frames.html: Use of <th>, <code>, and <var> for better tagging.
Reactivating of FT_DEBUG_LEVEL_xxx macros.
Added a lot of #include directives to make `multi' builds possible -- note
that currently the modules cid, t1, and t1z have clashing structures and
functions which means that you can only use one of these three modules for a
multi build.
Added some missing function declarations to (local) header files.
Renamed some T1_Open_Face() to CID_Open_Face() in the cid module -- a lot
of other functions should be renamed also...
Replaced many FT_xxx stuff with T1_xxx in t1z driver -- this isn't finished
yet...
Fixed FT_Free() to allow a NULL pointer without an assertion (this has
always been a valid assumption in FreeType, at least in FT 1.x).
A lot of other, minor fixes (mostly documentation).
2000-06-11 05:46:57 +02:00
|
|
|
error = T1_Err_Invalid_File_Format;
|
2000-01-27 15:02:04 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* now determine where to write the _encrypted_ binary private */
|
|
|
|
/* dictionary. We overwrite the base dictionary for disk-based */
|
|
|
|
/* resources and allocate a new block otherwise */
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
size = parser->base_len - ( cur - parser->base_dict);
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
if ( parser->in_memory )
|
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
/* note that we allocate one more byte to put a terminating `0' */
|
|
|
|
if ( ALLOC( parser->private_dict, size + 1 ) )
|
|
|
|
goto Fail;
|
2000-01-27 15:02:04 +01:00
|
|
|
parser->private_len = size;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-05-17 01:44:38 +02:00
|
|
|
parser->single_block = 1;
|
2000-01-27 15:02:04 +01:00
|
|
|
parser->private_dict = parser->base_dict;
|
|
|
|
parser->private_len = size;
|
|
|
|
parser->base_dict = 0;
|
|
|
|
parser->base_len = 0;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
/* now determine whether the private dictionary is encoded in binary */
|
|
|
|
/* or hexadecimal ASCII format -- decode it accordingly */
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
/* we need to access the next 4 bytes (after the final \r following */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* the `eexec' keyword); if they all are hexadecimal digits, then */
|
|
|
|
/* we have a case of ASCII storage */
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
if ( ( hexa_value( cur[0] ) | hexa_value( cur[1] ) |
|
|
|
|
hexa_value( cur[2] ) | hexa_value( cur[3] ) ) < 0 )
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
/* binary encoding -- `simply' copy the private dict */
|
|
|
|
MEM_Copy( parser->private_dict, cur, size );
|
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
else
|
2000-05-17 01:44:38 +02:00
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
/* ASCII hexadecimal encoding */
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte* write;
|
|
|
|
FT_Int count;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
write = parser->private_dict;
|
|
|
|
count = 0;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
for ( ;cur < limit; cur++ )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
|
|
|
int hex1;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/* check for newline */
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( cur[0] == '\r' || cur[0] == '\n' )
|
2000-01-27 15:02:04 +01:00
|
|
|
continue;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/* exit if we have a non-hexadecimal digit that isn't a newline */
|
2000-07-08 21:51:42 +02:00
|
|
|
hex1 = hexa_value( cur[0] );
|
|
|
|
if ( hex1 < 0 || cur + 1 >= limit )
|
2000-01-27 15:02:04 +01:00
|
|
|
break;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/* otherwise, store byte */
|
2000-07-08 21:51:42 +02:00
|
|
|
*write++ = ( hex1 << 4 ) | hexa_value( cur[1] );
|
2000-01-27 15:02:04 +01:00
|
|
|
count++;
|
|
|
|
cur++;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/* put a safeguard */
|
|
|
|
parser->private_len = write - parser->private_dict;
|
|
|
|
*write++ = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/* we now decrypt the encoded binary private dictionary */
|
2000-06-28 01:21:51 +02:00
|
|
|
Z1_Decrypt( parser->private_dict, parser->private_len, 55665 );
|
2000-08-23 04:47:57 +02:00
|
|
|
parser->root.base = parser->private_dict;
|
|
|
|
parser->root.cursor = parser->private_dict;
|
|
|
|
parser->root.limit = parser->root.cursor + parser->private_len;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
Fail:
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
/* END */
|