aboutsummaryrefslogtreecommitdiff
path: root/freetype/src/sfnt
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2015-06-15 20:22:43 +0200
committermarha <marha@users.sourceforge.net>2015-06-15 20:22:43 +0200
commit0b3be550b20ad9f991f77bf979b2c306a7d4ef11 (patch)
tree523f6db090457118723eca33dabc7758eeb2dcde /freetype/src/sfnt
parent5fe210ff514aa4b3149ea7561862776d7b8849e7 (diff)
downloadvcxsrv-0b3be550b20ad9f991f77bf979b2c306a7d4ef11.tar.gz
vcxsrv-0b3be550b20ad9f991f77bf979b2c306a7d4ef11.tar.bz2
vcxsrv-0b3be550b20ad9f991f77bf979b2c306a7d4ef11.zip
Update to freetype 2.6
Diffstat (limited to 'freetype/src/sfnt')
-rw-r--r--freetype/src/sfnt/Jamfile2
-rw-r--r--freetype/src/sfnt/module.mk2
-rw-r--r--freetype/src/sfnt/pngshim.c35
-rw-r--r--freetype/src/sfnt/pngshim.h3
-rw-r--r--freetype/src/sfnt/rules.mk7
-rw-r--r--freetype/src/sfnt/sfdriver.c8
-rw-r--r--freetype/src/sfnt/sfdriver.h2
-rw-r--r--freetype/src/sfnt/sferrors.h2
-rw-r--r--freetype/src/sfnt/sfnt.c2
-rw-r--r--freetype/src/sfnt/sfntpic.c2
-rw-r--r--freetype/src/sfnt/sfntpic.h2
-rw-r--r--freetype/src/sfnt/sfobjs.c33
-rw-r--r--freetype/src/sfnt/sfobjs.h2
-rw-r--r--freetype/src/sfnt/ttbdf.c2
-rw-r--r--freetype/src/sfnt/ttbdf.h2
-rw-r--r--freetype/src/sfnt/ttcmap.c24
-rw-r--r--freetype/src/sfnt/ttcmap.h2
-rw-r--r--freetype/src/sfnt/ttcmapc.h2
-rw-r--r--freetype/src/sfnt/ttkern.c6
-rw-r--r--freetype/src/sfnt/ttkern.h2
-rw-r--r--freetype/src/sfnt/ttload.c57
-rw-r--r--freetype/src/sfnt/ttload.h2
-rw-r--r--freetype/src/sfnt/ttmtx.c2
-rw-r--r--freetype/src/sfnt/ttmtx.h2
-rw-r--r--freetype/src/sfnt/ttpost.c34
-rw-r--r--freetype/src/sfnt/ttpost.h2
-rw-r--r--freetype/src/sfnt/ttsbit.c62
-rw-r--r--freetype/src/sfnt/ttsbit.h2
28 files changed, 177 insertions, 128 deletions
diff --git a/freetype/src/sfnt/Jamfile b/freetype/src/sfnt/Jamfile
index cb20b1b04..73c6e152d 100644
--- a/freetype/src/sfnt/Jamfile
+++ b/freetype/src/sfnt/Jamfile
@@ -1,6 +1,6 @@
# FreeType 2 src/sfnt Jamfile
#
-# Copyright 2001, 2002, 2004, 2005 by
+# Copyright 2001-2015 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/freetype/src/sfnt/module.mk b/freetype/src/sfnt/module.mk
index 95fd6a314..535fe22af 100644
--- a/freetype/src/sfnt/module.mk
+++ b/freetype/src/sfnt/module.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2006 by
+# Copyright 1996-2015 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
diff --git a/freetype/src/sfnt/pngshim.c b/freetype/src/sfnt/pngshim.c
index 9bfcc2a77..ea6045263 100644
--- a/freetype/src/sfnt/pngshim.c
+++ b/freetype/src/sfnt/pngshim.c
@@ -4,7 +4,8 @@
/* */
/* PNG Bitmap glyph support. */
/* */
-/* Copyright 2013, 2014 by Google, Inc. */
+/* Copyright 2013-2015 by */
+/* Google, Inc. */
/* Written by Stuart Gill and Behdad Esfahbod. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -36,11 +37,11 @@
/* This code is freely based on cairo-png.c. There's so many ways */
/* to call libpng, and the way cairo does it is defacto standard. */
- static int
- multiply_alpha( int alpha,
- int color )
+ static unsigned int
+ multiply_alpha( unsigned int alpha,
+ unsigned int color )
{
- int temp = ( alpha * color ) + 0x80;
+ unsigned int temp = alpha * color + 0x80;
return ( temp + ( temp >> 8 ) ) >> 8;
@@ -81,10 +82,10 @@
blue = multiply_alpha( alpha, blue );
}
- base[0] = blue;
- base[1] = green;
- base[2] = red;
- base[3] = alpha;
+ base[0] = (unsigned char)blue;
+ base[1] = (unsigned char)green;
+ base[2] = (unsigned char)red;
+ base[3] = (unsigned char)alpha;
}
}
}
@@ -109,9 +110,9 @@
unsigned int blue = base[2];
- base[0] = blue;
- base[1] = green;
- base[2] = red;
+ base[0] = (unsigned char)blue;
+ base[1] = (unsigned char)green;
+ base[2] = (unsigned char)red;
base[3] = 0xFF;
}
}
@@ -257,16 +258,16 @@
if ( populate_map_and_metrics )
{
- FT_Long size;
+ FT_ULong size;
- metrics->width = (FT_Int)imgWidth;
- metrics->height = (FT_Int)imgHeight;
+ metrics->width = (FT_UShort)imgWidth;
+ metrics->height = (FT_UShort)imgHeight;
map->width = metrics->width;
map->rows = metrics->height;
map->pixel_mode = FT_PIXEL_MODE_BGRA;
- map->pitch = map->width * 4;
+ map->pitch = (int)( map->width * 4 );
map->num_grays = 256;
/* reject too large bitmaps similarly to the rasterizer */
@@ -277,7 +278,7 @@
}
/* this doesn't overflow: 0x7FFF * 0x7FFF * 4 < 2^32 */
- size = map->rows * map->pitch;
+ size = map->rows * (FT_ULong)map->pitch;
error = ft_glyphslot_alloc_bitmap( slot, size );
if ( error )
diff --git a/freetype/src/sfnt/pngshim.h b/freetype/src/sfnt/pngshim.h
index dc9ecaf91..4cc5c2b3a 100644
--- a/freetype/src/sfnt/pngshim.h
+++ b/freetype/src/sfnt/pngshim.h
@@ -4,7 +4,8 @@
/* */
/* PNG Bitmap glyph support. */
/* */
-/* Copyright 2013 by Google, Inc. */
+/* Copyright 2013-2015 by */
+/* Google, Inc. */
/* Written by Stuart Gill and Behdad Esfahbod. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/rules.mk b/freetype/src/sfnt/rules.mk
index a6c956ab6..3cc76b3f7 100644
--- a/freetype/src/sfnt/rules.mk
+++ b/freetype/src/sfnt/rules.mk
@@ -3,7 +3,7 @@
#
-# Copyright 1996-2000, 2002-2007, 2009, 2011, 2013 by
+# Copyright 1996-2015 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -20,7 +20,10 @@ SFNT_DIR := $(SRC_DIR)/sfnt
# compilation flags for the driver
#
-SFNT_COMPILE := $(FT_COMPILE) $I$(subst /,$(COMPILER_SEP),$(SFNT_DIR))
+SFNT_COMPILE := $(CC) $(ANSIFLAGS) \
+ $I$(subst /,$(COMPILER_SEP),$(SFNT_DIR)) \
+ $(INCLUDE_FLAGS) \
+ $(FT_CFLAGS)
# SFNT driver sources (i.e., C files)
diff --git a/freetype/src/sfnt/sfdriver.c b/freetype/src/sfnt/sfdriver.c
index badb159dc..0948ad4e7 100644
--- a/freetype/src/sfnt/sfdriver.c
+++ b/freetype/src/sfnt/sfdriver.c
@@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (body). */
/* */
-/* Copyright 1996-2007, 2009-2014 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -266,7 +266,7 @@
{
FT_Stream stream = face->name_table.stream;
FT_String* r = (FT_String*)result;
- FT_Byte* p;
+ FT_Char* p;
if ( FT_STREAM_SEEK( name->stringOffset ) ||
@@ -280,11 +280,11 @@
goto Exit;
}
- p = (FT_Byte*)stream->cursor;
+ p = (FT_Char*)stream->cursor;
for ( ; len > 0; len--, p += 2 )
{
- if ( p[0] == 0 && p[1] >= 32 && p[1] < 128 )
+ if ( p[0] == 0 && p[1] >= 32 )
*r++ = p[1];
}
*r = '\0';
diff --git a/freetype/src/sfnt/sfdriver.h b/freetype/src/sfnt/sfdriver.h
index 5de25d51c..944119cc2 100644
--- a/freetype/src/sfnt/sfdriver.h
+++ b/freetype/src/sfnt/sfdriver.h
@@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (specification). */
/* */
-/* Copyright 1996-2001 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/sferrors.h b/freetype/src/sfnt/sferrors.h
index e981e1d26..e3bef3f74 100644
--- a/freetype/src/sfnt/sferrors.h
+++ b/freetype/src/sfnt/sferrors.h
@@ -4,7 +4,7 @@
/* */
/* SFNT error codes (specification only). */
/* */
-/* Copyright 2001, 2004, 2012, 2013 by */
+/* Copyright 2001-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/sfnt.c b/freetype/src/sfnt/sfnt.c
index d62ed4e0b..0b8b5f457 100644
--- a/freetype/src/sfnt/sfnt.c
+++ b/freetype/src/sfnt/sfnt.c
@@ -4,7 +4,7 @@
/* */
/* Single object library component. */
/* */
-/* Copyright 1996-2006, 2013 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/sfntpic.c b/freetype/src/sfnt/sfntpic.c
index b3fb24b3f..2aaf4bcc4 100644
--- a/freetype/src/sfnt/sfntpic.c
+++ b/freetype/src/sfnt/sfntpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
-/* Copyright 2009, 2010, 2012, 2013 by */
+/* Copyright 2009-2015 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/sfntpic.h b/freetype/src/sfnt/sfntpic.h
index b09a9141e..563d6344d 100644
--- a/freetype/src/sfnt/sfntpic.h
+++ b/freetype/src/sfnt/sfntpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
-/* Copyright 2009, 2012 by */
+/* Copyright 2009-2015 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/sfobjs.c b/freetype/src/sfnt/sfobjs.c
index 70b988d65..40c27fa9a 100644
--- a/freetype/src/sfnt/sfobjs.c
+++ b/freetype/src/sfnt/sfobjs.c
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (base). */
/* */
-/* Copyright 1996-2008, 2010-2014 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -376,8 +376,8 @@
FT_FREE( stream->base );
stream->size = 0;
- stream->base = 0;
- stream->close = 0;
+ stream->base = NULL;
+ stream->close = NULL;
}
@@ -580,8 +580,8 @@
table->OrigOffset = sfnt_offset;
/* The offsets must be multiples of 4. */
- woff_offset += ( table->CompLength + 3 ) & ~3;
- sfnt_offset += ( table->OrigLength + 3 ) & ~3;
+ woff_offset += ( table->CompLength + 3 ) & ~3U;
+ sfnt_offset += ( table->OrigLength + 3 ) & ~3U;
}
/*
@@ -609,7 +609,7 @@
if ( woff.privOffset )
{
/* ... if it isn't the last block. */
- woff_offset = ( woff_offset + 3 ) & ~3;
+ woff_offset = ( woff_offset + 3 ) & ~3U;
if ( woff.privOffset != woff_offset ||
woff.privOffset + woff.privLength > woff.length )
@@ -1431,8 +1431,8 @@
root->ascender = face->horizontal.Ascender;
root->descender = face->horizontal.Descender;
- root->height = (FT_Short)( root->ascender - root->descender +
- face->horizontal.Line_Gap );
+ root->height = root->ascender - root->descender +
+ face->horizontal.Line_Gap;
if ( !( root->ascender || root->descender ) )
{
@@ -1443,23 +1443,24 @@
root->ascender = face->os2.sTypoAscender;
root->descender = face->os2.sTypoDescender;
- root->height = (FT_Short)( root->ascender - root->descender +
- face->os2.sTypoLineGap );
+ root->height = root->ascender - root->descender +
+ face->os2.sTypoLineGap;
}
else
{
root->ascender = (FT_Short)face->os2.usWinAscent;
root->descender = -(FT_Short)face->os2.usWinDescent;
- root->height = (FT_UShort)( root->ascender - root->descender );
+ root->height = root->ascender - root->descender;
}
}
}
- root->max_advance_width = face->horizontal.advance_Width_Max;
- root->max_advance_height = (FT_Short)( face->vertical_info
- ? face->vertical.advance_Height_Max
- : root->height );
+ root->max_advance_width =
+ (FT_Short)face->horizontal.advance_Width_Max;
+ root->max_advance_height =
+ (FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max
+ : root->height );
/* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */
/* Adjust underline position from top edge to centre of */
@@ -1569,7 +1570,7 @@
FT_FREE( face->postscript_name );
- face->sfnt = 0;
+ face->sfnt = NULL;
}
diff --git a/freetype/src/sfnt/sfobjs.h b/freetype/src/sfnt/sfobjs.h
index 6241c93b3..77c7d92c3 100644
--- a/freetype/src/sfnt/sfobjs.h
+++ b/freetype/src/sfnt/sfobjs.h
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (specification). */
/* */
-/* Copyright 1996-2001, 2002 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttbdf.c b/freetype/src/sfnt/ttbdf.c
index 9401dae5f..098b781a1 100644
--- a/freetype/src/sfnt/ttbdf.c
+++ b/freetype/src/sfnt/ttbdf.c
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded BDF properties (body). */
/* */
-/* Copyright 2005, 2006, 2010, 2013 by */
+/* Copyright 2005-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttbdf.h b/freetype/src/sfnt/ttbdf.h
index 48a10d6e9..fe4ba489e 100644
--- a/freetype/src/sfnt/ttbdf.h
+++ b/freetype/src/sfnt/ttbdf.h
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded BDF properties (specification). */
/* */
-/* Copyright 2005 by */
+/* Copyright 2005-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttcmap.c b/freetype/src/sfnt/ttcmap.c
index f54de7069..815ee7c4e 100644
--- a/freetype/src/sfnt/ttcmap.c
+++ b/freetype/src/sfnt/ttcmap.c
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (body). */
/* */
-/* Copyright 2002-2010, 2012-2014 by */
+/* Copyright 2002-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -360,7 +360,7 @@
ids = p - 2 + offset;
- if ( ids < glyph_ids || ids + code_count*2 > table + length )
+ if ( ids < glyph_ids || ids + code_count * 2 > table + length )
FT_INVALID_OFFSET;
/* check glyph IDs */
@@ -375,7 +375,7 @@
idx = TT_NEXT_USHORT( p );
if ( idx != 0 )
{
- idx = ( idx + delta ) & 0xFFFFU;
+ idx = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
}
@@ -472,7 +472,7 @@
idx = TT_PEEK_USHORT( p );
if ( idx != 0 )
- result = (FT_UInt)( idx + delta ) & 0xFFFFU;
+ result = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
}
}
return result;
@@ -524,7 +524,7 @@
if ( idx != 0 )
{
- gindex = ( idx + delta ) & 0xFFFFU;
+ gindex = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
if ( gindex != 0 )
{
result = charcode;
@@ -786,7 +786,7 @@
if ( gindex != 0 )
{
- gindex = (FT_UInt)( ( gindex + delta ) & 0xFFFFU );
+ gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
if ( gindex != 0 )
{
cmap->cur_charcode = charcode;
@@ -800,7 +800,7 @@
{
do
{
- FT_UInt gindex = (FT_UInt)( ( charcode + delta ) & 0xFFFFU );
+ FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
if ( gindex != 0 )
@@ -993,7 +993,7 @@
idx = FT_NEXT_USHORT( p );
if ( idx != 0 )
{
- idx = (FT_UInt)( idx + delta ) & 0xFFFFU;
+ idx = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU;
if ( idx >= TT_VALID_GLYPH_COUNT( valid ) )
FT_INVALID_GLYPH_ID;
@@ -1090,10 +1090,10 @@
p += offset + ( charcode - start ) * 2;
gindex = TT_PEEK_USHORT( p );
if ( gindex != 0 )
- gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU;
+ gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
}
else
- gindex = (FT_UInt)( charcode + delta ) & 0xFFFFU;
+ gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
break;
}
@@ -1294,10 +1294,10 @@
p += offset + ( charcode - start ) * 2;
gindex = TT_PEEK_USHORT( p );
if ( gindex != 0 )
- gindex = (FT_UInt)( gindex + delta ) & 0xFFFFU;
+ gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
}
else
- gindex = (FT_UInt)( charcode + delta ) & 0xFFFFU;
+ gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
break;
}
diff --git a/freetype/src/sfnt/ttcmap.h b/freetype/src/sfnt/ttcmap.h
index 0fde1676b..b7ea8ee37 100644
--- a/freetype/src/sfnt/ttcmap.h
+++ b/freetype/src/sfnt/ttcmap.h
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (specification). */
/* */
-/* Copyright 2002-2005, 2009, 2012 by */
+/* Copyright 2002-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttcmapc.h b/freetype/src/sfnt/ttcmapc.h
index 2ea204309..4a489402c 100644
--- a/freetype/src/sfnt/ttcmapc.h
+++ b/freetype/src/sfnt/ttcmapc.h
@@ -4,7 +4,7 @@
/* */
/* TT CMAP classes definitions (specification only). */
/* */
-/* Copyright 2009 by */
+/* Copyright 2009-2015 by */
/* Oran Agra and Mickey Gabel. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttkern.c b/freetype/src/sfnt/ttkern.c
index 455e7b5e3..4fccc535c 100644
--- a/freetype/src/sfnt/ttkern.c
+++ b/freetype/src/sfnt/ttkern.c
@@ -5,7 +5,7 @@
/* Load the basic TrueType kerning table. This doesn't handle */
/* kerning data within the GPOS table at the moment. */
/* */
-/* Copyright 1996-2007, 2009, 2010, 2013 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -108,8 +108,8 @@
p_next = p_limit;
/* only use horizontal kerning tables */
- if ( ( coverage & ~8 ) != 0x0001 ||
- p + 8 > p_limit )
+ if ( ( coverage & ~8U ) != 0x0001 ||
+ p + 8 > p_limit )
goto NextTable;
num_pairs = FT_NEXT_USHORT( p );
diff --git a/freetype/src/sfnt/ttkern.h b/freetype/src/sfnt/ttkern.h
index df1da9b27..89cb24f07 100644
--- a/freetype/src/sfnt/ttkern.h
+++ b/freetype/src/sfnt/ttkern.h
@@ -5,7 +5,7 @@
/* Load the basic TrueType kerning table. This doesn't handle */
/* kerning data within the GPOS table at the moment. */
/* */
-/* Copyright 1996-2001, 2002, 2005, 2007 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttload.c b/freetype/src/sfnt/ttload.c
index 8338150ab..ad2975de0 100644
--- a/freetype/src/sfnt/ttload.c
+++ b/freetype/src/sfnt/ttload.c
@@ -5,7 +5,7 @@
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (body). */
/* */
-/* Copyright 1996-2010, 2012-2014 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -208,12 +208,23 @@
/* we ignore invalid tables */
- /* table.Offset + table.Length > stream->size ? */
- if ( table.Length > stream->size ||
- table.Offset > stream->size - table.Length )
- {
- FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn ));
+ if ( table.Offset > stream->size )
continue;
+ else if ( table.Length > stream->size - table.Offset )
+ {
+ /* Some tables have such a simple structure that clipping its */
+ /* contents is harmless. This also makes FreeType less sensitive */
+ /* to invalid table lengths (which programs like Acroread seem to */
+ /* ignore in general). */
+
+ if ( table.Tag == TTAG_hmtx ||
+ table.Tag == TTAG_vmtx )
+ valid_entries++;
+ else
+ {
+ FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn ));
+ continue;
+ }
}
else
valid_entries++;
@@ -397,12 +408,38 @@
entry->Offset = FT_GET_ULONG();
entry->Length = FT_GET_ULONG();
- /* ignore invalid tables */
+ /* ignore invalid tables that can't be sanitized */
- /* entry->Offset + entry->Length > stream->size ? */
- if ( entry->Length > stream->size ||
- entry->Offset > stream->size - entry->Length )
+ if ( entry->Offset > stream->size )
continue;
+ else if ( entry->Length > stream->size - entry->Offset )
+ {
+ if ( entry->Tag == TTAG_hmtx ||
+ entry->Tag == TTAG_vmtx )
+ {
+#ifdef FT_DEBUG_LEVEL_TRACE
+ FT_ULong old_length = entry->Length;
+#endif
+
+
+ /* make metrics table length a multiple of 4 */
+ entry->Length = ( stream->size - entry->Offset ) & ~3U;
+
+ FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx"
+ " (sanitized; original length %08lx)\n",
+ (FT_Char)( entry->Tag >> 24 ),
+ (FT_Char)( entry->Tag >> 16 ),
+ (FT_Char)( entry->Tag >> 8 ),
+ (FT_Char)( entry->Tag ),
+ entry->Offset,
+ entry->Length,
+ entry->CheckSum,
+ old_length ));
+ entry++;
+ }
+ else
+ continue;
+ }
else
{
FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx\n",
diff --git a/freetype/src/sfnt/ttload.h b/freetype/src/sfnt/ttload.h
index 49a1aee16..a6d91c5b7 100644
--- a/freetype/src/sfnt/ttload.h
+++ b/freetype/src/sfnt/ttload.h
@@ -5,7 +5,7 @@
/* Load the basic TrueType tables, i.e., tables that can be either in */
/* TTF or OTF fonts (specification). */
/* */
-/* Copyright 1996-2001, 2002, 2005, 2006 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttmtx.c b/freetype/src/sfnt/ttmtx.c
index bb319577e..58309aa49 100644
--- a/freetype/src/sfnt/ttmtx.c
+++ b/freetype/src/sfnt/ttmtx.c
@@ -4,7 +4,7 @@
/* */
/* Load the metrics tables common to TTF and OTF fonts (body). */
/* */
-/* Copyright 2006-2009, 2011-2014 by */
+/* Copyright 2006-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttmtx.h b/freetype/src/sfnt/ttmtx.h
index fb040394c..096ee062c 100644
--- a/freetype/src/sfnt/ttmtx.h
+++ b/freetype/src/sfnt/ttmtx.h
@@ -4,7 +4,7 @@
/* */
/* Load the metrics tables common to TTF and OTF fonts (specification). */
/* */
-/* Copyright 2006, 2014 by */
+/* Copyright 2006-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttpost.c b/freetype/src/sfnt/ttpost.c
index 99d800549..8d29d1e9f 100644
--- a/freetype/src/sfnt/ttpost.c
+++ b/freetype/src/sfnt/ttpost.c
@@ -5,7 +5,7 @@
/* Postcript name table processing for TrueType and OpenType fonts */
/* (body). */
/* */
-/* Copyright 1996-2003, 2006-2010, 2013, 2014 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -52,7 +52,7 @@
#include FT_SERVICE_POSTSCRIPT_CMAPS_H
-#define MAC_NAME( x ) ( (FT_String*)psnames->macintosh_name( x ) )
+#define MAC_NAME( x ) (FT_String*)psnames->macintosh_name( (FT_UInt)(x) )
#else /* FT_CONFIG_OPTION_POSTSCRIPT_NAMES */
@@ -62,7 +62,7 @@
/* table of Mac names. Thus, it is possible to build a version of */
/* FreeType without the Type 1 driver & PSNames module. */
-#define MAC_NAME( x ) ( (FT_String*)tt_post_default_names[x] )
+#define MAC_NAME( x ) (FT_String*)tt_post_default_names[x]
/* the 258 default Mac PS glyph names; see file `tools/glnames.py' */
@@ -155,7 +155,7 @@
static FT_Error
load_format_20( TT_Face face,
FT_Stream stream,
- FT_Long post_limit )
+ FT_ULong post_limit )
{
FT_Memory memory = stream->memory;
FT_Error error;
@@ -163,8 +163,8 @@
FT_Int num_glyphs;
FT_UShort num_names;
- FT_UShort* glyph_indices = 0;
- FT_Char** name_strings = 0;
+ FT_UShort* glyph_indices = NULL;
+ FT_Char** name_strings = NULL;
if ( FT_READ_USHORT( num_glyphs ) )
@@ -243,14 +243,17 @@
goto Fail1;
}
- if ( (FT_Int)len > post_limit ||
- FT_STREAM_POS() > post_limit - (FT_Int)len )
+ if ( len > post_limit ||
+ FT_STREAM_POS() > post_limit - len )
{
+ FT_Int d = (FT_Int)post_limit - (FT_Int)FT_STREAM_POS();
+
+
FT_ERROR(( "load_format_20:"
" exceeding string length (%d),"
" truncating at end of post table (%d byte left)\n",
- len, post_limit - FT_STREAM_POS() ));
- len = FT_MAX( 0, post_limit - FT_STREAM_POS() );
+ len, d ));
+ len = (FT_UInt)FT_MAX( 0, d );
}
if ( FT_NEW_ARRAY( name_strings[n], len + 1 ) ||
@@ -307,13 +310,13 @@
static FT_Error
load_format_25( TT_Face face,
FT_Stream stream,
- FT_Long post_limit )
+ FT_ULong post_limit )
{
FT_Memory memory = stream->memory;
FT_Error error;
FT_Int num_glyphs;
- FT_Char* offset_table = 0;
+ FT_Char* offset_table = NULL;
FT_UNUSED( post_limit );
@@ -377,7 +380,7 @@
FT_Error error;
FT_Fixed format;
FT_ULong post_len;
- FT_Long post_limit;
+ FT_ULong post_limit;
/* get a stream for the face's resource */
@@ -547,10 +550,7 @@
}
if ( idx < (FT_UInt)table->num_glyphs ) /* paranoid checking */
- {
- idx += table->offsets[idx];
- *PSname = MAC_NAME( idx );
- }
+ *PSname = MAC_NAME( (FT_Int)idx + table->offsets[idx] );
}
/* nothing to do for format == 0x00030000L */
diff --git a/freetype/src/sfnt/ttpost.h b/freetype/src/sfnt/ttpost.h
index 6f06d75a7..e3eca02c6 100644
--- a/freetype/src/sfnt/ttpost.h
+++ b/freetype/src/sfnt/ttpost.h
@@ -5,7 +5,7 @@
/* Postcript name table processing for TrueType and OpenType fonts */
/* (specification). */
/* */
-/* Copyright 1996-2001, 2002 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
diff --git a/freetype/src/sfnt/ttsbit.c b/freetype/src/sfnt/ttsbit.c
index c2db96c6d..143f276d3 100644
--- a/freetype/src/sfnt/ttsbit.c
+++ b/freetype/src/sfnt/ttsbit.c
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded bitmap support (body). */
/* */
-/* Copyright 2005-2009, 2013, 2014 by */
+/* Copyright 2005-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* Copyright 2013 by Google, Inc. */
@@ -101,10 +101,10 @@
p = face->sbit_table;
- version = FT_NEXT_ULONG( p );
+ version = FT_NEXT_LONG( p );
num_strikes = FT_NEXT_ULONG( p );
- if ( ( version & 0xFFFF0000UL ) != 0x00020000UL )
+ if ( ( (FT_ULong)version & 0xFFFF0000UL ) != 0x00020000UL )
{
error = FT_THROW( Unknown_File_Format );
goto Exit;
@@ -273,6 +273,7 @@
FT_UShort ppem, resolution;
TT_HoriHeader *hori;
FT_ULong table_size;
+ FT_Pos ppem_, upem_; /* to reduce casts */
FT_Error error;
FT_Byte* p;
@@ -305,12 +306,15 @@
metrics->x_ppem = ppem;
metrics->y_ppem = ppem;
- metrics->ascender = ppem * hori->Ascender * 64 / upem;
- metrics->descender = ppem * hori->Descender * 64 / upem;
- metrics->height = ppem * ( hori->Ascender -
- hori->Descender +
- hori->Line_Gap ) * 64 / upem;
- metrics->max_advance = ppem * hori->advance_Width_Max * 64 / upem;
+ ppem_ = (FT_Pos)ppem;
+ upem_ = (FT_Pos)upem;
+
+ metrics->ascender = ppem_ * hori->Ascender * 64 / upem_;
+ metrics->descender = ppem_ * hori->Descender * 64 / upem_;
+ metrics->height = ppem_ * ( hori->Ascender -
+ hori->Descender +
+ hori->Line_Gap ) * 64 / upem_;
+ metrics->max_advance = ppem_ * hori->advance_Width_Max * 64 / upem_;
return error;
}
@@ -420,7 +424,7 @@
FT_Error error = FT_Err_Ok;
FT_UInt width, height;
FT_Bitmap* map = decoder->bitmap;
- FT_Long size;
+ FT_ULong size;
if ( !decoder->metrics_loaded )
@@ -432,38 +436,38 @@
width = decoder->metrics->width;
height = decoder->metrics->height;
- map->width = (int)width;
- map->rows = (int)height;
+ map->width = width;
+ map->rows = height;
switch ( decoder->bit_depth )
{
case 1:
map->pixel_mode = FT_PIXEL_MODE_MONO;
- map->pitch = ( map->width + 7 ) >> 3;
+ map->pitch = (int)( ( map->width + 7 ) >> 3 );
map->num_grays = 2;
break;
case 2:
map->pixel_mode = FT_PIXEL_MODE_GRAY2;
- map->pitch = ( map->width + 3 ) >> 2;
+ map->pitch = (int)( ( map->width + 3 ) >> 2 );
map->num_grays = 4;
break;
case 4:
map->pixel_mode = FT_PIXEL_MODE_GRAY4;
- map->pitch = ( map->width + 1 ) >> 1;
+ map->pitch = (int)( ( map->width + 1 ) >> 1 );
map->num_grays = 16;
break;
case 8:
map->pixel_mode = FT_PIXEL_MODE_GRAY;
- map->pitch = map->width;
+ map->pitch = (int)( map->width );
map->num_grays = 256;
break;
case 32:
map->pixel_mode = FT_PIXEL_MODE_BGRA;
- map->pitch = map->width * 4;
+ map->pitch = (int)( map->width * 4 );
map->num_grays = 256;
break;
@@ -472,7 +476,7 @@
goto Exit;
}
- size = map->rows * map->pitch;
+ size = map->rows * (FT_ULong)map->pitch;
/* check that there is no empty image */
if ( size == 0 )
@@ -561,7 +565,8 @@
{
FT_Error error = FT_Err_Ok;
FT_Byte* line;
- FT_Int bit_height, bit_width, pitch, width, height, line_bits, h;
+ FT_Int pitch, width, height, line_bits, h;
+ FT_UInt bit_height, bit_width;
FT_Bitmap* bitmap;
@@ -577,8 +582,8 @@
line_bits = width * decoder->bit_depth;
- if ( x_pos < 0 || x_pos + width > bit_width ||
- y_pos < 0 || y_pos + height > bit_height )
+ if ( x_pos < 0 || (FT_UInt)( x_pos + width ) > bit_width ||
+ y_pos < 0 || (FT_UInt)( y_pos + height ) > bit_height )
{
FT_TRACE1(( "tt_sbit_decoder_load_byte_aligned:"
" invalid bitmap dimensions\n" ));
@@ -699,7 +704,8 @@
{
FT_Error error = FT_Err_Ok;
FT_Byte* line;
- FT_Int bit_height, bit_width, pitch, width, height, line_bits, h, nbits;
+ FT_Int pitch, width, height, line_bits, h, nbits;
+ FT_UInt bit_height, bit_width;
FT_Bitmap* bitmap;
FT_UShort rval;
@@ -716,8 +722,8 @@
line_bits = width * decoder->bit_depth;
- if ( x_pos < 0 || x_pos + width > bit_width ||
- y_pos < 0 || y_pos + height > bit_height )
+ if ( x_pos < 0 || (FT_UInt)( x_pos + width ) > bit_width ||
+ y_pos < 0 || (FT_UInt)( y_pos + height ) > bit_height )
{
FT_TRACE1(( "tt_sbit_decoder_load_bit_aligned:"
" invalid bitmap dimensions\n" ));
@@ -1379,9 +1385,9 @@
metrics->horiBearingX = (FT_Short)originOffsetX;
metrics->horiBearingY = (FT_Short)( -originOffsetY + metrics->height );
- metrics->horiAdvance = (FT_Short)( aadvance *
- face->root.size->metrics.x_ppem /
- face->header.Units_Per_EM );
+ metrics->horiAdvance = (FT_UShort)( aadvance *
+ face->root.size->metrics.x_ppem /
+ face->header.Units_Per_EM );
}
return error;
@@ -1442,7 +1448,7 @@
FT_Library library = face->root.glyph->library;
- FT_Bitmap_New( &new_map );
+ FT_Bitmap_Init( &new_map );
/* Convert to 8bit grayscale. */
error = FT_Bitmap_Convert( library, map, &new_map, 1 );
diff --git a/freetype/src/sfnt/ttsbit.h b/freetype/src/sfnt/ttsbit.h
index 695d0d8d0..d4e13aefb 100644
--- a/freetype/src/sfnt/ttsbit.h
+++ b/freetype/src/sfnt/ttsbit.h
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded bitmap support (specification). */
/* */
-/* Copyright 1996-2008, 2013 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */