2000-07-08 21:51:42 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
2000-10-28 19:10:06 +02:00
|
|
|
/* t1parse.c */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* */
|
2000-10-28 19:10:06 +02:00
|
|
|
/* Type 1 parser (body). */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* */
|
2008-06-09 22:49:29 +02:00
|
|
|
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2008 by */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* 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 */
|
2000-10-28 19:10:06 +02:00
|
|
|
/* a `T1_Table' (used to build various tables needed by the loader). */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* */
|
|
|
|
/* - opening .pfb and .pfa files to extract their top-level and private */
|
|
|
|
/* dictionaries. */
|
|
|
|
/* */
|
|
|
|
/* - read numbers, arrays & strings from any dictionary. */
|
|
|
|
/* */
|
2000-10-28 19:10:06 +02:00
|
|
|
/* See `t1load.c' to see how data is loaded from the font file. */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_CALC_H
|
|
|
|
#include FT_INTERNAL_STREAM_H
|
|
|
|
#include FT_INTERNAL_POSTSCRIPT_AUX_H
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "t1parse.h"
|
2000-12-08 17:17:16 +01:00
|
|
|
|
Complete redesign of error codes. Please check ftmoderr.h for more
details.
* include/freetype/internal/cfferrs.h,
include/freetype/internal/tterrors.h,
include/freetype/internal/t1errors.h: Removed. Replaced with files
local to the module. All extra error codes have been moved to
`fterrors.h'.
* src/sfnt/ttpost.h: Move error codes to `fterrors.h'.
* src/autohint/aherrors.h, src/cache/ftcerror.h, src/cff/cfferrs.h,
src/cid/ciderrs.h, src/pcf/pcferror.h, src/psaux/psauxerr.h,
src/psnames/psnamerr.h, src/raster/rasterrs.h, src/sfnt/sferrors.h,
src/smooth/ftsmerrs.h, src/truetype/tterrors.h,
src/type1/t1errors.h, src/winfonts/fnterrs.h: New files defining the
error names for the module it belongs to.
* include/freetype/ftmoderr.h: New file, defining the module error
offsets. Its structure is similar to `fterrors.h'.
* include/freetype/fterrors.h (FT_NOERRORDEF): New macro.
(FT_ERRORDEF): Redefined to use module error offsets.
All internal error codes are now public; unused error codes have
been removed, some are new.
* include/freetype/config/ftheader.h (FT_MODULE_ERRORS_H): New
macro.
* include/freetype/config/ftoption.h
(FT_CONFIG_OPTION_USE_MODULE_ERRORS): New macro.
All other source files have been updated to use the new error codes;
some already existing (internal) error codes local to a module have
been renamed to give them the same name as in the base module.
All make files have been updated to include the local error files.
* src/cid/cidtokens.h: Replaced with...
* src/cid/cidtoken.h: This file for 8+3 consistency.
* src/raster/ftraster.c: Use macros for header file names.
2001-06-06 19:30:41 +02:00
|
|
|
#include "t1errors.h"
|
|
|
|
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* 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
|
2000-10-28 19:10:06 +02:00
|
|
|
#define FT_COMPONENT trace_t1parse
|
2000-07-08 21:51:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** INPUT STREAM PARSER *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
|
2008-06-09 22:49:29 +02:00
|
|
|
/* see Adobe Technical Note 5040.Download_Fonts.pdf */
|
|
|
|
|
2001-06-28 09:17:51 +02:00
|
|
|
static FT_Error
|
|
|
|
read_pfb_tag( FT_Stream stream,
|
2003-09-30 08:43:54 +02:00
|
|
|
FT_UShort *atag,
|
2008-06-09 22:49:29 +02:00
|
|
|
FT_ULong *asize )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2003-09-30 08:43:54 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_UShort tag;
|
2008-06-09 22:49:29 +02:00
|
|
|
FT_ULong size;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2003-09-30 08:43:54 +02:00
|
|
|
*atag = 0;
|
|
|
|
*asize = 0;
|
2003-09-20 16:25:10 +02:00
|
|
|
|
2003-09-30 08:43:54 +02:00
|
|
|
if ( !FT_READ_USHORT( tag ) )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2003-09-30 08:43:54 +02:00
|
|
|
if ( tag == 0x8001U || tag == 0x8002U )
|
2000-08-23 04:47:57 +02:00
|
|
|
{
|
2008-06-09 22:49:29 +02:00
|
|
|
if ( !FT_READ_ULONG_LE( size ) )
|
2003-09-30 08:43:54 +02:00
|
|
|
*asize = size;
|
2000-08-23 04:47:57 +02:00
|
|
|
}
|
2003-09-20 16:25:10 +02:00
|
|
|
|
2003-09-30 08:43:54 +02:00
|
|
|
*atag = tag;
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2003-09-20 16:25:10 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-16 00:31:48 +01:00
|
|
|
static FT_Error
|
|
|
|
check_type1_format( FT_Stream stream,
|
|
|
|
const char* header_string,
|
|
|
|
size_t header_length )
|
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_UShort tag;
|
2008-06-09 22:49:29 +02:00
|
|
|
FT_ULong dummy;
|
2005-03-16 00:31:48 +01:00
|
|
|
|
2005-03-16 02:49:54 +01:00
|
|
|
|
2005-03-16 00:31:48 +01:00
|
|
|
if ( FT_STREAM_SEEK( 0 ) )
|
|
|
|
goto Exit;
|
2007-01-16 07:11:27 +01:00
|
|
|
|
2008-06-09 22:49:29 +02:00
|
|
|
error = read_pfb_tag( stream, &tag, &dummy );
|
2005-03-16 00:31:48 +01:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2007-01-16 07:11:27 +01:00
|
|
|
|
2008-06-09 22:49:29 +02:00
|
|
|
/* We assume that the first segment in a PFB is always encoded as */
|
|
|
|
/* text. This might be wrong (and the specification doesn't insist */
|
|
|
|
/* on that), but we have never seen a counterexample. */
|
2005-03-16 00:31:48 +01:00
|
|
|
if ( tag != 0x8001U && FT_STREAM_SEEK( 0 ) )
|
|
|
|
goto Exit;
|
2007-01-16 07:11:27 +01:00
|
|
|
|
2005-03-16 00:31:48 +01:00
|
|
|
if ( !FT_FRAME_ENTER( header_length ) )
|
|
|
|
{
|
2008-06-09 22:49:29 +02:00
|
|
|
error = T1_Err_Ok;
|
2007-01-16 07:11:27 +01:00
|
|
|
|
2005-03-16 00:31:48 +01:00
|
|
|
if ( ft_memcmp( stream->cursor, header_string, header_length ) != 0 )
|
|
|
|
error = T1_Err_Unknown_File_Format;
|
|
|
|
|
|
|
|
FT_FRAME_EXIT();
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2002-02-28 17:10:29 +01:00
|
|
|
T1_New_Parser( T1_Parser parser,
|
|
|
|
FT_Stream stream,
|
|
|
|
FT_Memory memory,
|
|
|
|
PSAux_Service psaux )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2000-08-23 19:32:42 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_UShort tag;
|
2008-06-09 22:49:29 +02:00
|
|
|
FT_ULong size;
|
2000-08-23 19:32:42 +02:00
|
|
|
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2003-10-07 07:49:41 +02:00
|
|
|
psaux->ps_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
|
|
|
|
2005-03-16 02:49:54 +01:00
|
|
|
/* check the header format */
|
2005-04-03 22:44:43 +02:00
|
|
|
error = check_type1_format( stream, "%!PS-AdobeFont", 14 );
|
2005-03-16 00:31:48 +01:00
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
if ( error != T1_Err_Unknown_File_Format )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
error = check_type1_format( stream, "%!FontType", 10 );
|
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( "[not a Type1 font]\n" ));
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 */
|
2008-06-09 22:49:29 +02:00
|
|
|
/* the base dictionary if this is possible (i.e., for PFB */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* 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
|
|
|
/* */
|
2008-06-09 22:49:29 +02:00
|
|
|
/* parser->in_pfb is set if we are in a binary (`.pfb') font. */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* 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
|
|
|
|
2008-06-09 22:49:29 +02:00
|
|
|
/* try to compute the size of the base dictionary; */
|
|
|
|
/* look for a Postscript binary file tag, i.e., 0x8001 */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_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
|
|
|
|
2002-04-02 00:01:46 +02:00
|
|
|
if ( tag != 0x8001U )
|
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 */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( 0L ) )
|
2000-07-31 20:59:02 +02:00
|
|
|
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 */
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SKIP( size ) )
|
2000-07-08 21:51:42 +02:00
|
|
|
goto Exit;
|
2000-02-15 13:55:57 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-06-09 22:49:29 +02:00
|
|
|
/* read segment in memory -- this is clumsy, but so does the format */
|
2005-03-16 02:49:54 +01:00
|
|
|
if ( FT_ALLOC( parser->base_dict, size ) ||
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_STREAM_READ( parser->base_dict, size ) )
|
2000-02-15 13:55:57 +01:00
|
|
|
goto Exit;
|
|
|
|
parser->base_len = size;
|
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2005-03-16 00:31:48 +01:00
|
|
|
parser->root.base = parser->base_dict;
|
|
|
|
parser->root.cursor = parser->base_dict;
|
|
|
|
parser->root.limit = parser->root.cursor + parser->base_len;
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
Exit:
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( error && !parser->in_memory )
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( parser->base_dict );
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
2002-02-28 17:10:29 +01:00
|
|
|
T1_Finalize_Parser( T1_Parser parser )
|
2000-01-27 15:02:04 +01:00
|
|
|
{
|
2002-04-02 00:01:46 +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 */
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( parser->private_dict );
|
2000-01-27 15:02:04 +01:00
|
|
|
|
|
|
|
/* free the base dictionary only when we have a disk stream */
|
2000-07-08 21:51:42 +02:00
|
|
|
if ( !parser->in_memory )
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( parser->base_dict );
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-08-23 04:47:57 +02:00
|
|
|
parser->root.funcs.done( &parser->root );
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2002-02-28 17:10:29 +01:00
|
|
|
T1_Get_Private_Dict( T1_Parser parser,
|
|
|
|
PSAux_Service psaux )
|
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;
|
2003-10-07 07:49:41 +02:00
|
|
|
FT_Error error = T1_Err_Ok;
|
2008-06-09 22:49:29 +02:00
|
|
|
FT_ULong 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. */
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_Long start_pos = FT_STREAM_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
|
|
|
|
2002-04-02 00:01:46 +02:00
|
|
|
if ( tag != 0x8002U )
|
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;
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_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-10-28 19:10:06 +02:00
|
|
|
FT_ERROR(( "T1_Get_Private_Dict:" ));
|
2000-07-08 21:51:42 +02:00
|
|
|
FT_ERROR(( " invalid private dictionary section\n" ));
|
2000-01-27 15:02:04 +01:00
|
|
|
error = T1_Err_Invalid_File_Format;
|
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
2008-06-09 22:49:29 +02:00
|
|
|
if ( FT_STREAM_SEEK( start_pos ) ||
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_ALLOC( parser->private_dict, parser->private_len ) )
|
2000-01-27 15:02:04 +01:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
parser->private_len = 0;
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
error = read_pfb_tag( stream, &tag, &size );
|
2002-04-02 00:01:46 +02:00
|
|
|
if ( error || tag != 0x8002U )
|
2000-07-08 21:51:42 +02:00
|
|
|
{
|
* README: Formatting.
* Jamfile: Fix typo.
* src/cff/cffparse.c: Move error code #defines to...
* include/freetype/internal/cfferrs.h: This file.
* src/cff/cffdrivr.c, src/cff/cffobjs.c, src/cff/cffload.c: Replaced
`FT_Err_*' with `CFF_Err_*'.
* src/cid/cidparse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* src/psaux/psobjs.c, src/psaux/t1decode.c: Ditto.
* src/sfnt/sfobcs.c, src/sfnt/ttload.c: Replaced `FT_Err_*' with
`TT_Err_*'.
* src/truetype/ttgload.c, src/truetype/ttobjs.c: Ditto.
* src/type1/t1gload.c, src/type1/t1load.c, src/type1/t1objs.c,
src/type1/t1parse.c: Replaced `FT_Err_*' with `T1_Err_*'.
* include/freetype/internal/cfferrs.h: Add
`CFF_Err_Unknown_File_Format'.
* include/freetype/internal/t1errors.h: Add
`T1_Err_Unknown_File_Format'.
* include/freetype/internal/tterrors.h: Add
`TT_Err_Unknown_File_Format'.
* src/cff/cffload.h: Add `cff_*_encoding' and `cff_*_charset'
references.
* src/psaux/psobjs.c: Include `FT_INTERNAL_TYPE1_ERRORS_H'.
* src/cff/cffobjs.c (CFF_Init_Face, CFF_Done_Face): Use
FT_LOCAL_DEF.
* src/cid/cidobjs.c (CID_Done_Driver): Ditto.
* src/trutype/ttobjs.c (TT_Init_Face, TT_Done_Face, TT_Init_Size):
Ditto.
* src/type1/t1objs.c (T1_Done_Driver): Ditto.
* src/pcf/pcfdriver.c (PCF_Done_Face): Ditto.
* src/pcf/pcf.h: Use FT_LOCAL for `PCF_Done_Face'.
2001-04-03 01:54:01 +02:00
|
|
|
error = T1_Err_Ok;
|
2000-07-08 21:51:42 +02:00
|
|
|
break;
|
|
|
|
}
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2003-10-07 07:49:41 +02:00
|
|
|
if ( FT_STREAM_READ( parser->private_dict + parser->private_len,
|
|
|
|
size ) )
|
2000-01-27 15:02:04 +01:00
|
|
|
goto Fail;
|
|
|
|
|
|
|
|
parser->private_len += size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-10-07 07:49:41 +02:00
|
|
|
/* We have already `loaded' the whole PFA font file into memory; */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* if this is a memory resource, allocate a new block to hold */
|
2003-10-07 07:49:41 +02:00
|
|
|
/* the private dict. Otherwise, simply overwrite into the base */
|
2000-07-08 21:51:42 +02:00
|
|
|
/* 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
|
|
|
|
2003-10-23 18:24:10 +02:00
|
|
|
Again:
|
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
|
|
|
{
|
2003-10-23 18:24:10 +02:00
|
|
|
if ( cur[1] == 'e' &&
|
|
|
|
cur[2] == 'x' &&
|
|
|
|
cur[3] == 'e' &&
|
|
|
|
cur[4] == 'c' )
|
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-10-28 19:10:06 +02:00
|
|
|
FT_ERROR(( "T1_Get_Private_Dict:" ));
|
2000-07-08 21:51:42 +02:00
|
|
|
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
|
|
|
|
2003-10-23 18:24:10 +02:00
|
|
|
/* check whether `eexec' was real -- it could be in a comment */
|
|
|
|
/* or string (as e.g. in u003043t.gsf from ghostscript) */
|
|
|
|
|
|
|
|
parser->root.cursor = parser->base_dict;
|
|
|
|
parser->root.limit = cur + 9;
|
|
|
|
|
|
|
|
cur = parser->root.cursor;
|
|
|
|
limit = parser->root.limit;
|
|
|
|
|
|
|
|
while ( cur < limit )
|
|
|
|
{
|
|
|
|
if ( *cur == 'e' && ft_strncmp( (char*)cur, "eexec", 5 ) == 0 )
|
|
|
|
goto Found;
|
|
|
|
|
|
|
|
T1_Skip_PS_Token( parser );
|
2005-02-13 22:42:42 +01:00
|
|
|
if ( parser->root.error )
|
|
|
|
break;
|
2003-10-23 18:24:10 +02:00
|
|
|
T1_Skip_Spaces ( parser );
|
|
|
|
cur = parser->root.cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we haven't found the correct `eexec'; go back and continue */
|
|
|
|
/* searching */
|
|
|
|
|
|
|
|
cur = limit;
|
|
|
|
limit = parser->base_dict + parser->base_len;
|
|
|
|
goto Again;
|
|
|
|
|
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
|
|
|
|
2003-10-23 18:24:10 +02:00
|
|
|
Found:
|
|
|
|
parser->root.limit = parser->base_dict + parser->base_len;
|
|
|
|
|
|
|
|
T1_Skip_PS_Token( parser );
|
|
|
|
cur = parser->root.cursor;
|
2004-01-20 00:31:56 +01:00
|
|
|
if ( *cur == '\r' )
|
|
|
|
{
|
|
|
|
cur++;
|
|
|
|
if ( *cur == '\n' )
|
|
|
|
cur++;
|
|
|
|
}
|
|
|
|
else if ( *cur == '\n' )
|
|
|
|
cur++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_ERROR(( "T1_Get_Private_Dict:" ));
|
|
|
|
FT_ERROR(( " `eexec' not properly terminated\n" ));
|
|
|
|
error = T1_Err_Invalid_File_Format;
|
|
|
|
goto Exit;
|
|
|
|
}
|
2003-10-23 18:24:10 +02:00
|
|
|
|
2008-06-09 22:49:29 +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' */
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_ALLOC( parser->private_dict, size + 1 ) )
|
2000-07-08 21:51:42 +02:00
|
|
|
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
|
|
|
|
2003-10-07 07:49:41 +02:00
|
|
|
if ( ft_isxdigit( cur[0] ) && ft_isxdigit( cur[1] ) &&
|
|
|
|
ft_isxdigit( cur[2] ) && ft_isxdigit( cur[3] ) )
|
2000-05-17 01:44:38 +02:00
|
|
|
{
|
2000-07-08 21:51:42 +02:00
|
|
|
/* ASCII hexadecimal encoding */
|
2003-10-07 07:49:41 +02:00
|
|
|
FT_Long len;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
|
2003-10-07 07:49:41 +02:00
|
|
|
parser->root.cursor = cur;
|
|
|
|
(void)psaux->ps_parser_funcs->to_bytes( &parser->root,
|
|
|
|
parser->private_dict,
|
|
|
|
parser->private_len,
|
|
|
|
&len,
|
|
|
|
0 );
|
|
|
|
parser->private_len = len;
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/* put a safeguard */
|
2003-10-07 07:49:41 +02:00
|
|
|
parser->private_dict[len] = '\0';
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2003-10-07 07:49:41 +02:00
|
|
|
else
|
|
|
|
/* binary encoding -- copy the private dict */
|
2004-02-01 01:49:56 +01:00
|
|
|
FT_MEM_MOVE( parser->private_dict, cur, size );
|
2000-01-27 15:02:04 +01:00
|
|
|
}
|
2000-05-17 01:44:38 +02:00
|
|
|
|
2000-01-27 15:02:04 +01:00
|
|
|
/* we now decrypt the encoded binary private dictionary */
|
2001-07-03 14:45:24 +02:00
|
|
|
psaux->t1_decrypt( parser->private_dict, parser->private_len, 55665U );
|
2003-10-07 07:49:41 +02:00
|
|
|
|
|
|
|
/* replace the four random bytes at the beginning with whitespace */
|
|
|
|
parser->private_dict[0] = ' ';
|
|
|
|
parser->private_dict[1] = ' ';
|
|
|
|
parser->private_dict[2] = ' ';
|
|
|
|
parser->private_dict[3] = ' ';
|
|
|
|
|
2002-02-28 17:10:29 +01:00
|
|
|
parser->root.base = parser->private_dict;
|
2000-08-23 04:47:57 +02:00
|
|
|
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 */
|