diff --git a/src/_ftbase.c b/src/_ftbase.c index 60607829d..f3bd92bb7 100644 --- a/src/_ftbase.c +++ b/src/_ftbase.c @@ -27,7 +27,6 @@ #include "freetype/ftmac.c" #include "freetype/ftobjs.c" #include "freetype/ftoutln.c" -#include "freetype/ftpsprop.c" #include "freetype/ftstream.c" #include "freetype/fttrigon.c" #include "freetype/ftutil.c" diff --git a/src/freetype/cffdrivr.c b/src/freetype/cffdrivr.c index 91e7412cb..889180bba 100644 --- a/src/freetype/cffdrivr.c +++ b/src/freetype/cffdrivr.c @@ -22,7 +22,6 @@ #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_SFNT_H #include FT_INTERNAL_POSTSCRIPT_AUX_H -#include FT_INTERNAL_POSTSCRIPT_PROPS_H #include FT_SERVICE_TT_CMAP_H #include FT_SERVICE_CFF_TABLE_LOAD_H diff --git a/src/freetype/cidriver.c b/src/freetype/cidriver.c index 587266099..4d439e0fa 100644 --- a/src/freetype/cidriver.c +++ b/src/freetype/cidriver.c @@ -20,7 +20,6 @@ #include "cidriver.h" #include "cidgload.h" #include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_POSTSCRIPT_PROPS_H #include "ciderrs.h" diff --git a/src/freetype/fthash.c b/src/freetype/fthash.c index bf067f101..f1ecc72be 100644 --- a/src/freetype/fthash.c +++ b/src/freetype/fthash.c @@ -48,24 +48,9 @@ static FT_ULong - hash_str_lookup( FT_Hashkey* key ) + hash_num_lookup( FT_Int key ) { - const char* kp = key->str; - FT_ULong res = 0; - - - /* Mocklisp hash function. */ - while ( *kp ) - res = ( res << 5 ) - res + (FT_ULong)*kp++; - - return res; - } - - - static FT_ULong - hash_num_lookup( FT_Hashkey* key ) - { - FT_ULong num = (FT_ULong)key->num; + FT_ULong num = (FT_ULong)key; FT_ULong res; @@ -80,22 +65,10 @@ static FT_Bool - hash_str_compare( FT_Hashkey* a, - FT_Hashkey* b ) + hash_num_compare( FT_Int a, + FT_Int b ) { - if ( a->str[0] == b->str[0] && - ft_strcmp( a->str, b->str ) == 0 ) - return 1; - - return 0; - } - - - static FT_Bool - hash_num_compare( FT_Hashkey* a, - FT_Hashkey* b ) - { - if ( a->num == b->num ) + if ( a == b ) return 1; return 0; @@ -103,20 +76,20 @@ static FT_Hashnode* - hash_bucket( FT_Hashkey key, - FT_Hash hash ) + hash_bucket( FT_Int key, + FT_Hash hash ) { FT_ULong res = 0; FT_Hashnode* bp = hash->table; FT_Hashnode* ndp; + res = hash_num_lookup( key ); - res = (hash->lookup)( &key ); ndp = bp + ( res % hash->size ); while ( *ndp ) { - if ( (hash->compare)( &(*ndp)->key, &key ) ) + if ( hash_num_compare( (*ndp)->key, key ) ) break; ndp--; @@ -162,54 +135,25 @@ } - static FT_Error - hash_init( FT_Hash hash, - FT_Bool is_num, - FT_Memory memory ) + FT_Error + ft_hash_num_init( FT_Hash hash, + FT_Memory memory ) { FT_UInt sz = INITIAL_HT_SIZE; FT_Error error; - hash->size = sz; hash->limit = sz / 3; hash->used = 0; - if ( is_num ) - { - hash->lookup = hash_num_lookup; - hash->compare = hash_num_compare; - } - else - { - hash->lookup = hash_str_lookup; - hash->compare = hash_str_compare; - } - FT_MEM_NEW_ARRAY( hash->table, sz ); return error; } - FT_Error - ft_hash_str_init( FT_Hash hash, - FT_Memory memory ) - { - return hash_init( hash, 0, memory ); - } - - - FT_Error - ft_hash_num_init( FT_Hash hash, - FT_Memory memory ) - { - return hash_init( hash, 1, memory ); - } - - void - ft_hash_str_free( FT_Hash hash, + ft_hash_num_free( FT_Hash hash, FT_Memory memory ) { if ( hash ) @@ -227,17 +171,14 @@ } - /* `ft_hash_num_free' is the same as `ft_hash_str_free' */ - - - static FT_Error - hash_insert( FT_Hashkey key, - size_t data, - FT_Hash hash, - FT_Memory memory ) + FT_Error + ft_hash_num_insert( FT_Int num, + size_t data, + FT_Hash hash, + FT_Memory memory ) { FT_Hashnode nn; - FT_Hashnode* bp = hash_bucket( key, hash ); + FT_Hashnode* bp = hash_bucket( num, hash ); FT_Error error = FT_Err_Ok; @@ -248,7 +189,7 @@ goto Exit; *bp = nn; - nn->key = key; + nn->key = num; nn->data = data; if ( hash->used >= hash->limit ) @@ -268,41 +209,11 @@ } - FT_Error - ft_hash_str_insert( const char* key, - size_t data, - FT_Hash hash, - FT_Memory memory ) + size_t* + ft_hash_num_lookup( FT_Int num, + FT_Hash hash ) { - FT_Hashkey hk; - - - hk.str = key; - - return hash_insert( hk, data, hash, memory ); - } - - - FT_Error - ft_hash_num_insert( FT_Int num, - size_t data, - FT_Hash hash, - FT_Memory memory ) - { - FT_Hashkey hk; - - - hk.num = num; - - return hash_insert( hk, data, hash, memory ); - } - - - static size_t* - hash_lookup( FT_Hashkey key, - FT_Hash hash ) - { - FT_Hashnode* np = hash_bucket( key, hash ); + FT_Hashnode* np = hash_bucket( num, hash ); return (*np) ? &(*np)->data @@ -310,30 +221,4 @@ } - size_t* - ft_hash_str_lookup( const char* key, - FT_Hash hash ) - { - FT_Hashkey hk; - - - hk.str = key; - - return hash_lookup( hk, hash ); - } - - - size_t* - ft_hash_num_lookup( FT_Int num, - FT_Hash hash ) - { - FT_Hashkey hk; - - - hk.num = num; - - return hash_lookup( hk, hash ); - } - - /* END */ diff --git a/src/freetype/fthash.h b/src/freetype/fthash.h index bbb935bbd..22f0c92e9 100644 --- a/src/freetype/fthash.h +++ b/src/freetype/fthash.h @@ -49,42 +49,22 @@ FT_BEGIN_HEADER - - typedef union FT_Hashkey_ - { - FT_Int num; - const char* str; - - } FT_Hashkey; - - typedef struct FT_HashnodeRec_ { - FT_Hashkey key; - size_t data; + FT_Int key; + size_t data; } FT_HashnodeRec; typedef struct FT_HashnodeRec_ *FT_Hashnode; - typedef FT_ULong - (*FT_Hash_LookupFunc)( FT_Hashkey* key ); - - typedef FT_Bool - (*FT_Hash_CompareFunc)( FT_Hashkey* a, - FT_Hashkey* b ); - - typedef struct FT_HashRec_ { FT_UInt limit; FT_UInt size; FT_UInt used; - FT_Hash_LookupFunc lookup; - FT_Hash_CompareFunc compare; - FT_Hashnode* table; } FT_HashRec; @@ -92,36 +72,20 @@ FT_BEGIN_HEADER typedef struct FT_HashRec_ *FT_Hash; - FT_Error - ft_hash_str_init( FT_Hash hash, - FT_Memory memory ); - FT_Error ft_hash_num_init( FT_Hash hash, FT_Memory memory ); void - ft_hash_str_free( FT_Hash hash, + ft_hash_num_free( FT_Hash hash, FT_Memory memory ); -#define ft_hash_num_free ft_hash_str_free - - FT_Error - ft_hash_str_insert( const char* key, - size_t data, - FT_Hash hash, - FT_Memory memory ); - FT_Error ft_hash_num_insert( FT_Int num, size_t data, FT_Hash hash, FT_Memory memory ); - size_t* - ft_hash_str_lookup( const char* key, - FT_Hash hash ); - size_t* ft_hash_num_lookup( FT_Int num, FT_Hash hash ); diff --git a/src/freetype/ftpsprop.c b/src/freetype/ftpsprop.c deleted file mode 100644 index d88b1af70..000000000 --- a/src/freetype/ftpsprop.c +++ /dev/null @@ -1,230 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftpsprop.c */ -/* */ -/* Get and set properties of PostScript drivers (body). */ -/* See `ftdriver.h' for available properties. */ -/* */ -/* Copyright 2017-2018 by */ -/* 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. */ -/* */ -/***************************************************************************/ - - -#include "ft2build.h" -#include FT_DRIVER_H -#include FT_INTERNAL_DEBUG_H -#include FT_INTERNAL_POSTSCRIPT_AUX_H -#include FT_INTERNAL_OBJECTS_H -#include FT_INTERNAL_POSTSCRIPT_PROPS_H - - - /*************************************************************************/ - /* */ - /* 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 -#define FT_COMPONENT trace_psprops - - - FT_BASE_CALLBACK_DEF( FT_Error ) - ps_property_set( FT_Module module, /* PS_Driver */ - const char* property_name, - const void* value, - FT_Bool value_is_string ) - { - FT_Error error = FT_Err_Ok; - PS_Driver driver = (PS_Driver)module; - -#ifndef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - FT_UNUSED( value_is_string ); -#endif - - - if ( !ft_strcmp( property_name, "darkening-parameters" ) ) - { - FT_Int* darken_params; - FT_Int x1, y1, x2, y2, x3, y3, x4, y4; - -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - FT_Int dp[8]; - - - if ( value_is_string ) - { - const char* s = (const char*)value; - char* ep; - int i; - - - /* eight comma-separated numbers */ - for ( i = 0; i < 7; i++ ) - { - dp[i] = (FT_Int)ft_strtol( s, &ep, 10 ); - if ( *ep != ',' || s == ep ) - return FT_THROW( Invalid_Argument ); - - s = ep + 1; - } - - dp[7] = (FT_Int)ft_strtol( s, &ep, 10 ); - if ( !( *ep == '\0' || *ep == ' ' ) || s == ep ) - return FT_THROW( Invalid_Argument ); - - darken_params = dp; - } - else -#endif - darken_params = (FT_Int*)value; - - x1 = darken_params[0]; - y1 = darken_params[1]; - x2 = darken_params[2]; - y2 = darken_params[3]; - x3 = darken_params[4]; - y3 = darken_params[5]; - x4 = darken_params[6]; - y4 = darken_params[7]; - - if ( x1 < 0 || x2 < 0 || x3 < 0 || x4 < 0 || - y1 < 0 || y2 < 0 || y3 < 0 || y4 < 0 || - x1 > x2 || x2 > x3 || x3 > x4 || - y1 > 500 || y2 > 500 || y3 > 500 || y4 > 500 ) - return FT_THROW( Invalid_Argument ); - - driver->darken_params[0] = x1; - driver->darken_params[1] = y1; - driver->darken_params[2] = x2; - driver->darken_params[3] = y2; - driver->darken_params[4] = x3; - driver->darken_params[5] = y3; - driver->darken_params[6] = x4; - driver->darken_params[7] = y4; - - return error; - } - - else if ( !ft_strcmp( property_name, "hinting-engine" ) ) - { -#if defined( CFF_CONFIG_OPTION_OLD_ENGINE ) || \ - defined( T1_CONFIG_OPTION_OLD_ENGINE ) - const char* module_name = module->clazz->module_name; -#endif - - -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - - - if ( !ft_strcmp( s, "adobe" ) ) - driver->hinting_engine = FT_HINTING_ADOBE; - -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - else if ( !ft_strcmp( module_name, "cff" ) && - !ft_strcmp( s, "freetype" ) ) - driver->hinting_engine = FT_HINTING_FREETYPE; -#endif - -#ifdef T1_CONFIG_OPTION_OLD_ENGINE - else if ( ( !ft_strcmp( module_name, "type1" ) || - !ft_strcmp( module_name, "t1cid" ) ) && - !ft_strcmp( s, "freetype" ) ) - driver->hinting_engine = FT_HINTING_FREETYPE; -#endif - - else - return FT_THROW( Invalid_Argument ); - } - else -#endif /* FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES */ - { - FT_UInt* hinting_engine = (FT_UInt*)value; - - - if ( *hinting_engine == FT_HINTING_ADOBE -#ifdef CFF_CONFIG_OPTION_OLD_ENGINE - || ( *hinting_engine == FT_HINTING_FREETYPE && - !ft_strcmp( module_name, "cff" ) ) -#endif -#ifdef T1_CONFIG_OPTION_OLD_ENGINE - || ( *hinting_engine == FT_HINTING_FREETYPE && - ( !ft_strcmp( module_name, "type1" ) || - !ft_strcmp( module_name, "t1cid" ) ) ) -#endif - ) - driver->hinting_engine = *hinting_engine; - else - error = FT_ERR( Unimplemented_Feature ); - - return error; - } - } - - else if ( !ft_strcmp( property_name, "no-stem-darkening" ) ) - { -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - long nsd = ft_strtol( s, NULL, 10 ); - - - if ( !nsd ) - driver->no_stem_darkening = FALSE; - else - driver->no_stem_darkening = TRUE; - } - else -#endif - { - FT_Bool* no_stem_darkening = (FT_Bool*)value; - - - driver->no_stem_darkening = *no_stem_darkening; - } - - return error; - } - - else if ( !ft_strcmp( property_name, "random-seed" ) ) - { - FT_Int32 random_seed; - - -#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES - if ( value_is_string ) - { - const char* s = (const char*)value; - - - random_seed = (FT_Int32)ft_strtol( s, NULL, 10 ); - } - else -#endif - random_seed = *(FT_Int32*)value; - - if ( random_seed < 0 ) - random_seed = 0; - - driver->random_seed = random_seed; - - return error; - } - - FT_TRACE0(( "ps_property_set: missing property `%s'\n", - property_name )); - return FT_THROW( Missing_Property ); - } - - -/* END */ diff --git a/src/freetype/ftpsprop.h b/src/freetype/ftpsprop.h deleted file mode 100644 index e07f1c206..000000000 --- a/src/freetype/ftpsprop.h +++ /dev/null @@ -1,43 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftpsprop.h */ -/* */ -/* Get and set properties of PostScript drivers (specification). */ -/* */ -/* Copyright 2017-2018 by */ -/* 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 FTPSPROP_H_ -#define FTPSPROP_H_ - - -#include "ft2build.h" -#include FT_FREETYPE_H - - -FT_BEGIN_HEADER - - - FT_BASE_CALLBACK( FT_Error ) - ps_property_set( FT_Module module, /* PS_Driver */ - const char* property_name, - const void* value, - FT_Bool value_is_string ); - - -FT_END_HEADER - - -#endif /* FTPSPROP_H_ */ - - -/* END */ diff --git a/src/freetype/internal.h b/src/freetype/internal.h index 3ba6f2683..1bc2343d0 100644 --- a/src/freetype/internal.h +++ b/src/freetype/internal.h @@ -50,7 +50,6 @@ #define FT_INTERNAL_POSTSCRIPT_AUX_H "psaux.h" #define FT_INTERNAL_POSTSCRIPT_HINTS_H "pshints.h" -#define FT_INTERNAL_POSTSCRIPT_PROPS_H "ftpsprop.h" #define FT_INTERNAL_AUTOHINT_H "autohint.h" diff --git a/src/freetype/t1driver.c b/src/freetype/t1driver.c index 2cc78cecb..8196ca8cd 100644 --- a/src/freetype/t1driver.c +++ b/src/freetype/t1driver.c @@ -26,7 +26,6 @@ #include FT_INTERNAL_DEBUG_H #include FT_INTERNAL_STREAM_H #include FT_INTERNAL_HASH_H -#include FT_INTERNAL_POSTSCRIPT_PROPS_H #include FT_DRIVER_H #include FT_SERVICE_GLYPH_DICT_H