2000-12-08 03:42:29 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* cffparse.c */
|
|
|
|
/* */
|
|
|
|
/* CFF token stream parser (body) */
|
|
|
|
/* */
|
2013-03-14 10:27:35 +01:00
|
|
|
/* Copyright 1996-2004, 2007-2013 by */
|
2000-12-08 03:42:29 +01: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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
#include <ft2build.h>
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "cffparse.h"
|
2000-12-08 03:42:29 +01:00
|
|
|
#include FT_INTERNAL_STREAM_H
|
2008-06-10 07:58:25 +02:00
|
|
|
#include FT_INTERNAL_DEBUG_H
|
2000-12-08 03:42:29 +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 "cfferrs.h"
|
2009-04-05 17:12:03 +02:00
|
|
|
#include "cffpic.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
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
2000-12-08 03:42:29 +01: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
|
2001-01-03 01:21:59 +01:00
|
|
|
#define FT_COMPONENT trace_cffparse
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( void )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_parser_init( CFF_Parser parser,
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_UInt code,
|
2009-04-05 16:34:40 +02:00
|
|
|
void* object,
|
|
|
|
FT_Library library)
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-07-28 07:05:24 +02:00
|
|
|
FT_MEM_ZERO( parser, sizeof ( *parser ) );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
parser->top = parser->stack;
|
|
|
|
parser->object_code = code;
|
|
|
|
parser->object = object;
|
2009-04-05 16:34:40 +02:00
|
|
|
parser->library = library;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
/* read an integer */
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Long
|
|
|
|
cff_parse_integer( FT_Byte* start,
|
|
|
|
FT_Byte* limit )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
FT_Byte* p = start;
|
|
|
|
FT_Int v = *p++;
|
|
|
|
FT_Long val = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if ( v == 28 )
|
|
|
|
{
|
|
|
|
if ( p + 2 > limit )
|
|
|
|
goto Bad;
|
|
|
|
|
2013-05-04 18:57:56 +02:00
|
|
|
val = (FT_Short)( ( (FT_UShort)p[0] << 8 ) | p[1] );
|
2000-12-08 03:42:29 +01:00
|
|
|
p += 2;
|
|
|
|
}
|
|
|
|
else if ( v == 29 )
|
|
|
|
{
|
|
|
|
if ( p + 4 > limit )
|
|
|
|
goto Bad;
|
|
|
|
|
2013-05-04 18:57:56 +02:00
|
|
|
val = (FT_Long)( ( (FT_ULong)p[0] << 24 ) |
|
|
|
|
( (FT_ULong)p[1] << 16 ) |
|
|
|
|
( (FT_ULong)p[2] << 8 ) |
|
|
|
|
(FT_ULong)p[3] );
|
2000-12-08 03:42:29 +01:00
|
|
|
p += 4;
|
|
|
|
}
|
|
|
|
else if ( v < 247 )
|
|
|
|
{
|
|
|
|
val = v - 139;
|
|
|
|
}
|
|
|
|
else if ( v < 251 )
|
|
|
|
{
|
|
|
|
if ( p + 1 > limit )
|
|
|
|
goto Bad;
|
|
|
|
|
|
|
|
val = ( v - 247 ) * 256 + p[0] + 108;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( p + 1 > limit )
|
|
|
|
goto Bad;
|
|
|
|
|
|
|
|
val = -( v - 251 ) * 256 - p[0] - 108;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return val;
|
|
|
|
|
|
|
|
Bad:
|
|
|
|
val = 0;
|
2012-10-19 09:06:53 +02:00
|
|
|
FT_TRACE4(( "!!!END OF DATA:!!!" ));
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
static const FT_Long power_tens[] =
|
|
|
|
{
|
|
|
|
1L,
|
|
|
|
10L,
|
|
|
|
100L,
|
|
|
|
1000L,
|
|
|
|
10000L,
|
|
|
|
100000L,
|
|
|
|
1000000L,
|
|
|
|
10000000L,
|
|
|
|
100000000L,
|
|
|
|
1000000000L
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
/* read a real */
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Fixed
|
|
|
|
cff_parse_real( FT_Byte* start,
|
|
|
|
FT_Byte* limit,
|
2009-07-31 17:32:08 +02:00
|
|
|
FT_Long power_ten,
|
|
|
|
FT_Long* scaling )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2008-05-04 15:37:38 +02:00
|
|
|
FT_Byte* p = start;
|
2001-06-19 10:28:24 +02:00
|
|
|
FT_UInt nib;
|
|
|
|
FT_UInt phase;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2010-03-09 17:01:21 +01:00
|
|
|
FT_Long result, number, exponent;
|
2012-10-20 21:27:17 +02:00
|
|
|
FT_Int sign = 0, exponent_sign = 0, have_overflow = 0;
|
2009-07-31 17:32:08 +02:00
|
|
|
FT_Long exponent_add, integer_length, fraction_length;
|
2008-05-04 15:37:38 +02:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
if ( scaling )
|
2010-03-09 17:01:21 +01:00
|
|
|
*scaling = 0;
|
2008-05-04 15:37:38 +02:00
|
|
|
|
|
|
|
result = 0;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
number = 0;
|
|
|
|
exponent = 0;
|
|
|
|
|
|
|
|
exponent_add = 0;
|
|
|
|
integer_length = 0;
|
|
|
|
fraction_length = 0;
|
|
|
|
|
|
|
|
/* First of all, read the integer part. */
|
2000-12-08 03:42:29 +01:00
|
|
|
phase = 4;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
/* If we entered this iteration with phase == 4, we need to */
|
2007-01-26 23:18:56 +01:00
|
|
|
/* read a new byte. This also skips past the initial 0x1E. */
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( phase )
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
|
|
|
|
/* Make sure we don't read past the end. */
|
|
|
|
if ( p >= limit )
|
2012-10-19 09:06:53 +02:00
|
|
|
goto Bad;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the nibble. */
|
|
|
|
nib = ( p[0] >> phase ) & 0xF;
|
|
|
|
phase = 4 - phase;
|
|
|
|
|
|
|
|
if ( nib == 0xE )
|
|
|
|
sign = 1;
|
|
|
|
else if ( nib > 9 )
|
|
|
|
break;
|
|
|
|
else
|
2008-05-04 15:37:38 +02:00
|
|
|
{
|
|
|
|
/* Increase exponent if we can't add the digit. */
|
|
|
|
if ( number >= 0xCCCCCCCL )
|
|
|
|
exponent_add++;
|
|
|
|
/* Skip leading zeros. */
|
|
|
|
else if ( nib || number )
|
|
|
|
{
|
|
|
|
integer_length++;
|
|
|
|
number = number * 10 + nib;
|
|
|
|
}
|
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
/* Read fraction part, if any. */
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( nib == 0xa )
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
/* If we entered this iteration with phase == 4, we need */
|
|
|
|
/* to read a new byte. */
|
|
|
|
if ( phase )
|
2000-12-08 17:17:16 +01:00
|
|
|
{
|
2000-12-08 03:42:29 +01:00
|
|
|
p++;
|
|
|
|
|
|
|
|
/* Make sure we don't read past the end. */
|
|
|
|
if ( p >= limit )
|
2012-10-19 09:06:53 +02:00
|
|
|
goto Bad;
|
2000-12-08 17:17:16 +01:00
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
/* Get the nibble. */
|
|
|
|
nib = ( p[0] >> phase ) & 0xF;
|
|
|
|
phase = 4 - phase;
|
|
|
|
if ( nib >= 10 )
|
|
|
|
break;
|
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
/* Skip leading zeros if possible. */
|
|
|
|
if ( !nib && !number )
|
|
|
|
exponent_add--;
|
|
|
|
/* Only add digit if we don't overflow. */
|
2009-03-11 11:20:51 +01:00
|
|
|
else if ( number < 0xCCCCCCCL && fraction_length < 9 )
|
2008-04-01 07:55:48 +02:00
|
|
|
{
|
2008-05-04 15:37:38 +02:00
|
|
|
fraction_length++;
|
|
|
|
number = number * 10 + nib;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
/* Read exponent, if any. */
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( nib == 12 )
|
|
|
|
{
|
2004-08-29 18:50:09 +02:00
|
|
|
exponent_sign = 1;
|
|
|
|
nib = 11;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( nib == 11 )
|
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
2008-05-04 15:37:38 +02:00
|
|
|
/* If we entered this iteration with phase == 4, */
|
|
|
|
/* we need to read a new byte. */
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( phase )
|
2000-12-08 17:17:16 +01:00
|
|
|
{
|
2000-12-08 03:42:29 +01:00
|
|
|
p++;
|
|
|
|
|
|
|
|
/* Make sure we don't read past the end. */
|
|
|
|
if ( p >= limit )
|
2012-10-19 09:06:53 +02:00
|
|
|
goto Bad;
|
2000-12-08 17:17:16 +01:00
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
/* Get the nibble. */
|
|
|
|
nib = ( p[0] >> phase ) & 0xF;
|
|
|
|
phase = 4 - phase;
|
|
|
|
if ( nib >= 10 )
|
|
|
|
break;
|
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
/* Arbitrarily limit exponent. */
|
|
|
|
if ( exponent > 1000 )
|
2012-10-20 21:27:17 +02:00
|
|
|
have_overflow = 1;
|
|
|
|
else
|
|
|
|
exponent = exponent * 10 + nib;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2004-08-29 18:50:09 +02:00
|
|
|
if ( exponent_sign )
|
|
|
|
exponent = -exponent;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2012-10-19 09:06:53 +02:00
|
|
|
if ( !number )
|
|
|
|
goto Exit;
|
|
|
|
|
2012-10-20 21:27:17 +02:00
|
|
|
if ( have_overflow )
|
|
|
|
{
|
|
|
|
if ( exponent_sign )
|
|
|
|
goto Underflow;
|
|
|
|
else
|
|
|
|
goto Overflow;
|
|
|
|
}
|
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
/* We don't check `power_ten' and `exponent_add'. */
|
|
|
|
exponent += power_ten + exponent_add;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
if ( scaling )
|
2007-12-14 08:48:32 +01:00
|
|
|
{
|
2008-05-04 15:37:38 +02:00
|
|
|
/* Only use `fraction_length'. */
|
|
|
|
fraction_length += integer_length;
|
|
|
|
exponent += integer_length;
|
|
|
|
|
|
|
|
if ( fraction_length <= 5 )
|
|
|
|
{
|
|
|
|
if ( number > 0x7FFFL )
|
|
|
|
{
|
|
|
|
result = FT_DivFix( number, 10 );
|
|
|
|
*scaling = exponent - fraction_length + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( exponent > 0 )
|
|
|
|
{
|
2009-07-31 17:32:08 +02:00
|
|
|
FT_Long new_fraction_length, shift;
|
2008-05-04 15:37:38 +02:00
|
|
|
|
2007-12-14 08:48:32 +01:00
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
/* Make `scaling' as small as possible. */
|
|
|
|
new_fraction_length = FT_MIN( exponent, 5 );
|
|
|
|
shift = new_fraction_length - fraction_length;
|
|
|
|
|
2012-06-25 10:58:20 +02:00
|
|
|
if ( shift > 0 )
|
2008-05-04 15:37:38 +02:00
|
|
|
{
|
2012-06-25 10:58:20 +02:00
|
|
|
exponent -= new_fraction_length;
|
|
|
|
number *= power_tens[shift];
|
|
|
|
if ( number > 0x7FFFL )
|
|
|
|
{
|
|
|
|
number /= 10;
|
|
|
|
exponent += 1;
|
|
|
|
}
|
2008-05-04 15:37:38 +02:00
|
|
|
}
|
2012-06-25 10:58:20 +02:00
|
|
|
else
|
|
|
|
exponent -= fraction_length;
|
2008-05-04 15:37:38 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
exponent -= fraction_length;
|
|
|
|
|
2013-05-04 16:40:12 +02:00
|
|
|
result = (FT_Long)( (FT_ULong)number << 16 );
|
2008-05-04 15:37:38 +02:00
|
|
|
*scaling = exponent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( ( number / power_tens[fraction_length - 5] ) > 0x7FFFL )
|
|
|
|
{
|
|
|
|
result = FT_DivFix( number, power_tens[fraction_length - 4] );
|
|
|
|
*scaling = exponent - 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = FT_DivFix( number, power_tens[fraction_length - 5] );
|
|
|
|
*scaling = exponent - 5;
|
|
|
|
}
|
|
|
|
}
|
2007-12-14 08:48:32 +01:00
|
|
|
}
|
2008-05-04 15:37:38 +02:00
|
|
|
else
|
2007-12-14 08:48:32 +01:00
|
|
|
{
|
2008-05-04 15:37:38 +02:00
|
|
|
integer_length += exponent;
|
|
|
|
fraction_length -= exponent;
|
2007-12-14 08:48:32 +01:00
|
|
|
|
2012-10-20 21:27:17 +02:00
|
|
|
if ( integer_length > 5 )
|
2012-10-19 09:06:53 +02:00
|
|
|
goto Overflow;
|
2012-10-20 21:27:17 +02:00
|
|
|
if ( integer_length < -5 )
|
|
|
|
goto Underflow;
|
2008-05-04 15:37:38 +02:00
|
|
|
|
2008-11-27 22:55:20 +01:00
|
|
|
/* Remove non-significant digits. */
|
2010-06-08 08:37:11 +02:00
|
|
|
if ( integer_length < 0 )
|
|
|
|
{
|
2008-11-27 22:55:20 +01:00
|
|
|
number /= power_tens[-integer_length];
|
|
|
|
fraction_length += integer_length;
|
|
|
|
}
|
|
|
|
|
2010-06-08 09:21:39 +02:00
|
|
|
/* this can only happen if exponent was non-zero */
|
|
|
|
if ( fraction_length == 10 )
|
|
|
|
{
|
|
|
|
number /= 10;
|
|
|
|
fraction_length -= 1;
|
|
|
|
}
|
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
/* Convert into 16.16 format. */
|
|
|
|
if ( fraction_length > 0 )
|
|
|
|
{
|
|
|
|
if ( ( number / power_tens[fraction_length] ) > 0x7FFFL )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
result = FT_DivFix( number, power_tens[fraction_length] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
number *= power_tens[-fraction_length];
|
|
|
|
|
|
|
|
if ( number > 0x7FFFL )
|
2012-10-19 09:06:53 +02:00
|
|
|
goto Overflow;
|
2008-05-04 15:37:38 +02:00
|
|
|
|
2013-05-04 16:40:12 +02:00
|
|
|
result = (FT_Long)( (FT_ULong)number << 16 );
|
2008-05-04 15:37:38 +02:00
|
|
|
}
|
2007-12-14 08:48:32 +01:00
|
|
|
}
|
|
|
|
|
2012-10-19 09:06:53 +02:00
|
|
|
Exit:
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( sign )
|
|
|
|
result = -result;
|
|
|
|
|
|
|
|
return result;
|
2012-10-19 09:06:53 +02:00
|
|
|
|
|
|
|
Overflow:
|
|
|
|
result = 0x7FFFFFFFL;
|
|
|
|
FT_TRACE4(( "!!!OVERFLOW:!!!" ));
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
Underflow:
|
|
|
|
result = 0;
|
|
|
|
FT_TRACE4(( "!!!UNDERFLOW:!!!" ));
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
Bad:
|
|
|
|
result = 0;
|
|
|
|
FT_TRACE4(( "!!!END OF DATA:!!!" ));
|
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* read a number, either integer or real */
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Long
|
|
|
|
cff_parse_num( FT_Byte** d )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2008-05-04 15:37:38 +02:00
|
|
|
return **d == 30 ? ( cff_parse_real( d[0], d[1], 0, NULL ) >> 16 )
|
|
|
|
: cff_parse_integer( d[0], d[1] );
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
/* read a floating point number, either integer or real */
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Fixed
|
2012-10-19 09:06:53 +02:00
|
|
|
do_fixed( FT_Byte** d,
|
|
|
|
FT_Long scaling )
|
2001-02-07 02:11:54 +01:00
|
|
|
{
|
2012-10-17 19:55:20 +02:00
|
|
|
if ( **d == 30 )
|
|
|
|
return cff_parse_real( d[0], d[1], scaling, NULL );
|
|
|
|
else
|
|
|
|
{
|
2012-10-19 09:06:53 +02:00
|
|
|
FT_Long val = cff_parse_integer( d[0], d[1] );
|
|
|
|
|
2012-10-17 19:55:20 +02:00
|
|
|
|
2012-10-19 09:06:53 +02:00
|
|
|
if ( scaling )
|
|
|
|
val *= power_tens[scaling];
|
2012-10-17 19:55:20 +02:00
|
|
|
|
|
|
|
if ( val > 0x7FFF )
|
2012-10-19 09:06:53 +02:00
|
|
|
{
|
|
|
|
val = 0x7FFFFFFFL;
|
|
|
|
goto Overflow;
|
|
|
|
}
|
2012-10-17 19:55:20 +02:00
|
|
|
else if ( val < -0x7FFF )
|
2012-10-19 09:06:53 +02:00
|
|
|
{
|
|
|
|
val = -0x7FFFFFFFL;
|
|
|
|
goto Overflow;
|
|
|
|
}
|
2012-10-17 19:55:20 +02:00
|
|
|
|
2013-05-04 16:40:12 +02:00
|
|
|
return (FT_Long)( (FT_ULong)val << 16 );
|
2012-10-19 09:06:53 +02:00
|
|
|
|
|
|
|
Overflow:
|
|
|
|
FT_TRACE4(( "!!!OVERFLOW:!!!" ));
|
|
|
|
return val;
|
2012-10-17 19:55:20 +02:00
|
|
|
}
|
2001-02-07 02:11:54 +01:00
|
|
|
}
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2008-05-04 15:37:38 +02:00
|
|
|
|
2012-10-19 09:06:53 +02:00
|
|
|
/* read a floating point number, either integer or real */
|
|
|
|
static FT_Fixed
|
|
|
|
cff_parse_fixed( FT_Byte** d )
|
|
|
|
{
|
|
|
|
return do_fixed( d, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* read a floating point number, either integer or real, */
|
|
|
|
/* but return `10^scaling' times the number read in */
|
|
|
|
static FT_Fixed
|
|
|
|
cff_parse_fixed_scaled( FT_Byte** d,
|
|
|
|
FT_Long scaling )
|
|
|
|
{
|
|
|
|
return do_fixed( d, scaling );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
/* read a floating point number, either integer or real, */
|
|
|
|
/* and return it as precise as possible -- `scaling' returns */
|
|
|
|
/* the scaling factor (as a power of 10) */
|
|
|
|
static FT_Fixed
|
|
|
|
cff_parse_fixed_dynamic( FT_Byte** d,
|
2009-07-31 17:32:08 +02:00
|
|
|
FT_Long* scaling )
|
2008-05-15 01:05:38 +02:00
|
|
|
{
|
|
|
|
FT_ASSERT( scaling );
|
|
|
|
|
|
|
|
if ( **d == 30 )
|
|
|
|
return cff_parse_real( d[0], d[1], 0, scaling );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FT_Long number;
|
|
|
|
FT_Int integer_length;
|
|
|
|
|
|
|
|
|
|
|
|
number = cff_parse_integer( d[0], d[1] );
|
|
|
|
|
|
|
|
if ( number > 0x7FFFL )
|
|
|
|
{
|
|
|
|
for ( integer_length = 5; integer_length < 10; integer_length++ )
|
|
|
|
if ( number < power_tens[integer_length] )
|
|
|
|
break;
|
|
|
|
|
|
|
|
if ( ( number / power_tens[integer_length - 5] ) > 0x7FFFL )
|
|
|
|
{
|
|
|
|
*scaling = integer_length - 4;
|
|
|
|
return FT_DivFix( number, power_tens[integer_length - 4] );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*scaling = integer_length - 5;
|
|
|
|
return FT_DivFix( number, power_tens[integer_length - 5] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*scaling = 0;
|
2013-05-04 16:40:12 +02:00
|
|
|
return (FT_Long)( (FT_ULong)number << 16 );
|
2008-05-15 01:05:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
2002-03-30 17:41:09 +01:00
|
|
|
cff_parse_font_matrix( CFF_Parser parser )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-03-14 09:57:10 +01:00
|
|
|
CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Matrix* matrix = &dict->font_matrix;
|
|
|
|
FT_Vector* offset = &dict->font_offset;
|
2008-05-15 01:05:38 +02:00
|
|
|
FT_ULong* upm = &dict->units_per_em;
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Byte** data = parser->stack;
|
2013-03-14 17:50:49 +01:00
|
|
|
FT_Error error = FT_ERR( Stack_Underflow );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2000-12-30 23:14:58 +01:00
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( parser->top >= parser->stack + 6 )
|
|
|
|
{
|
2009-07-31 17:32:08 +02:00
|
|
|
FT_Long scaling;
|
2000-12-24 10:57:28 +01:00
|
|
|
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2008-05-15 01:05:38 +02:00
|
|
|
|
2011-09-07 15:01:20 +02:00
|
|
|
dict->has_font_matrix = TRUE;
|
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
/* We expect a well-formed font matrix, this is, the matrix elements */
|
|
|
|
/* `xx' and `yy' are of approximately the same magnitude. To avoid */
|
|
|
|
/* loss of precision, we use the magnitude of element `xx' to scale */
|
|
|
|
/* all other elements. The scaling factor is then contained in the */
|
|
|
|
/* `units_per_em' value. */
|
2008-04-01 07:55:48 +02:00
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
matrix->xx = cff_parse_fixed_dynamic( data++, &scaling );
|
2001-02-07 02:11:54 +01:00
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
scaling = -scaling;
|
|
|
|
|
|
|
|
if ( scaling < 0 || scaling > 9 )
|
2000-12-24 10:57:28 +01:00
|
|
|
{
|
2012-03-04 08:35:03 +01:00
|
|
|
/* Return default matrix in case of unlikely values. */
|
|
|
|
|
2011-07-29 06:15:20 +02:00
|
|
|
FT_TRACE1(( "cff_parse_font_matrix:"
|
|
|
|
" strange scaling value for xx element (%d),\n"
|
|
|
|
" "
|
|
|
|
" using default matrix\n", scaling ));
|
2012-03-04 08:35:03 +01:00
|
|
|
|
|
|
|
matrix->xx = 0x10000L;
|
|
|
|
matrix->yx = 0;
|
|
|
|
matrix->xy = 0;
|
|
|
|
matrix->yy = 0x10000L;
|
|
|
|
offset->x = 0;
|
|
|
|
offset->y = 0;
|
|
|
|
*upm = 1;
|
|
|
|
|
|
|
|
goto Exit;
|
2000-12-24 10:57:28 +01:00
|
|
|
}
|
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
matrix->yx = cff_parse_fixed_scaled( data++, scaling );
|
|
|
|
matrix->xy = cff_parse_fixed_scaled( data++, scaling );
|
|
|
|
matrix->yy = cff_parse_fixed_scaled( data++, scaling );
|
|
|
|
offset->x = cff_parse_fixed_scaled( data++, scaling );
|
|
|
|
offset->y = cff_parse_fixed_scaled( data, scaling );
|
2000-12-24 10:57:28 +01:00
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
*upm = power_tens[scaling];
|
2011-07-29 06:15:20 +02:00
|
|
|
|
2011-09-07 15:01:20 +02:00
|
|
|
FT_TRACE4(( " [%f %f %f %f %f %f]\n",
|
2011-07-29 06:15:20 +02:00
|
|
|
(double)matrix->xx / *upm / 65536,
|
|
|
|
(double)matrix->xy / *upm / 65536,
|
|
|
|
(double)matrix->yx / *upm / 65536,
|
2011-09-07 15:01:20 +02:00
|
|
|
(double)matrix->yy / *upm / 65536,
|
|
|
|
(double)offset->x / *upm / 65536,
|
|
|
|
(double)offset->y / *upm / 65536 ));
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
2008-05-15 01:05:38 +02:00
|
|
|
Exit:
|
2000-12-08 03:42:29 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
2002-03-30 17:41:09 +01:00
|
|
|
cff_parse_font_bbox( CFF_Parser parser )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-03-14 09:57:10 +01:00
|
|
|
CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_BBox* bbox = &dict->font_bbox;
|
|
|
|
FT_Byte** data = parser->stack;
|
|
|
|
FT_Error error;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
error = FT_ERR( Stack_Underflow );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
if ( parser->top >= parser->stack + 4 )
|
|
|
|
{
|
2001-03-17 20:01:25 +01:00
|
|
|
bbox->xMin = FT_RoundFix( cff_parse_fixed( data++ ) );
|
|
|
|
bbox->yMin = FT_RoundFix( cff_parse_fixed( data++ ) );
|
|
|
|
bbox->xMax = FT_RoundFix( cff_parse_fixed( data++ ) );
|
|
|
|
bbox->yMax = FT_RoundFix( cff_parse_fixed( data ) );
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2011-07-29 06:15:20 +02:00
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
FT_TRACE4(( " [%d %d %d %d]\n",
|
2011-07-29 06:15:20 +02:00
|
|
|
bbox->xMin / 65536,
|
|
|
|
bbox->yMin / 65536,
|
|
|
|
bbox->xMax / 65536,
|
|
|
|
bbox->yMax / 65536 ));
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
2002-03-30 17:41:09 +01:00
|
|
|
cff_parse_private_dict( CFF_Parser parser )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-03-14 09:57:10 +01:00
|
|
|
CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Byte** data = parser->stack;
|
|
|
|
FT_Error error;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
error = FT_ERR( Stack_Underflow );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
if ( parser->top >= parser->stack + 2 )
|
|
|
|
{
|
|
|
|
dict->private_size = cff_parse_num( data++ );
|
|
|
|
dict->private_offset = cff_parse_num( data );
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
FT_TRACE4(( " %lu %lu\n",
|
|
|
|
dict->private_size, dict->private_offset ));
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
2002-03-30 17:41:09 +01:00
|
|
|
cff_parse_cid_ros( CFF_Parser parser )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2002-03-14 09:57:10 +01:00
|
|
|
CFF_FontRecDict dict = (CFF_FontRecDict)parser->object;
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Byte** data = parser->stack;
|
|
|
|
FT_Error error;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
2013-03-14 17:50:49 +01:00
|
|
|
error = FT_ERR( Stack_Underflow );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
if ( parser->top >= parser->stack + 3 )
|
|
|
|
{
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
dict->cid_registry = (FT_UInt)cff_parse_num( data++ );
|
|
|
|
dict->cid_ordering = (FT_UInt)cff_parse_num( data++ );
|
2009-07-31 17:32:06 +02:00
|
|
|
if ( **data == 30 )
|
|
|
|
FT_TRACE1(( "cff_parse_cid_ros: real supplement is rounded\n" ));
|
|
|
|
dict->cid_supplement = cff_parse_num( data );
|
|
|
|
if ( dict->cid_supplement < 0 )
|
|
|
|
FT_TRACE1(( "cff_parse_cid_ros: negative supplement %d is found\n",
|
|
|
|
dict->cid_supplement ));
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2011-07-29 06:15:20 +02:00
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
FT_TRACE4(( " %d %d %d\n",
|
2011-07-29 06:15:20 +02:00
|
|
|
dict->cid_registry,
|
|
|
|
dict->cid_ordering,
|
|
|
|
dict->cid_supplement ));
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD_NUM( code, name, id ) \
|
|
|
|
CFF_FIELD( code, name, id, cff_kind_num )
|
|
|
|
#define CFF_FIELD_FIXED( code, name, id ) \
|
|
|
|
CFF_FIELD( code, name, id, cff_kind_fixed )
|
|
|
|
#define CFF_FIELD_FIXED_1000( code, name, id ) \
|
|
|
|
CFF_FIELD( code, name, id, cff_kind_fixed_thousand )
|
|
|
|
#define CFF_FIELD_STRING( code, name, id ) \
|
|
|
|
CFF_FIELD( code, name, id, cff_kind_string )
|
|
|
|
#define CFF_FIELD_BOOL( code, name, id ) \
|
|
|
|
CFF_FIELD( code, name, id, cff_kind_bool )
|
2000-12-08 03:42:29 +01:00
|
|
|
|
2009-04-05 17:12:03 +02:00
|
|
|
#define CFFCODE_TOPDICT 0x1000
|
|
|
|
#define CFFCODE_PRIVATE 0x2000
|
|
|
|
|
2011-08-24 20:50:25 +02:00
|
|
|
|
2009-04-05 17:12:03 +02:00
|
|
|
#ifndef FT_CONFIG_OPTION_PIC
|
|
|
|
|
2011-08-24 20:50:25 +02:00
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#undef CFF_FIELD
|
|
|
|
#undef CFF_FIELD_DELTA
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FT_DEBUG_LEVEL_TRACE
|
|
|
|
|
|
|
|
|
|
|
|
#define CFF_FIELD_CALLBACK( code, name, id ) \
|
|
|
|
{ \
|
|
|
|
cff_kind_callback, \
|
|
|
|
code | CFFCODE, \
|
|
|
|
0, 0, \
|
|
|
|
cff_parse_ ## name, \
|
|
|
|
0, 0 \
|
2000-12-08 03:42:29 +01:00
|
|
|
},
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD( code, name, id, kind ) \
|
|
|
|
{ \
|
|
|
|
kind, \
|
|
|
|
code | CFFCODE, \
|
|
|
|
FT_FIELD_OFFSET( name ), \
|
|
|
|
FT_FIELD_SIZE( name ), \
|
|
|
|
0, 0, 0 \
|
2000-12-08 03:42:29 +01:00
|
|
|
},
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD_DELTA( code, name, max, id ) \
|
|
|
|
{ \
|
|
|
|
cff_kind_delta, \
|
|
|
|
code | CFFCODE, \
|
|
|
|
FT_FIELD_OFFSET( name ), \
|
|
|
|
FT_FIELD_SIZE_DELTA( name ), \
|
|
|
|
0, \
|
|
|
|
max, \
|
|
|
|
FT_FIELD_OFFSET( num_ ## name ) \
|
|
|
|
},
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
static const CFF_Field_Handler cff_field_handlers[] =
|
|
|
|
{
|
|
|
|
|
2001-03-20 12:14:24 +01:00
|
|
|
#include "cfftoken.h"
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
{ 0, 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#else /* FT_DEBUG_LEVEL_TRACE */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define CFF_FIELD_CALLBACK( code, name, id ) \
|
|
|
|
{ \
|
|
|
|
cff_kind_callback, \
|
|
|
|
code | CFFCODE, \
|
|
|
|
0, 0, \
|
|
|
|
cff_parse_ ## name, \
|
|
|
|
0, 0, \
|
|
|
|
id \
|
|
|
|
},
|
|
|
|
|
|
|
|
#define CFF_FIELD( code, name, id, kind ) \
|
|
|
|
{ \
|
|
|
|
kind, \
|
|
|
|
code | CFFCODE, \
|
|
|
|
FT_FIELD_OFFSET( name ), \
|
|
|
|
FT_FIELD_SIZE( name ), \
|
|
|
|
0, 0, 0, \
|
|
|
|
id \
|
|
|
|
},
|
|
|
|
|
|
|
|
#define CFF_FIELD_DELTA( code, name, max, id ) \
|
|
|
|
{ \
|
|
|
|
cff_kind_delta, \
|
|
|
|
code | CFFCODE, \
|
|
|
|
FT_FIELD_OFFSET( name ), \
|
|
|
|
FT_FIELD_SIZE_DELTA( name ), \
|
|
|
|
0, \
|
|
|
|
max, \
|
|
|
|
FT_FIELD_OFFSET( num_ ## name ), \
|
|
|
|
id \
|
|
|
|
},
|
|
|
|
|
|
|
|
static const CFF_Field_Handler cff_field_handlers[] =
|
|
|
|
{
|
|
|
|
|
|
|
|
#include "cfftoken.h"
|
|
|
|
|
|
|
|
{ 0, 0, 0, 0, 0, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FT_DEBUG_LEVEL_TRACE */
|
|
|
|
|
|
|
|
|
2009-04-05 17:12:03 +02:00
|
|
|
#else /* FT_CONFIG_OPTION_PIC */
|
|
|
|
|
2011-08-24 20:50:25 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
FT_Destroy_Class_cff_field_handlers( FT_Library library,
|
|
|
|
CFF_Field_Handler* clazz )
|
2009-04-05 17:12:03 +02:00
|
|
|
{
|
2011-08-24 20:50:25 +02:00
|
|
|
FT_Memory memory = library->memory;
|
|
|
|
|
|
|
|
|
2009-04-05 17:12:03 +02:00
|
|
|
if ( clazz )
|
|
|
|
FT_FREE( clazz );
|
|
|
|
}
|
|
|
|
|
2011-08-24 20:50:25 +02:00
|
|
|
|
|
|
|
FT_Error
|
|
|
|
FT_Create_Class_cff_field_handlers( FT_Library library,
|
|
|
|
CFF_Field_Handler** output_class )
|
2009-04-05 17:12:03 +02:00
|
|
|
{
|
[FT_CONFIG_OPTION_PIC] Fix g++ 4.6.2 compiler warnings.
* include/freetype/internal/ftdriver.h (FT_DEFINE_DRIVER),
include/freetype/internal/ftobjs.h (FT_DEFINE_RENDERER,
FT_DEFINE_MODULE), include/freetype/internal/ftserv.h
(FT_DEFINE_SERVICEDESCREC1, FT_DEFINE_SERVICEDESCREC2,
FT_DEFINE_SERVICEDESCREC3, FT_DEFINE_SERVICEDESCREC4,
FT_DEFINE_SERVICEDESCREC5, FT_DEFINE_SERVICEDESCREC6),
src/autofit/afpic.c (autofit_module_class_pic_init),
src/base/basepic.c (ft_base_pic_init), src/base/ftinit.c
(ft_create_default_module_classes), src/cff/cffparse.c
(FT_Create_Class_cff_field_handlers), src/cff/cffpic.c
(cff_driver_class_pic_init), src/pshinter/pshpic.c
(pshinter_module_class_pic_init), src/psnames/pspic.c
(psnames_module_class_pic_init), src/raster/rastpic.c
(ft_raster1_renderer_class_pic_init), src/sfnt/sfntpic.c
(sfnt_module_class_pic_init), src/sfnt/ttcmap.c
(FT_Create_Class_tt_cmap_classes), src/smooth/ftspic.c
(ft_smooth_renderer_class_pic_init), src/truetype/ttpic.c
(tt_driver_class_pic_init): Initialize allocation variable.
2012-08-27 11:23:41 +02:00
|
|
|
CFF_Field_Handler* clazz = NULL;
|
2011-08-24 20:50:25 +02:00
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory = library->memory;
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
2009-04-05 17:12:03 +02:00
|
|
|
|
|
|
|
#undef CFF_FIELD
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD( code, name, id, kind ) i++;
|
2009-04-05 17:12:03 +02:00
|
|
|
#undef CFF_FIELD_DELTA
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD_DELTA( code, name, max, id ) i++;
|
2009-04-05 17:12:03 +02:00
|
|
|
#undef CFF_FIELD_CALLBACK
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD_CALLBACK( code, name, id ) i++;
|
2009-04-05 17:12:03 +02:00
|
|
|
|
|
|
|
#include "cfftoken.h"
|
|
|
|
|
2011-08-24 20:50:25 +02:00
|
|
|
i++; /* { 0, 0, 0, 0, 0, 0, 0 } */
|
|
|
|
|
|
|
|
if ( FT_ALLOC( clazz, sizeof ( CFF_Field_Handler ) * i ) )
|
2009-04-05 17:12:03 +02:00
|
|
|
return error;
|
|
|
|
|
2011-08-24 20:50:25 +02:00
|
|
|
i = 0;
|
2009-04-05 17:12:03 +02:00
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
|
|
|
|
#ifndef FT_DEBUG_LEVEL_TRACE
|
|
|
|
|
|
|
|
|
2011-08-24 20:50:25 +02:00
|
|
|
#undef CFF_FIELD_CALLBACK
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD_CALLBACK( code_, name_, id_ ) \
|
2011-08-24 20:50:25 +02:00
|
|
|
clazz[i].kind = cff_kind_callback; \
|
|
|
|
clazz[i].code = code_ | CFFCODE; \
|
|
|
|
clazz[i].offset = 0; \
|
|
|
|
clazz[i].size = 0; \
|
|
|
|
clazz[i].reader = cff_parse_ ## name_; \
|
|
|
|
clazz[i].array_max = 0; \
|
|
|
|
clazz[i].count_offset = 0; \
|
|
|
|
i++;
|
2009-04-05 17:12:03 +02:00
|
|
|
|
|
|
|
#undef CFF_FIELD
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD( code_, name_, id_, kind_ ) \
|
2011-08-24 20:50:25 +02:00
|
|
|
clazz[i].kind = kind_; \
|
|
|
|
clazz[i].code = code_ | CFFCODE; \
|
|
|
|
clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
|
|
|
|
clazz[i].size = FT_FIELD_SIZE( name_ ); \
|
|
|
|
clazz[i].reader = 0; \
|
|
|
|
clazz[i].array_max = 0; \
|
|
|
|
clazz[i].count_offset = 0; \
|
|
|
|
i++; \
|
2009-04-05 17:12:03 +02:00
|
|
|
|
|
|
|
#undef CFF_FIELD_DELTA
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \
|
2011-08-24 20:50:25 +02:00
|
|
|
clazz[i].kind = cff_kind_delta; \
|
|
|
|
clazz[i].code = code_ | CFFCODE; \
|
|
|
|
clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
|
|
|
|
clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
|
|
|
|
clazz[i].reader = 0; \
|
|
|
|
clazz[i].array_max = max_; \
|
|
|
|
clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
|
|
|
|
i++;
|
2009-04-05 17:12:03 +02:00
|
|
|
|
|
|
|
#include "cfftoken.h"
|
|
|
|
|
2011-08-24 20:50:25 +02:00
|
|
|
clazz[i].kind = 0;
|
|
|
|
clazz[i].code = 0;
|
|
|
|
clazz[i].offset = 0;
|
|
|
|
clazz[i].size = 0;
|
|
|
|
clazz[i].reader = 0;
|
|
|
|
clazz[i].array_max = 0;
|
2009-04-05 17:12:03 +02:00
|
|
|
clazz[i].count_offset = 0;
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
|
|
|
|
#else /* FT_DEBUG_LEVEL_TRACE */
|
|
|
|
|
|
|
|
|
|
|
|
#undef CFF_FIELD_CALLBACK
|
|
|
|
#define CFF_FIELD_CALLBACK( code_, name_, id_ ) \
|
|
|
|
clazz[i].kind = cff_kind_callback; \
|
|
|
|
clazz[i].code = code_ | CFFCODE; \
|
|
|
|
clazz[i].offset = 0; \
|
|
|
|
clazz[i].size = 0; \
|
|
|
|
clazz[i].reader = cff_parse_ ## name_; \
|
|
|
|
clazz[i].array_max = 0; \
|
|
|
|
clazz[i].count_offset = 0; \
|
|
|
|
clazz[i].id = id_; \
|
|
|
|
i++;
|
|
|
|
|
|
|
|
#undef CFF_FIELD
|
|
|
|
#define CFF_FIELD( code_, name_, id_, kind_ ) \
|
|
|
|
clazz[i].kind = kind_; \
|
|
|
|
clazz[i].code = code_ | CFFCODE; \
|
|
|
|
clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
|
|
|
|
clazz[i].size = FT_FIELD_SIZE( name_ ); \
|
|
|
|
clazz[i].reader = 0; \
|
|
|
|
clazz[i].array_max = 0; \
|
|
|
|
clazz[i].count_offset = 0; \
|
|
|
|
clazz[i].id = id_; \
|
|
|
|
i++; \
|
|
|
|
|
|
|
|
#undef CFF_FIELD_DELTA
|
|
|
|
#define CFF_FIELD_DELTA( code_, name_, max_, id_ ) \
|
|
|
|
clazz[i].kind = cff_kind_delta; \
|
|
|
|
clazz[i].code = code_ | CFFCODE; \
|
|
|
|
clazz[i].offset = FT_FIELD_OFFSET( name_ ); \
|
|
|
|
clazz[i].size = FT_FIELD_SIZE_DELTA( name_ ); \
|
|
|
|
clazz[i].reader = 0; \
|
|
|
|
clazz[i].array_max = max_; \
|
|
|
|
clazz[i].count_offset = FT_FIELD_OFFSET( num_ ## name_ ); \
|
|
|
|
clazz[i].id = id_; \
|
|
|
|
i++;
|
|
|
|
|
|
|
|
#include "cfftoken.h"
|
|
|
|
|
|
|
|
clazz[i].kind = 0;
|
|
|
|
clazz[i].code = 0;
|
|
|
|
clazz[i].offset = 0;
|
|
|
|
clazz[i].size = 0;
|
|
|
|
clazz[i].reader = 0;
|
|
|
|
clazz[i].array_max = 0;
|
|
|
|
clazz[i].count_offset = 0;
|
|
|
|
clazz[i].id = 0;
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FT_DEBUG_LEVEL_TRACE */
|
|
|
|
|
|
|
|
|
2009-04-05 17:12:03 +02:00
|
|
|
*output_class = clazz;
|
2011-08-24 20:50:25 +02:00
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
2009-04-05 17:12:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* FT_CONFIG_OPTION_PIC */
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
* src/cff/cffcmap.c, src/cff/cffcmap.h, Jamfile, rules.mk: new files added
to support charmaps for CFF fonts
* src/cff/cffload.c, src/cff/cffload.h, src/cff/cffobjs.c,
src/cff/cffobjs.h, src/cff/cffparse.c, src/cffparse.h, src/cff/cffgload.c,
src/cff/cffgload.h: adding support for CFF charmaps, reformatting the
sources, and removing some bugs in the Encoding and Charset loaders
2002-07-10 18:52:06 +02:00
|
|
|
cff_parser_run( CFF_Parser parser,
|
2002-03-30 17:41:09 +01:00
|
|
|
FT_Byte* start,
|
|
|
|
FT_Byte* limit )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
2009-04-05 17:12:03 +02:00
|
|
|
FT_Byte* p = start;
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2009-04-05 17:12:03 +02:00
|
|
|
FT_Library library = parser->library;
|
2011-08-24 20:50:25 +02:00
|
|
|
FT_UNUSED( library );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
parser->top = parser->stack;
|
|
|
|
parser->start = start;
|
|
|
|
parser->limit = limit;
|
|
|
|
parser->cursor = start;
|
|
|
|
|
|
|
|
while ( p < limit )
|
|
|
|
{
|
2001-06-19 10:28:24 +02:00
|
|
|
FT_UInt v = *p;
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( v >= 27 && v != 31 )
|
|
|
|
{
|
|
|
|
/* it's a number; we will push its position on the stack */
|
|
|
|
if ( parser->top - parser->stack >= CFF_MAX_STACK_DEPTH )
|
|
|
|
goto Stack_Overflow;
|
|
|
|
|
|
|
|
*parser->top ++ = p;
|
|
|
|
|
|
|
|
/* now, skip it */
|
|
|
|
if ( v == 30 )
|
|
|
|
{
|
|
|
|
/* skip real number */
|
|
|
|
p++;
|
|
|
|
for (;;)
|
|
|
|
{
|
2009-12-18 07:13:22 +01:00
|
|
|
/* An unterminated floating point number at the */
|
|
|
|
/* end of a dictionary is invalid but harmless. */
|
2000-12-08 03:42:29 +01:00
|
|
|
if ( p >= limit )
|
2009-12-18 07:13:22 +01:00
|
|
|
goto Exit;
|
2000-12-08 03:42:29 +01:00
|
|
|
v = p[0] >> 4;
|
|
|
|
if ( v == 15 )
|
|
|
|
break;
|
|
|
|
v = p[0] & 0xF;
|
|
|
|
if ( v == 15 )
|
|
|
|
break;
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( v == 28 )
|
|
|
|
p += 2;
|
|
|
|
else if ( v == 29 )
|
|
|
|
p += 4;
|
|
|
|
else if ( v > 246 )
|
|
|
|
p += 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* This is not a number, hence it's an operator. Compute its code */
|
|
|
|
/* and look for it in our current list. */
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
FT_UInt code;
|
|
|
|
FT_UInt num_args = (FT_UInt)
|
|
|
|
( parser->top - parser->stack );
|
2000-12-08 03:42:29 +01:00
|
|
|
const CFF_Field_Handler* field;
|
|
|
|
|
|
|
|
|
|
|
|
*parser->top = p;
|
|
|
|
code = v;
|
|
|
|
if ( v == 12 )
|
|
|
|
{
|
|
|
|
/* two byte operator */
|
|
|
|
p++;
|
2002-09-10 01:45:29 +02:00
|
|
|
if ( p >= limit )
|
|
|
|
goto Syntax_Error;
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
code = 0x100 | p[0];
|
|
|
|
}
|
|
|
|
code = code | parser->object_code;
|
|
|
|
|
2012-08-27 08:41:43 +02:00
|
|
|
for ( field = CFF_FIELD_HANDLERS_GET; field->kind; field++ )
|
2000-12-08 03:42:29 +01:00
|
|
|
{
|
|
|
|
if ( field->code == (FT_Int)code )
|
|
|
|
{
|
|
|
|
/* we found our field's handler; read it */
|
|
|
|
FT_Long val;
|
|
|
|
FT_Byte* q = (FT_Byte*)parser->object + field->offset;
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
|
|
FT_TRACE4(( " %s", field->id ));
|
|
|
|
#endif
|
|
|
|
|
2002-09-10 01:45:29 +02:00
|
|
|
/* check that we have enough arguments -- except for */
|
|
|
|
/* delta encoded arrays, which can be empty */
|
|
|
|
if ( field->kind != cff_kind_delta && num_args < 1 )
|
|
|
|
goto Stack_Underflow;
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
switch ( field->kind )
|
|
|
|
{
|
|
|
|
case cff_kind_bool:
|
|
|
|
case cff_kind_string:
|
|
|
|
case cff_kind_num:
|
|
|
|
val = cff_parse_num( parser->stack );
|
|
|
|
goto Store_Number;
|
|
|
|
|
|
|
|
case cff_kind_fixed:
|
|
|
|
val = cff_parse_fixed( parser->stack );
|
2003-06-06 07:07:53 +02:00
|
|
|
goto Store_Number;
|
|
|
|
|
|
|
|
case cff_kind_fixed_thousand:
|
2008-05-04 15:37:38 +02:00
|
|
|
val = cff_parse_fixed_scaled( parser->stack, 3 );
|
2000-12-08 03:42:29 +01:00
|
|
|
|
|
|
|
Store_Number:
|
|
|
|
switch ( field->size )
|
|
|
|
{
|
2004-04-24 08:06:39 +02:00
|
|
|
case (8 / FT_CHAR_BIT):
|
2000-12-08 03:42:29 +01:00
|
|
|
*(FT_Byte*)q = (FT_Byte)val;
|
|
|
|
break;
|
|
|
|
|
2004-04-24 08:06:39 +02:00
|
|
|
case (16 / FT_CHAR_BIT):
|
2000-12-08 03:42:29 +01:00
|
|
|
*(FT_Short*)q = (FT_Short)val;
|
|
|
|
break;
|
|
|
|
|
2004-04-24 08:06:39 +02:00
|
|
|
case (32 / FT_CHAR_BIT):
|
2000-12-08 03:42:29 +01:00
|
|
|
*(FT_Int32*)q = (FT_Int)val;
|
|
|
|
break;
|
|
|
|
|
2004-04-24 08:06:39 +02:00
|
|
|
default: /* for 64-bit systems */
|
2000-12-08 03:42:29 +01:00
|
|
|
*(FT_Long*)q = val;
|
|
|
|
}
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
|
|
|
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
|
|
switch ( field->kind )
|
|
|
|
{
|
|
|
|
case cff_kind_bool:
|
|
|
|
FT_TRACE4(( " %s\n", val ? "true" : "false" ));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cff_kind_string:
|
2011-09-26 08:59:21 +02:00
|
|
|
FT_TRACE4(( " %ld (SID)\n", val ));
|
|
|
|
break;
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
case cff_kind_num:
|
|
|
|
FT_TRACE4(( " %ld\n", val ));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cff_kind_fixed:
|
|
|
|
FT_TRACE4(( " %f\n", (double)val / 65536 ));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case cff_kind_fixed_thousand:
|
|
|
|
FT_TRACE4(( " %f\n", (double)val / 65536 / 1000 ));
|
|
|
|
|
|
|
|
default:
|
|
|
|
; /* never reached */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case cff_kind_delta:
|
|
|
|
{
|
|
|
|
FT_Byte* qcount = (FT_Byte*)parser->object +
|
|
|
|
field->count_offset;
|
|
|
|
|
|
|
|
FT_Byte** data = parser->stack;
|
|
|
|
|
|
|
|
|
|
|
|
if ( num_args > field->array_max )
|
|
|
|
num_args = field->array_max;
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
FT_TRACE4(( " [" ));
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
/* store count */
|
|
|
|
*qcount = (FT_Byte)num_args;
|
|
|
|
|
|
|
|
val = 0;
|
|
|
|
while ( num_args > 0 )
|
|
|
|
{
|
|
|
|
val += cff_parse_num( data++ );
|
|
|
|
switch ( field->size )
|
|
|
|
{
|
2004-04-24 08:06:39 +02:00
|
|
|
case (8 / FT_CHAR_BIT):
|
2000-12-08 03:42:29 +01:00
|
|
|
*(FT_Byte*)q = (FT_Byte)val;
|
|
|
|
break;
|
|
|
|
|
2004-04-24 08:06:39 +02:00
|
|
|
case (16 / FT_CHAR_BIT):
|
2000-12-08 03:42:29 +01:00
|
|
|
*(FT_Short*)q = (FT_Short)val;
|
|
|
|
break;
|
|
|
|
|
2004-04-24 08:06:39 +02:00
|
|
|
case (32 / FT_CHAR_BIT):
|
2000-12-08 03:42:29 +01:00
|
|
|
*(FT_Int32*)q = (FT_Int)val;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* for 64-bit systems */
|
|
|
|
*(FT_Long*)q = val;
|
|
|
|
}
|
|
|
|
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
FT_TRACE4(( " %ld", val ));
|
|
|
|
|
2000-12-08 03:42:29 +01:00
|
|
|
q += field->size;
|
|
|
|
num_args--;
|
|
|
|
}
|
[cff] Better tracing of the parsing process.
* src/cff/cffload.c (cff_subfont_load, cff_font_load): Decorate with
FT_TRACE.
* src/cff/cffparse.c (cff_parse_font_matrix, cff_parse_font_bbox,
cff_parse_private_dict, cff_parse_cid_ros): Updated.
(CFF_FIELD_NUM, CFF_FIELD_FIXED, CFF_FIELD_FIXED_1000,
CFF_FIELD_STRING, CFF_FIELD_BOOL, CFF_FIELD_CALLBACK, CFF_FIELD,
CFF_FIELD_DELTA): Add argument for ID.
(cff_parser_run): Decorate with FT_TRACE.
* src/cff/cffparse.h (CFF_Field_Handler) [FT_DEBUG_LEVEL_TRACE]: Add
`id' member.
* src/cff/cfftoken.h: Add IDs to all fields.
2011-08-25 13:41:16 +02:00
|
|
|
|
|
|
|
FT_TRACE4(( "]\n" ));
|
2000-12-08 03:42:29 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* callback */
|
|
|
|
error = field->reader( parser );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
goto Found;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is an unknown operator, or it is unsupported; */
|
|
|
|
/* we will ignore it for now. */
|
|
|
|
|
|
|
|
Found:
|
|
|
|
/* clear stack */
|
|
|
|
parser->top = parser->stack;
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
|
|
|
|
Stack_Overflow:
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
Stack_Underflow:
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
Syntax_Error:
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Invalid_Argument );
|
2000-12-08 03:42:29 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|