2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* cidload.c
|
|
|
|
*
|
|
|
|
* CID-keyed Type1 font loader (body).
|
|
|
|
*
|
2021-01-17 07:18:48 +01:00
|
|
|
* Copyright (C) 1996-2021 by
|
2018-06-03 09:01:17 +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.
|
|
|
|
*
|
|
|
|
*/
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/internal/ftdebug.h>
|
2000-12-08 17:17:16 +01:00
|
|
|
#include FT_CONFIG_CONFIG_H
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/ftmm.h>
|
|
|
|
#include <freetype/internal/t1types.h>
|
|
|
|
#include <freetype/internal/psaux.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 "cidload.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 "ciderrs.h"
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2018-06-03 09:01:17 +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.
|
|
|
|
*/
|
2000-06-01 05:27:48 +02:00
|
|
|
#undef FT_COMPONENT
|
2018-08-15 18:13:17 +02:00
|
|
|
#define FT_COMPONENT cidload
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-07-01 00:24:36 +02:00
|
|
|
/* read a single offset */
|
2015-02-20 20:14:11 +01:00
|
|
|
FT_LOCAL_DEF( FT_ULong )
|
2003-10-07 07:49:41 +02:00
|
|
|
cid_get_offset( FT_Byte* *start,
|
2021-10-08 04:41:56 +02:00
|
|
|
FT_UInt offsize )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2013-05-04 16:40:12 +02:00
|
|
|
FT_ULong result;
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte* p = *start;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
for ( result = 0; offsize > 0; offsize-- )
|
2000-07-01 00:24:36 +02:00
|
|
|
{
|
|
|
|
result <<= 8;
|
|
|
|
result |= *p++;
|
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
*start = p;
|
2015-02-20 20:14:11 +01:00
|
|
|
return result;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/***** *****/
|
|
|
|
/***** TYPE 1 SYMBOL PARSING *****/
|
|
|
|
/***** *****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
2002-03-30 18:08:04 +01:00
|
|
|
cid_load_keyword( CID_Face face,
|
|
|
|
CID_Loader* loader,
|
2002-02-28 17:10:29 +01:00
|
|
|
const T1_Field keyword )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2002-03-30 18:08:04 +01:00
|
|
|
FT_Error error;
|
|
|
|
CID_Parser* parser = &loader->parser;
|
|
|
|
FT_Byte* object;
|
|
|
|
void* dummy_object;
|
|
|
|
CID_FaceInfo cid = &face->cid;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
/* if the keyword has a dedicated callback, call it */
|
2002-02-28 17:10:29 +01:00
|
|
|
if ( keyword->type == T1_FIELD_TYPE_CALLBACK )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2018-07-31 10:46:57 +02:00
|
|
|
FT_TRACE4(( " %s", keyword->ident ));
|
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
keyword->reader( (FT_Face)face, parser );
|
|
|
|
error = parser->root.error;
|
2000-06-01 05:27:48 +02:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we must now compute the address of our target object */
|
2000-06-16 08:49:56 +02:00
|
|
|
switch ( keyword->location )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2002-03-14 11:09:35 +01:00
|
|
|
case T1_FIELD_LOCATION_CID_INFO:
|
2000-06-16 21:34:52 +02:00
|
|
|
object = (FT_Byte*)cid;
|
2000-06-16 08:49:56 +02:00
|
|
|
break;
|
|
|
|
|
2002-03-14 11:09:35 +01:00
|
|
|
case T1_FIELD_LOCATION_FONT_INFO:
|
2000-06-16 21:34:52 +02:00
|
|
|
object = (FT_Byte*)&cid->font_info;
|
2000-06-16 08:49:56 +02:00
|
|
|
break;
|
|
|
|
|
2009-03-03 14:28:59 +01:00
|
|
|
case T1_FIELD_LOCATION_FONT_EXTRA:
|
|
|
|
object = (FT_Byte*)&face->font_extra;
|
|
|
|
break;
|
|
|
|
|
2003-06-12 06:59:07 +02:00
|
|
|
case T1_FIELD_LOCATION_BBOX:
|
|
|
|
object = (FT_Byte*)&cid->font_bbox;
|
|
|
|
break;
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
default:
|
|
|
|
{
|
2002-02-28 19:59:37 +01:00
|
|
|
CID_FaceDict dict;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2021-10-11 05:11:10 +02:00
|
|
|
if ( parser->num_dict >= cid->num_dicts )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2009-06-26 06:15:41 +02:00
|
|
|
FT_ERROR(( "cid_load_keyword: invalid use of `%s'\n",
|
2000-06-16 08:49:56 +02:00
|
|
|
keyword->ident ));
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Syntax_Error );
|
2000-06-16 08:49:56 +02:00
|
|
|
goto Exit;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
dict = cid->font_dicts + parser->num_dict;
|
|
|
|
switch ( keyword->location )
|
|
|
|
{
|
2002-03-14 11:09:35 +01:00
|
|
|
case T1_FIELD_LOCATION_PRIVATE:
|
2000-06-16 21:34:52 +02:00
|
|
|
object = (FT_Byte*)&dict->private_dict;
|
2000-06-16 08:49:56 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2000-06-16 21:34:52 +02:00
|
|
|
object = (FT_Byte*)dict;
|
2000-06-16 08:49:56 +02:00
|
|
|
}
|
|
|
|
}
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2018-07-31 10:46:57 +02:00
|
|
|
FT_TRACE4(( " %s", keyword->ident ));
|
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
dummy_object = object;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
/* now, load the keyword data in the object's field(s) */
|
2002-02-28 17:10:29 +01:00
|
|
|
if ( keyword->type == T1_FIELD_TYPE_INTEGER_ARRAY ||
|
|
|
|
keyword->type == T1_FIELD_TYPE_FIXED_ARRAY )
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
error = cid_parser_load_field_table( &loader->parser, keyword,
|
2003-06-06 07:07:53 +02:00
|
|
|
&dummy_object );
|
2000-06-01 05:27:48 +02:00
|
|
|
else
|
2003-06-06 07:07:53 +02:00
|
|
|
error = cid_parser_load_field( &loader->parser,
|
|
|
|
keyword, &dummy_object );
|
2018-07-31 10:46:57 +02:00
|
|
|
|
|
|
|
FT_TRACE4(( "\n" ));
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
Exit:
|
|
|
|
return error;
|
2000-06-16 08:49:56 +02:00
|
|
|
}
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
|
2019-03-07 09:42:25 +01:00
|
|
|
FT_CALLBACK_DEF( void )
|
2012-02-24 12:26:25 +01:00
|
|
|
cid_parse_font_matrix( CID_Face face,
|
|
|
|
CID_Parser* parser )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2002-02-28 19:59:37 +01:00
|
|
|
CID_FaceDict dict;
|
2002-03-30 18:08:04 +01:00
|
|
|
FT_Face root = (FT_Face)&face->root;
|
|
|
|
FT_Fixed temp[6];
|
|
|
|
FT_Fixed temp_scale;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2001-03-11 12:28:39 +01:00
|
|
|
|
2021-10-11 05:11:10 +02:00
|
|
|
if ( parser->num_dict < face->cid.num_dicts )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2013-08-01 12:20:20 +02:00
|
|
|
FT_Matrix* matrix;
|
|
|
|
FT_Vector* offset;
|
2014-01-23 08:14:53 +01:00
|
|
|
FT_Int result;
|
2013-08-01 12:20:20 +02:00
|
|
|
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
dict = face->cid.font_dicts + parser->num_dict;
|
|
|
|
matrix = &dict->font_matrix;
|
2000-08-24 00:47:44 +02:00
|
|
|
offset = &dict->font_offset;
|
|
|
|
|
2015-08-13 05:51:02 +02:00
|
|
|
/* input is scaled by 1000 to accommodate default FontMatrix */
|
2014-01-23 08:14:53 +01:00
|
|
|
result = cid_parser_to_fixed_array( parser, 6, temp, 3 );
|
|
|
|
|
|
|
|
if ( result < 6 )
|
2019-03-07 09:42:25 +01:00
|
|
|
{
|
|
|
|
FT_ERROR(( "cid_parse_font_matrix: not enough matrix elements\n" ));
|
|
|
|
goto Exit;
|
|
|
|
}
|
2000-08-24 00:47:44 +02:00
|
|
|
|
2018-07-31 10:46:57 +02:00
|
|
|
FT_TRACE4(( " [%f %f %f %f %f %f]\n",
|
|
|
|
(double)temp[0] / 65536 / 1000,
|
|
|
|
(double)temp[1] / 65536 / 1000,
|
|
|
|
(double)temp[2] / 65536 / 1000,
|
|
|
|
(double)temp[3] / 65536 / 1000,
|
|
|
|
(double)temp[4] / 65536 / 1000,
|
|
|
|
(double)temp[5] / 65536 / 1000 ));
|
|
|
|
|
2004-03-05 10:26:24 +01:00
|
|
|
temp_scale = FT_ABS( temp[3] );
|
2001-03-10 20:04:41 +01:00
|
|
|
|
2014-01-23 08:14:53 +01:00
|
|
|
if ( temp_scale == 0 )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "cid_parse_font_matrix: invalid font matrix\n" ));
|
2019-03-07 09:42:25 +01:00
|
|
|
goto Exit;
|
2014-01-23 08:14:53 +01:00
|
|
|
}
|
|
|
|
|
2015-08-11 05:05:02 +02:00
|
|
|
/* atypical case */
|
2001-03-10 20:04:41 +01:00
|
|
|
if ( temp_scale != 0x10000L )
|
2000-08-24 00:47:44 +02:00
|
|
|
{
|
2015-08-11 05:05:02 +02:00
|
|
|
/* set units per EM based on FontMatrix values */
|
|
|
|
root->units_per_EM = (FT_UShort)FT_DivFix( 1000, temp_scale );
|
|
|
|
|
2001-03-10 20:04:41 +01:00
|
|
|
temp[0] = FT_DivFix( temp[0], temp_scale );
|
|
|
|
temp[1] = FT_DivFix( temp[1], temp_scale );
|
|
|
|
temp[2] = FT_DivFix( temp[2], temp_scale );
|
|
|
|
temp[4] = FT_DivFix( temp[4], temp_scale );
|
|
|
|
temp[5] = FT_DivFix( temp[5], temp_scale );
|
2014-01-23 08:14:53 +01:00
|
|
|
temp[3] = temp[3] < 0 ? -0x10000L : 0x10000L;
|
2000-08-24 00:47:44 +02:00
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
matrix->xx = temp[0];
|
|
|
|
matrix->yx = temp[1];
|
|
|
|
matrix->xy = temp[2];
|
|
|
|
matrix->yy = temp[3];
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2018-06-24 06:22:48 +02:00
|
|
|
if ( !FT_Matrix_Check( matrix ) )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "t1_parse_font_matrix: invalid font matrix\n" ));
|
|
|
|
parser->root.error = FT_THROW( Invalid_File_Format );
|
2019-03-07 09:42:25 +01:00
|
|
|
goto Exit;
|
2018-06-24 06:22:48 +02:00
|
|
|
}
|
|
|
|
|
2000-10-05 06:53:31 +02:00
|
|
|
/* note that the font offsets are expressed in integer font units */
|
2000-10-04 00:03:09 +02:00
|
|
|
offset->x = temp[4] >> 16;
|
|
|
|
offset->y = temp[5] >> 16;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2019-03-07 09:42:25 +01:00
|
|
|
Exit:
|
|
|
|
return;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2019-03-07 09:42:25 +01:00
|
|
|
FT_CALLBACK_DEF( void )
|
2001-06-27 11:26:46 +02:00
|
|
|
parse_fd_array( CID_Face face,
|
|
|
|
CID_Parser* parser )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2002-02-28 19:59:37 +01:00
|
|
|
CID_FaceInfo cid = &face->cid;
|
2002-03-30 18:08:04 +01:00
|
|
|
FT_Memory memory = face->root.memory;
|
2015-10-20 22:31:57 +02:00
|
|
|
FT_Stream stream = parser->stream;
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2021-10-12 05:25:29 +02:00
|
|
|
FT_Long num_dicts, max_dicts;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2021-10-12 05:25:29 +02:00
|
|
|
num_dicts = cid_parser_to_int( parser );
|
|
|
|
if ( num_dicts < 0 || num_dicts > FT_INT_MAX )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" ));
|
|
|
|
goto Exit;
|
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2021-10-12 05:25:29 +02:00
|
|
|
FT_TRACE4(( " %ld\n", num_dicts ));
|
2018-07-31 10:46:57 +02:00
|
|
|
|
2015-10-20 22:31:57 +02:00
|
|
|
/*
|
|
|
|
* A single entry in the FDArray must (at least) contain the following
|
|
|
|
* structure elements.
|
|
|
|
*
|
|
|
|
* %ADOBeginFontDict 18
|
|
|
|
* X dict begin 13
|
|
|
|
* /FontMatrix [X X X X] 22
|
|
|
|
* /Private X dict begin 22
|
|
|
|
* end 4
|
|
|
|
* end 4
|
|
|
|
* %ADOEndFontDict 16
|
|
|
|
*
|
|
|
|
* This needs 18+13+22+22+4+4+16=99 bytes or more. Normally, you also
|
|
|
|
* need a `dup X' at the very beginning and a `put' at the end, so a
|
|
|
|
* rough guess using 100 bytes as the minimum is justified.
|
|
|
|
*/
|
2021-10-12 05:25:29 +02:00
|
|
|
max_dicts = (FT_Long)( stream->size / 100 );
|
2021-10-11 05:11:10 +02:00
|
|
|
if ( num_dicts > max_dicts )
|
2015-10-20 22:31:57 +02:00
|
|
|
{
|
|
|
|
FT_TRACE0(( "parse_fd_array: adjusting FDArray size"
|
2021-10-12 05:25:29 +02:00
|
|
|
" (from %ld to %ld)\n",
|
2021-10-11 05:11:10 +02:00
|
|
|
num_dicts, max_dicts ));
|
|
|
|
num_dicts = max_dicts;
|
2015-10-20 22:31:57 +02:00
|
|
|
}
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
if ( !cid->font_dicts )
|
|
|
|
{
|
2021-10-11 05:11:10 +02:00
|
|
|
FT_UInt n;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) )
|
2000-06-01 05:27:48 +02:00
|
|
|
goto Exit;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2015-02-20 20:14:11 +01:00
|
|
|
cid->num_dicts = num_dicts;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2018-07-22 12:11:52 +02:00
|
|
|
/* set some default values (the same as for Type 1 fonts) */
|
2000-06-01 05:27:48 +02:00
|
|
|
for ( n = 0; n < cid->num_dicts; n++ )
|
|
|
|
{
|
2002-02-28 19:59:37 +01:00
|
|
|
CID_FaceDict dict = cid->font_dicts + n;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2018-07-22 12:11:52 +02:00
|
|
|
dict->private_dict.blue_shift = 7;
|
|
|
|
dict->private_dict.blue_fuzz = 1;
|
|
|
|
dict->private_dict.lenIV = 4;
|
|
|
|
dict->private_dict.expansion_factor = (FT_Fixed)( 0.06 * 0x10000L );
|
|
|
|
dict->private_dict.blue_scale = (FT_Fixed)(
|
|
|
|
0.039625 * 0x10000L * 1000 );
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
Exit:
|
2019-03-07 09:42:25 +01:00
|
|
|
return;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-31 10:46:57 +02:00
|
|
|
/* By mistake, `expansion_factor' appears both in PS_PrivateRec */
|
2008-08-04 20:46:37 +02:00
|
|
|
/* and CID_FaceDictRec (both are public header files and can't */
|
2018-07-31 10:46:57 +02:00
|
|
|
/* changed). We simply copy the value. */
|
2008-08-04 20:46:37 +02:00
|
|
|
|
2019-03-07 09:42:25 +01:00
|
|
|
FT_CALLBACK_DEF( void )
|
2008-08-04 20:46:37 +02:00
|
|
|
parse_expansion_factor( CID_Face face,
|
|
|
|
CID_Parser* parser )
|
|
|
|
{
|
|
|
|
CID_FaceDict dict;
|
|
|
|
|
|
|
|
|
2021-10-11 05:11:10 +02:00
|
|
|
if ( parser->num_dict < face->cid.num_dicts )
|
2008-08-04 20:46:37 +02:00
|
|
|
{
|
|
|
|
dict = face->cid.font_dicts + parser->num_dict;
|
|
|
|
|
|
|
|
dict->expansion_factor = cid_parser_to_fixed( parser, 0 );
|
|
|
|
dict->private_dict.expansion_factor = dict->expansion_factor;
|
2018-07-31 10:46:57 +02:00
|
|
|
|
2020-07-28 07:33:40 +02:00
|
|
|
FT_TRACE4(( "%ld\n", dict->expansion_factor ));
|
2008-08-04 20:46:37 +02:00
|
|
|
}
|
|
|
|
|
2019-03-07 09:42:25 +01:00
|
|
|
return;
|
2008-08-04 20:46:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-31 10:46:57 +02:00
|
|
|
/* By mistake, `CID_FaceDictRec' doesn't contain a field for the */
|
|
|
|
/* `FontName' keyword. FreeType doesn't need it, but it is nice */
|
|
|
|
/* to catch it for producing better trace output. */
|
|
|
|
|
2019-03-07 09:42:25 +01:00
|
|
|
FT_CALLBACK_DEF( void )
|
2018-07-31 10:46:57 +02:00
|
|
|
parse_font_name( CID_Face face,
|
|
|
|
CID_Parser* parser )
|
|
|
|
{
|
|
|
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
2021-10-11 05:11:10 +02:00
|
|
|
if ( parser->num_dict < face->cid.num_dicts )
|
2018-07-31 10:46:57 +02:00
|
|
|
{
|
|
|
|
T1_TokenRec token;
|
|
|
|
FT_UInt len;
|
|
|
|
|
|
|
|
|
|
|
|
cid_parser_to_token( parser, &token );
|
|
|
|
|
|
|
|
len = (FT_UInt)( token.limit - token.start );
|
|
|
|
if ( len )
|
|
|
|
FT_TRACE4(( " %.*s\n", len, token.start ));
|
|
|
|
else
|
|
|
|
FT_TRACE4(( " <no value>\n" ));
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
FT_UNUSED( face );
|
|
|
|
FT_UNUSED( parser );
|
|
|
|
#endif
|
|
|
|
|
2019-03-07 09:42:25 +01:00
|
|
|
return;
|
2018-07-31 10:46:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
static
|
2002-02-28 17:10:29 +01:00
|
|
|
const T1_FieldRec cid_field_records[] =
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-07-08 21:51:42 +02: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 "cidtoken.h"
|
2000-07-08 21:51:42 +02:00
|
|
|
|
2008-08-04 20:46:37 +02:00
|
|
|
T1_FIELD_CALLBACK( "FDArray", parse_fd_array, 0 )
|
2012-02-24 12:26:25 +01:00
|
|
|
T1_FIELD_CALLBACK( "FontMatrix", cid_parse_font_matrix, 0 )
|
2008-08-04 20:46:37 +02:00
|
|
|
T1_FIELD_CALLBACK( "ExpansionFactor", parse_expansion_factor, 0 )
|
2018-07-31 10:46:57 +02:00
|
|
|
T1_FIELD_CALLBACK( "FontName", parse_font_name, 0 )
|
2003-06-12 06:59:07 +02:00
|
|
|
|
2006-08-13 14:14:36 +02:00
|
|
|
{ 0, T1_FIELD_LOCATION_CID_INFO, T1_FIELD_TYPE_NONE, 0, 0, 0, 0, 0, 0 }
|
2000-06-01 05:27:48 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
|
|
|
cid_parse_dict( CID_Face face,
|
|
|
|
CID_Loader* loader,
|
|
|
|
FT_Byte* base,
|
2015-02-20 20:14:11 +01:00
|
|
|
FT_ULong size )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-06-16 08:49:56 +02:00
|
|
|
CID_Parser* parser = &loader->parser;
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
parser->root.cursor = base;
|
|
|
|
parser->root.limit = base + size;
|
2013-03-14 11:21:17 +01:00
|
|
|
parser->root.error = FT_Err_Ok;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte* cur = base;
|
|
|
|
FT_Byte* limit = cur + size;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2003-10-07 07:49:41 +02:00
|
|
|
for (;;)
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2003-10-07 07:49:41 +02:00
|
|
|
FT_Byte* newlimit;
|
|
|
|
|
|
|
|
|
|
|
|
parser->root.cursor = cur;
|
|
|
|
cid_parser_skip_spaces( parser );
|
|
|
|
|
|
|
|
if ( parser->root.cursor >= limit )
|
|
|
|
newlimit = limit - 1 - 17;
|
|
|
|
else
|
|
|
|
newlimit = parser->root.cursor - 17;
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
/* look for `%ADOBeginFontDict' */
|
2003-10-07 07:49:41 +02:00
|
|
|
for ( ; cur < newlimit; cur++ )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2003-10-07 07:49:41 +02:00
|
|
|
if ( *cur == '%' &&
|
|
|
|
ft_strncmp( (char*)cur, "%ADOBeginFontDict", 17 ) == 0 )
|
|
|
|
{
|
|
|
|
/* if /FDArray was found, then cid->num_dicts is > 0, and */
|
|
|
|
/* we can start increasing parser->num_dict */
|
|
|
|
if ( face->cid.num_dicts > 0 )
|
2018-07-31 10:46:57 +02:00
|
|
|
{
|
2003-10-07 07:49:41 +02:00
|
|
|
parser->num_dict++;
|
2018-07-31 10:46:57 +02:00
|
|
|
|
|
|
|
#ifdef FT_DEBUG_LEVEL_TRACE
|
2021-10-11 05:11:10 +02:00
|
|
|
FT_TRACE4(( " FontDict %u", parser->num_dict ));
|
2018-07-31 10:46:57 +02:00
|
|
|
if ( parser->num_dict > face->cid.num_dicts )
|
|
|
|
FT_TRACE4(( " (ignored)" ));
|
|
|
|
FT_TRACE4(( "\n" ));
|
|
|
|
#endif
|
|
|
|
}
|
2003-10-07 07:49:41 +02:00
|
|
|
}
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
2003-10-07 07:49:41 +02:00
|
|
|
|
|
|
|
cur = parser->root.cursor;
|
|
|
|
/* no error can occur in cid_parser_skip_spaces */
|
|
|
|
if ( cur >= limit )
|
|
|
|
break;
|
|
|
|
|
|
|
|
cid_parser_skip_PS_token( parser );
|
|
|
|
if ( parser->root.cursor >= limit || parser->root.error )
|
|
|
|
break;
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
/* look for immediates */
|
2003-10-07 07:49:41 +02:00
|
|
|
if ( *cur == '/' && cur + 2 < limit )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2015-02-18 09:22:06 +01:00
|
|
|
FT_UInt len;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
cur++;
|
2015-02-18 09:22:06 +01:00
|
|
|
len = (FT_UInt)( parser->root.cursor - cur );
|
2003-10-07 07:49:41 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( len > 0 && len < 22 )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-07-01 00:24:36 +02:00
|
|
|
/* now compare the immediate name to the keyword table */
|
2003-09-30 08:43:54 +02:00
|
|
|
T1_Field keyword = (T1_Field)cid_field_records;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
for (;;)
|
|
|
|
{
|
2000-06-16 21:34:52 +02:00
|
|
|
FT_Byte* name;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-06-16 21:34:52 +02:00
|
|
|
name = (FT_Byte*)keyword->ident;
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( !name )
|
|
|
|
break;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2015-02-18 09:22:06 +01:00
|
|
|
if ( cur[0] == name[0] &&
|
|
|
|
len == ft_strlen( (const char*)name ) )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2015-02-18 09:22:06 +01:00
|
|
|
FT_UInt n;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
for ( n = 1; n < len; n++ )
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( cur[n] != name[n] )
|
2000-06-01 05:27:48 +02:00
|
|
|
break;
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( n >= len )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-06-16 08:49:56 +02:00
|
|
|
/* we found it - run the parsing callback */
|
2000-08-24 18:29:15 +02:00
|
|
|
parser->root.error = cid_load_keyword( face,
|
|
|
|
loader,
|
|
|
|
keyword );
|
2000-08-24 00:47:44 +02:00
|
|
|
if ( parser->root.error )
|
|
|
|
return parser->root.error;
|
2000-06-01 05:27:48 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
keyword++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-10-07 07:49:41 +02:00
|
|
|
|
|
|
|
cur = parser->root.cursor;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
2015-10-17 06:15:55 +02:00
|
|
|
|
|
|
|
if ( !face->cid.num_dicts )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "cid_parse_dict: No font dictionary found\n" ));
|
2015-10-17 09:29:52 +02:00
|
|
|
return FT_THROW( Invalid_File_Format );
|
|
|
|
}
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
2015-10-17 06:15:55 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
return parser->root.error;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* read the subrmap and the subrs of each font dict */
|
2001-06-27 21:46:12 +02:00
|
|
|
static FT_Error
|
|
|
|
cid_read_subrs( CID_Face face )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2003-06-12 09:11:05 +02:00
|
|
|
CID_FaceInfo cid = &face->cid;
|
|
|
|
FT_Memory memory = face->root.memory;
|
2004-01-23 20:52:40 +01:00
|
|
|
FT_Stream stream = face->cid_stream;
|
2003-06-12 09:11:05 +02:00
|
|
|
FT_Error error;
|
2021-10-11 05:11:10 +02:00
|
|
|
FT_UInt n;
|
2003-06-12 09:11:05 +02:00
|
|
|
CID_Subrs subr;
|
|
|
|
FT_UInt max_offsets = 0;
|
2015-04-16 05:20:23 +02:00
|
|
|
FT_ULong* offsets = NULL;
|
2003-06-12 09:11:05 +02:00
|
|
|
PSAux_Service psaux = (PSAux_Service)face->psaux;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
if ( FT_NEW_ARRAY( face->subrs, cid->num_dicts ) )
|
2000-06-01 05:27:48 +02:00
|
|
|
goto Exit;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
subr = face->subrs;
|
|
|
|
for ( n = 0; n < cid->num_dicts; n++, subr++ )
|
|
|
|
{
|
2002-02-28 19:59:37 +01:00
|
|
|
CID_FaceDict dict = cid->font_dicts + n;
|
2002-03-30 18:08:04 +01:00
|
|
|
FT_Int lenIV = dict->private_dict.lenIV;
|
|
|
|
FT_UInt count, num_subrs = dict->num_subrs;
|
|
|
|
FT_ULong data_len;
|
|
|
|
FT_Byte* p;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2017-01-03 00:27:07 +01:00
|
|
|
if ( !num_subrs )
|
|
|
|
continue;
|
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
/* reallocate offsets array if needed */
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( num_subrs + 1 > max_offsets )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2003-12-24 02:10:46 +01:00
|
|
|
FT_UInt new_max = FT_PAD_CEIL( num_subrs + 1, 4 );
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2011-11-08 08:27:42 +01:00
|
|
|
if ( new_max <= max_offsets )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Syntax_Error );
|
2011-11-08 08:27:42 +01:00
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
2021-05-07 04:51:37 +02:00
|
|
|
if ( FT_QRENEW_ARRAY( offsets, max_offsets, new_max ) )
|
2000-06-01 05:27:48 +02:00
|
|
|
goto Fail;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
max_offsets = new_max;
|
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
/* read the subrmap's offsets */
|
2021-11-22 19:36:45 +01:00
|
|
|
if ( FT_STREAM_SEEK( cid->data_offset + dict->subrmap_offset ) ||
|
|
|
|
FT_FRAME_ENTER( ( num_subrs + 1 ) * dict->sd_bytes ) )
|
2000-06-01 05:27:48 +02:00
|
|
|
goto Fail;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
p = (FT_Byte*)stream->cursor;
|
|
|
|
for ( count = 0; count <= num_subrs; count++ )
|
2021-10-08 04:41:56 +02:00
|
|
|
offsets[count] = cid_get_offset( &p, dict->sd_bytes );
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
FT_FRAME_EXIT();
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2011-11-08 08:27:42 +01:00
|
|
|
/* offsets must be ordered */
|
|
|
|
for ( count = 1; count <= num_subrs; count++ )
|
|
|
|
if ( offsets[count - 1] > offsets[count] )
|
2015-10-20 12:24:36 +02:00
|
|
|
{
|
2015-10-20 22:31:57 +02:00
|
|
|
FT_ERROR(( "cid_read_subrs: offsets are not ordered\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
2011-11-08 08:27:42 +01:00
|
|
|
goto Fail;
|
2015-10-20 12:24:36 +02:00
|
|
|
}
|
2011-11-08 08:27:42 +01:00
|
|
|
|
2015-10-20 22:31:57 +02:00
|
|
|
if ( offsets[num_subrs] > stream->size - cid->data_offset )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "cid_read_subrs: too large `subrs' offsets\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Fail;
|
|
|
|
}
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
/* now, compute the size of subrs charstrings, */
|
|
|
|
/* allocate, and read them */
|
2000-06-01 05:27:48 +02:00
|
|
|
data_len = offsets[num_subrs] - offsets[0];
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2021-05-02 05:49:11 +02:00
|
|
|
if ( FT_QNEW_ARRAY( subr->code, num_subrs + 1 ) ||
|
|
|
|
FT_QALLOC( subr->code[0], data_len ) )
|
2000-06-01 05:27:48 +02:00
|
|
|
goto Fail;
|
|
|
|
|
2002-03-20 11:49:31 +01:00
|
|
|
if ( FT_STREAM_SEEK( cid->data_offset + offsets[0] ) ||
|
2021-09-21 04:18:29 +02:00
|
|
|
FT_STREAM_READ( subr->code[0], data_len ) )
|
2001-12-21 16:26:19 +01:00
|
|
|
goto Fail;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
/* set up pointers */
|
|
|
|
for ( count = 1; count <= num_subrs; count++ )
|
|
|
|
{
|
* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names,
tt_face_get_ps_name): Replace switch statement with if clauses to
make it more portable.
* src/cff/cffobjs.c (cff_face_init): Ditto.
* include/freetype/ftmodule.h (FT_Module_Class): Use `FT_Long' for
`module_size'.
* include/freetype/ftrender.h (FT_Glyph_Class_): Use `FT_Long' for
`glyph_size'.
* src/base/ftobjs.c (FT_Render_Glyph): Change second parameter to
`FT_Render_Mode'.
(FT_Render_Glyph_Internal): Change third parameter to
`FT_Render_Mode'.
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): Change second parameter
to `FT_Render_Mode'.
* src/raster/ftrend1.c (ft_raster1_render): Change third parameter
to `FT_Render_Mode'.
* src/smooth/ftsmooth.c (ft_smooth_render, ft_smooth_render_lcd,
ft_smooth_render_lcd_v): Ditto.
(ft_smooth_render_generic): Change third and fifth parameter to
`FT_Render_Mode'.
* include/freetype/freetype.h, include/freetype/internal/ftobjs.h,
include/freetype/ftglyph.h: Updated.
* src/cff/cffdrivr.c (Load_Glyph), src/pcf/pcfdriver.c
(PCF_Glyph_Load), src/pfr/pfrobjs.c (pfr_slot_load),
src/winfonts/winfnt.c (FNT_Load_Glyph), src/t42/t42objs.c
(T42_GlyphSlot_Load), src/bdf/bdfdrivr.c (BDF_Glyph_Load): Change
fourth parameter to `FT_Int32'.
* src/pfr/pfrobjs.c (pfr_face_init): Add two missing parameters
and declare them as unused.
* src/cid/cidparse.h (CID_Parser): Use FT_Long for `postscript_len'.
* src/psnames/psnames.h (PS_Unicode_Value_Func): Change return
value to FT_UInt32.
* src/psnames/psmodule.c (ps_unicode_value, ps_build_unicode_table):
Updated accordingly.
* src/cff/cffdrivr.c (Get_Kerning): Use FT_Long for `middle'.
(cff_get_glyph_name): Use cast for result of ft_strlen.
* src/cff/cffparse.c (cff_parse_real): User cast for assigning
`exp'.
* src/cff/cffload.c (cff_index_get_pointers): Use FT_ULong for
some local variables.
(cff_charset_load, cff_encoding_load): Use casts to FT_UInt for some
switch statements.
(cff_font_load): Use cast in call to CFF_Load_FD_Select.
* src/cff/cffobjs.c (cff_size_init): Use more casts.
(cff_face_init): Use FT_Int32 for `flags'.
* src/cff/cffgload.c (cff_operator_seac): Use cast for assigning
`adx' and `ady'.
(cff_decoder_parse_charstrings): Use FT_ULong for third parameter.
Use more casts.
* src/cff/cffcmap.c (cff_cmap_unicode_init): Use cast for `count'.
* src/cid/cidload.c (cid_read_subrs): Use FT_ULong for `len'.
* src/cid/cidgload.c (cid_load_glyph): Add missing cast for
`cid_get_offset'.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings) <18>: Use
cast for `num_points'.
(t1_decoder_init): Use cast for assigning `decoder->num_glyphs'.
* src/base/ftdebug.c (ft_debug_init): Use FT_Int.
* include/freetype/internal/ftdriver.h (FT_Slot_LoadFunc): Use
`FT_Int32' for fourth parameter.
* src/base/ftobjs.c (open_face): Use cast for calling
clazz->init_face.
* src/raster/ftraster.c (Set_High_Precision): Use `1' instead of
`1L'.
(Finalize_Profile_Table, Line_Up, ft_black_init): Use casts.
* src/raster/ftrend1.c (ft_raster1_render): Ditto.
* src/sfnt/sfnt_dir_check: Compare `magic' with unsigned long
constant.
* builds/amiga/include/freetype/config/ftmodule.h: Updated.
2002-09-27 13:09:23 +02:00
|
|
|
FT_ULong len;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
len = offsets[count] - offsets[count - 1];
|
|
|
|
subr->code[count] = subr->code[count - 1] + len;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
2001-03-12 23:33:52 +01:00
|
|
|
/* decrypt subroutines, but only if lenIV >= 0 */
|
2001-03-12 03:17:50 +01:00
|
|
|
if ( lenIV >= 0 )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2001-03-12 03:17:50 +01:00
|
|
|
for ( count = 0; count < num_subrs; count++ )
|
|
|
|
{
|
* src/sfnt/ttpost.c (load_post_names, tt_face_free_ps_names,
tt_face_get_ps_name): Replace switch statement with if clauses to
make it more portable.
* src/cff/cffobjs.c (cff_face_init): Ditto.
* include/freetype/ftmodule.h (FT_Module_Class): Use `FT_Long' for
`module_size'.
* include/freetype/ftrender.h (FT_Glyph_Class_): Use `FT_Long' for
`glyph_size'.
* src/base/ftobjs.c (FT_Render_Glyph): Change second parameter to
`FT_Render_Mode'.
(FT_Render_Glyph_Internal): Change third parameter to
`FT_Render_Mode'.
* src/base/ftglyph.c (FT_Glyph_To_Bitmap): Change second parameter
to `FT_Render_Mode'.
* src/raster/ftrend1.c (ft_raster1_render): Change third parameter
to `FT_Render_Mode'.
* src/smooth/ftsmooth.c (ft_smooth_render, ft_smooth_render_lcd,
ft_smooth_render_lcd_v): Ditto.
(ft_smooth_render_generic): Change third and fifth parameter to
`FT_Render_Mode'.
* include/freetype/freetype.h, include/freetype/internal/ftobjs.h,
include/freetype/ftglyph.h: Updated.
* src/cff/cffdrivr.c (Load_Glyph), src/pcf/pcfdriver.c
(PCF_Glyph_Load), src/pfr/pfrobjs.c (pfr_slot_load),
src/winfonts/winfnt.c (FNT_Load_Glyph), src/t42/t42objs.c
(T42_GlyphSlot_Load), src/bdf/bdfdrivr.c (BDF_Glyph_Load): Change
fourth parameter to `FT_Int32'.
* src/pfr/pfrobjs.c (pfr_face_init): Add two missing parameters
and declare them as unused.
* src/cid/cidparse.h (CID_Parser): Use FT_Long for `postscript_len'.
* src/psnames/psnames.h (PS_Unicode_Value_Func): Change return
value to FT_UInt32.
* src/psnames/psmodule.c (ps_unicode_value, ps_build_unicode_table):
Updated accordingly.
* src/cff/cffdrivr.c (Get_Kerning): Use FT_Long for `middle'.
(cff_get_glyph_name): Use cast for result of ft_strlen.
* src/cff/cffparse.c (cff_parse_real): User cast for assigning
`exp'.
* src/cff/cffload.c (cff_index_get_pointers): Use FT_ULong for
some local variables.
(cff_charset_load, cff_encoding_load): Use casts to FT_UInt for some
switch statements.
(cff_font_load): Use cast in call to CFF_Load_FD_Select.
* src/cff/cffobjs.c (cff_size_init): Use more casts.
(cff_face_init): Use FT_Int32 for `flags'.
* src/cff/cffgload.c (cff_operator_seac): Use cast for assigning
`adx' and `ady'.
(cff_decoder_parse_charstrings): Use FT_ULong for third parameter.
Use more casts.
* src/cff/cffcmap.c (cff_cmap_unicode_init): Use cast for `count'.
* src/cid/cidload.c (cid_read_subrs): Use FT_ULong for `len'.
* src/cid/cidgload.c (cid_load_glyph): Add missing cast for
`cid_get_offset'.
* src/psaux/t1decode.c (t1_decoder_parse_charstrings) <18>: Use
cast for `num_points'.
(t1_decoder_init): Use cast for assigning `decoder->num_glyphs'.
* src/base/ftdebug.c (ft_debug_init): Use FT_Int.
* include/freetype/internal/ftdriver.h (FT_Slot_LoadFunc): Use
`FT_Int32' for fourth parameter.
* src/base/ftobjs.c (open_face): Use cast for calling
clazz->init_face.
* src/raster/ftraster.c (Set_High_Precision): Use `1' instead of
`1L'.
(Finalize_Profile_Table, Line_Up, ft_black_init): Use casts.
* src/raster/ftrend1.c (ft_raster1_render): Ditto.
* src/sfnt/sfnt_dir_check: Compare `magic' with unsigned long
constant.
* builds/amiga/include/freetype/config/ftmodule.h: Updated.
2002-09-27 13:09:23 +02:00
|
|
|
FT_ULong len;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
2001-03-12 03:17:50 +01:00
|
|
|
len = offsets[count + 1] - offsets[count];
|
2003-06-12 09:11:05 +02:00
|
|
|
psaux->t1_decrypt( subr->code[count], len, 4330 );
|
2001-03-12 03:17:50 +01:00
|
|
|
}
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
2015-02-20 20:14:11 +01:00
|
|
|
subr->num_subrs = (FT_Int)num_subrs;
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Exit:
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( offsets );
|
2000-06-01 05:27:48 +02:00
|
|
|
return error;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
Fail:
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( face->subrs )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
|
|
|
for ( n = 0; n < cid->num_dicts; n++ )
|
|
|
|
{
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( face->subrs[n].code )
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->subrs[n].code[0] );
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->subrs[n].code );
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
2002-03-22 14:52:37 +01:00
|
|
|
FT_FREE( face->subrs );
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2001-06-27 21:46:12 +02:00
|
|
|
static void
|
2012-02-24 12:26:25 +01:00
|
|
|
cid_init_loader( CID_Loader* loader,
|
|
|
|
CID_Face face )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2000-07-04 20:12:13 +02:00
|
|
|
FT_UNUSED( face );
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2016-09-28 19:06:21 +02:00
|
|
|
FT_ZERO( loader );
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2012-02-24 12:26:25 +01:00
|
|
|
static void
|
|
|
|
cid_done_loader( CID_Loader* loader )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
|
|
|
CID_Parser* parser = &loader->parser;
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
/* finalize parser */
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
cid_parser_done( parser );
|
2000-06-01 05:27:48 +02:00
|
|
|
}
|
|
|
|
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2004-01-23 20:52:40 +01:00
|
|
|
static FT_Error
|
2021-06-08 18:23:16 +02:00
|
|
|
cid_hex_to_binary( FT_Byte* data,
|
|
|
|
FT_ULong data_len,
|
|
|
|
FT_ULong offset,
|
|
|
|
CID_Face face,
|
|
|
|
FT_ULong* data_written )
|
2004-01-23 20:52:40 +01:00
|
|
|
{
|
|
|
|
FT_Stream stream = face->root.stream;
|
|
|
|
FT_Error error;
|
|
|
|
|
|
|
|
FT_Byte buffer[256];
|
|
|
|
FT_Byte *p, *plimit;
|
2021-05-03 19:49:14 +02:00
|
|
|
FT_Byte *d = data, *dlimit;
|
2004-01-23 20:52:40 +01:00
|
|
|
FT_Byte val;
|
|
|
|
|
|
|
|
FT_Bool upper_nibble, done;
|
|
|
|
|
|
|
|
|
|
|
|
if ( FT_STREAM_SEEK( offset ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
dlimit = d + data_len;
|
|
|
|
p = buffer;
|
|
|
|
plimit = p;
|
|
|
|
|
|
|
|
upper_nibble = 1;
|
|
|
|
done = 0;
|
|
|
|
|
|
|
|
while ( d < dlimit )
|
|
|
|
{
|
|
|
|
if ( p >= plimit )
|
|
|
|
{
|
|
|
|
FT_ULong oldpos = FT_STREAM_POS();
|
|
|
|
FT_ULong size = stream->size - oldpos;
|
|
|
|
|
|
|
|
|
|
|
|
if ( size == 0 )
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Syntax_Error );
|
2004-01-23 20:52:40 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( FT_STREAM_READ( buffer, 256 > size ? size : 256 ) )
|
|
|
|
goto Exit;
|
|
|
|
p = buffer;
|
|
|
|
plimit = p + FT_STREAM_POS() - oldpos;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ft_isdigit( *p ) )
|
2005-05-10 00:11:36 +02:00
|
|
|
val = (FT_Byte)( *p - '0' );
|
2004-01-23 20:52:40 +01:00
|
|
|
else if ( *p >= 'a' && *p <= 'f' )
|
2019-07-22 09:49:22 +02:00
|
|
|
val = (FT_Byte)( *p - 'a' + 10 );
|
2004-01-23 20:52:40 +01:00
|
|
|
else if ( *p >= 'A' && *p <= 'F' )
|
2005-05-10 00:11:36 +02:00
|
|
|
val = (FT_Byte)( *p - 'A' + 10 );
|
2004-01-23 20:52:40 +01:00
|
|
|
else if ( *p == ' ' ||
|
|
|
|
*p == '\t' ||
|
|
|
|
*p == '\r' ||
|
|
|
|
*p == '\n' ||
|
|
|
|
*p == '\f' ||
|
|
|
|
*p == '\0' )
|
|
|
|
{
|
|
|
|
p++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if ( *p == '>' )
|
|
|
|
{
|
|
|
|
val = 0;
|
|
|
|
done = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-14 10:27:35 +01:00
|
|
|
error = FT_THROW( Syntax_Error );
|
2004-01-23 20:52:40 +01:00
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( upper_nibble )
|
2005-05-10 00:11:36 +02:00
|
|
|
*d = (FT_Byte)( val << 4 );
|
2004-01-23 20:52:40 +01:00
|
|
|
else
|
|
|
|
{
|
2005-05-10 00:11:36 +02:00
|
|
|
*d = (FT_Byte)( *d + val );
|
2004-01-23 20:52:40 +01:00
|
|
|
d++;
|
|
|
|
}
|
|
|
|
|
2005-05-10 00:11:36 +02:00
|
|
|
upper_nibble = (FT_Byte)( 1 - upper_nibble );
|
2004-01-23 20:52:40 +01:00
|
|
|
|
|
|
|
if ( done )
|
|
|
|
break;
|
|
|
|
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
error = FT_Err_Ok;
|
2004-01-23 20:52:40 +01:00
|
|
|
|
|
|
|
Exit:
|
2021-05-29 11:05:41 +02:00
|
|
|
*data_written = (FT_ULong)( d - data );
|
2004-01-23 20:52:40 +01:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-01 03:26:22 +01:00
|
|
|
FT_LOCAL_DEF( FT_Error )
|
2004-01-23 20:52:40 +01:00
|
|
|
cid_face_open( CID_Face face,
|
|
|
|
FT_Int face_index )
|
2000-06-01 05:27:48 +02:00
|
|
|
{
|
2002-03-30 18:08:04 +01:00
|
|
|
CID_Loader loader;
|
|
|
|
CID_Parser* parser;
|
2004-01-23 20:52:40 +01:00
|
|
|
FT_Memory memory = face->root.memory;
|
2002-03-30 18:08:04 +01:00
|
|
|
FT_Error error;
|
2021-10-11 05:11:10 +02:00
|
|
|
FT_UInt n;
|
2015-10-20 22:31:57 +02:00
|
|
|
|
|
|
|
CID_FaceInfo cid = &face->cid;
|
|
|
|
|
|
|
|
FT_ULong binary_length;
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2012-02-24 12:26:25 +01:00
|
|
|
cid_init_loader( &loader, face );
|
2000-06-01 05:27:48 +02:00
|
|
|
|
|
|
|
parser = &loader.parser;
|
* massive re-formatting changes to many, many source files. I don't
want to list them all here. The operations performed were all logical
transformations of the sources:
- trying to convert all enums and constants to CAPITALIZED_STYLE, with
#define definitions like
#define my_old_constants MY_NEW_CONSTANT
- big, big update of the documentation comments
* include/freetype/freetype.h, src/base/ftobjs.c, src/smooth/ftsmooth.c,
include/freetype/ftimage.h: adding support for LCD-optimized rendering
though the new constants/enums:
FT_RENDER_MODE_LCD, FT_RENDER_MODE_LCD_V
FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_LCD_V
this is still work in progress, don't expect everything to work correctly
though most of the features have been implemented.
* adding new FT_LOAD_XXX flags, used to specify both hinting and rendering
targets:
FT_LOAD_TARGET_NORMAL :: anti-aliased hinting & rendering
FT_LOAD_TARGET_MONO :: monochrome bitmaps
FT_LOAD_TARGET_LCD :: horizontal RGB/BGR decimated hinting & rendering
FT_LOAD_TARGET_LCD_V :: vertical RGB/BGR decimated hinting & rendering
note that FT_LOAD_TARGET_NORMAL is 0, which means that the default
behaviour of the font engine is _unchanged_.
2002-08-27 22:20:29 +02:00
|
|
|
error = cid_parser_new( parser, face->root.stream, face->root.memory,
|
2002-02-28 17:10:29 +01:00
|
|
|
(PSAux_Service)face->psaux );
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2000-08-24 00:47:44 +02:00
|
|
|
error = cid_parse_dict( face, &loader,
|
|
|
|
parser->postscript,
|
|
|
|
parser->postscript_len );
|
2000-06-16 08:49:56 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
2000-06-01 05:27:48 +02:00
|
|
|
|
2004-01-23 20:52:40 +01:00
|
|
|
if ( face_index < 0 )
|
|
|
|
goto Exit;
|
|
|
|
|
2004-02-12 09:33:20 +01:00
|
|
|
if ( FT_NEW( face->cid_stream ) )
|
|
|
|
goto Exit;
|
|
|
|
|
2004-01-23 20:52:40 +01:00
|
|
|
if ( parser->binary_length )
|
|
|
|
{
|
2015-10-20 22:31:57 +02:00
|
|
|
if ( parser->binary_length >
|
|
|
|
face->root.stream->size - parser->data_offset )
|
|
|
|
{
|
2020-12-02 14:15:07 +01:00
|
|
|
FT_TRACE0(( "cid_face_open: adjusting length of binary data\n" ));
|
2021-10-08 04:41:56 +02:00
|
|
|
FT_TRACE0(( " (from %lu to %lu bytes)\n",
|
2015-10-20 22:31:57 +02:00
|
|
|
parser->binary_length,
|
|
|
|
face->root.stream->size - parser->data_offset ));
|
|
|
|
parser->binary_length = face->root.stream->size -
|
|
|
|
parser->data_offset;
|
|
|
|
}
|
|
|
|
|
2004-01-23 20:52:40 +01:00
|
|
|
/* we must convert the data section from hexadecimal to binary */
|
2021-04-23 19:48:34 +02:00
|
|
|
if ( FT_QALLOC( face->binary_data, parser->binary_length ) ||
|
2016-12-27 07:50:22 +01:00
|
|
|
FT_SET_ERROR( cid_hex_to_binary( face->binary_data,
|
|
|
|
parser->binary_length,
|
|
|
|
parser->data_offset,
|
2021-05-03 19:49:14 +02:00
|
|
|
face,
|
|
|
|
&binary_length ) ) )
|
2004-01-23 20:52:40 +01:00
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
FT_Stream_OpenMemory( face->cid_stream,
|
2021-05-03 19:49:14 +02:00
|
|
|
face->binary_data, binary_length );
|
2015-10-20 22:31:57 +02:00
|
|
|
cid->data_offset = 0;
|
2004-01-23 20:52:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-20 22:31:57 +02:00
|
|
|
*face->cid_stream = *face->root.stream;
|
|
|
|
cid->data_offset = loader.parser.data_offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sanity tests */
|
|
|
|
|
2021-10-08 04:41:56 +02:00
|
|
|
if ( cid->gd_bytes == 0 )
|
2015-10-22 09:26:00 +02:00
|
|
|
{
|
2018-07-22 12:11:52 +02:00
|
|
|
FT_ERROR(( "cid_face_open:"
|
2021-10-08 04:41:56 +02:00
|
|
|
" Invalid `GDBytes' value\n" ));
|
2015-10-22 09:26:00 +02:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2015-10-20 22:31:57 +02:00
|
|
|
/* allow at most 32bit offsets */
|
|
|
|
if ( cid->fd_bytes > 4 || cid->gd_bytes > 4 )
|
|
|
|
{
|
2018-07-22 12:11:52 +02:00
|
|
|
FT_ERROR(( "cid_face_open:"
|
2021-02-04 07:44:06 +01:00
|
|
|
" Values of `FDBytes' or `GDBytes' larger than 4\n" ));
|
|
|
|
FT_ERROR(( " "
|
2015-10-20 22:31:57 +02:00
|
|
|
" are not supported\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
binary_length = face->cid_stream->size - cid->data_offset;
|
2021-10-09 04:14:12 +02:00
|
|
|
|
|
|
|
if ( cid->cidmap_offset > binary_length )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "cid_face_open: Invalid `CIDMapOffset' value\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the initial pre-check prevents the multiplication overflow */
|
|
|
|
if ( cid->cid_count > FT_ULONG_MAX / 8 ||
|
|
|
|
cid->cid_count * ( cid->fd_bytes + cid->gd_bytes ) >
|
|
|
|
binary_length - cid->cidmap_offset )
|
|
|
|
{
|
|
|
|
FT_ERROR(( "cid_face_open: Invalid `CIDCount' value\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2015-10-20 22:31:57 +02:00
|
|
|
|
|
|
|
for ( n = 0; n < cid->num_dicts; n++ )
|
|
|
|
{
|
|
|
|
CID_FaceDict dict = cid->font_dicts + n;
|
|
|
|
|
|
|
|
|
2018-07-22 12:11:52 +02:00
|
|
|
/* the upper limits are ad-hoc values */
|
|
|
|
if ( dict->private_dict.blue_shift > 1000 ||
|
|
|
|
dict->private_dict.blue_shift < 0 )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( "cid_face_open:"
|
|
|
|
" setting unlikely BlueShift value %d to default (7)\n",
|
|
|
|
dict->private_dict.blue_shift ));
|
|
|
|
dict->private_dict.blue_shift = 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( dict->private_dict.blue_fuzz > 1000 ||
|
|
|
|
dict->private_dict.blue_fuzz < 0 )
|
|
|
|
{
|
|
|
|
FT_TRACE2(( "cid_face_open:"
|
|
|
|
" setting unlikely BlueFuzz value %d to default (1)\n",
|
|
|
|
dict->private_dict.blue_fuzz ));
|
|
|
|
dict->private_dict.blue_fuzz = 1;
|
|
|
|
}
|
|
|
|
|
2021-10-08 04:41:56 +02:00
|
|
|
if ( dict->num_subrs && dict->sd_bytes == 0 )
|
2015-10-22 09:26:00 +02:00
|
|
|
{
|
2018-07-22 12:11:52 +02:00
|
|
|
FT_ERROR(( "cid_face_open: Invalid `SDBytes' value\n" ));
|
2015-10-22 09:26:00 +02:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2015-10-20 22:31:57 +02:00
|
|
|
if ( dict->sd_bytes > 4 )
|
|
|
|
{
|
2018-07-22 12:11:52 +02:00
|
|
|
FT_ERROR(( "cid_face_open:"
|
2015-10-20 22:31:57 +02:00
|
|
|
" Values of `SDBytes' larger than 4"
|
|
|
|
" are not supported\n" ));
|
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( dict->subrmap_offset > binary_length )
|
|
|
|
{
|
2018-07-22 12:11:52 +02:00
|
|
|
FT_ERROR(( "cid_face_open: Invalid `SubrMapOffset' value\n" ));
|
2015-10-20 22:31:57 +02:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
2021-10-09 04:14:12 +02:00
|
|
|
/* the initial pre-check prevents the multiplication overflow */
|
|
|
|
if ( dict->num_subrs > FT_UINT_MAX / 4 ||
|
2021-10-08 04:44:53 +02:00
|
|
|
dict->num_subrs * dict->sd_bytes >
|
|
|
|
binary_length - dict->subrmap_offset )
|
2015-10-20 22:31:57 +02:00
|
|
|
{
|
2018-07-22 12:11:52 +02:00
|
|
|
FT_ERROR(( "cid_face_open: Invalid `SubrCount' value\n" ));
|
2015-10-20 22:31:57 +02:00
|
|
|
error = FT_THROW( Invalid_File_Format );
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we can now safely proceed */
|
2000-06-01 05:27:48 +02:00
|
|
|
error = cid_read_subrs( face );
|
2000-06-16 08:49:56 +02:00
|
|
|
|
2000-06-01 05:27:48 +02:00
|
|
|
Exit:
|
2012-02-24 12:26:25 +01:00
|
|
|
cid_done_loader( &loader );
|
2000-06-01 05:27:48 +02:00
|
|
|
return error;
|
|
|
|
}
|
2000-06-16 08:49:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* END */
|