2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* gxvmod.c
|
|
|
|
*
|
|
|
|
* FreeType's TrueTypeGX/AAT validation module implementation (body).
|
|
|
|
*
|
2019-01-22 20:31:44 +01:00
|
|
|
* Copyright 2004-2019 by
|
2018-06-03 09:01:17 +02:00
|
|
|
* suzuki toshiya, Masatake YAMATO, Red Hat K.K.,
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* gxvalid is derived from both gxlayout module and otvalid module.
|
|
|
|
* Development of gxlayout is supported by the Information-technology
|
|
|
|
* Promotion Agency(IPA), Japan.
|
|
|
|
*
|
|
|
|
*/
|
2005-08-24 06:31:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_TRUETYPE_TABLES_H
|
|
|
|
#include FT_TRUETYPE_TAGS_H
|
|
|
|
#include FT_GX_VALIDATE_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
|
|
|
#include FT_SERVICE_GX_VALIDATE_H
|
|
|
|
|
|
|
|
#include "gxvmod.h"
|
|
|
|
#include "gxvalid.h"
|
|
|
|
#include "gxvcommn.h"
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2005-08-24 06:31:31 +02:00
|
|
|
#undef FT_COMPONENT
|
2018-08-15 18:13:17 +02:00
|
|
|
#define FT_COMPONENT gxvmodule
|
2005-08-24 06:31:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
2006-08-22 16:24:30 +02:00
|
|
|
gxv_load_table( FT_Face face,
|
|
|
|
FT_Tag tag,
|
|
|
|
FT_Byte* volatile* table,
|
|
|
|
FT_ULong* table_len )
|
2005-08-24 06:31:31 +02:00
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
FT_Memory memory = FT_FACE_MEMORY( face );
|
|
|
|
|
|
|
|
|
|
|
|
error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len );
|
2013-03-14 17:50:49 +01:00
|
|
|
if ( FT_ERR_EQ( error, Table_Missing ) )
|
2013-03-14 11:21:17 +01:00
|
|
|
return FT_Err_Ok;
|
2005-08-24 06:31:31 +02:00
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( FT_ALLOC( *table, *table_len ) )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
error = FT_Load_Sfnt_Table( face, tag, 0, *table, table_len );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
|
2006-08-19 13:18:09 +02:00
|
|
|
#define GXV_TABLE_DECL( _sfnt ) \
|
|
|
|
FT_Byte* volatile _sfnt = NULL; \
|
|
|
|
FT_ULong len_ ## _sfnt = 0
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
|
|
|
|
#define GXV_TABLE_LOAD( _sfnt ) \
|
|
|
|
if ( ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) && \
|
|
|
|
( gx_flags & FT_VALIDATE_ ## _sfnt ) ) \
|
|
|
|
{ \
|
|
|
|
error = gxv_load_table( face, TTAG_ ## _sfnt, \
|
|
|
|
&_sfnt, &len_ ## _sfnt ); \
|
|
|
|
if ( error ) \
|
|
|
|
goto Exit; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GXV_TABLE_VALIDATE( _sfnt ) \
|
|
|
|
if ( _sfnt ) \
|
|
|
|
{ \
|
|
|
|
ft_validator_init( &valid, _sfnt, _sfnt + len_ ## _sfnt, \
|
|
|
|
FT_VALIDATE_DEFAULT ); \
|
2006-08-15 19:00:43 +02:00
|
|
|
if ( ft_setjmp( valid.jump_buffer ) == 0 ) \
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
gxv_ ## _sfnt ## _validate( _sfnt, face, &valid ); \
|
|
|
|
error = valid.error; \
|
|
|
|
if ( error ) \
|
|
|
|
goto Exit; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GXV_TABLE_SET( _sfnt ) \
|
|
|
|
if ( FT_VALIDATE_ ## _sfnt ## _INDEX < table_count ) \
|
|
|
|
tables[FT_VALIDATE_ ## _sfnt ## _INDEX] = (FT_Bytes)_sfnt
|
|
|
|
|
2005-08-24 06:31:31 +02:00
|
|
|
|
|
|
|
static FT_Error
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
gxv_validate( FT_Face face,
|
|
|
|
FT_UInt gx_flags,
|
|
|
|
FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
|
|
|
|
FT_UInt table_count )
|
2005-08-24 06:31:31 +02:00
|
|
|
{
|
2006-08-19 13:18:09 +02:00
|
|
|
FT_Memory volatile memory = FT_FACE_MEMORY( face );
|
2005-08-24 06:31:31 +02:00
|
|
|
|
2013-03-14 11:21:17 +01:00
|
|
|
FT_Error error = FT_Err_Ok;
|
2006-08-19 13:18:09 +02:00
|
|
|
FT_ValidatorRec volatile valid;
|
2005-08-24 06:31:31 +02:00
|
|
|
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
FT_UInt i;
|
2005-08-24 06:31:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
GXV_TABLE_DECL( feat );
|
|
|
|
GXV_TABLE_DECL( bsln );
|
|
|
|
GXV_TABLE_DECL( trak );
|
|
|
|
GXV_TABLE_DECL( just );
|
|
|
|
GXV_TABLE_DECL( mort );
|
|
|
|
GXV_TABLE_DECL( morx );
|
|
|
|
GXV_TABLE_DECL( kern );
|
|
|
|
GXV_TABLE_DECL( opbd );
|
|
|
|
GXV_TABLE_DECL( prop );
|
|
|
|
GXV_TABLE_DECL( lcar );
|
|
|
|
|
|
|
|
for ( i = 0; i < table_count; i++ )
|
|
|
|
tables[i] = 0;
|
|
|
|
|
|
|
|
/* load tables */
|
|
|
|
GXV_TABLE_LOAD( feat );
|
|
|
|
GXV_TABLE_LOAD( bsln );
|
|
|
|
GXV_TABLE_LOAD( trak );
|
|
|
|
GXV_TABLE_LOAD( just );
|
|
|
|
GXV_TABLE_LOAD( mort );
|
|
|
|
GXV_TABLE_LOAD( morx );
|
|
|
|
GXV_TABLE_LOAD( kern );
|
|
|
|
GXV_TABLE_LOAD( opbd );
|
|
|
|
GXV_TABLE_LOAD( prop );
|
|
|
|
GXV_TABLE_LOAD( lcar );
|
|
|
|
|
|
|
|
/* validate tables */
|
|
|
|
GXV_TABLE_VALIDATE( feat );
|
|
|
|
GXV_TABLE_VALIDATE( bsln );
|
|
|
|
GXV_TABLE_VALIDATE( trak );
|
|
|
|
GXV_TABLE_VALIDATE( just );
|
|
|
|
GXV_TABLE_VALIDATE( mort );
|
|
|
|
GXV_TABLE_VALIDATE( morx );
|
|
|
|
GXV_TABLE_VALIDATE( kern );
|
|
|
|
GXV_TABLE_VALIDATE( opbd );
|
|
|
|
GXV_TABLE_VALIDATE( prop );
|
|
|
|
GXV_TABLE_VALIDATE( lcar );
|
|
|
|
|
|
|
|
/* Set results */
|
|
|
|
GXV_TABLE_SET( feat );
|
|
|
|
GXV_TABLE_SET( mort );
|
|
|
|
GXV_TABLE_SET( morx );
|
|
|
|
GXV_TABLE_SET( bsln );
|
|
|
|
GXV_TABLE_SET( just );
|
|
|
|
GXV_TABLE_SET( kern );
|
|
|
|
GXV_TABLE_SET( opbd );
|
|
|
|
GXV_TABLE_SET( trak );
|
|
|
|
GXV_TABLE_SET( prop );
|
|
|
|
GXV_TABLE_SET( lcar );
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
if ( error )
|
|
|
|
{
|
|
|
|
FT_FREE( feat );
|
|
|
|
FT_FREE( bsln );
|
|
|
|
FT_FREE( trak );
|
|
|
|
FT_FREE( just );
|
|
|
|
FT_FREE( mort );
|
|
|
|
FT_FREE( morx );
|
|
|
|
FT_FREE( kern );
|
|
|
|
FT_FREE( opbd );
|
|
|
|
FT_FREE( prop );
|
|
|
|
FT_FREE( lcar );
|
|
|
|
}
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
|
2005-08-24 06:31:31 +02:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error
|
|
|
|
classic_kern_validate( FT_Face face,
|
|
|
|
FT_UInt ckern_flags,
|
|
|
|
FT_Bytes* ckern_table )
|
|
|
|
{
|
2006-08-18 19:20:37 +02:00
|
|
|
FT_Memory volatile memory = FT_FACE_MEMORY( face );
|
2005-08-24 06:31:31 +02:00
|
|
|
|
2006-08-18 19:20:37 +02:00
|
|
|
FT_Byte* volatile ckern = NULL;
|
|
|
|
FT_ULong len_ckern = 0;
|
2005-08-24 06:31:31 +02:00
|
|
|
|
2006-08-27 13:26:18 +02:00
|
|
|
/* without volatile on `error' GCC 4.1.1. emits: */
|
|
|
|
/* warning: variable 'error' might be clobbered by 'longjmp' or 'vfork' */
|
|
|
|
/* this warning seems spurious but --- */
|
2013-06-04 10:30:48 +02:00
|
|
|
FT_Error volatile error;
|
2006-08-18 19:20:37 +02:00
|
|
|
FT_ValidatorRec volatile valid;
|
2005-08-24 06:31:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
*ckern_table = NULL;
|
|
|
|
|
|
|
|
error = gxv_load_table( face, TTAG_kern, &ckern, &len_ckern );
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
|
|
|
|
if ( ckern )
|
|
|
|
{
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
ft_validator_init( &valid, ckern, ckern + len_ckern,
|
|
|
|
FT_VALIDATE_DEFAULT );
|
2006-08-15 19:00:43 +02:00
|
|
|
if ( ft_setjmp( valid.jump_buffer ) == 0 )
|
2005-08-24 06:31:31 +02:00
|
|
|
gxv_kern_validate_classic( ckern, face,
|
|
|
|
ckern_flags & FT_VALIDATE_CKERN, &valid );
|
|
|
|
error = valid.error;
|
|
|
|
if ( error )
|
|
|
|
goto Exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
*ckern_table = ckern;
|
|
|
|
|
|
|
|
Exit:
|
|
|
|
if ( error )
|
|
|
|
FT_FREE( ckern );
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
|
2005-08-24 06:31:31 +02:00
|
|
|
static
|
|
|
|
const FT_Service_GXvalidateRec gxvalid_interface =
|
|
|
|
{
|
2015-10-30 08:07:56 +01:00
|
|
|
gxv_validate /* validate */
|
2005-08-24 06:31:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
const FT_Service_CKERNvalidateRec ckernvalid_interface =
|
|
|
|
{
|
2015-10-30 08:07:56 +01:00
|
|
|
classic_kern_validate /* validate */
|
2005-08-24 06:31:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
const FT_ServiceDescRec gxvalid_services[] =
|
|
|
|
{
|
* src/gxvalid/gxvbsln.c (gxv_bsln_validate): Fix tracing message.
* src/gxvalid/gxvcommn.c (gxv_odtect_add_range): Use `const'.
* src/gxvalid/gxvfeat.c, src/gxvalid/gxvjust.c,
src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c, src/gxvalid/gxvmod.c,
src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c,
src/gxvalid/gxvmort5.c, src/gxvalid/gxvmort.c: Improve tracing
messages.
Decorate constants with `U' and `L' where appropriate.
Fix compiler warnings.
2005-09-01 00:39:23 +02:00
|
|
|
{ FT_SERVICE_ID_GX_VALIDATE, &gxvalid_interface },
|
2005-08-24 06:31:31 +02:00
|
|
|
{ FT_SERVICE_ID_CLASSICKERN_VALIDATE, &ckernvalid_interface },
|
|
|
|
{ NULL, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Pointer
|
|
|
|
gxvalid_get_service( FT_Module module,
|
|
|
|
const char* service_id )
|
|
|
|
{
|
|
|
|
FT_UNUSED( module );
|
|
|
|
|
|
|
|
return ft_service_list_lookup( gxvalid_services, service_id );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_TABLE_DEF
|
|
|
|
const FT_Module_Class gxv_module_class =
|
|
|
|
{
|
|
|
|
0,
|
2011-11-30 10:46:53 +01:00
|
|
|
sizeof ( FT_ModuleRec ),
|
2005-08-24 06:31:31 +02:00
|
|
|
"gxvalid",
|
|
|
|
0x10000L,
|
|
|
|
0x20000L,
|
|
|
|
|
2016-09-17 17:12:50 +02:00
|
|
|
NULL, /* module-specific interface */
|
2005-08-24 06:31:31 +02:00
|
|
|
|
2016-09-17 17:12:50 +02:00
|
|
|
(FT_Module_Constructor)NULL, /* module_init */
|
|
|
|
(FT_Module_Destructor) NULL, /* module_done */
|
|
|
|
(FT_Module_Requester) gxvalid_get_service /* get_interface */
|
2005-08-24 06:31:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|