summaryrefslogtreecommitdiffstats
path: root/src/sfnt
diff options
context:
space:
mode:
Diffstat (limited to 'src/sfnt')
-rw-r--r--src/sfnt/pngshim.c2
-rw-r--r--src/sfnt/pngshim.h8
-rw-r--r--src/sfnt/sfdriver.c55
-rw-r--r--src/sfnt/sfdriver.h8
-rw-r--r--src/sfnt/sferrors.h11
-rw-r--r--src/sfnt/sfnt.c2
-rw-r--r--src/sfnt/sfntpic.c2
-rw-r--r--src/sfnt/sfntpic.h8
-rw-r--r--src/sfnt/sfobjs.c51
-rw-r--r--src/sfnt/sfobjs.h8
-rw-r--r--src/sfnt/ttbdf.c2
-rw-r--r--src/sfnt/ttbdf.h8
-rw-r--r--src/sfnt/ttcmap.c75
-rw-r--r--src/sfnt/ttcmap.h8
-rw-r--r--src/sfnt/ttcmapc.h2
-rw-r--r--src/sfnt/ttkern.c2
-rw-r--r--src/sfnt/ttkern.h8
-rw-r--r--src/sfnt/ttload.c15
-rw-r--r--src/sfnt/ttload.h8
-rw-r--r--src/sfnt/ttmtx.c2
-rw-r--r--src/sfnt/ttmtx.h8
-rw-r--r--src/sfnt/ttpost.c4
-rw-r--r--src/sfnt/ttpost.h10
-rw-r--r--src/sfnt/ttsbit.c76
-rw-r--r--src/sfnt/ttsbit.h8
25 files changed, 258 insertions, 133 deletions
diff --git a/src/sfnt/pngshim.c b/src/sfnt/pngshim.c
index ea60452..2815759 100644
--- a/src/sfnt/pngshim.c
+++ b/src/sfnt/pngshim.c
@@ -4,7 +4,7 @@
/* */
/* PNG Bitmap glyph support. */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2016 by */
/* Google, Inc. */
/* Written by Stuart Gill and Behdad Esfahbod. */
/* */
diff --git a/src/sfnt/pngshim.h b/src/sfnt/pngshim.h
index 4cc5c2b..ff05871 100644
--- a/src/sfnt/pngshim.h
+++ b/src/sfnt/pngshim.h
@@ -4,7 +4,7 @@
/* */
/* PNG Bitmap glyph support. */
/* */
-/* Copyright 2013-2015 by */
+/* Copyright 2013-2016 by */
/* Google, Inc. */
/* Written by Stuart Gill and Behdad Esfahbod. */
/* */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __PNGSHIM_H__
-#define __PNGSHIM_H__
+#ifndef PNGSHIM_H_
+#define PNGSHIM_H_
#include <ft2build.h>
@@ -44,7 +44,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __PNGSHIM_H__ */
+#endif /* PNGSHIM_H_ */
/* END */
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 5dd8449..2233269 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver 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, */
@@ -459,55 +459,62 @@
FT_DEFINE_SFNT_INTERFACE(
sfnt_interface,
- tt_face_goto_table,
+ tt_face_goto_table, /* TT_Loader_GotoTableFunc goto_table */
- sfnt_init_face,
- sfnt_load_face,
- sfnt_done_face,
- sfnt_get_interface,
+ sfnt_init_face, /* TT_Init_Face_Func init_face */
+ sfnt_load_face, /* TT_Load_Face_Func load_face */
+ sfnt_done_face, /* TT_Done_Face_Func done_face */
+ sfnt_get_interface, /* FT_Module_Requester get_interface */
- tt_face_load_any,
+ tt_face_load_any, /* TT_Load_Any_Func load_any */
- tt_face_load_head,
- tt_face_load_hhea,
- tt_face_load_cmap,
- tt_face_load_maxp,
- tt_face_load_os2,
- tt_face_load_post,
+ tt_face_load_head, /* TT_Load_Table_Func load_head */
+ tt_face_load_hhea, /* TT_Load_Metrics_Func load_hhea */
+ tt_face_load_cmap, /* TT_Load_Table_Func load_cmap */
+ tt_face_load_maxp, /* TT_Load_Table_Func load_maxp */
+ tt_face_load_os2, /* TT_Load_Table_Func load_os2 */
+ tt_face_load_post, /* TT_Load_Table_Func load_post */
- tt_face_load_name,
- tt_face_free_name,
+ tt_face_load_name, /* TT_Load_Table_Func load_name */
+ tt_face_free_name, /* TT_Free_Table_Func free_name */
- tt_face_load_kern,
- tt_face_load_gasp,
- tt_face_load_pclt,
+ tt_face_load_kern, /* TT_Load_Table_Func load_kern */
+ tt_face_load_gasp, /* TT_Load_Table_Func load_gasp */
+ tt_face_load_pclt, /* TT_Load_Table_Func load_init */
/* see `ttload.h' */
PUT_EMBEDDED_BITMAPS( tt_face_load_bhed ),
-
+ /* TT_Load_Table_Func load_bhed */
PUT_EMBEDDED_BITMAPS( tt_face_load_sbit_image ),
+ /* TT_Load_SBit_Image_Func load_sbit_image */
/* see `ttpost.h' */
PUT_PS_NAMES( tt_face_get_ps_name ),
+ /* TT_Get_PS_Name_Func get_psname */
PUT_PS_NAMES( tt_face_free_ps_names ),
+ /* TT_Free_Table_Func free_psnames */
/* since version 2.1.8 */
- tt_face_get_kerning,
+ tt_face_get_kerning, /* TT_Face_GetKerningFunc get_kerning */
/* since version 2.2 */
- tt_face_load_font_dir,
- tt_face_load_hmtx,
+ tt_face_load_font_dir, /* TT_Load_Table_Func load_font_dir */
+ tt_face_load_hmtx, /* TT_Load_Metrics_Func load_hmtx */
/* see `ttsbit.h' and `sfnt.h' */
PUT_EMBEDDED_BITMAPS( tt_face_load_sbit ),
+ /* TT_Load_Table_Func load_eblc */
PUT_EMBEDDED_BITMAPS( tt_face_free_sbit ),
+ /* TT_Free_Table_Func free_eblc */
PUT_EMBEDDED_BITMAPS( tt_face_set_sbit_strike ),
+ /* TT_Set_SBit_Strike_Func set_sbit_strike */
PUT_EMBEDDED_BITMAPS( tt_face_load_strike_metrics ),
+ /* TT_Load_Strike_Metrics_Func load_strike_metrics */
- tt_face_get_metrics,
+ tt_face_get_metrics, /* TT_Get_Metrics_Func get_metrics */
- tt_face_get_name
+ tt_face_get_name /* TT_Get_Name_Func get_name */
)
diff --git a/src/sfnt/sfdriver.h b/src/sfnt/sfdriver.h
index 944119c..2694488 100644
--- a/src/sfnt/sfdriver.h
+++ b/src/sfnt/sfdriver.h
@@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (specification). */
/* */
-/* 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, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __SFDRIVER_H__
-#define __SFDRIVER_H__
+#ifndef SFDRIVER_H_
+#define SFDRIVER_H_
#include <ft2build.h>
@@ -32,7 +32,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __SFDRIVER_H__ */
+#endif /* SFDRIVER_H_ */
/* END */
diff --git a/src/sfnt/sferrors.h b/src/sfnt/sferrors.h
index e3bef3f..c2f9fdf 100644
--- a/src/sfnt/sferrors.h
+++ b/src/sfnt/sferrors.h
@@ -4,7 +4,7 @@
/* */
/* SFNT error codes (specification only). */
/* */
-/* 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, */
@@ -22,12 +22,12 @@
/* */
/*************************************************************************/
-#ifndef __SFERRORS_H__
-#define __SFERRORS_H__
+#ifndef SFERRORS_H_
+#define SFERRORS_H_
#include FT_MODULE_ERRORS_H
-#undef __FTERRORS_H__
+#undef FTERRORS_H_
#undef FT_ERR_PREFIX
#define FT_ERR_PREFIX SFNT_Err_
@@ -35,6 +35,7 @@
#include FT_ERRORS_H
-#endif /* __SFERRORS_H__ */
+#endif /* SFERRORS_H_ */
+
/* END */
diff --git a/src/sfnt/sfnt.c b/src/sfnt/sfnt.c
index 0b8b5f4..952d6d4 100644
--- a/src/sfnt/sfnt.c
+++ b/src/sfnt/sfnt.c
@@ -4,7 +4,7 @@
/* */
/* Single object library component. */
/* */
-/* 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/sfnt/sfntpic.c b/src/sfnt/sfntpic.c
index 2aaf4bc..1f596c0 100644
--- a/src/sfnt/sfntpic.c
+++ b/src/sfnt/sfntpic.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
-/* 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/sfnt/sfntpic.h b/src/sfnt/sfntpic.h
index d99be6a..5ce96d3 100644
--- a/src/sfnt/sfntpic.h
+++ b/src/sfnt/sfntpic.h
@@ -4,7 +4,7 @@
/* */
/* The FreeType position independent code services for sfnt module. */
/* */
-/* 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 __SFNTPIC_H__
-#define __SFNTPIC_H__
+#ifndef SFNTPIC_H_
+#define SFNTPIC_H_
#include FT_INTERNAL_PIC_H
@@ -106,7 +106,7 @@ FT_END_HEADER
/* */
-#endif /* __SFNTPIC_H__ */
+#endif /* SFNTPIC_H_ */
/* END */
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index de030ea..ceeae20 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (base). */
/* */
-/* 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, */
@@ -949,6 +949,10 @@
instance_size * num_instances > fvar_len )
num_instances = 0;
+ /* we don't support Multiple Master CFFs yet */
+ if ( !face->goto_table( face, TTAG_CFF, stream, 0 ) )
+ num_instances = 0;
+
/* we support at most 2^15 - 1 instances */
if ( num_instances >= ( 1U << 15 ) - 1 )
{
@@ -973,7 +977,7 @@
#endif
face->root.num_faces = face->ttc_header.count;
- face->root.face_index = face_index;
+ face->root.face_index = face_instance_index;
return error;
}
@@ -1407,7 +1411,7 @@
* depths in the FT_Bitmap_Size record. This is a design error.
*/
{
- FT_UInt i, count;
+ FT_UInt count;
count = face->sbit_num_strikes;
@@ -1419,6 +1423,9 @@
FT_Short avgwidth = face->os2.xAvgCharWidth;
FT_Size_Metrics metrics;
+ FT_UInt* sbit_strike_map = NULL;
+ FT_UInt strike_idx, bsize_idx;
+
if ( em_size == 0 || face->os2.version == 0xFFFFU )
{
@@ -1426,31 +1433,50 @@
em_size = 1;
}
- if ( FT_NEW_ARRAY( root->available_sizes, count ) )
+ /* to avoid invalid strike data in the `available_sizes' field */
+ /* of `FT_Face', we map `available_sizes' indices to strike */
+ /* indices */
+ if ( FT_NEW_ARRAY( root->available_sizes, count ) ||
+ FT_NEW_ARRAY( sbit_strike_map, count ) )
goto Exit;
- for ( i = 0; i < count; i++ )
+ bsize_idx = 0;
+ for ( strike_idx = 0; strike_idx < count; strike_idx++ )
{
- FT_Bitmap_Size* bsize = root->available_sizes + i;
+ FT_Bitmap_Size* bsize = root->available_sizes + bsize_idx;
- error = sfnt->load_strike_metrics( face, i, &metrics );
+ error = sfnt->load_strike_metrics( face, strike_idx, &metrics );
if ( error )
- goto Exit;
+ continue;
bsize->height = (FT_Short)( metrics.height >> 6 );
- bsize->width = (FT_Short)(
- ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
+ bsize->width = (FT_Short)(
+ ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size );
bsize->x_ppem = metrics.x_ppem << 6;
bsize->y_ppem = metrics.y_ppem << 6;
/* assume 72dpi */
bsize->size = metrics.y_ppem << 6;
+
+ /* only use strikes with valid PPEM values */
+ if ( bsize->x_ppem && bsize->y_ppem )
+ sbit_strike_map[bsize_idx++] = strike_idx;
}
- root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
- root->num_fixed_sizes = (FT_Int)count;
+ /* reduce array size to the actually used elements */
+ (void)FT_RENEW_ARRAY( sbit_strike_map, count, bsize_idx );
+
+ /* from now on, all strike indices are mapped */
+ /* using `sbit_strike_map' */
+ if ( bsize_idx )
+ {
+ face->sbit_strike_map = sbit_strike_map;
+
+ root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
+ root->num_fixed_sizes = (FT_Int)bsize_idx;
+ }
}
}
@@ -1644,6 +1670,7 @@
/* freeing sbit size table */
FT_FREE( face->root.available_sizes );
+ FT_FREE( face->sbit_strike_map );
face->root.num_fixed_sizes = 0;
FT_FREE( face->postscript_name );
diff --git a/src/sfnt/sfobjs.h b/src/sfnt/sfobjs.h
index 455f867..60b5698 100644
--- a/src/sfnt/sfobjs.h
+++ b/src/sfnt/sfobjs.h
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (specification). */
/* */
-/* 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, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __SFOBJS_H__
-#define __SFOBJS_H__
+#ifndef SFOBJS_H_
+#define SFOBJS_H_
#include <ft2build.h>
@@ -53,7 +53,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __SFDRIVER_H__ */
+#endif /* SFDRIVER_H_ */
/* END */
diff --git a/src/sfnt/ttbdf.c b/src/sfnt/ttbdf.c
index 098b781..f891691 100644
--- a/src/sfnt/ttbdf.c
+++ b/src/sfnt/ttbdf.c
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded BDF properties (body). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-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/sfnt/ttbdf.h b/src/sfnt/ttbdf.h
index fe4ba48..ae521c6 100644
--- a/src/sfnt/ttbdf.h
+++ b/src/sfnt/ttbdf.h
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded BDF properties (specification). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTBDF_H__
-#define __TTBDF_H__
+#ifndef TTBDF_H_
+#define TTBDF_H_
#include <ft2build.h>
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTBDF_H__ */
+#endif /* TTBDF_H_ */
/* END */
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index 2b1337f..cd7467d 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) 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, */
@@ -763,6 +763,9 @@
static void
tt_cmap4_next( TT_CMap4 cmap )
{
+ TT_Face face = (TT_Face)cmap->cmap.cmap.charmap.face;
+ FT_Byte* limit = face->cmap_table + face->cmap_size;
+
FT_UInt charcode;
@@ -788,15 +791,19 @@
FT_Byte* p = values + 2 * ( charcode - cmap->cur_start );
+ /* if p > limit, the whole segment is invalid */
+ if ( p > limit )
+ goto Next_Segment;
+
do
{
FT_UInt gindex = FT_NEXT_USHORT( p );
- if ( gindex != 0 )
+ if ( gindex )
{
gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
- if ( gindex != 0 )
+ if ( gindex )
{
cmap->cur_charcode = charcode;
cmap->cur_gindex = gindex;
@@ -812,7 +819,26 @@
FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
- if ( gindex != 0 )
+ if ( gindex >= (FT_UInt)face->root.num_glyphs )
+ {
+ /* we have an invalid glyph index; if there is an overflow, */
+ /* we can adjust `charcode', otherwise the whole segment is */
+ /* invalid */
+ gindex = 0;
+
+ if ( (FT_Int)charcode + delta < 0 &&
+ (FT_Int)end + delta >= 0 )
+ charcode = (FT_UInt)( -delta );
+
+ else if ( (FT_Int)charcode + delta < 0x10000L &&
+ (FT_Int)end + delta >= 0x10000L )
+ charcode = (FT_UInt)( 0x10000L - delta );
+
+ else
+ goto Next_Segment;
+ }
+
+ if ( gindex )
{
cmap->cur_charcode = charcode;
cmap->cur_gindex = gindex;
@@ -822,6 +848,7 @@
}
}
+ Next_Segment:
/* we need to find another range */
if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 )
break;
@@ -1170,6 +1197,9 @@
FT_UInt32* pcharcode,
FT_Bool next )
{
+ TT_Face face = (TT_Face)cmap->cmap.charmap.face;
+ FT_Byte* limit = face->cmap_table + face->cmap_size;
+
FT_UInt num_segs2, start, end, offset;
FT_Int delta;
FT_UInt max, min, mid, num_segs;
@@ -1221,10 +1251,6 @@
if ( mid >= num_segs - 1 &&
start == 0xFFFFU && end == 0xFFFFU )
{
- TT_Face face = (TT_Face)cmap->cmap.charmap.face;
- FT_Byte* limit = face->cmap_table + face->cmap_size;
-
-
if ( offset && p + offset + 2 > limit )
{
delta = 1;
@@ -1245,7 +1271,7 @@
mid = max + 1;
/* search in segments before the current segment */
- for ( i = max ; i > 0; i-- )
+ for ( i = max; i > 0; i-- )
{
FT_UInt prev_end;
FT_Byte* old_p;
@@ -1347,13 +1373,40 @@
if ( offset )
{
p += offset + ( charcode - start ) * 2;
+
+ /* if p > limit, the whole segment is invalid */
+ if ( next && p > limit )
+ break;
+
gindex = TT_PEEK_USHORT( p );
- if ( gindex != 0 )
+ if ( gindex )
+ {
gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU;
+ if ( gindex >= (FT_UInt)face->root.num_glyphs )
+ gindex = 0;
+ }
}
else
+ {
gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU;
+ if ( next && gindex >= (FT_UInt)face->root.num_glyphs )
+ {
+ /* we have an invalid glyph index; if there is an overflow, */
+ /* we can adjust `charcode', otherwise the whole segment is */
+ /* invalid */
+ gindex = 0;
+
+ if ( (FT_Int)charcode + delta < 0 &&
+ (FT_Int)end + delta >= 0 )
+ charcode = (FT_UInt)( -delta );
+
+ else if ( (FT_Int)charcode + delta < 0x10000L &&
+ (FT_Int)end + delta >= 0x10000L )
+ charcode = (FT_UInt)( 0x10000L - delta );
+ }
+ }
+
break;
}
}
@@ -3104,7 +3157,7 @@
if ( char_code < start )
max = mid;
- else if ( char_code > start+cnt )
+ else if ( char_code > start + cnt )
min = mid + 1;
else
return TRUE;
diff --git a/src/sfnt/ttcmap.h b/src/sfnt/ttcmap.h
index b7ea8ee..2273cbd 100644
--- a/src/sfnt/ttcmap.h
+++ b/src/sfnt/ttcmap.h
@@ -4,7 +4,7 @@
/* */
/* TrueType character mapping table (cmap) support (specification). */
/* */
-/* 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, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTCMAP_H__
-#define __TTCMAP_H__
+#ifndef TTCMAP_H_
+#define TTCMAP_H_
#include <ft2build.h>
@@ -152,7 +152,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTCMAP_H__ */
+#endif /* TTCMAP_H_ */
/* END */
diff --git a/src/sfnt/ttcmapc.h b/src/sfnt/ttcmapc.h
index 4a48940..7c732fb 100644
--- a/src/sfnt/ttcmapc.h
+++ b/src/sfnt/ttcmapc.h
@@ -4,7 +4,7 @@
/* */
/* TT CMAP classes definitions (specification only). */
/* */
-/* 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/sfnt/ttkern.c b/src/sfnt/ttkern.c
index 4fccc53..6f9fa52 100644
--- a/src/sfnt/ttkern.c
+++ b/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-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/sfnt/ttkern.h b/src/sfnt/ttkern.h
index 89cb24f..85dd5c3 100644
--- a/src/sfnt/ttkern.h
+++ b/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-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, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __TTKERN_H__
-#define __TTKERN_H__
+#ifndef TTKERN_H_
+#define TTKERN_H_
#include <ft2build.h>
@@ -46,7 +46,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTKERN_H__ */
+#endif /* TTKERN_H_ */
/* END */
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index c1bd7f0..a653a71 100644
--- a/src/sfnt/ttload.c
+++ b/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-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, */
@@ -775,15 +775,6 @@
maxProfile->maxTwilightPoints = 0xFFFFU - 4;
}
-
- /* we arbitrarily limit recursion to avoid stack exhaustion */
- if ( maxProfile->maxComponentDepth > 100 )
- {
- FT_TRACE0(( "tt_face_load_maxp:"
- " abnormally large component depth (%d) set to 100\n",
- maxProfile->maxComponentDepth ));
- maxProfile->maxComponentDepth = 100;
- }
}
FT_TRACE3(( "numGlyphs: %u\n", maxProfile->numGlyphs ));
@@ -1193,8 +1184,8 @@
#define FT_STRUCTURE TT_Postscript
FT_FRAME_START( 32 ),
- FT_FRAME_ULONG( FormatType ),
- FT_FRAME_ULONG( italicAngle ),
+ FT_FRAME_LONG ( FormatType ),
+ FT_FRAME_LONG ( italicAngle ),
FT_FRAME_SHORT( underlinePosition ),
FT_FRAME_SHORT( underlineThickness ),
FT_FRAME_ULONG( isFixedPitch ),
diff --git a/src/sfnt/ttload.h b/src/sfnt/ttload.h
index a6d91c5..bec42b9 100644
--- a/src/sfnt/ttload.h
+++ b/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-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, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __TTLOAD_H__
-#define __TTLOAD_H__
+#ifndef TTLOAD_H_
+#define TTLOAD_H_
#include <ft2build.h>
@@ -106,7 +106,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTLOAD_H__ */
+#endif /* TTLOAD_H_ */
/* END */
diff --git a/src/sfnt/ttmtx.c b/src/sfnt/ttmtx.c
index 58309aa..186f873 100644
--- a/src/sfnt/ttmtx.c
+++ b/src/sfnt/ttmtx.c
@@ -4,7 +4,7 @@
/* */
/* Load the metrics tables common to TTF and OTF fonts (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, */
diff --git a/src/sfnt/ttmtx.h b/src/sfnt/ttmtx.h
index 096ee06..78395de 100644
--- a/src/sfnt/ttmtx.h
+++ b/src/sfnt/ttmtx.h
@@ -4,7 +4,7 @@
/* */
/* Load the metrics tables common to TTF and OTF fonts (specification). */
/* */
-/* 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, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTMTX_H__
-#define __TTMTX_H__
+#ifndef TTMTX_H_
+#define TTMTX_H_
#include <ft2build.h>
@@ -49,7 +49,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTMTX_H__ */
+#endif /* TTMTX_H_ */
/* END */
diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c
index 8d29d1e..3277f1e 100644
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -2,10 +2,10 @@
/* */
/* ttpost.c */
/* */
-/* Postcript name table processing for TrueType and OpenType fonts */
+/* PostScript name table processing for TrueType and OpenType fonts */
/* (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/sfnt/ttpost.h b/src/sfnt/ttpost.h
index e3eca02..ede45fd 100644
--- a/src/sfnt/ttpost.h
+++ b/src/sfnt/ttpost.h
@@ -2,10 +2,10 @@
/* */
/* ttpost.h */
/* */
-/* Postcript name table processing for TrueType and OpenType fonts */
+/* PostScript name table processing for TrueType and OpenType fonts */
/* (specification). */
/* */
-/* 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, */
@@ -17,8 +17,8 @@
/***************************************************************************/
-#ifndef __TTPOST_H__
-#define __TTPOST_H__
+#ifndef TTPOST_H_
+#define TTPOST_H_
#include <ft2build.h>
@@ -40,7 +40,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTPOST_H__ */
+#endif /* TTPOST_H_ */
/* END */
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 09260b8..0a90111 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded bitmap support (body). */
/* */
-/* Copyright 2005-2015 by */
+/* Copyright 2005-2016 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* Copyright 2013 by Google, Inc. */
@@ -197,6 +197,27 @@
if ( !error )
FT_TRACE3(( "sbit_num_strikes: %u\n", face->sbit_num_strikes ));
+ face->ebdt_start = 0;
+ face->ebdt_size = 0;
+
+ if ( face->sbit_table_type != TT_SBIT_TABLE_TYPE_NONE )
+ {
+ FT_ULong ebdt_size;
+
+
+ error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size );
+ if ( error )
+ error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
+ if ( error )
+ error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
+
+ if ( !error )
+ {
+ face->ebdt_start = FT_STREAM_POS();
+ face->ebdt_size = ebdt_size;
+ }
+ }
+
return FT_Err_Ok;
Exit:
@@ -239,8 +260,22 @@
FT_ULong strike_index,
FT_Size_Metrics* metrics )
{
- if ( strike_index >= (FT_ULong)face->sbit_num_strikes )
- return FT_THROW( Invalid_Argument );
+ /* we have to test for the existence of `sbit_strike_map' */
+ /* because the function gets also used at the very beginning */
+ /* to construct `sbit_strike_map' itself */
+ if ( face->sbit_strike_map )
+ {
+ if ( strike_index >= (FT_ULong)face->root.num_fixed_sizes )
+ return FT_THROW( Invalid_Argument );
+
+ /* map to real index */
+ strike_index = face->sbit_strike_map[strike_index];
+ }
+ else
+ {
+ if ( strike_index >= (FT_ULong)face->sbit_num_strikes )
+ return FT_THROW( Invalid_Argument );
+ }
switch ( (FT_UInt)face->sbit_table_type )
{
@@ -284,7 +319,8 @@
FT_TRACE2(( "tt_face_load_strike_metrics:"
" sanitizing invalid ascender and descender\n"
" "
- " values for strike (%d, %d)\n",
+ " values for strike %d (%dppem, %dppem)\n",
+ strike_index,
metrics->x_ppem, metrics->y_ppem ));
/* sanitize buggy ascender and descender values */
@@ -323,6 +359,16 @@
strike[18] + /* max_width */
(FT_Char)strike[23] /* min_advance_SB */
) * 64;
+
+ /* set the scale values (in 16.16 units) so advances */
+ /* from the hmtx and vmtx table are scaled correctly */
+ metrics->x_scale = FT_MulDiv( metrics->x_ppem,
+ 64 * 0x10000,
+ face->header.Units_Per_EM );
+ metrics->y_scale = FT_MulDiv( metrics->y_ppem,
+ 64 * 0x10000,
+ face->header.Units_Per_EM );
+
return FT_Err_Ok;
}
@@ -414,17 +460,15 @@
FT_ULong strike_index,
TT_SBit_MetricsRec* metrics )
{
- FT_Error error;
+ FT_Error error = FT_ERR( Table_Missing );
FT_Stream stream = face->root.stream;
- FT_ULong ebdt_size;
- error = face->goto_table( face, TTAG_CBDT, stream, &ebdt_size );
- if ( error )
- error = face->goto_table( face, TTAG_EBDT, stream, &ebdt_size );
- if ( error )
- error = face->goto_table( face, TTAG_bdat, stream, &ebdt_size );
- if ( error )
+ strike_index = face->sbit_strike_map[strike_index];
+
+ if ( !face->ebdt_size )
+ goto Exit;
+ if ( FT_STREAM_SEEK( face->ebdt_start ) )
goto Exit;
decoder->face = face;
@@ -435,8 +479,8 @@
decoder->metrics_loaded = 0;
decoder->bitmap_allocated = 0;
- decoder->ebdt_start = FT_STREAM_POS();
- decoder->ebdt_size = ebdt_size;
+ decoder->ebdt_start = face->ebdt_start;
+ decoder->ebdt_size = face->ebdt_size;
decoder->eblc_base = face->sbit_table;
decoder->eblc_limit = face->sbit_table + face->sbit_table_size;
@@ -854,7 +898,7 @@
}
*pwrite++ |= ( ( rval >> nbits ) & 0xFF ) &
- ( ~( 0xFF << w ) << ( 8 - w - x_pos ) );
+ ( ~( 0xFFU << w ) << ( 8 - w - x_pos ) );
rval <<= 8;
w = line_bits - w;
@@ -1383,6 +1427,8 @@
FT_UNUSED( map );
+ strike_index = face->sbit_strike_map[strike_index];
+
metrics->width = 0;
metrics->height = 0;
diff --git a/src/sfnt/ttsbit.h b/src/sfnt/ttsbit.h
index d4e13ae..d8a8167 100644
--- a/src/sfnt/ttsbit.h
+++ b/src/sfnt/ttsbit.h
@@ -4,7 +4,7 @@
/* */
/* TrueType and OpenType embedded bitmap support (specification). */
/* */
-/* 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, */
@@ -16,8 +16,8 @@
/***************************************************************************/
-#ifndef __TTSBIT_H__
-#define __TTSBIT_H__
+#ifndef TTSBIT_H_
+#define TTSBIT_H_
#include <ft2build.h>
@@ -57,7 +57,7 @@ FT_BEGIN_HEADER
FT_END_HEADER
-#endif /* __TTSBIT_H__ */
+#endif /* TTSBIT_H_ */
/* END */