summaryrefslogtreecommitdiffstats
path: root/src/base
diff options
context:
space:
mode:
authorJungshik Shin <jungshik@google.com>2016-09-18 03:50:36 -0700
committerSean McCreary <mccreary@mcwest.org>2017-04-07 16:53:42 -0600
commit3ff870b9dbbd88173df82269d3c1cffb1eba2eda (patch)
tree0e443679e800bb442b2cbb2f7ae086b787ca65ff /src/base
parentf720f0dbcf012d6c984dbbefa0875ef9840458c6 (diff)
downloadandroid_external_freetype-3ff870b9dbbd88173df82269d3c1cffb1eba2eda.tar.gz
android_external_freetype-3ff870b9dbbd88173df82269d3c1cffb1eba2eda.tar.bz2
android_external_freetype-3ff870b9dbbd88173df82269d3c1cffb1eba2eda.zip
Update FreeType from 2.6.2 to c38be52bf8de (2.7 + a few post-2.7 CLs)HEADreplicant-6.0-0002replicant-6.0-0001cm-13.0
http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=c38be52b Keep all the configuration options as before. Likewise, exclude unused files (Jamfiles, various mk files, builds/, docs/, ChangeLog*, directories under src/ for disabled modules, etc). Update README.android to record the configurations. Besides, disable a new option (TT_CONFIG_OPTION_SUBPIXEL_HINTING) for branches. Note that a bulk of changes in this CL come from the code to implement this option. BUG: 31470908 AOSP-Change-Id: I1ca90aec171d9580415b8531e2b767e9dd31164c CVE-2016-10244 Change-Id: I4485d2ea543c52f8145ab23372cf3e5c7345879b (cherry picked from commit 055aee28cedc3631434b2636fc6093c0d4d818ab)
Diffstat (limited to 'src/base')
-rw-r--r--src/base/basepic.c2
-rw-r--r--src/base/basepic.h8
-rw-r--r--src/base/ftadvanc.c18
-rw-r--r--src/base/ftapi.c2
-rw-r--r--src/base/ftbase.c3
-rw-r--r--src/base/ftbase.h8
-rw-r--r--src/base/ftbbox.c2
-rw-r--r--src/base/ftbdf.c91
-rw-r--r--src/base/ftbitmap.c4
-rw-r--r--src/base/ftcalc.c4
-rw-r--r--src/base/ftcid.c118
-rw-r--r--src/base/ftdbgmem.c11
-rw-r--r--src/base/ftdebug.c2
-rw-r--r--src/base/ftfntfmt.c2
-rw-r--r--src/base/ftfstype.c2
-rw-r--r--src/base/ftgasp.c2
-rw-r--r--src/base/ftgloadr.c2
-rw-r--r--src/base/ftglyph.c2
-rw-r--r--src/base/ftgxval.c142
-rw-r--r--src/base/fthash.c339
-rw-r--r--src/base/ftinit.c113
-rw-r--r--src/base/ftlcdfil.c20
-rw-r--r--src/base/ftmac.c1080
-rw-r--r--src/base/ftmm.c2
-rw-r--r--src/base/ftobjs.c91
-rw-r--r--src/base/ftotval.c91
-rw-r--r--src/base/ftoutln.c15
-rw-r--r--src/base/ftpatent.c246
-rw-r--r--src/base/ftpfr.c153
-rw-r--r--src/base/ftpic.c2
-rw-r--r--src/base/ftrfork.c4
-rw-r--r--src/base/ftsnames.c2
-rw-r--r--src/base/ftstream.c4
-rw-r--r--src/base/ftstroke.c9
-rw-r--r--src/base/ftsynth.c2
-rw-r--r--src/base/ftsystem.c2
-rw-r--r--src/base/fttrigon.c5
-rw-r--r--src/base/fttype1.c2
-rw-r--r--src/base/ftutil.c2
-rw-r--r--src/base/ftwinfnt.c2
-rw-r--r--src/base/md5.c57
41 files changed, 630 insertions, 2038 deletions
diff --git a/src/base/basepic.c b/src/base/basepic.c
index 9850ed9..f2cea90 100644
--- a/src/base/basepic.c
+++ b/src/base/basepic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for base. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2016 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/basepic.h b/src/base/basepic.h
index c5d7cbf..a1a75a0 100644
--- a/src/base/basepic.h
+++ b/src/base/basepic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for base. */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2016 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __BASEPIC_H__
-#define __BASEPIC_H__
+#ifndef BASEPIC_H_
+#define BASEPIC_H_
#include FT_INTERNAL_PIC_H
@@ -85,7 +85,7 @@ FT_END_HEADER
/* */
-#endif /* __BASEPIC_H__ */
+#endif /* BASEPIC_H_ */
/* END */
diff --git a/src/base/ftadvanc.c b/src/base/ftadvanc.c
index f12908f..9e2ab89 100644
--- a/src/base/ftadvanc.c
+++ b/src/base/ftadvanc.c
@@ -4,7 +4,7 @@
/* */
/* Quick computation of advance widths (body). */
/* */
-/* Copyright 2008-2015 by */
+/* Copyright 2008-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -60,10 +60,12 @@
/* - unscaled load */
/* - unhinted load */
/* - light-hinted load */
+ /* - neither a MM nor a GX font */
-#define LOAD_ADVANCE_FAST_CHECK( flags ) \
- ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \
- FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT )
+#define LOAD_ADVANCE_FAST_CHECK( face, flags ) \
+ ( ( flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) || \
+ FT_LOAD_TARGET_MODE( flags ) == FT_RENDER_MODE_LIGHT ) && \
+ !FT_HAS_MULTIPLE_MASTERS( face ) )
/* documentation is in ftadvanc.h */
@@ -87,7 +89,7 @@
return FT_THROW( Invalid_Glyph_Index );
func = face->driver->clazz->get_advances;
- if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) )
+ if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
{
FT_Error error;
@@ -133,7 +135,7 @@
return FT_Err_Ok;
func = face->driver->clazz->get_advances;
- if ( func && LOAD_ADVANCE_FAST_CHECK( flags ) )
+ if ( func && LOAD_ADVANCE_FAST_CHECK( face, flags ) )
{
error = func( face, start, count, flags, padvances );
if ( !error )
@@ -157,8 +159,8 @@
/* scale from 26.6 to 16.16 */
padvances[nn] = ( flags & FT_LOAD_VERTICAL_LAYOUT )
- ? face->glyph->advance.y << 10
- : face->glyph->advance.x << 10;
+ ? face->glyph->advance.y * 1024
+ : face->glyph->advance.x * 1024;
}
return error;
diff --git a/src/base/ftapi.c b/src/base/ftapi.c
index f22a181..b94c3eb 100644
--- a/src/base/ftapi.c
+++ b/src/base/ftapi.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType compatibility functions (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftbase.c b/src/base/ftbase.c
index 253dfb7..ab1af6f 100644
--- a/src/base/ftbase.c
+++ b/src/base/ftbase.c
@@ -4,7 +4,7 @@
/* */
/* Single object library component (body only). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -26,6 +26,7 @@
#include "ftcalc.c"
#include "ftdbgmem.c"
#include "ftgloadr.c"
+#include "fthash.c"
#include "ftobjs.c"
#include "ftoutln.c"
#include "ftrfork.c"
diff --git a/src/base/ftbase.h b/src/base/ftbase.h
index e37fefa..717fdaa 100644
--- a/src/base/ftbase.h
+++ b/src/base/ftbase.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType private functions used in base module (specification). */
/* */
-/* Copyright 2008-2015 by */
+/* Copyright 2008-2016 by */
/* David Turner, Robert Wilhelm, Werner Lemberg, and suzuki toshiya. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __FTBASE_H__
-#define __FTBASE_H__
+#ifndef FTBASE_H_
+#define FTBASE_H_
#include <ft2build.h>
@@ -68,7 +68,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __FTBASE_H__ */
+#endif /* FTBASE_H_ */
/* END */
diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c
index 10df98d..d3e45ff 100644
--- a/src/base/ftbbox.c
+++ b/src/base/ftbbox.c
@@ -4,7 +4,7 @@
/* */
/* FreeType bbox computation (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used */
diff --git a/src/base/ftbdf.c b/src/base/ftbdf.c
deleted file mode 100644
index aa72ddc..0000000
--- a/src/base/ftbdf.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftbdf.c */
-/* */
-/* FreeType API for accessing BDF-specific strings (body). */
-/* */
-/* Copyright 2002-2015 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_INTERNAL_DEBUG_H
-
-#include FT_INTERNAL_OBJECTS_H
-#include FT_SERVICE_BDF_H
-
-
- /* documentation is in ftbdf.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_BDF_Charset_ID( FT_Face face,
- const char* *acharset_encoding,
- const char* *acharset_registry )
- {
- FT_Error error;
- const char* encoding = NULL;
- const char* registry = NULL;
-
- FT_Service_BDF service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- FT_FACE_FIND_SERVICE( face, service, BDF );
-
- if ( service && service->get_charset_id )
- error = service->get_charset_id( face, &encoding, &registry );
- else
- error = FT_THROW( Invalid_Argument );
-
- if ( acharset_encoding )
- *acharset_encoding = encoding;
-
- if ( acharset_registry )
- *acharset_registry = registry;
-
- return error;
- }
-
-
- /* documentation is in ftbdf.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_BDF_Property( FT_Face face,
- const char* prop_name,
- BDF_PropertyRec *aproperty )
- {
- FT_Error error;
-
- FT_Service_BDF service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !aproperty )
- return FT_THROW( Invalid_Argument );
-
- aproperty->type = BDF_PROPERTY_TYPE_NONE;
-
- FT_FACE_FIND_SERVICE( face, service, BDF );
-
- if ( service && service->get_property )
- error = service->get_property( face, prop_name, aproperty );
- else
- error = FT_THROW( Invalid_Argument );
-
- return error;
- }
-
-
-/* END */
diff --git a/src/base/ftbitmap.c b/src/base/ftbitmap.c
index a54572a..24fead3 100644
--- a/src/base/ftbitmap.c
+++ b/src/base/ftbitmap.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility functions for bitmaps (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -351,7 +351,7 @@
}
/* for each row */
- for ( y = 0; y < bitmap->rows ; y++ )
+ for ( y = 0; y < bitmap->rows; y++ )
{
/*
* Horizontally:
diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c
index 619a08b..67549d0 100644
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -4,7 +4,7 @@
/* */
/* Arithmetic computations (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -233,7 +233,7 @@
{
#ifdef FT_MULFIX_ASSEMBLER
- return FT_MULFIX_ASSEMBLER( a_, b_ );
+ return FT_MULFIX_ASSEMBLER( (FT_Int32)a_, (FT_Int32)b_ );
#else
diff --git a/src/base/ftcid.c b/src/base/ftcid.c
deleted file mode 100644
index 0734881..0000000
--- a/src/base/ftcid.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftcid.c */
-/* */
-/* FreeType API for accessing CID font information. */
-/* */
-/* Copyright 2007-2015 by */
-/* Derek Clegg and Michael Toftdal. */
-/* */
-/* 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_CID_H
-#include FT_INTERNAL_OBJECTS_H
-#include FT_SERVICE_CID_H
-
-
- /* documentation is in ftcid.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_CID_Registry_Ordering_Supplement( FT_Face face,
- const char* *registry,
- const char* *ordering,
- FT_Int *supplement)
- {
- FT_Error error;
- const char* r = NULL;
- const char* o = NULL;
- FT_Int s = 0;
-
-
- error = FT_ERR( Invalid_Argument );
-
- if ( face )
- {
- FT_Service_CID service;
-
-
- FT_FACE_FIND_SERVICE( face, service, CID );
-
- if ( service && service->get_ros )
- error = service->get_ros( face, &r, &o, &s );
- }
-
- if ( registry )
- *registry = r;
-
- if ( ordering )
- *ordering = o;
-
- if ( supplement )
- *supplement = s;
-
- return error;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face,
- FT_Bool *is_cid )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
- FT_Bool ic = 0;
-
-
- if ( face )
- {
- FT_Service_CID service;
-
-
- FT_FACE_FIND_SERVICE( face, service, CID );
-
- if ( service && service->get_is_cid )
- error = service->get_is_cid( face, &ic);
- }
-
- if ( is_cid )
- *is_cid = ic;
-
- return error;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_CID_From_Glyph_Index( FT_Face face,
- FT_UInt glyph_index,
- FT_UInt *cid )
- {
- FT_Error error = FT_ERR( Invalid_Argument );
- FT_UInt c = 0;
-
-
- if ( face )
- {
- FT_Service_CID service;
-
-
- FT_FACE_FIND_SERVICE( face, service, CID );
-
- if ( service && service->get_cid_from_glyph_index )
- error = service->get_cid_from_glyph_index( face, glyph_index, &c);
- }
-
- if ( cid )
- *cid = c;
-
- return error;
- }
-
-
-/* END */
diff --git a/src/base/ftdbgmem.c b/src/base/ftdbgmem.c
index 02eeb01..38d1a80 100644
--- a/src/base/ftdbgmem.c
+++ b/src/base/ftdbgmem.c
@@ -4,7 +4,7 @@
/* */
/* Memory debugger (body). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -367,7 +367,8 @@
{
printf(
"leaked memory block at address %p, size %8ld in (%s:%ld)\n",
- node->address, node->size,
+ (void*)node->address,
+ node->size,
FT_FILENAME( node->source->file_name ),
node->source->line_no );
@@ -841,7 +842,7 @@
p = getenv( "FT2_ALLOC_TOTAL_MAX" );
if ( p != NULL )
{
- FT_Long total_max = ft_atol( p );
+ FT_Long total_max = ft_strtol( p, NULL, 10 );
if ( total_max > 0 )
@@ -854,7 +855,7 @@
p = getenv( "FT2_ALLOC_COUNT_MAX" );
if ( p != NULL )
{
- FT_Long total_count = ft_atol( p );
+ FT_Long total_count = ft_strtol( p, NULL, 10 );
if ( total_count > 0 )
@@ -867,7 +868,7 @@
p = getenv( "FT2_KEEP_ALIVE" );
if ( p != NULL )
{
- FT_Long keep_alive = ft_atol( p );
+ FT_Long keep_alive = ft_strtol( p, NULL, 10 );
if ( keep_alive > 0 )
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index 03e18a8..40925d1 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -4,7 +4,7 @@
/* */
/* Debugging and logging component (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftfntfmt.c b/src/base/ftfntfmt.c
index 98e7431..c6eb319 100644
--- a/src/base/ftfntfmt.c
+++ b/src/base/ftfntfmt.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for font formats (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftfstype.c b/src/base/ftfstype.c
index cd3458f..ae56c8f 100644
--- a/src/base/ftfstype.c
+++ b/src/base/ftfstype.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file to access FSType data (body). */
/* */
-/* Copyright 2008-2015 by */
+/* Copyright 2008-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftgasp.c b/src/base/ftgasp.c
index bbd257c..e38e55b 100644
--- a/src/base/ftgasp.c
+++ b/src/base/ftgasp.c
@@ -4,7 +4,7 @@
/* */
/* Access of TrueType's `gasp' table (body). */
/* */
-/* Copyright 2007-2015 by */
+/* Copyright 2007-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftgloadr.c b/src/base/ftgloadr.c
index 7e28638..c4f0ff7 100644
--- a/src/base/ftgloadr.c
+++ b/src/base/ftgloadr.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph loader (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftglyph.c b/src/base/ftglyph.c
index 2778743..c2376dd 100644
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -4,7 +4,7 @@
/* */
/* FreeType convenience functions to handle glyphs (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftgxval.c b/src/base/ftgxval.c
deleted file mode 100644
index 58868f2..0000000
--- a/src/base/ftgxval.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftgxval.c */
-/* */
-/* FreeType API for validating TrueTyepGX/AAT tables (body). */
-/* */
-/* Copyright 2004-2015 by */
-/* Masatake YAMATO, Redhat 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. */
-/* */
-/***************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_DEBUG_H
-
-#include FT_INTERNAL_OBJECTS_H
-#include FT_SERVICE_GX_VALIDATE_H
-
-
- /* documentation is in ftgxval.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_TrueTypeGX_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes tables[FT_VALIDATE_GX_LENGTH],
- FT_UInt table_length )
- {
- FT_Service_GXvalidate service;
- FT_Error error;
-
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- if ( !tables )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, service, GX_VALIDATE );
-
- if ( service )
- error = service->validate( face,
- validation_flags,
- tables,
- table_length );
- else
- error = FT_THROW( Unimplemented_Feature );
-
- Exit:
- return error;
- }
-
-
- FT_EXPORT_DEF( void )
- FT_TrueTypeGX_Free( FT_Face face,
- FT_Bytes table )
- {
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
- FT_FREE( table );
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_ClassicKern_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes *ckern_table )
- {
- FT_Service_CKERNvalidate service;
- FT_Error error;
-
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- if ( !ckern_table )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, service, CLASSICKERN_VALIDATE );
-
- if ( service )
- error = service->validate( face,
- validation_flags,
- ckern_table );
- else
- error = FT_THROW( Unimplemented_Feature );
-
- Exit:
- return error;
- }
-
-
- FT_EXPORT_DEF( void )
- FT_ClassicKern_Free( FT_Face face,
- FT_Bytes table )
- {
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
-
- FT_FREE( table );
- }
-
-
-/* END */
diff --git a/src/base/fthash.c b/src/base/fthash.c
new file mode 100644
index 0000000..21bc8dd
--- /dev/null
+++ b/src/base/fthash.c
@@ -0,0 +1,339 @@
+/***************************************************************************/
+/* */
+/* fthash.c */
+/* */
+/* Hashing functions (body). */
+/* */
+/***************************************************************************/
+
+/*
+ * Copyright 2000 Computing Research Labs, New Mexico State University
+ * Copyright 2001-2015
+ * Francesco Zappa Nardelli
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COMPUTING RESEARCH LAB OR NEW MEXICO STATE UNIVERSITY BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+ /*************************************************************************/
+ /* */
+ /* This file is based on code from bdf.c,v 1.22 2000/03/16 20:08:50 */
+ /* */
+ /* taken from Mark Leisher's xmbdfed package */
+ /* */
+ /*************************************************************************/
+
+
+#include <ft2build.h>
+#include FT_INTERNAL_HASH_H
+#include FT_INTERNAL_MEMORY_H
+
+
+#define INITIAL_HT_SIZE 241
+
+
+ static FT_ULong
+ hash_str_lookup( FT_Hashkey* 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 res;
+
+
+ /* Mocklisp hash function. */
+ res = num & 0xFF;
+ res = ( res << 5 ) - res + ( ( num >> 8 ) & 0xFF );
+ res = ( res << 5 ) - res + ( ( num >> 16 ) & 0xFF );
+ res = ( res << 5 ) - res + ( ( num >> 24 ) & 0xFF );
+
+ return res;
+ }
+
+
+ static FT_Bool
+ hash_str_compare( FT_Hashkey* a,
+ FT_Hashkey* 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 )
+ return 1;
+
+ return 0;
+ }
+
+
+ static FT_Hashnode*
+ hash_bucket( FT_Hashkey key,
+ FT_Hash hash )
+ {
+ FT_ULong res = 0;
+ FT_Hashnode* bp = hash->table;
+ FT_Hashnode* ndp;
+
+
+ res = (hash->lookup)( &key );
+
+ ndp = bp + ( res % hash->size );
+ while ( *ndp )
+ {
+ if ( (hash->compare)( &(*ndp)->key, &key ) )
+ break;
+
+ ndp--;
+ if ( ndp < bp )
+ ndp = bp + ( hash->size - 1 );
+ }
+
+ return ndp;
+ }
+
+
+ static FT_Error
+ hash_rehash( FT_Hash hash,
+ FT_Memory memory )
+ {
+ FT_Hashnode* obp = hash->table;
+ FT_Hashnode* bp;
+ FT_Hashnode* nbp;
+
+ FT_UInt i, sz = hash->size;
+ FT_Error error = FT_Err_Ok;
+
+
+ hash->size <<= 1;
+ hash->limit = hash->size / 3;
+
+ if ( FT_NEW_ARRAY( hash->table, hash->size ) )
+ goto Exit;
+
+ for ( i = 0, bp = obp; i < sz; i++, bp++ )
+ {
+ if ( *bp )
+ {
+ nbp = hash_bucket( (*bp)->key, hash );
+ *nbp = *bp;
+ }
+ }
+
+ FT_FREE( obp );
+
+ Exit:
+ return error;
+ }
+
+
+ static FT_Error
+ hash_init( FT_Hash hash,
+ FT_Bool is_num,
+ 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_Memory memory )
+ {
+ if ( hash )
+ {
+ FT_UInt sz = hash->size;
+ FT_Hashnode* bp = hash->table;
+ FT_UInt i;
+
+
+ for ( i = 0; i < sz; i++, bp++ )
+ FT_FREE( *bp );
+
+ FT_FREE( hash->table );
+ }
+ }
+
+
+ /* `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_Hashnode nn;
+ FT_Hashnode* bp = hash_bucket( key, hash );
+ FT_Error error = FT_Err_Ok;
+
+
+ nn = *bp;
+ if ( !nn )
+ {
+ if ( FT_NEW( nn ) )
+ goto Exit;
+ *bp = nn;
+
+ nn->key = key;
+ nn->data = data;
+
+ if ( hash->used >= hash->limit )
+ {
+ error = hash_rehash( hash, memory );
+ if ( error )
+ goto Exit;
+ }
+
+ hash->used++;
+ }
+ else
+ nn->data = data;
+
+ Exit:
+ return error;
+ }
+
+
+ FT_Error
+ ft_hash_str_insert( const char* key,
+ size_t data,
+ FT_Hash hash,
+ FT_Memory memory )
+ {
+ 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 );
+
+
+ return (*np) ? &(*np)->data
+ : NULL;
+ }
+
+
+ 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/base/ftinit.c b/src/base/ftinit.c
index b65a91d..02ef938 100644
--- a/src/base/ftinit.c
+++ b/src/base/ftinit.c
@@ -4,7 +4,7 @@
/* */
/* FreeType initialization layer (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -226,6 +226,115 @@
}
+#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+
+#define MAX_LENGTH 128
+
+ /*
+ * Set default properties derived from the `FREETYPE_PROPERTIES'
+ * environment variable.
+ *
+ * `FREETYPE_PROPERTIES' has the following syntax form (broken here into
+ * multiple lines for better readability)
+ *
+ * <optional whitespace>
+ * <module-name1> ':'
+ * <property-name1> '=' <property-value1>
+ * <whitespace>
+ * <module-name2> ':'
+ * <property-name2> '=' <property-value2>
+ * ...
+ *
+ * Example:
+ *
+ * FREETYPE_PROPERTIES=truetype:interpreter-version=35 \
+ * cff:no-stem-darkening=1 \
+ * autofitter:warping=1
+ *
+ */
+
+ static void
+ ft_set_default_properties( FT_Library library )
+ {
+ const char* env;
+ const char* p;
+ const char* q;
+
+ char module_name[MAX_LENGTH + 1];
+ char property_name[MAX_LENGTH + 1];
+ char property_value[MAX_LENGTH + 1];
+
+ int i;
+
+
+ env = ft_getenv( "FREETYPE_PROPERTIES" );
+ if ( !env )
+ return;
+
+ for ( p = env; *p; p++ )
+ {
+ /* skip leading whitespace and separators */
+ if ( *p == ' ' || *p == '\t' )
+ continue;
+
+ /* read module name, followed by `:' */
+ q = p;
+ for ( i = 0; i < MAX_LENGTH; i++ )
+ {
+ if ( !*p || *p == ':' )
+ break;
+ module_name[i] = *p++;
+ }
+ module_name[i] = '\0';
+
+ if ( !*p || *p != ':' || p == q )
+ break;
+
+ /* read property name, followed by `=' */
+ q = ++p;
+ for ( i = 0; i < MAX_LENGTH; i++ )
+ {
+ if ( !*p || *p == '=' )
+ break;
+ property_name[i] = *p++;
+ }
+ property_name[i] = '\0';
+
+ if ( !*p || *p != '=' || p == q )
+ break;
+
+ /* read property value, followed by whitespace (if any) */
+ q = ++p;
+ for ( i = 0; i < MAX_LENGTH; i++ )
+ {
+ if ( !*p || *p == ' ' || *p == '\t' )
+ break;
+ property_value[i] = *p++;
+ }
+ property_value[i] = '\0';
+
+ if ( !( *p == '\0' || *p == ' ' || *p == '\t' ) || p == q )
+ break;
+
+ /* we completely ignore errors */
+ ft_property_string_set( library,
+ module_name,
+ property_name,
+ property_value );
+ }
+ }
+
+#else
+
+ static void
+ ft_set_default_properties( FT_Library library )
+ {
+ FT_UNUSED( library );
+ }
+
+#endif
+
+
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Error )
@@ -256,6 +365,8 @@
else
FT_Add_Default_Modules( *alibrary );
+ ft_set_default_properties( *alibrary );
+
return error;
}
diff --git a/src/base/ftlcdfil.c b/src/base/ftlcdfil.c
index 5ee7e0a..8bcbed7 100644
--- a/src/base/ftlcdfil.c
+++ b/src/base/ftlcdfil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for color filtering of subpixel bitmap glyphs (body). */
/* */
-/* Copyright 2006-2015 by */
+/* Copyright 2006-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -296,6 +296,8 @@
return FT_THROW( Invalid_Argument );
ft_memcpy( library->lcd_weights, weights, 5 );
+ library->lcd_filter_func = _ft_lcd_filter_fir;
+ library->lcd_extra = 2;
return FT_Err_Ok;
}
@@ -322,25 +324,9 @@
break;
case FT_LCD_FILTER_DEFAULT:
-#if defined( FT_FORCE_LEGACY_LCD_FILTER )
-
- library->lcd_filter_func = _ft_lcd_filter_legacy;
- library->lcd_extra = 0;
-
-#elif defined( FT_FORCE_LIGHT_LCD_FILTER )
-
- ft_memcpy( library->lcd_weights, light_filter, 5 );
- library->lcd_filter_func = _ft_lcd_filter_fir;
- library->lcd_extra = 2;
-
-#else
-
ft_memcpy( library->lcd_weights, default_filter, 5 );
library->lcd_filter_func = _ft_lcd_filter_fir;
library->lcd_extra = 2;
-
-#endif
-
break;
case FT_LCD_FILTER_LIGHT:
diff --git a/src/base/ftmac.c b/src/base/ftmac.c
deleted file mode 100644
index 114bbb6..0000000
--- a/src/base/ftmac.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftmac.c */
-/* */
-/* Mac FOND support. Written by just@letterror.com. */
-/* Heavily modified by mpsuzuki, George Williams, and Sean McBride. */
-/* */
-/* This file is for Mac OS X only; see builds/mac/ftoldmac.c for */
-/* classic platforms built by MPW. */
-/* */
-/* Copyright 1996-2015 by */
-/* Just van Rossum, 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. */
-/* */
-/***************************************************************************/
-
-
- /*
- Notes
-
- Mac suitcase files can (and often do!) contain multiple fonts. To
- support this I use the face_index argument of FT_(Open|New)_Face()
- functions, and pretend the suitcase file is a collection.
-
- Warning: fbit and NFNT bitmap resources are not supported yet. In old
- sfnt fonts, bitmap glyph data for each size is stored in each `NFNT'
- resources instead of the `bdat' table in the sfnt resource. Therefore,
- face->num_fixed_sizes is set to 0, because bitmap data in `NFNT'
- resource is unavailable at present.
-
- The Mac FOND support works roughly like this:
-
- - Check whether the offered stream points to a Mac suitcase file. This
- is done by checking the file type: it has to be 'FFIL' or 'tfil'. The
- stream that gets passed to our init_face() routine is a stdio stream,
- which isn't usable for us, since the FOND resources live in the
- resource fork. So we just grab the stream->pathname field.
-
- - Read the FOND resource into memory, then check whether there is a
- TrueType font and/or(!) a Type 1 font available.
-
- - If there is a Type 1 font available (as a separate `LWFN' file), read
- its data into memory, massage it slightly so it becomes PFB data, wrap
- it into a memory stream, load the Type 1 driver and delegate the rest
- of the work to it by calling FT_Open_Face(). (XXX TODO: after this
- has been done, the kerning data from the FOND resource should be
- appended to the face: On the Mac there are usually no AFM files
- available. However, this is tricky since we need to map Mac char
- codes to ps glyph names to glyph ID's...)
-
- - If there is a TrueType font (an `sfnt' resource), read it into memory,
- wrap it into a memory stream, load the TrueType driver and delegate
- the rest of the work to it, by calling FT_Open_Face().
-
- - Some suitcase fonts (notably Onyx) might point the `LWFN' file to
- itself, even though it doesn't contains `POST' resources. To handle
- this special case without opening the file an extra time, we just
- ignore errors from the `LWFN' and fallback to the `sfnt' if both are
- available.
- */
-
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_TRUETYPE_TAGS_H
-#include FT_INTERNAL_STREAM_H
-#include "ftbase.h"
-
- /* This is for Mac OS X. Without redefinition, OS_INLINE */
- /* expands to `static inline' which doesn't survive the */
- /* -ansi compilation flag of GCC. */
-#if !HAVE_ANSI_OS_INLINE
-#undef OS_INLINE
-#define OS_INLINE static __inline__
-#endif
-
- /* `configure' checks the availability of `ResourceIndex' strictly */
- /* and sets HAVE_TYPE_RESOURCE_INDEX 1 or 0 always. If it is */
- /* not set (e.g., a build without `configure'), the availability */
- /* is guessed from the SDK version. */
-#ifndef HAVE_TYPE_RESOURCE_INDEX
-#if !defined( MAC_OS_X_VERSION_10_5 ) || \
- ( MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 )
-#define HAVE_TYPE_RESOURCE_INDEX 0
-#else
-#define HAVE_TYPE_RESOURCE_INDEX 1
-#endif
-#endif /* !HAVE_TYPE_RESOURCE_INDEX */
-
-#if ( HAVE_TYPE_RESOURCE_INDEX == 0 )
- typedef short ResourceIndex;
-#endif
-
-#include <CoreServices/CoreServices.h>
-#include <ApplicationServices/ApplicationServices.h>
-#include <sys/syslimits.h> /* PATH_MAX */
-
- /* Don't want warnings about our own use of deprecated functions. */
-#define FT_DEPRECATED_ATTRIBUTE
-
-#include FT_MAC_H
-
-#ifndef kATSOptionFlagsUnRestrictedScope /* since Mac OS X 10.1 */
-#define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
-#endif
-
-
- /* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
- TrueType in case *both* are available (this is not common,
- but it *is* possible). */
-#ifndef PREFER_LWFN
-#define PREFER_LWFN 1
-#endif
-
-
-#ifdef FT_MACINTOSH
-
- /* This function is deprecated because FSSpec is deprecated in Mac OS X */
- FT_EXPORT_DEF( FT_Error )
- FT_GetFile_From_Mac_Name( const char* fontName,
- FSSpec* pathSpec,
- FT_Long* face_index )
- {
- FT_UNUSED( fontName );
- FT_UNUSED( pathSpec );
- FT_UNUSED( face_index );
-
- return FT_THROW( Unimplemented_Feature );
- }
-
-
- /* Private function. */
- /* The FSSpec type has been discouraged for a long time, */
- /* unfortunately an FSRef replacement API for */
- /* ATSFontGetFileSpecification() is only available in */
- /* Mac OS X 10.5 and later. */
- static OSStatus
- FT_ATSFontGetFileReference( ATSFontRef ats_font_id,
- FSRef* ats_font_ref )
- {
-#if defined( MAC_OS_X_VERSION_10_5 ) && \
- ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 )
-
- OSStatus err;
-
- err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
-
- return err;
-#elif __LP64__ /* No 64bit Carbon API on legacy platforms */
- FT_UNUSED( ats_font_id );
- FT_UNUSED( ats_font_ref );
-
-
- return fnfErr;
-#else /* 32bit Carbon API on legacy platforms */
- OSStatus err;
- FSSpec spec;
-
-
- err = ATSFontGetFileSpecification( ats_font_id, &spec );
- if ( noErr == err )
- err = FSpMakeFSRef( &spec, ats_font_ref );
-
- return err;
-#endif
- }
-
-
- static FT_Error
- FT_GetFileRef_From_Mac_ATS_Name( const char* fontName,
- FSRef* ats_font_ref,
- FT_Long* face_index )
- {
- CFStringRef cf_fontName;
- ATSFontRef ats_font_id;
-
-
- *face_index = 0;
-
- cf_fontName = CFStringCreateWithCString( NULL, fontName,
- kCFStringEncodingMacRoman );
- ats_font_id = ATSFontFindFromName( cf_fontName,
- kATSOptionFlagsUnRestrictedScope );
- CFRelease( cf_fontName );
-
- if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
- return FT_THROW( Unknown_File_Format );
-
- if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
- return FT_THROW( Unknown_File_Format );
-
- /* face_index calculation by searching preceding fontIDs */
- /* with same FSRef */
- {
- ATSFontRef id2 = ats_font_id - 1;
- FSRef ref2;
-
-
- while ( id2 > 0 )
- {
- if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
- break;
- if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
- break;
-
- id2 --;
- }
- *face_index = ats_font_id - ( id2 + 1 );
- }
-
- return FT_Err_Ok;
- }
-
-
- FT_EXPORT_DEF( FT_Error )
- FT_GetFilePath_From_Mac_ATS_Name( const char* fontName,
- UInt8* path,
- UInt32 maxPathSize,
- FT_Long* face_index )
- {
- FSRef ref;
- FT_Error err;
-
-
- if ( !fontName || !face_index )
- return FT_THROW( Invalid_Argument) ;
-
- err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
- if ( err )
- return err;
-
- if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
- return FT_THROW( Unknown_File_Format );
-
- return FT_Err_Ok;
- }
-
-
- /* This function is deprecated because FSSpec is deprecated in Mac OS X */
- FT_EXPORT_DEF( FT_Error )
- FT_GetFile_From_Mac_ATS_Name( const char* fontName,
- FSSpec* pathSpec,
- FT_Long* face_index )
- {
-#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
- ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
- FT_UNUSED( fontName );
- FT_UNUSED( pathSpec );
- FT_UNUSED( face_index );
-
- return FT_THROW( Unimplemented_Feature );
-#else
- FSRef ref;
- FT_Error err;
-
-
- if ( !fontName || !face_index )
- return FT_THROW( Invalid_Argument );
-
- err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
- if ( err )
- return err;
-
- if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
- pathSpec, NULL ) )
- return FT_THROW( Unknown_File_Format );
-
- return FT_Err_Ok;
-#endif
- }
-
-
- static OSErr
- FT_FSPathMakeRes( const UInt8* pathname,
- ResFileRefNum* res )
- {
- OSErr err;
- FSRef ref;
-
-
- if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
- return FT_THROW( Cannot_Open_Resource );
-
- /* at present, no support for dfont format */
- err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res );
- if ( noErr == err )
- return err;
-
- /* fallback to original resource-fork font */
- *res = FSOpenResFile( &ref, fsRdPerm );
- err = ResError();
-
- return err;
- }
-
-
- /* Return the file type for given pathname */
- static OSType
- get_file_type_from_path( const UInt8* pathname )
- {
- FSRef ref;
- FSCatalogInfo info;
-
-
- if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
- return ( OSType ) 0;
-
- if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoFinderInfo, &info,
- NULL, NULL, NULL ) )
- return ( OSType ) 0;
-
- return ((FInfo *)(info.finderInfo))->fdType;
- }
-
-
- /* Given a PostScript font name, create the Macintosh LWFN file name. */
- static void
- create_lwfn_name( char* ps_name,
- Str255 lwfn_file_name )
- {
- int max = 5, count = 0;
- FT_Byte* p = lwfn_file_name;
- FT_Byte* q = (FT_Byte*)ps_name;
-
-
- lwfn_file_name[0] = 0;
-
- while ( *q )
- {
- if ( ft_isupper( *q ) )
- {
- if ( count )
- max = 3;
- count = 0;
- }
- if ( count < max && ( ft_isalnum( *q ) || *q == '_' ) )
- {
- *++p = *q;
- lwfn_file_name[0]++;
- count++;
- }
- q++;
- }
- }
-
-
- static short
- count_faces_sfnt( char* fond_data )
- {
- /* The count is 1 greater than the value in the FOND. */
- /* Isn't that cute? :-) */
-
- return EndianS16_BtoN( *( (short*)( fond_data +
- sizeof ( FamRec ) ) ) ) + 1;
- }
-
-
- static short
- count_faces_scalable( char* fond_data )
- {
- AsscEntry* assoc;
- short i, face, face_all;
-
-
- face_all = EndianS16_BtoN( *( (short *)( fond_data +
- sizeof ( FamRec ) ) ) ) + 1;
- assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
- face = 0;
-
- for ( i = 0; i < face_all; i++ )
- {
- if ( 0 == EndianS16_BtoN( assoc[i].fontSize ) )
- face++;
- }
- return face;
- }
-
-
- /* Look inside the FOND data, answer whether there should be an SFNT
- resource, and answer the name of a possible LWFN Type 1 file.
-
- Thanks to Paul Miller (paulm@profoundeffects.com) for the fix
- to load a face OTHER than the first one in the FOND!
- */
-
-
- static void
- parse_fond( char* fond_data,
- short* have_sfnt,
- ResID* sfnt_id,
- Str255 lwfn_file_name,
- short face_index )
- {
- AsscEntry* assoc;
- AsscEntry* base_assoc;
- FamRec* fond;
-
-
- *sfnt_id = 0;
- *have_sfnt = 0;
- lwfn_file_name[0] = 0;
-
- fond = (FamRec*)fond_data;
- assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
- base_assoc = assoc;
-
- /* the maximum faces in a FOND is 48, size of StyleTable.indexes[] */
- if ( 47 < face_index )
- return;
-
- /* Let's do a little range checking before we get too excited here */
- if ( face_index < count_faces_sfnt( fond_data ) )
- {
- assoc += face_index; /* add on the face_index! */
-
- /* if the face at this index is not scalable,
- fall back to the first one (old behavior) */
- if ( EndianS16_BtoN( assoc->fontSize ) == 0 )
- {
- *have_sfnt = 1;
- *sfnt_id = EndianS16_BtoN( assoc->fontID );
- }
- else if ( base_assoc->fontSize == 0 )
- {
- *have_sfnt = 1;
- *sfnt_id = EndianS16_BtoN( base_assoc->fontID );
- }
- }
-
- if ( EndianS32_BtoN( fond->ffStylOff ) )
- {
- unsigned char* p = (unsigned char*)fond_data;
- StyleTable* style;
- unsigned short string_count;
- char ps_name[256];
- unsigned char* names[64];
- int i;
-
-
- p += EndianS32_BtoN( fond->ffStylOff );
- style = (StyleTable*)p;
- p += sizeof ( StyleTable );
- string_count = EndianS16_BtoN( *(short*)(p) );
- string_count = FT_MIN( 64, string_count );
- p += sizeof ( short );
-
- for ( i = 0; i < string_count; i++ )
- {
- names[i] = p;
- p += names[i][0];
- p++;
- }
-
- {
- size_t ps_name_len = (size_t)names[0][0];
-
-
- if ( ps_name_len != 0 )
- {
- ft_memcpy(ps_name, names[0] + 1, ps_name_len);
- ps_name[ps_name_len] = 0;
- }
- if ( style->indexes[face_index] > 1 &&
- style->indexes[face_index] <= string_count )
- {
- unsigned char* suffixes = names[style->indexes[face_index] - 1];
-
-
- for ( i = 1; i <= suffixes[0]; i++ )
- {
- unsigned char* s;
- size_t j = suffixes[i] - 1;
-
-
- if ( j < string_count && ( s = names[j] ) != NULL )
- {
- size_t s_len = (size_t)s[0];
-
-
- if ( s_len != 0 && ps_name_len + s_len < sizeof ( ps_name ) )
- {
- ft_memcpy( ps_name + ps_name_len, s + 1, s_len );
- ps_name_len += s_len;
- ps_name[ps_name_len] = 0;
- }
- }
- }
- }
- }
-
- create_lwfn_name( ps_name, lwfn_file_name );
- }
- }
-
-
- static FT_Error
- lookup_lwfn_by_fond( const UInt8* path_fond,
- ConstStr255Param base_lwfn,
- UInt8* path_lwfn,
- size_t path_size )
- {
- FSRef ref, par_ref;
- size_t dirname_len;
-
-
- /* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
- /* We should not extract parent directory by string manipulation. */
-
- if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
- return FT_THROW( Invalid_Argument );
-
- if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
- NULL, NULL, NULL, &par_ref ) )
- return FT_THROW( Invalid_Argument );
-
- if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
- return FT_THROW( Invalid_Argument );
-
- if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
- return FT_THROW( Invalid_Argument );
-
- /* now we have absolute dirname in path_lwfn */
- ft_strcat( (char *)path_lwfn, "/" );
- dirname_len = ft_strlen( (char *)path_lwfn );
- ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 );
- path_lwfn[dirname_len + base_lwfn[0]] = '\0';
-
- if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
- return FT_THROW( Cannot_Open_Resource );
-
- if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
- NULL, NULL, NULL, NULL ) )
- return FT_THROW( Cannot_Open_Resource );
-
- return FT_Err_Ok;
- }
-
-
- static short
- count_faces( Handle fond,
- const UInt8* pathname )
- {
- ResID sfnt_id;
- short have_sfnt, have_lwfn;
- Str255 lwfn_file_name;
- UInt8 buff[PATH_MAX];
- FT_Error err;
- short num_faces;
-
-
- have_sfnt = have_lwfn = 0;
-
- parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, 0 );
-
- if ( lwfn_file_name[0] )
- {
- err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
- buff, sizeof ( buff ) );
- if ( !err )
- have_lwfn = 1;
- }
-
- if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
- num_faces = 1;
- else
- num_faces = count_faces_scalable( *fond );
-
- return num_faces;
- }
-
-
- /* Read Type 1 data from the POST resources inside the LWFN file,
- return a PFB buffer. This is somewhat convoluted because the FT2
- PFB parser wants the ASCII header as one chunk, and the LWFN
- chunks are often not organized that way, so we glue chunks
- of the same type together. */
- static FT_Error
- read_lwfn( FT_Memory memory,
- ResFileRefNum res,
- FT_Byte** pfb_data,
- FT_ULong* size )
- {
- FT_Error error = FT_Err_Ok;
- ResID res_id;
- unsigned char *buffer, *p, *size_p = NULL;
- FT_ULong total_size = 0;
- FT_ULong old_total_size = 0;
- FT_ULong post_size, pfb_chunk_size;
- Handle post_data;
- char code, last_code;
-
-
- UseResFile( res );
-
- /* First pass: load all POST resources, and determine the size of */
- /* the output buffer. */
- res_id = 501;
- last_code = -1;
-
- for (;;)
- {
- post_data = Get1Resource( TTAG_POST, res_id++ );
- if ( post_data == NULL )
- break; /* we are done */
-
- code = (*post_data)[0];
-
- if ( code != last_code )
- {
- if ( code == 5 )
- total_size += 2; /* just the end code */
- else
- total_size += 6; /* code + 4 bytes chunk length */
- }
-
- total_size += (FT_ULong)GetHandleSize( post_data ) - 2;
- last_code = code;
-
- /* detect resource fork overflow */
- if ( FT_MAC_RFORK_MAX_LEN < total_size )
- {
- error = FT_THROW( Array_Too_Large );
- goto Error;
- }
-
- old_total_size = total_size;
- }
-
- if ( FT_ALLOC( buffer, (FT_Long)total_size ) )
- goto Error;
-
- /* Second pass: append all POST data to the buffer, add PFB fields. */
- /* Glue all consecutive chunks of the same type together. */
- p = buffer;
- res_id = 501;
- last_code = -1;
- pfb_chunk_size = 0;
-
- for (;;)
- {
- post_data = Get1Resource( TTAG_POST, res_id++ );
- if ( post_data == NULL )
- break; /* we are done */
-
- post_size = (FT_ULong)GetHandleSize( post_data ) - 2;
- code = (*post_data)[0];
-
- if ( code != last_code )
- {
- if ( last_code != -1 )
- {
- /* we are done adding a chunk, fill in the size field */
- if ( size_p != NULL )
- {
- *size_p++ = (FT_Byte)( pfb_chunk_size & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8 ) & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 16 ) & 0xFF );
- *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 24 ) & 0xFF );
- }
- pfb_chunk_size = 0;
- }
-
- *p++ = 0x80;
- if ( code == 5 )
- *p++ = 0x03; /* the end */
- else if ( code == 2 )
- *p++ = 0x02; /* binary segment */
- else
- *p++ = 0x01; /* ASCII segment */
-
- if ( code != 5 )
- {
- size_p = p; /* save for later */
- p += 4; /* make space for size field */
- }
- }
-
- ft_memcpy( p, *post_data + 2, post_size );
- pfb_chunk_size += post_size;
- p += post_size;
- last_code = code;
- }
-
- *pfb_data = buffer;
- *size = total_size;
-
- Error:
- CloseResFile( res );
- return error;
- }
-
-
- /* Create a new FT_Face from a file path to an LWFN file. */
- static FT_Error
- FT_New_Face_From_LWFN( FT_Library library,
- const UInt8* pathname,
- FT_Long face_index,
- FT_Face* aface )
- {
- FT_Byte* pfb_data;
- FT_ULong pfb_size;
- FT_Error error;
- ResFileRefNum res;
-
-
- if ( noErr != FT_FSPathMakeRes( pathname, &res ) )
- return FT_THROW( Cannot_Open_Resource );
-
- pfb_data = NULL;
- pfb_size = 0;
- error = read_lwfn( library->memory, res, &pfb_data, &pfb_size );
- CloseResFile( res ); /* PFB is already loaded, useless anymore */
- if ( error )
- return error;
-
- return open_face_from_buffer( library,
- pfb_data,
- pfb_size,
- face_index,
- "type1",
- aface );
- }
-
-
- /* Create a new FT_Face from an SFNT resource, specified by res ID. */
- static FT_Error
- FT_New_Face_From_SFNT( FT_Library library,
- ResID sfnt_id,
- FT_Long face_index,
- FT_Face* aface )
- {
- Handle sfnt = NULL;
- FT_Byte* sfnt_data;
- size_t sfnt_size;
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = library->memory;
- int is_cff, is_sfnt_ps;
-
-
- sfnt = GetResource( TTAG_sfnt, sfnt_id );
- if ( sfnt == NULL )
- return FT_THROW( Invalid_Handle );
-
- sfnt_size = (FT_ULong)GetHandleSize( sfnt );
-
- /* detect resource fork overflow */
- if ( FT_MAC_RFORK_MAX_LEN < sfnt_size )
- return FT_THROW( Array_Too_Large );
-
- if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
- {
- ReleaseResource( sfnt );
- return error;
- }
-
- ft_memcpy( sfnt_data, *sfnt, sfnt_size );
- ReleaseResource( sfnt );
-
- is_cff = sfnt_size > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
- is_sfnt_ps = sfnt_size > 4 && !ft_memcmp( sfnt_data, "typ1", 4 );
-
- if ( is_sfnt_ps )
- {
- FT_Stream stream;
-
-
- if ( FT_NEW( stream ) )
- goto Try_OpenType;
-
- FT_Stream_OpenMemory( stream, sfnt_data, sfnt_size );
- if ( !open_face_PS_from_sfnt_stream( library,
- stream,
- face_index,
- 0, NULL,
- aface ) )
- {
- FT_Stream_Close( stream );
- FT_FREE( stream );
- FT_FREE( sfnt_data );
- goto Exit;
- }
-
- FT_FREE( stream );
- }
- Try_OpenType:
- error = open_face_from_buffer( library,
- sfnt_data,
- sfnt_size,
- face_index,
- is_cff ? "cff" : "truetype",
- aface );
- Exit:
- return error;
- }
-
-
- /* Create a new FT_Face from a file path to a suitcase file. */
- static FT_Error
- FT_New_Face_From_Suitcase( FT_Library library,
- const UInt8* pathname,
- FT_Long face_index,
- FT_Face* aface )
- {
- FT_Error error = FT_ERR( Cannot_Open_Resource );
- ResFileRefNum res_ref;
- ResourceIndex res_index;
- Handle fond;
- short num_faces_in_res;
-
-
- if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
- return FT_THROW( Cannot_Open_Resource );
-
- UseResFile( res_ref );
- if ( ResError() )
- return FT_THROW( Cannot_Open_Resource );
-
- num_faces_in_res = 0;
- for ( res_index = 1; ; ++res_index )
- {
- short num_faces_in_fond;
-
-
- fond = Get1IndResource( TTAG_FOND, res_index );
- if ( ResError() )
- break;
-
- num_faces_in_fond = count_faces( fond, pathname );
- num_faces_in_res += num_faces_in_fond;
-
- if ( 0 <= face_index && face_index < num_faces_in_fond && error )
- error = FT_New_Face_From_FOND( library, fond, face_index, aface );
-
- face_index -= num_faces_in_fond;
- }
-
- CloseResFile( res_ref );
- if ( !error && aface && *aface )
- (*aface)->num_faces = num_faces_in_res;
- return error;
- }
-
-
- /* documentation is in ftmac.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face_From_FOND( FT_Library library,
- Handle fond,
- FT_Long face_index,
- FT_Face* aface )
- {
- short have_sfnt, have_lwfn = 0;
- ResID sfnt_id, fond_id;
- OSType fond_type;
- Str255 fond_name;
- Str255 lwfn_file_name;
- UInt8 path_lwfn[PATH_MAX];
- OSErr err;
- FT_Error error = FT_Err_Ok;
-
-
- /* check of `library' and `aface' delayed to `FT_New_Face_From_XXX' */
-
- GetResInfo( fond, &fond_id, &fond_type, fond_name );
- if ( ResError() != noErr || fond_type != TTAG_FOND )
- return FT_THROW( Invalid_File_Format );
-
- parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
-
- if ( lwfn_file_name[0] )
- {
- ResFileRefNum res;
-
-
- res = HomeResFile( fond );
- if ( noErr != ResError() )
- goto found_no_lwfn_file;
-
- {
- UInt8 path_fond[PATH_MAX];
- FSRef ref;
-
-
- err = FSGetForkCBInfo( res, kFSInvalidVolumeRefNum,
- NULL, NULL, NULL, &ref, NULL );
- if ( noErr != err )
- goto found_no_lwfn_file;
-
- err = FSRefMakePath( &ref, path_fond, sizeof ( path_fond ) );
- if ( noErr != err )
- goto found_no_lwfn_file;
-
- error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
- path_lwfn, sizeof ( path_lwfn ) );
- if ( !error )
- have_lwfn = 1;
- }
- }
-
- if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
- error = FT_New_Face_From_LWFN( library,
- path_lwfn,
- face_index,
- aface );
- else
- error = FT_THROW( Unknown_File_Format );
-
- found_no_lwfn_file:
- if ( have_sfnt && error )
- error = FT_New_Face_From_SFNT( library,
- sfnt_id,
- face_index,
- aface );
-
- return error;
- }
-
-
- /* Common function to load a new FT_Face from a resource file. */
- static FT_Error
- FT_New_Face_From_Resource( FT_Library library,
- const UInt8* pathname,
- FT_Long face_index,
- FT_Face* aface )
- {
- OSType file_type;
- FT_Error error;
-
-
- /* LWFN is a (very) specific file format, check for it explicitly */
- file_type = get_file_type_from_path( pathname );
- if ( file_type == TTAG_LWFN )
- return FT_New_Face_From_LWFN( library, pathname, face_index, aface );
-
- /* Otherwise the file type doesn't matter (there are more than */
- /* `FFIL' and `tfil'). Just try opening it as a font suitcase; */
- /* if it works, fine. */
-
- error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface );
- if ( error == 0 )
- return error;
-
- /* let it fall through to normal loader (.ttf, .otf, etc.); */
- /* we signal this by returning no error and no FT_Face */
- *aface = NULL;
- return 0;
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_New_Face */
- /* */
- /* <Description> */
- /* This is the Mac-specific implementation of FT_New_Face. In */
- /* addition to the standard FT_New_Face() functionality, it also */
- /* accepts pathnames to Mac suitcase files. For further */
- /* documentation see the original FT_New_Face() in freetype.h. */
- /* */
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face( FT_Library library,
- const char* pathname,
- FT_Long face_index,
- FT_Face* aface )
- {
- FT_Open_Args args;
- FT_Error error;
-
-
- /* test for valid `library' and `aface' delayed to FT_Open_Face() */
- if ( !pathname )
- return FT_THROW( Invalid_Argument );
-
- *aface = NULL;
-
- /* try resourcefork based font: LWFN, FFIL */
- error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
- face_index, aface );
- if ( error != 0 || *aface != NULL )
- return error;
-
- /* let it fall through to normal loader (.ttf, .otf, etc.) */
- args.flags = FT_OPEN_PATHNAME;
- args.pathname = (char*)pathname;
- return FT_Open_Face( library, &args, face_index, aface );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_New_Face_From_FSRef */
- /* */
- /* <Description> */
- /* FT_New_Face_From_FSRef is identical to FT_New_Face except it */
- /* accepts an FSRef instead of a path. */
- /* */
- /* This function is deprecated because Carbon data types (FSRef) */
- /* are not cross-platform, and thus not suitable for the freetype API. */
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face_From_FSRef( FT_Library library,
- const FSRef* ref,
- FT_Long face_index,
- FT_Face* aface )
- {
- FT_Error error;
- FT_Open_Args args;
-
- OSErr err;
- UInt8 pathname[PATH_MAX];
-
-
- /* check of `library' and `aface' delayed to */
- /* `FT_New_Face_From_Resource' */
-
- if ( !ref )
- return FT_THROW( Invalid_Argument );
-
- err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
- if ( err )
- error = FT_THROW( Cannot_Open_Resource );
-
- error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
- if ( error != 0 || *aface != NULL )
- return error;
-
- /* fallback to datafork font */
- args.flags = FT_OPEN_PATHNAME;
- args.pathname = (char*)pathname;
- return FT_Open_Face( library, &args, face_index, aface );
- }
-
-
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_New_Face_From_FSSpec */
- /* */
- /* <Description> */
- /* FT_New_Face_From_FSSpec is identical to FT_New_Face except it */
- /* accepts an FSSpec instead of a path. */
- /* */
- /* This function is deprecated because FSSpec is deprecated in Mac OS X */
- FT_EXPORT_DEF( FT_Error )
- FT_New_Face_From_FSSpec( FT_Library library,
- const FSSpec* spec,
- FT_Long face_index,
- FT_Face* aface )
- {
-#if ( __LP64__ ) || ( defined( MAC_OS_X_VERSION_10_5 ) && \
- ( MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 ) )
- FT_UNUSED( library );
- FT_UNUSED( spec );
- FT_UNUSED( face_index );
- FT_UNUSED( aface );
-
- return FT_THROW( Unimplemented_Feature );
-#else
- FSRef ref;
-
-
- /* check of `library' and `aface' delayed to `FT_New_Face_From_FSRef' */
-
- if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
- return FT_THROW( Invalid_Argument );
- else
- return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
-#endif
- }
-
-#endif /* FT_MACINTOSH */
-
-
-/* END */
diff --git a/src/base/ftmm.c b/src/base/ftmm.c
index 7c012aa..6b759ca 100644
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -4,7 +4,7 @@
/* */
/* Multiple Master font support (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 96572bd..9006b59 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType private base classes (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -688,7 +688,6 @@
/* both `fpgm' and `prep' tables are missing */
if ( ( mode == FT_RENDER_MODE_LIGHT &&
!FT_DRIVER_HINTS_LIGHTLY( driver ) ) ||
- face->internal->ignore_unpatented_hinter ||
( FT_IS_SFNT( face ) &&
ttface->num_locations &&
ttface->max_profile.maxSizeOfInstructions == 0 &&
@@ -1419,7 +1418,7 @@
/* Type 1 and CID-keyed font drivers should recognize sfnt-wrapped */
/* format too. Here, since we can't expect that the TrueType font */
- /* driver is loaded unconditially, we must parse the font by */
+ /* driver is loaded unconditionally, we must parse the font by */
/* ourselves. We are only interested in the name of the table and */
/* the offset. */
@@ -1484,6 +1483,7 @@
if ( face_index >= 0 && pstable_index == face_index )
return FT_Err_Ok;
}
+
return FT_THROW( Table_Missing );
}
@@ -1521,6 +1521,19 @@
if ( error )
goto Exit;
+ if ( offset > stream->size )
+ {
+ FT_TRACE2(( "open_face_PS_from_sfnt_stream: invalid table offset\n" ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+ else if ( length > stream->size - offset )
+ {
+ FT_TRACE2(( "open_face_PS_from_sfnt_stream: invalid table length\n" ));
+ error = FT_THROW( Invalid_Table );
+ goto Exit;
+ }
+
error = FT_Stream_Seek( stream, pos + offset );
if ( error )
goto Exit;
@@ -1529,7 +1542,8 @@
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length );
- if ( error ) {
+ if ( error )
+ {
FT_FREE( sfnt_ps );
goto Exit;
}
@@ -1777,8 +1791,8 @@
FT_Long face_index_in_resource = 0;
- if ( face_index == -1 )
- face_index = 0;
+ if ( face_index < 0 )
+ face_index = -face_index - 1;
if ( face_index >= resource_cnt )
return FT_THROW( Cannot_Open_Resource );
@@ -2300,11 +2314,24 @@
if ( bsize->height < 0 )
- bsize->height = (FT_Short)-bsize->height;
+ bsize->height = -bsize->height;
if ( bsize->x_ppem < 0 )
- bsize->x_ppem = (FT_Short)-bsize->x_ppem;
+ bsize->x_ppem = -bsize->x_ppem;
if ( bsize->y_ppem < 0 )
bsize->y_ppem = -bsize->y_ppem;
+
+ /* check whether negation actually has worked */
+ if ( bsize->height < 0 || bsize->x_ppem < 0 || bsize->y_ppem < 0 )
+ {
+ FT_TRACE0(( "FT_Open_Face:"
+ " Invalid bitmap dimensions for stroke %d,"
+ " now disabled\n", i ));
+ bsize->width = 0;
+ bsize->height = 0;
+ bsize->size = 0;
+ bsize->x_ppem = 0;
+ bsize->y_ppem = 0;
+ }
}
}
@@ -2604,6 +2631,9 @@
w = FT_PIX_ROUND( w );
h = FT_PIX_ROUND( h );
+ if ( !w || !h )
+ return FT_THROW( Invalid_Pixel_Size );
+
for ( i = 0; i < face->num_fixed_sizes; i++ )
{
FT_Bitmap_Size* bsize = face->available_sizes + i;
@@ -2623,6 +2653,8 @@
}
}
+ FT_TRACE3(( "FT_Match_Size: no matching bitmap strike\n" ));
+
return FT_THROW( Invalid_Pixel_Size );
}
@@ -4202,7 +4234,8 @@
MD5_Init( &ctx );
- MD5_Update( &ctx, bitmap.buffer, rows * pitch );
+ if ( bitmap.buffer )
+ MD5_Update( &ctx, bitmap.buffer, rows * pitch );
MD5_Final( md5, &ctx );
FT_TRACE3(( "MD5 checksum for %dx%d bitmap:\n"
@@ -4308,7 +4341,7 @@
{
FT_Error error;
FT_Memory memory;
- FT_Module module;
+ FT_Module module = NULL;
FT_UInt nn;
@@ -4549,7 +4582,8 @@
const FT_String* module_name,
const FT_String* property_name,
void* value,
- FT_Bool set )
+ FT_Bool set,
+ FT_Bool value_is_string )
{
FT_Module* cur;
FT_Module* limit;
@@ -4619,8 +4653,13 @@
return FT_THROW( Unimplemented_Feature );
}
- return set ? service->set_property( cur[0], property_name, value )
- : service->get_property( cur[0], property_name, value );
+ return set ? service->set_property( cur[0],
+ property_name,
+ value,
+ value_is_string )
+ : service->get_property( cur[0],
+ property_name,
+ value );
}
@@ -4636,7 +4675,8 @@
module_name,
property_name,
(void*)value,
- TRUE );
+ TRUE,
+ FALSE );
}
@@ -4652,10 +4692,33 @@
module_name,
property_name,
value,
+ FALSE,
FALSE );
}
+#ifdef FT_CONFIG_OPTION_ENVIRONMENT_PROPERTIES
+
+ /* this variant is used for handling the FREETYPE_PROPERTIES */
+ /* environment variable */
+
+ FT_BASE_DEF( FT_Error )
+ ft_property_string_set( FT_Library library,
+ const FT_String* module_name,
+ const FT_String* property_name,
+ FT_String* value )
+ {
+ return ft_property_do( library,
+ module_name,
+ property_name,
+ (void*)value,
+ TRUE,
+ TRUE );
+ }
+
+#endif
+
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
diff --git a/src/base/ftotval.c b/src/base/ftotval.c
deleted file mode 100644
index 786457b..0000000
--- a/src/base/ftotval.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftotval.c */
-/* */
-/* FreeType API for validating OpenType tables (body). */
-/* */
-/* Copyright 2004-2015 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_INTERNAL_DEBUG_H
-
-#include FT_INTERNAL_OBJECTS_H
-#include FT_SERVICE_OPENTYPE_VALIDATE_H
-#include FT_OPENTYPE_VALIDATE_H
-
-
- /* documentation is in ftotval.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_OpenType_Validate( FT_Face face,
- FT_UInt validation_flags,
- FT_Bytes *BASE_table,
- FT_Bytes *GDEF_table,
- FT_Bytes *GPOS_table,
- FT_Bytes *GSUB_table,
- FT_Bytes *JSTF_table )
- {
- FT_Service_OTvalidate service;
- FT_Error error;
-
-
- if ( !face )
- {
- error = FT_THROW( Invalid_Face_Handle );
- goto Exit;
- }
-
- if ( !( BASE_table &&
- GDEF_table &&
- GPOS_table &&
- GSUB_table &&
- JSTF_table ) )
- {
- error = FT_THROW( Invalid_Argument );
- goto Exit;
- }
-
- FT_FACE_FIND_GLOBAL_SERVICE( face, service, OPENTYPE_VALIDATE );
-
- if ( service )
- error = service->validate( face,
- validation_flags,
- BASE_table,
- GDEF_table,
- GPOS_table,
- GSUB_table,
- JSTF_table );
- else
- error = FT_THROW( Unimplemented_Feature );
-
- Exit:
- return error;
- }
-
-
- FT_EXPORT_DEF( void )
- FT_OpenType_Free( FT_Face face,
- FT_Bytes table )
- {
- FT_Memory memory;
-
-
- if ( !face )
- return;
-
- memory = FT_FACE_MEMORY( face );
-
- FT_FREE( table );
- }
-
-
-/* END */
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 201ceab..fc28225 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -4,7 +4,7 @@
/* */
/* FreeType outline management (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -42,7 +42,7 @@
static
- const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
+ const FT_Outline null_outline = { 0, 0, NULL, NULL, NULL, 0 };
/* documentation is in ftoutln.h */
@@ -415,11 +415,14 @@
if ( source == target )
return FT_Err_Ok;
- FT_ARRAY_COPY( target->points, source->points, source->n_points );
-
- FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
+ if ( source->n_points )
+ {
+ FT_ARRAY_COPY( target->points, source->points, source->n_points );
+ FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
+ }
- FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
+ if ( source->n_contours )
+ FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
/* copy all flags, except the `FT_OUTLINE_OWNER' one */
is_owner = target->flags & FT_OUTLINE_OWNER;
diff --git a/src/base/ftpatent.c b/src/base/ftpatent.c
index bf2b085..4861be1 100644
--- a/src/base/ftpatent.c
+++ b/src/base/ftpatent.c
@@ -3,9 +3,9 @@
/* ftpatent.c */
/* */
/* FreeType API for checking patented TrueType bytecode instructions */
-/* (body). */
+/* (body). Obsolete, retained for backwards compatibility. */
/* */
-/* Copyright 2007-2015 by */
+/* Copyright 2007-2016 by */
/* David Turner. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -25,238 +25,14 @@
#include FT_SERVICE_TRUETYPE_GLYF_H
- static FT_Bool
- _tt_check_patents_in_range( FT_Stream stream,
- FT_ULong size )
- {
- FT_Bool result = FALSE;
- FT_Error error;
- FT_Bytes p, end;
-
-
- if ( FT_FRAME_ENTER( size ) )
- return 0;
-
- p = stream->cursor;
- end = p + size;
-
- while ( p < end )
- {
- switch (p[0])
- {
- case 0x06: /* SPvTL // */
- case 0x07: /* SPvTL + */
- case 0x08: /* SFvTL // */
- case 0x09: /* SFvTL + */
- case 0x0A: /* SPvFS */
- case 0x0B: /* SFvFS */
- result = TRUE;
- goto Exit;
-
- case 0x40:
- if ( p + 1 >= end )
- goto Exit;
-
- p += p[1] + 2;
- break;
-
- case 0x41:
- if ( p + 1 >= end )
- goto Exit;
-
- p += p[1] * 2 + 2;
- break;
-
- case 0x71: /* DELTAP2 */
- case 0x72: /* DELTAP3 */
- case 0x73: /* DELTAC0 */
- case 0x74: /* DELTAC1 */
- case 0x75: /* DELTAC2 */
- result = TRUE;
- goto Exit;
-
- case 0xB0:
- case 0xB1:
- case 0xB2:
- case 0xB3:
- case 0xB4:
- case 0xB5:
- case 0xB6:
- case 0xB7:
- p += ( p[0] - 0xB0 ) + 2;
- break;
-
- case 0xB8:
- case 0xB9:
- case 0xBA:
- case 0xBB:
- case 0xBC:
- case 0xBD:
- case 0xBE:
- case 0xBF:
- p += ( p[0] - 0xB8 ) * 2 + 3;
- break;
-
- default:
- p += 1;
- break;
- }
- }
-
- Exit:
- FT_UNUSED( error );
- FT_FRAME_EXIT();
- return result;
- }
-
-
- static FT_Bool
- _tt_check_patents_in_table( FT_Face face,
- FT_ULong tag )
- {
- FT_Stream stream = face->stream;
- FT_Error error = FT_Err_Ok;
- FT_Service_SFNT_Table service;
- FT_Bool result = FALSE;
-
-
- FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
-
- if ( service )
- {
- FT_UInt i = 0;
- FT_ULong tag_i = 0, offset_i = 0, length_i = 0;
-
-
- for ( i = 0; !error && tag_i != tag ; i++ )
- error = service->table_info( face, i,
- &tag_i, &offset_i, &length_i );
-
- if ( error ||
- FT_STREAM_SEEK( offset_i ) )
- goto Exit;
-
- result = _tt_check_patents_in_range( stream, length_i );
- }
-
- Exit:
- return result;
- }
-
-
- static FT_Bool
- _tt_face_check_patents( FT_Face face )
- {
- FT_Stream stream = face->stream;
- FT_UInt gindex;
- FT_Error error;
- FT_Bool result;
-
- FT_Service_TTGlyf service;
-
-
- result = _tt_check_patents_in_table( face, TTAG_fpgm );
- if ( result )
- goto Exit;
-
- result = _tt_check_patents_in_table( face, TTAG_prep );
- if ( result )
- goto Exit;
-
- FT_FACE_FIND_SERVICE( face, service, TT_GLYF );
- if ( service == NULL )
- goto Exit;
-
- for ( gindex = 0; gindex < (FT_UInt)face->num_glyphs; gindex++ )
- {
- FT_ULong offset, num_ins, size;
- FT_Int num_contours;
-
-
- offset = service->get_location( face, gindex, &size );
- if ( size == 0 )
- continue;
-
- if ( FT_STREAM_SEEK( offset ) ||
- FT_READ_SHORT( num_contours ) )
- continue;
-
- if ( num_contours >= 0 ) /* simple glyph */
- {
- if ( FT_STREAM_SKIP( 8 + num_contours * 2 ) )
- continue;
- }
- else /* compound glyph */
- {
- FT_Bool has_instr = 0;
-
-
- if ( FT_STREAM_SKIP( 8 ) )
- continue;
-
- /* now read each component */
- for (;;)
- {
- FT_UInt flags, toskip;
-
-
- if( FT_READ_USHORT( flags ) )
- break;
-
- toskip = 2 + 1 + 1;
-
- if ( ( flags & ( 1 << 0 ) ) != 0 ) /* ARGS_ARE_WORDS */
- toskip += 2;
-
- if ( ( flags & ( 1 << 3 ) ) != 0 ) /* WE_HAVE_A_SCALE */
- toskip += 2;
- else if ( ( flags & ( 1 << 6 ) ) != 0 ) /* WE_HAVE_X_Y_SCALE */
- toskip += 4;
- else if ( ( flags & ( 1 << 7 ) ) != 0 ) /* WE_HAVE_A_2x2 */
- toskip += 8;
-
- if ( ( flags & ( 1 << 8 ) ) != 0 ) /* WE_HAVE_INSTRUCTIONS */
- has_instr = 1;
-
- if ( FT_STREAM_SKIP( toskip ) )
- goto NextGlyph;
-
- if ( ( flags & ( 1 << 5 ) ) == 0 ) /* MORE_COMPONENTS */
- break;
- }
-
- if ( !has_instr )
- goto NextGlyph;
- }
-
- if ( FT_READ_USHORT( num_ins ) )
- continue;
-
- result = _tt_check_patents_in_range( stream, num_ins );
- if ( result )
- goto Exit;
-
- NextGlyph:
- ;
- }
-
- Exit:
- return result;
- }
-
-
/* documentation is in freetype.h */
FT_EXPORT_DEF( FT_Bool )
FT_Face_CheckTrueTypePatents( FT_Face face )
{
- FT_Bool result = FALSE;
-
-
- if ( face && FT_IS_SFNT( face ) )
- result = _tt_face_check_patents( face );
+ FT_UNUSED( face );
- return result;
+ return FALSE;
}
@@ -266,22 +42,10 @@
FT_Face_SetUnpatentedHinting( FT_Face face,
FT_Bool value )
{
- FT_Bool result = FALSE;
-
-
-#if defined( TT_CONFIG_OPTION_UNPATENTED_HINTING ) && \
- !defined( TT_CONFIG_OPTION_BYTECODE_INTERPRETER )
- if ( face && FT_IS_SFNT( face ) )
- {
- result = !face->internal->ignore_unpatented_hinter;
- face->internal->ignore_unpatented_hinter = !value;
- }
-#else
FT_UNUSED( face );
FT_UNUSED( value );
-#endif
- return result;
+ return FALSE;
}
/* END */
diff --git a/src/base/ftpfr.c b/src/base/ftpfr.c
deleted file mode 100644
index 39f089e..0000000
--- a/src/base/ftpfr.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/***************************************************************************/
-/* */
-/* ftpfr.c */
-/* */
-/* FreeType API for accessing PFR-specific data (body). */
-/* */
-/* Copyright 2002-2015 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_INTERNAL_DEBUG_H
-
-#include FT_INTERNAL_OBJECTS_H
-#include FT_SERVICE_PFR_H
-
-
- /* check the format */
- static FT_Service_PfrMetrics
- ft_pfr_check( FT_Face face )
- {
- FT_Service_PfrMetrics service = NULL;
-
-
- if ( face )
- FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
-
- return service;
- }
-
-
- /* documentation is in ftpfr.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_PFR_Metrics( FT_Face face,
- FT_UInt *aoutline_resolution,
- FT_UInt *ametrics_resolution,
- FT_Fixed *ametrics_x_scale,
- FT_Fixed *ametrics_y_scale )
- {
- FT_Error error = FT_Err_Ok;
- FT_Service_PfrMetrics service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- service = ft_pfr_check( face );
- if ( service )
- {
- error = service->get_metrics( face,
- aoutline_resolution,
- ametrics_resolution,
- ametrics_x_scale,
- ametrics_y_scale );
- }
- else
- {
- FT_Fixed x_scale, y_scale;
-
-
- /* this is not a PFR font */
- if ( aoutline_resolution )
- *aoutline_resolution = face->units_per_EM;
-
- if ( ametrics_resolution )
- *ametrics_resolution = face->units_per_EM;
-
- x_scale = y_scale = 0x10000L;
- if ( face->size )
- {
- x_scale = face->size->metrics.x_scale;
- y_scale = face->size->metrics.y_scale;
- }
-
- if ( ametrics_x_scale )
- *ametrics_x_scale = x_scale;
-
- if ( ametrics_y_scale )
- *ametrics_y_scale = y_scale;
-
- error = FT_THROW( Unknown_File_Format );
- }
-
- return error;
- }
-
-
- /* documentation is in ftpfr.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_PFR_Kerning( FT_Face face,
- FT_UInt left,
- FT_UInt right,
- FT_Vector *avector )
- {
- FT_Error error;
- FT_Service_PfrMetrics service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !avector )
- return FT_THROW( Invalid_Argument );
-
- service = ft_pfr_check( face );
- if ( service )
- error = service->get_kerning( face, left, right, avector );
- else
- error = FT_Get_Kerning( face, left, right,
- FT_KERNING_UNSCALED, avector );
-
- return error;
- }
-
-
- /* documentation is in ftpfr.h */
-
- FT_EXPORT_DEF( FT_Error )
- FT_Get_PFR_Advance( FT_Face face,
- FT_UInt gindex,
- FT_Pos *aadvance )
- {
- FT_Error error;
- FT_Service_PfrMetrics service;
-
-
- if ( !face )
- return FT_THROW( Invalid_Face_Handle );
-
- if ( !aadvance )
- return FT_THROW( Invalid_Argument );
-
- service = ft_pfr_check( face );
- if ( service )
- error = service->get_advance( face, gindex, aadvance );
- else
- /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
- error = FT_THROW( Invalid_Argument );
-
- return error;
- }
-
-
-/* END */
diff --git a/src/base/ftpic.c b/src/base/ftpic.c
index 6c4b1cd..03769db 100644
--- a/src/base/ftpic.c
+++ b/src/base/ftpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services (body). */
/* */
-/* Copyright 2009-2015 by */
+/* Copyright 2009-2016 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c
index c30c766..4660c97 100644
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -4,7 +4,7 @@
/* */
/* Embedded resource forks accessor (body). */
/* */
-/* Copyright 2004-2015 by */
+/* Copyright 2004-2016 by */
/* Masatake YAMATO and Redhat K.K. */
/* */
/* FT_Raccess_Get_HeaderInfo() and raccess_guess_darwin_hfsplus() are */
@@ -403,7 +403,7 @@
errors[i] = FT_Err_Ok;
if ( errors[i] )
- continue ;
+ continue;
errors[i] = (FT_RACCESS_GUESS_TABLE_GET[i].func)( library,
stream, base_name,
diff --git a/src/base/ftsnames.c b/src/base/ftsnames.c
index 80304e5..ce79641 100644
--- a/src/base/ftsnames.c
+++ b/src/base/ftsnames.c
@@ -7,7 +7,7 @@
/* */
/* This is _not_ used to retrieve glyph names! */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftstream.c b/src/base/ftstream.c
index b68f3f8..bb512a7 100644
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -4,7 +4,7 @@
/* */
/* I/O stream support (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -778,7 +778,7 @@
case ft_frame_short_be:
case ft_frame_ushort_be: /* read a 2-byte big-endian short */
- value = FT_NEXT_USHORT( cursor) ;
+ value = FT_NEXT_USHORT( cursor );
sign_shift = 16;
break;
diff --git a/src/base/ftstroke.c b/src/base/ftstroke.c
index fecb3cc..4f3c493 100644
--- a/src/base/ftstroke.c
+++ b/src/base/ftstroke.c
@@ -4,7 +4,7 @@
/* */
/* FreeType path stroker (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -712,9 +712,10 @@
FT_Outline* outline )
{
/* copy point locations */
- FT_ARRAY_COPY( outline->points + outline->n_points,
- border->points,
- border->num_points );
+ if ( border->num_points )
+ FT_ARRAY_COPY( outline->points + outline->n_points,
+ border->points,
+ border->num_points );
/* copy tags */
{
diff --git a/src/base/ftsynth.c b/src/base/ftsynth.c
index cd68533..4b66a33 100644
--- a/src/base/ftsynth.c
+++ b/src/base/ftsynth.c
@@ -4,7 +4,7 @@
/* */
/* FreeType synthesizing code for emboldening and slanting (body). */
/* */
-/* Copyright 2000-2015 by */
+/* Copyright 2000-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c
index 1938fd8..ac1f01c 100644
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -4,7 +4,7 @@
/* */
/* ANSI-specific FreeType low-level system interface (body). */
/* */
-/* Copyright 1996-2015 by */
+/* Copyright 1996-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c
index 5b24304..7b582c8 100644
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -4,7 +4,7 @@
/* */
/* FreeType trigonometric functions (body). */
/* */
-/* Copyright 2001-2015 by */
+/* Copyright 2001-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -71,7 +71,8 @@
/* 0x40000000 comes from regression analysis between true */
/* and CORDIC hypotenuse, so it minimizes the error */
- val = (FT_Fixed)( ( (FT_Int64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
+ val = (FT_Fixed)(
+ ( (FT_UInt64)val * FT_TRIG_SCALE + 0x40000000UL ) >> 32 );
return s < 0 ? -val : val;
}
diff --git a/src/base/fttype1.c b/src/base/fttype1.c
index c549382..5c0fce8 100644
--- a/src/base/fttype1.c
+++ b/src/base/fttype1.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for PS names support (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftutil.c b/src/base/ftutil.c
index f5b72db..fad7d1a 100644
--- a/src/base/ftutil.c
+++ b/src/base/ftutil.c
@@ -4,7 +4,7 @@
/* */
/* FreeType utility file for memory and list management (body). */
/* */
-/* Copyright 2002-2015 by */
+/* Copyright 2002-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/ftwinfnt.c b/src/base/ftwinfnt.c
index 76a19af..89e9155 100644
--- a/src/base/ftwinfnt.c
+++ b/src/base/ftwinfnt.c
@@ -4,7 +4,7 @@
/* */
/* FreeType API for accessing Windows FNT specific info (body). */
/* */
-/* Copyright 2003-2015 by */
+/* Copyright 2003-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/src/base/md5.c b/src/base/md5.c
index 52d96ac..b235e17 100644
--- a/src/base/md5.c
+++ b/src/base/md5.c
@@ -63,12 +63,19 @@
(a) += (b);
/*
- * SET reads 4 input bytes in little-endian byte order and stores them
- * in a properly aligned word in host byte order.
+ * SET reads 4 input bytes in little-endian byte order and stores them in a
+ * properly aligned word in host byte order.
*
- * The check for little-endian architectures that tolerate unaligned
- * memory accesses is just an optimization. Nothing will break if it
- * doesn't work.
+ * The check for little-endian architectures that tolerate unaligned memory
+ * accesses is just an optimization. Nothing will break if it fails to detect
+ * a suitable architecture.
+ *
+ * Unfortunately, this optimization may be a C strict aliasing rules violation
+ * if the caller's data buffer has effective type that cannot be aliased by
+ * MD5_u32plus. In practice, this problem may occur if these MD5 routines are
+ * inlined into a calling function, or with future and dangerously advanced
+ * link-time optimizations. For the time being, keeping these MD5 routines in
+ * their own translation unit avoids the problem.
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
#define SET(n) \
@@ -87,8 +94,8 @@
#endif
/*
- * This processes one or more 64-byte data blocks, but does NOT update
- * the bit counters. There are no alignment requirements.
+ * This processes one or more 64-byte data blocks, but does NOT update the bit
+ * counters. There are no alignment requirements.
*/
static const void *body(MD5_CTX *ctx, const void *data, unsigned long size)
{
@@ -242,6 +249,12 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size)
memcpy(ctx->buffer, data, size);
}
+#define OUT(dst, src) \
+ (dst)[0] = (unsigned char)(src); \
+ (dst)[1] = (unsigned char)((src) >> 8); \
+ (dst)[2] = (unsigned char)((src) >> 16); \
+ (dst)[3] = (unsigned char)((src) >> 24);
+
void MD5_Final(unsigned char *result, MD5_CTX *ctx)
{
unsigned long used, available;
@@ -262,33 +275,15 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx)
memset(&ctx->buffer[used], 0, available - 8);
ctx->lo <<= 3;
- ctx->buffer[56] = ctx->lo;
- ctx->buffer[57] = ctx->lo >> 8;
- ctx->buffer[58] = ctx->lo >> 16;
- ctx->buffer[59] = ctx->lo >> 24;
- ctx->buffer[60] = ctx->hi;
- ctx->buffer[61] = ctx->hi >> 8;
- ctx->buffer[62] = ctx->hi >> 16;
- ctx->buffer[63] = ctx->hi >> 24;
+ OUT(&ctx->buffer[56], ctx->lo)
+ OUT(&ctx->buffer[60], ctx->hi)
body(ctx, ctx->buffer, 64);
- result[0] = ctx->a;
- result[1] = ctx->a >> 8;
- result[2] = ctx->a >> 16;
- result[3] = ctx->a >> 24;
- result[4] = ctx->b;
- result[5] = ctx->b >> 8;
- result[6] = ctx->b >> 16;
- result[7] = ctx->b >> 24;
- result[8] = ctx->c;
- result[9] = ctx->c >> 8;
- result[10] = ctx->c >> 16;
- result[11] = ctx->c >> 24;
- result[12] = ctx->d;
- result[13] = ctx->d >> 8;
- result[14] = ctx->d >> 16;
- result[15] = ctx->d >> 24;
+ OUT(&result[0], ctx->a)
+ OUT(&result[4], ctx->b)
+ OUT(&result[8], ctx->c)
+ OUT(&result[12], ctx->d)
memset(ctx, 0, sizeof(*ctx));
}