summaryrefslogtreecommitdiffstats
path: root/src/sfnt
diff options
context:
space:
mode:
Diffstat (limited to 'src/sfnt')
-rw-r--r--src/sfnt/sfdriver.c19
-rw-r--r--src/sfnt/sfobjs.c76
-rw-r--r--src/sfnt/ttload.c2
-rw-r--r--src/sfnt/ttmtx.c4
-rw-r--r--src/sfnt/ttsbit.c2
5 files changed, 58 insertions, 45 deletions
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index b74679b..247aa67 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -4,7 +4,7 @@
/* */
/* High-level SFNT driver interface (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010 by */
+/* Copyright 1996-2007, 2009-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -117,15 +117,20 @@
FT_ULong *offset,
FT_ULong *length )
{
- if ( !tag || !offset || !length )
+ if ( !offset || !length )
return SFNT_Err_Invalid_Argument;
- if ( idx >= face->num_tables )
- return SFNT_Err_Table_Missing;
+ if ( !tag )
+ *length = face->num_tables;
+ else
+ {
+ if ( idx >= face->num_tables )
+ return SFNT_Err_Table_Missing;
- *tag = face->dir_tables[idx].Tag;
- *offset = face->dir_tables[idx].Offset;
- *length = face->dir_tables[idx].Length;
+ *tag = face->dir_tables[idx].Tag;
+ *offset = face->dir_tables[idx].Offset;
+ *length = face->dir_tables[idx].Length;
+ }
return SFNT_Err_Ok;
}
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 5a1d003..44471f6 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -4,7 +4,7 @@
/* */
/* SFNT object management (base). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010 by */
+/* Copyright 1996-2008, 2010-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -356,7 +356,7 @@
FT_FRAME_START( 8 ),
FT_FRAME_LONG( version ),
- FT_FRAME_LONG( count ),
+ FT_FRAME_LONG( count ), /* this is ULong in the specs */
FT_FRAME_END
};
@@ -390,6 +390,17 @@
if ( FT_STREAM_READ_FIELDS( ttc_header_fields, &face->ttc_header ) )
return error;
+ if ( face->ttc_header.count == 0 )
+ return SFNT_Err_Invalid_Table;
+
+ /* a rough size estimate: let's conservatively assume that there */
+ /* is just a single table info in each subfont header (12 + 16*1 = */
+ /* 28 bytes), thus we have (at least) `12 + 4*count' bytes for the */
+ /* size of the TTC header plus `28*count' bytes for all subfont */
+ /* headers */
+ if ( (FT_ULong)face->ttc_header.count > stream->size / ( 28 + 4 ) )
+ return SFNT_Err_Array_Too_Large;
+
/* now read the offsets of each font in the file */
if ( FT_NEW_ARRAY( face->ttc_header.offsets, face->ttc_header.count ) )
return error;
@@ -536,7 +547,7 @@
FT_UNUSED( face_index );
/* Check parameters */
-
+
{
FT_Int i;
@@ -571,12 +582,12 @@
/* do we have outlines in there? */
#ifdef FT_CONFIG_OPTION_INCREMENTAL
- has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 ||
- tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
- tt_face_lookup_table( face, TTAG_CFF ) != 0 );
+ has_outline = FT_BOOL( face->root.internal->incremental_interface != 0 ||
+ tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
+ tt_face_lookup_table( face, TTAG_CFF ) != 0 );
#else
- has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
- tt_face_lookup_table( face, TTAG_CFF ) != 0 );
+ has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) != 0 ||
+ tt_face_lookup_table( face, TTAG_CFF ) != 0 );
#endif
is_apple_sbit = 0;
@@ -651,8 +662,9 @@
if ( face->format_tag == TTAG_true )
{
FT_TRACE2(( "This is an SFNT Mac font.\n" ));
+
has_outline = 0;
- error = SFNT_Err_Ok;
+ error = SFNT_Err_Ok;
}
else
{
@@ -987,40 +999,36 @@
/* table cannot be used to compute the text height reliably! */
/* */
- /* The ascender/descender/height are computed from the OS/2 table */
- /* when found. Otherwise, they're taken from the horizontal */
- /* header. */
- /* */
+ /* The ascender and descender are taken from the `hhea' table. */
+ /* If zero, they are taken from the `OS/2' table. */
root->ascender = face->horizontal.Ascender;
root->descender = face->horizontal.Descender;
- root->height = (FT_Short)( root->ascender - root->descender +
- face->horizontal.Line_Gap );
-
-#if 0
- /* if the line_gap is 0, we add an extra 15% to the text height -- */
- /* this computation is based on various versions of Times New Roman */
- if ( face->horizontal.Line_Gap == 0 )
- root->height = (FT_Short)( ( root->height * 115 + 50 ) / 100 );
-#endif /* 0 */
+ root->height = (FT_Short)( root->ascender - root->descender +
+ face->horizontal.Line_Gap );
-#if 0
- /* some fonts have the OS/2 "sTypoAscender", "sTypoDescender" & */
- /* "sTypoLineGap" fields set to 0, like ARIALNB.TTF */
- if ( face->os2.version != 0xFFFFU && root->ascender )
+ if ( !( root->ascender || root->descender ) )
{
- FT_Int height;
-
+ if ( face->os2.version != 0xFFFFU )
+ {
+ if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
+ {
+ root->ascender = face->os2.sTypoAscender;
+ root->descender = face->os2.sTypoDescender;
- root->ascender = face->os2.sTypoAscender;
- root->descender = -face->os2.sTypoDescender;
+ root->height = (FT_Short)( root->ascender - root->descender +
+ face->os2.sTypoLineGap );
+ }
+ else
+ {
+ root->ascender = (FT_Short)face->os2.usWinAscent;
+ root->descender = -(FT_Short)face->os2.usWinDescent;
- height = root->ascender + root->descender + face->os2.sTypoLineGap;
- if ( height > root->height )
- root->height = height;
+ root->height = (FT_UShort)( root->ascender - root->descender );
+ }
+ }
}
-#endif /* 0 */
root->max_advance_width = face->horizontal.advance_Width_Max;
root->max_advance_height = (FT_Short)( face->vertical_info
diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c
index 20bac73..5fb9aea 100644
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -1213,7 +1213,7 @@
FT_Memory memory = stream->memory;
FT_UInt j,num_ranges;
- TT_GaspRange gaspranges;
+ TT_GaspRange gaspranges = NULL;
/* the gasp table is optional */
diff --git a/src/sfnt/ttmtx.c b/src/sfnt/ttmtx.c
index 53e6ac7..73ac8b2 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, 2007, 2008, 2009 by */
+/* Copyright 2006-2009, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -163,7 +163,7 @@
{
FT_TRACE0(( "tt_face_load_hmtx:"
" %cmtx has more metrics than glyphs.\n",
- vertical ? "v" : "h" ));
+ vertical ? 'v' : 'h' ));
/* Adobe simply ignores this problem. So we shall do the same. */
#if 0
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index faa8f88..283ba7e 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -1343,7 +1343,7 @@
/* All right, we have a compound format. First of all, read */
/* the array of elements. */
{
- TT_SBit_Component components;
+ TT_SBit_Component components = NULL;
TT_SBit_Component comp;
FT_UShort num_components, count;