* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +02:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftvalid.h */
|
|
|
|
/* */
|
|
|
|
/* FreeType validation support (specification). */
|
|
|
|
/* */
|
2013-06-07 18:10:40 +02:00
|
|
|
/* Copyright 2004, 2013 by */
|
* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +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. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __FTVALID_H__
|
|
|
|
#define __FTVALID_H__
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_CONFIG_STANDARD_LIBRARY_H /* for ft_setjmp and ft_longjmp */
|
|
|
|
|
|
|
|
|
|
|
|
FT_BEGIN_HEADER
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/**** ****/
|
|
|
|
/**** ****/
|
|
|
|
/**** V A L I D A T I O N ****/
|
|
|
|
/**** ****/
|
|
|
|
/**** ****/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
/* handle to a validation object */
|
2006-08-22 16:24:30 +02:00
|
|
|
typedef struct FT_ValidatorRec_ volatile* FT_Validator;
|
* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* There are three distinct validation levels defined here: */
|
|
|
|
/* */
|
|
|
|
/* FT_VALIDATE_DEFAULT :: */
|
|
|
|
/* A table that passes this validation level can be used reliably by */
|
|
|
|
/* FreeType. It generally means that all offsets have been checked to */
|
Adding OpenType validation module. The code is based on the
(unfinished) `otlayout' module but has been heavily modified to make
it much more compact.
* src/otvalid/*: New module.
* include/freetype/ftotval.h, src/base/ftotval.c,
include/freetype/internal/services/svotval.h: New files.
* include/freetype/config/ftmodule.h: Add otv_module_class.
* include/freetype/config/ftheader.h (FT_OPENTYPE_VALIDATE_H): New
macro.
* include/freetype/internal/ftserv.h
(FT_SERVICE_OPENTYPE_VALIDATE_H): New macro.
* include/freetype/internal/fttrace.h (otvmodule, otvcommon,
otvbase, otvgdef, otvgpos, otvgsub, otvjstf): New trace components.
* include/freetype/ftchapters.h: Updated.
* src/base/Jamfile (Library), src/base/descrip.mms (OBJS),
src/base/rules.mk (BASE_EXT_SRC): Updated.
* docs/CHANGES: Updated.
2004-09-10 16:39:00 +02:00
|
|
|
/* prevent out-of-bound reads, that array counts are correct, etc. */
|
* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +02:00
|
|
|
/* */
|
|
|
|
/* FT_VALIDATE_TIGHT :: */
|
|
|
|
/* A table that passes this validation level can be used reliably and */
|
|
|
|
/* doesn't contain invalid data. For example, a charmap table that */
|
|
|
|
/* returns invalid glyph indices will not pass, even though it can */
|
|
|
|
/* be used with FreeType in default mode (the library will simply */
|
|
|
|
/* return an error later when trying to load the glyph). */
|
|
|
|
/* */
|
Adding OpenType validation module. The code is based on the
(unfinished) `otlayout' module but has been heavily modified to make
it much more compact.
* src/otvalid/*: New module.
* include/freetype/ftotval.h, src/base/ftotval.c,
include/freetype/internal/services/svotval.h: New files.
* include/freetype/config/ftmodule.h: Add otv_module_class.
* include/freetype/config/ftheader.h (FT_OPENTYPE_VALIDATE_H): New
macro.
* include/freetype/internal/ftserv.h
(FT_SERVICE_OPENTYPE_VALIDATE_H): New macro.
* include/freetype/internal/fttrace.h (otvmodule, otvcommon,
otvbase, otvgdef, otvgpos, otvgsub, otvjstf): New trace components.
* include/freetype/ftchapters.h: Updated.
* src/base/Jamfile (Library), src/base/descrip.mms (OBJS),
src/base/rules.mk (BASE_EXT_SRC): Updated.
* docs/CHANGES: Updated.
2004-09-10 16:39:00 +02:00
|
|
|
/* It also checks that fields which must be a multiple of 2, 4, or 8, */
|
* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +02:00
|
|
|
/* don't have incorrect values, etc. */
|
|
|
|
/* */
|
|
|
|
/* FT_VALIDATE_PARANOID :: */
|
|
|
|
/* Only for font debugging. Checks that a table follows the */
|
|
|
|
/* specification by 100%. Very few fonts will be able to pass this */
|
|
|
|
/* level anyway but it can be useful for certain tools like font */
|
|
|
|
/* editors/converters. */
|
|
|
|
/* */
|
|
|
|
typedef enum FT_ValidationLevel_
|
|
|
|
{
|
|
|
|
FT_VALIDATE_DEFAULT = 0,
|
|
|
|
FT_VALIDATE_TIGHT,
|
|
|
|
FT_VALIDATE_PARANOID
|
|
|
|
|
|
|
|
} FT_ValidationLevel;
|
|
|
|
|
|
|
|
|
2013-06-07 18:10:40 +02:00
|
|
|
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
|
|
|
|
/* We disable the warning `structure was padded due to */
|
|
|
|
/* __declspec(align())' in order to compile cleanly with */
|
|
|
|
/* the maximum level of warnings. */
|
|
|
|
#pragma warning( push )
|
|
|
|
#pragma warning( disable : 4324 )
|
|
|
|
#endif /* _MSC_VER */
|
|
|
|
|
* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +02:00
|
|
|
/* validator structure */
|
|
|
|
typedef struct FT_ValidatorRec_
|
|
|
|
{
|
|
|
|
const FT_Byte* base; /* address of table in memory */
|
|
|
|
const FT_Byte* limit; /* `base' + sizeof(table) in memory */
|
|
|
|
FT_ValidationLevel level; /* validation level */
|
|
|
|
FT_Error error; /* error returned. 0 means success */
|
|
|
|
|
|
|
|
ft_jmp_buf jump_buffer; /* used for exception handling */
|
|
|
|
|
|
|
|
} FT_ValidatorRec;
|
|
|
|
|
2013-06-07 18:10:40 +02:00
|
|
|
#if defined( _MSC_VER )
|
|
|
|
#pragma warning( pop )
|
|
|
|
#endif
|
* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +02:00
|
|
|
|
2013-06-07 18:10:40 +02:00
|
|
|
#define FT_VALIDATOR( x ) ( (FT_Validator)( x ) )
|
* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
FT_BASE( void )
|
|
|
|
ft_validator_init( FT_Validator valid,
|
|
|
|
const FT_Byte* base,
|
|
|
|
const FT_Byte* limit,
|
|
|
|
FT_ValidationLevel level );
|
|
|
|
|
2006-10-03 10:53:37 +02:00
|
|
|
/* Do not use this. It's broken and will cause your validator to crash */
|
|
|
|
/* if you run it on an invalid font. */
|
* include/freetype/internal/ftobjs.h: Don't include
FT_CONFIG_STANDARD_LIBRARY_H.
(FT_Validator, FT_VAlidationLevel, FT_ValidatorRec, FT_VALIDATOR,
ft_validator_init, ft_validator_run, ft_validator_error, FT_INVALID,
FT_INVALID_TOO_SHORT, FT_INVALID_OFFSET, FT_INVALID_FORMAT,
FT_INVALID_GLYPH_ID, FT_INVALID_DATA): Move to...
* include/freetype/internal/ftvalid.h: New file.
Make FT_INVALID return module-specific error codes.
* include/freetype/internal/internal.h (FT_INTERNAL_VALIDATE_H): New
macro.
* include/freetype/fterrors.h: Undefine FT_ERR_PREFIX only if
FT_KEEP_ERR_PREFIX isn't defined.
* src/base/ftobjs.c: Include FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.h: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
* src/sfnt/ttcmap.c: Don't include FT_INTERNAL_OBJECTS_H but
FT_INTERNAL_VALIDATE_H.
Include sferrors.h before FT_INTERNAL_VALIDATE_H.
s/FT_Err_Ok/SFNT_Err_Ok/.
* src/sfnt/sferrors.h: Define FT_KEEP_ERR_PREFIX.
* src/type1/t1afm.c: Include t1errors.h.
2004-09-06 09:06:56 +02:00
|
|
|
FT_BASE( FT_Int )
|
|
|
|
ft_validator_run( FT_Validator valid );
|
|
|
|
|
|
|
|
/* Sets the error field in a validator, then calls `longjmp' to return */
|
|
|
|
/* to high-level caller. Using `setjmp/longjmp' avoids many stupid */
|
|
|
|
/* error checks within the validation routines. */
|
|
|
|
/* */
|
|
|
|
FT_BASE( void )
|
|
|
|
ft_validator_error( FT_Validator valid,
|
|
|
|
FT_Error error );
|
|
|
|
|
|
|
|
|
|
|
|
/* Calls ft_validate_error. Assumes that the `valid' local variable */
|
|
|
|
/* holds a pointer to the current validator object. */
|
|
|
|
/* */
|
|
|
|
/* Use preprocessor prescan to pass FT_ERR_PREFIX. */
|
|
|
|
/* */
|
|
|
|
#define FT_INVALID( _prefix, _error ) FT_INVALID_( _prefix, _error )
|
|
|
|
#define FT_INVALID_( _prefix, _error ) \
|
|
|
|
ft_validator_error( valid, _prefix ## _error )
|
|
|
|
|
|
|
|
/* called when a broken table is detected */
|
|
|
|
#define FT_INVALID_TOO_SHORT \
|
|
|
|
FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
|
|
|
|
|
|
|
|
/* called when an invalid offset is detected */
|
|
|
|
#define FT_INVALID_OFFSET \
|
|
|
|
FT_INVALID( FT_ERR_PREFIX, Invalid_Offset )
|
|
|
|
|
|
|
|
/* called when an invalid format/value is detected */
|
|
|
|
#define FT_INVALID_FORMAT \
|
|
|
|
FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
|
|
|
|
|
|
|
|
/* called when an invalid glyph index is detected */
|
|
|
|
#define FT_INVALID_GLYPH_ID \
|
|
|
|
FT_INVALID( FT_ERR_PREFIX, Invalid_Glyph_Index )
|
|
|
|
|
|
|
|
/* called when an invalid field value is detected */
|
|
|
|
#define FT_INVALID_DATA \
|
|
|
|
FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
|
|
|
|
|
|
|
|
|
|
|
|
FT_END_HEADER
|
|
|
|
|
|
|
|
#endif /* __FTVALID_H__ */
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|