Index: third_party/freetype/src/sfnt/ttload.c |
diff --git a/core/src/fxge/fx_freetype/fxft2.5.01/src/sfnt/ttload.c b/third_party/freetype/src/sfnt/ttload.c |
similarity index 96% |
rename from core/src/fxge/fx_freetype/fxft2.5.01/src/sfnt/ttload.c |
rename to third_party/freetype/src/sfnt/ttload.c |
index 95eb2bb14cbc65dbb146a4e6a00249913454341f..8338150abd4adcbaa7259258e7b68905de11fd59 100644 |
--- a/core/src/fxge/fx_freetype/fxft2.5.01/src/sfnt/ttload.c |
+++ b/third_party/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, 2013 by */ |
+/* Copyright 1996-2010, 2012-2014 by */ |
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
/* */ |
/* This file is part of the FreeType project, and may only be used, */ |
@@ -17,10 +17,10 @@ |
/***************************************************************************/ |
-#include "../../include/ft2build.h" |
-#include "../../include/freetype/internal/ftdebug.h" |
-#include "../../include/freetype/internal/ftstream.h" |
-#include "../../include/freetype/tttags.h" |
+#include <ft2build.h> |
+#include FT_INTERNAL_DEBUG_H |
+#include FT_INTERNAL_STREAM_H |
+#include FT_TRUETYPE_TAGS_H |
#include "ttload.h" |
#include "sferrors.h" |
@@ -53,22 +53,6 @@ |
/* A pointer to the table directory entry. 0 if not found. */ |
/* */ |
FT_LOCAL_DEF( TT_Table ) |
- tt_face_get_nexttable(TT_Table first, TT_Table limit, TT_Table entry) |
- { |
- TT_Table temp = NULL; |
- if (!entry) return NULL; |
- |
- for (; first < limit; first++){ |
- if (entry->Offset + entry->Length <= first->Offset){ |
- if (!temp || first->Offset < temp->Offset){ |
- temp = first; |
- } |
- } |
- } |
- return temp; |
- } |
- |
- FT_LOCAL_DEF( TT_Table ) |
tt_face_lookup_table( TT_Face face, |
FT_ULong tag ) |
{ |
@@ -97,11 +81,6 @@ |
{ |
if ( entry->Length != 0 ) |
{ |
- if (tag == TTAG_loca){ |
- TT_Table next = tt_face_get_nexttable(face->dir_tables, limit, entry); |
- if (next && entry->Offset + entry->Length < next->Offset) |
- entry->Length = next->Offset - entry->Offset; |
- } |
FT_TRACE4(( "found table.\n" )); |
return entry; |
} |
@@ -150,7 +129,7 @@ |
FT_ULong* length ) |
{ |
TT_Table table; |
- FT_Error error = 0; |
+ FT_Error error; |
table = tt_face_lookup_table( face, tag ); |
@@ -228,10 +207,11 @@ |
} |
/* we ignore invalid tables */ |
- if ( table.Offset + table.Length > stream->size ) |
+ |
+ /* table.Offset + table.Length > stream->size ? */ |
+ if ( table.Length > stream->size || |
+ table.Offset > stream->size - table.Length ) |
{ |
- //BUGID: 53876, the cmap table is invalid, the font file couldn't be used. |
- if (table.Tag == TTAG_cmap) break; |
FT_TRACE2(( "check_table_dir: table entry %d invalid\n", nn )); |
continue; |
} |
@@ -259,7 +239,8 @@ |
*/ |
if ( table.Length < 0x36 ) |
{ |
- FT_TRACE2(( "check_table_dir: `head' table too small\n" )); |
+ FT_TRACE2(( "check_table_dir:" |
+ " `head' or `bhed' table too small\n" )); |
error = FT_THROW( Table_Missing ); |
goto Exit; |
} |
@@ -269,12 +250,8 @@ |
goto Exit; |
if ( magic != 0x5F0F3CF5UL ) |
- { |
FT_TRACE2(( "check_table_dir:" |
- " no magic number found in `head' table\n")); |
- error = FT_THROW( Table_Missing ); |
- goto Exit; |
- } |
+ " invalid magic number in `head' or `bhed' table\n")); |
if ( FT_STREAM_SEEK( offset + ( nn + 1 ) * 16 ) ) |
goto Exit; |
@@ -417,11 +394,14 @@ |
{ |
entry->Tag = FT_GET_TAG4(); |
entry->CheckSum = FT_GET_ULONG(); |
- entry->Offset = FT_GET_LONG(); |
- entry->Length = FT_GET_LONG(); |
+ entry->Offset = FT_GET_ULONG(); |
+ entry->Length = FT_GET_ULONG(); |
/* ignore invalid tables */ |
- if ( entry->Offset + entry->Length > stream->size ) |
+ |
+ /* entry->Offset + entry->Length > stream->size ? */ |
+ if ( entry->Length > stream->size || |
+ entry->Offset > stream->size - entry->Length ) |
continue; |
else |
{ |
@@ -1029,7 +1009,8 @@ |
FT_FRAME_END |
}; |
- static const FT_Frame_Field os2_fields_extra[] = |
+ /* `OS/2' version 1 and newer */ |
+ static const FT_Frame_Field os2_fields_extra1[] = |
{ |
FT_FRAME_START( 8 ), |
FT_FRAME_ULONG( ulCodePageRange1 ), |
@@ -1037,6 +1018,7 @@ |
FT_FRAME_END |
}; |
+ /* `OS/2' version 2 and newer */ |
static const FT_Frame_Field os2_fields_extra2[] = |
{ |
FT_FRAME_START( 10 ), |
@@ -1048,6 +1030,15 @@ |
FT_FRAME_END |
}; |
+ /* `OS/2' version 5 and newer */ |
+ static const FT_Frame_Field os2_fields_extra5[] = |
+ { |
+ FT_FRAME_START( 4 ), |
+ FT_FRAME_USHORT( usLowerOpticalPointSize ), |
+ FT_FRAME_USHORT( usUpperOpticalPointSize ), |
+ FT_FRAME_END |
+ }; |
+ |
/* We now support old Mac fonts where the OS/2 table doesn't */ |
/* exist. Simply put, we set the `version' field to 0xFFFF */ |
@@ -1061,18 +1052,20 @@ |
if ( FT_STREAM_READ_FIELDS( os2_fields, os2 ) ) |
goto Exit; |
- os2->ulCodePageRange1 = 0; |
- os2->ulCodePageRange2 = 0; |
- os2->sxHeight = 0; |
- os2->sCapHeight = 0; |
- os2->usDefaultChar = 0; |
- os2->usBreakChar = 0; |
- os2->usMaxContext = 0; |
+ os2->ulCodePageRange1 = 0; |
+ os2->ulCodePageRange2 = 0; |
+ os2->sxHeight = 0; |
+ os2->sCapHeight = 0; |
+ os2->usDefaultChar = 0; |
+ os2->usBreakChar = 0; |
+ os2->usMaxContext = 0; |
+ os2->usLowerOpticalPointSize = 0; |
+ os2->usUpperOpticalPointSize = 0xFFFF; |
if ( os2->version >= 0x0001 ) |
{ |
/* only version 1 tables */ |
- if ( FT_STREAM_READ_FIELDS( os2_fields_extra, os2 ) ) |
+ if ( FT_STREAM_READ_FIELDS( os2_fields_extra1, os2 ) ) |
goto Exit; |
if ( os2->version >= 0x0002 ) |
@@ -1080,6 +1073,13 @@ |
/* only version 2 tables */ |
if ( FT_STREAM_READ_FIELDS( os2_fields_extra2, os2 ) ) |
goto Exit; |
+ |
+ if ( os2->version >= 0x0005 ) |
+ { |
+ /* only version 5 tables */ |
+ if ( FT_STREAM_READ_FIELDS( os2_fields_extra5, os2 ) ) |
+ goto Exit; |
+ } |
} |
} |
@@ -1090,10 +1090,7 @@ |
FT_TRACE3(( "fsSelection: 0x%2x\n", os2->fsSelection )); |
Exit: |
- /*return error;*/ |
- return 0; /* XYQ 2007-11-23 We can't just quit if OS/2 table can't be loaded. |
- TESTDOC: Bug #3160 - MyDoc.pdf */ |
- |
+ return error; |
} |
@@ -1190,6 +1187,7 @@ |
FT_FRAME_USHORT( Style ), |
FT_FRAME_USHORT( TypeFamily ), |
FT_FRAME_USHORT( CapHeight ), |
+ FT_FRAME_USHORT( SymbolSet ), |
FT_FRAME_BYTES ( TypeFace, 16 ), |
FT_FRAME_BYTES ( CharacterComplement, 8 ), |
FT_FRAME_BYTES ( FileName, 6 ), |