Index: third_party/freetype/src/base/ftobjs.c |
diff --git a/core/src/fxge/fx_freetype/fxft2.5.01/src/base/ftobjs.c b/third_party/freetype/src/base/ftobjs.c |
similarity index 94% |
rename from core/src/fxge/fx_freetype/fxft2.5.01/src/base/ftobjs.c |
rename to third_party/freetype/src/base/ftobjs.c |
index 32c9ff76c4bfe519f906aae250fff0443e1bfc2d..32a372b7fbdc069a2a803692b9f33771d2f2b5b6 100644 |
--- a/core/src/fxge/fx_freetype/fxft2.5.01/src/base/ftobjs.c |
+++ b/third_party/freetype/src/base/ftobjs.c |
@@ -4,7 +4,7 @@ |
/* */ |
/* The FreeType private base classes (body). */ |
/* */ |
-/* Copyright 1996-2013 by */ |
+/* Copyright 1996-2014 by */ |
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
/* */ |
/* This file is part of the FreeType project, and may only be used, */ |
@@ -16,26 +16,26 @@ |
/***************************************************************************/ |
-#include "../../include/ft2build.h" |
-#include "../../include/freetype/ftlist.h" |
-#include "../../include/freetype/ftoutln.h" |
-#include "../../include/freetype/internal/ftvalid.h" |
-#include "../../include/freetype/internal/ftobjs.h" |
-#include "../../include/freetype/internal/ftdebug.h" |
-#include "../../include/freetype/internal/ftrfork.h" |
-#include "../../include/freetype/internal/ftstream.h" |
-#include "../../include/freetype/internal/sfnt.h" /* for SFNT_Load_Table_Func */ |
-#include "../../include/freetype/tttables.h" |
-#include "../../include/freetype/tttags.h" |
-#include "../../include/freetype/ttnameid.h" |
- |
-#include "../../include/freetype/internal/services/svprop.h" |
-#include "../../include/freetype/internal/services/svsfnt.h" |
-#include "../../include/freetype/internal/services/svpostnm.h" |
-#include "../../include/freetype/internal/services/svgldict.h" |
-#include "../../include/freetype/internal/services/svttcmap.h" |
-#include "../../include/freetype/internal/services/svkern.h" |
-#include "../../include/freetype/internal/services/svtteng.h" |
+#include <ft2build.h> |
+#include FT_LIST_H |
+#include FT_OUTLINE_H |
+#include FT_INTERNAL_VALIDATE_H |
+#include FT_INTERNAL_OBJECTS_H |
+#include FT_INTERNAL_DEBUG_H |
+#include FT_INTERNAL_RFORK_H |
+#include FT_INTERNAL_STREAM_H |
+#include FT_INTERNAL_SFNT_H /* for SFNT_Load_Table_Func */ |
+#include FT_TRUETYPE_TABLES_H |
+#include FT_TRUETYPE_TAGS_H |
+#include FT_TRUETYPE_IDS_H |
+ |
+#include FT_SERVICE_PROPERTIES_H |
+#include FT_SERVICE_SFNT_H |
+#include FT_SERVICE_POSTSCRIPT_NAME_H |
+#include FT_SERVICE_GLYPH_DICT_H |
+#include FT_SERVICE_TT_CMAP_H |
+#include FT_SERVICE_KERNING_H |
+#include FT_SERVICE_TRUETYPE_ENGINE_H |
#ifdef FT_CONFIG_OPTION_MAC_FONTS |
#include "ftbase.h" |
@@ -44,7 +44,7 @@ |
#ifdef FT_DEBUG_LEVEL_TRACE |
-#include "../../include/freetype/ftbitmap.h" |
+#include FT_BITMAP_H |
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */ |
/* We disable the warning `conversion from XXX to YYY, */ |
@@ -56,9 +56,7 @@ |
#endif /* _MSC_VER */ |
/* it's easiest to include `md5.c' directly */ |
-#define free md5_free /* suppress a shadow warning */ |
#include "md5.c" |
-#undef free |
#if defined( _MSC_VER ) |
#pragma warning( pop ) |
@@ -410,7 +408,10 @@ |
FT_GlyphSlot slot = NULL; |
- if ( !face || !face->driver ) |
+ if ( !face ) |
+ return FT_THROW( Invalid_Face_Handle ); |
+ |
+ if ( !face->driver ) |
return FT_THROW( Invalid_Argument ); |
driver = face->driver; |
@@ -510,6 +511,7 @@ |
internal->transform_matrix.xy = 0; |
internal->transform_matrix.yx = 0; |
internal->transform_matrix.yy = 0x10000L; |
+ |
matrix = &internal->transform_matrix; |
} |
else |
@@ -525,6 +527,7 @@ |
{ |
internal->transform_delta.x = 0; |
internal->transform_delta.y = 0; |
+ |
delta = &internal->transform_delta; |
} |
else |
@@ -667,11 +670,18 @@ |
/* the check for `num_locations' assures that we actually */ |
/* test for instructions in a TTF and not in a CFF-based OTF */ |
+ /* */ |
+ /* since `maxSizeOfInstructions' might be unreliable, we */ |
+ /* check the size of the `fpgm' and `prep' tables, too -- */ |
+ /* the assumption is that there don't exist real TTFs where */ |
+ /* both `fpgm' and `prep' tables are missing */ |
if ( mode == FT_RENDER_MODE_LIGHT || |
face->internal->ignore_unpatented_hinter || |
( FT_IS_SFNT( face ) && |
ttface->num_locations && |
- ttface->max_profile.maxSizeOfInstructions == 0 ) ) |
+ ttface->max_profile.maxSizeOfInstructions == 0 && |
+ ttface->font_program_size == 0 && |
+ ttface->cvt_program_size == 0 ) ) |
autohint = TRUE; |
} |
} |
@@ -1035,14 +1045,6 @@ |
( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && |
cur[0]->encoding_id == TT_APPLE_ID_UNICODE_32 ) ) |
{ |
-#ifdef FT_MAX_CHARMAP_CACHEABLE |
- if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) |
- { |
- FT_ERROR(( "find_unicode_charmap: UCS-4 cmap is found " |
- "at too late position (%d)\n", cur - first )); |
- continue; |
- } |
-#endif |
face->charmap = cur[0]; |
return FT_Err_Ok; |
} |
@@ -1057,14 +1059,6 @@ |
{ |
if ( cur[0]->encoding == FT_ENCODING_UNICODE ) |
{ |
-#ifdef FT_MAX_CHARMAP_CACHEABLE |
- if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) |
- { |
- FT_ERROR(( "find_unicode_charmap: UCS-2 cmap is found " |
- "at too late position (%d)\n", cur - first )); |
- continue; |
- } |
-#endif |
face->charmap = cur[0]; |
return FT_Err_Ok; |
} |
@@ -1106,17 +1100,7 @@ |
if ( cur[0]->platform_id == TT_PLATFORM_APPLE_UNICODE && |
cur[0]->encoding_id == TT_APPLE_ID_VARIANT_SELECTOR && |
FT_Get_CMap_Format( cur[0] ) == 14 ) |
- { |
-#ifdef FT_MAX_CHARMAP_CACHEABLE |
- if ( cur - first > FT_MAX_CHARMAP_CACHEABLE ) |
- { |
- FT_ERROR(( "find_unicode_charmap: UVS cmap is found " |
- "at too late position (%d)\n", cur - first )); |
- continue; |
- } |
-#endif |
return cur[0]; |
- } |
} |
return NULL; |
@@ -1133,7 +1117,8 @@ |
/* */ |
static FT_Error |
open_face( FT_Driver driver, |
- FT_Stream stream, |
+ FT_Stream *astream, |
+ FT_Bool external_stream, |
FT_Long face_index, |
FT_Int num_params, |
FT_Parameter* params, |
@@ -1141,10 +1126,11 @@ |
{ |
FT_Memory memory; |
FT_Driver_Class clazz; |
- FT_Face face = 0; |
- FT_Error error, error2; |
+ FT_Face face = NULL; |
FT_Face_Internal internal = NULL; |
+ FT_Error error, error2; |
+ |
clazz = driver->clazz; |
memory = driver->root.memory; |
@@ -1155,7 +1141,11 @@ |
face->driver = driver; |
face->memory = memory; |
- face->stream = stream; |
+ face->stream = *astream; |
+ |
+ /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ |
+ if ( external_stream ) |
+ face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; |
if ( FT_NEW( internal ) ) |
goto Fail; |
@@ -1177,11 +1167,12 @@ |
#endif |
if ( clazz->init_face ) |
- error = clazz->init_face( stream, |
+ error = clazz->init_face( *astream, |
face, |
(FT_Int)face_index, |
num_params, |
params ); |
+ *astream = face->stream; /* Stream may have been changed. */ |
if ( error ) |
goto Fail; |
@@ -1218,7 +1209,7 @@ |
/* there's a Mac-specific extended implementation of FT_New_Face() */ |
/* in src/base/ftmac.c */ |
-//#ifndef FT_MACINTOSH |
+#ifndef FT_MACINTOSH |
/* documentation is in freetype.h */ |
@@ -1231,7 +1222,7 @@ |
FT_Open_Args args; |
- /* test for valid `library' and `aface' delayed to FT_Open_Face() */ |
+ /* test for valid `library' and `aface' delayed to `FT_Open_Face' */ |
if ( !pathname ) |
return FT_THROW( Invalid_Argument ); |
@@ -1242,7 +1233,7 @@ |
return FT_Open_Face( library, &args, face_index, aface ); |
} |
-//#endif |
+#endif |
/* documentation is in freetype.h */ |
@@ -1257,7 +1248,7 @@ |
FT_Open_Args args; |
- /* test for valid `library' and `face' delayed to FT_Open_Face() */ |
+ /* test for valid `library' and `face' delayed to `FT_Open_Face' */ |
if ( !file_base ) |
return FT_THROW( Invalid_Argument ); |
@@ -1571,9 +1562,9 @@ |
FT_Memory memory = library->memory; |
FT_Byte* pfb_data = NULL; |
int i, type, flags; |
- FT_Long len; |
- FT_Long pfb_len, pfb_pos, pfb_lenpos; |
- FT_Long rlen, temp; |
+ FT_ULong len; |
+ FT_ULong pfb_len, pfb_pos, pfb_lenpos; |
+ FT_ULong rlen, temp; |
if ( face_index == -1 ) |
@@ -1589,11 +1580,34 @@ |
error = FT_Stream_Seek( stream, offsets[i] ); |
if ( error ) |
goto Exit; |
- if ( FT_READ_LONG( temp ) ) |
+ if ( FT_READ_ULONG( temp ) ) |
goto Exit; |
+ |
+ /* FT2 allocator takes signed long buffer length, |
+ * too large value causing overflow should be checked |
+ */ |
+ FT_TRACE4(( " POST fragment #%d: length=0x%08x\n", |
+ i, temp)); |
+ if ( 0x7FFFFFFFUL < temp || pfb_len + temp + 6 < pfb_len ) |
+ { |
+ FT_TRACE2(( " too long fragment length makes" |
+ " pfb_len confused: temp=0x%08x\n", temp )); |
+ error = FT_THROW( Invalid_Offset ); |
+ goto Exit; |
+ } |
+ |
pfb_len += temp + 6; |
} |
+ FT_TRACE2(( " total buffer size to concatenate %d" |
+ " POST fragments: 0x%08x\n", |
+ resource_cnt, pfb_len + 2)); |
+ if ( pfb_len + 2 < 6 ) { |
+ FT_TRACE2(( " too long fragment length makes" |
+ " pfb_len confused: pfb_len=0x%08x\n", pfb_len )); |
+ error = FT_THROW( Array_Too_Large ); |
+ goto Exit; |
+ } |
if ( FT_ALLOC( pfb_data, (FT_Long)pfb_len + 2 ) ) |
goto Exit; |
@@ -1613,16 +1627,30 @@ |
error = FT_Stream_Seek( stream, offsets[i] ); |
if ( error ) |
goto Exit2; |
- if ( FT_READ_LONG( rlen ) ) |
- goto Exit; |
+ if ( FT_READ_ULONG( rlen ) ) |
+ goto Exit2; |
+ |
+ /* FT2 allocator takes signed long buffer length, |
+ * too large fragment length causing overflow should be checked |
+ */ |
+ if ( 0x7FFFFFFFUL < rlen ) |
+ { |
+ error = FT_THROW( Invalid_Offset ); |
+ goto Exit2; |
+ } |
+ |
if ( FT_READ_USHORT( flags ) ) |
- goto Exit; |
+ goto Exit2; |
FT_TRACE3(( "POST fragment[%d]: offsets=0x%08x, rlen=0x%08x, flags=0x%04x\n", |
i, offsets[i], rlen, flags )); |
+ error = FT_ERR( Array_Too_Large ); |
/* postpone the check of rlen longer than buffer until FT_Stream_Read() */ |
if ( ( flags >> 8 ) == 0 ) /* Comment, should not be loaded */ |
+ { |
+ FT_TRACE3(( " Skip POST fragment #%d because it is a comment\n", i )); |
continue; |
+ } |
/* the flags are part of the resource, so rlen >= 2. */ |
/* but some fonts declare rlen = 0 for empty fragment */ |
@@ -1635,6 +1663,8 @@ |
len += rlen; |
else |
{ |
+ FT_TRACE3(( " Write POST fragment #%d header (4-byte) to buffer" |
+ " 0x%p + 0x%08x\n", i, pfb_data, pfb_lenpos )); |
if ( pfb_lenpos + 3 > pfb_len + 2 ) |
goto Exit2; |
pfb_data[pfb_lenpos ] = (FT_Byte)( len ); |
@@ -1645,6 +1675,8 @@ |
if ( ( flags >> 8 ) == 5 ) /* End of font mark */ |
break; |
+ FT_TRACE3(( " Write POST fragment #%d header (6-byte) to buffer" |
+ " 0x%p + 0x%08x\n", i, pfb_data, pfb_pos )); |
if ( pfb_pos + 6 > pfb_len + 2 ) |
goto Exit2; |
pfb_data[pfb_pos++] = 0x80; |
@@ -1660,16 +1692,18 @@ |
pfb_data[pfb_pos++] = 0; |
} |
- error = FT_ERR( Cannot_Open_Resource ); |
if ( pfb_pos > pfb_len || pfb_pos + rlen > pfb_len ) |
goto Exit2; |
+ FT_TRACE3(( " Load POST fragment #%d (%d byte) to buffer" |
+ " 0x%p + 0x%08x\n", i, rlen, pfb_data, pfb_pos )); |
error = FT_Stream_Read( stream, (FT_Byte *)pfb_data + pfb_pos, rlen ); |
if ( error ) |
goto Exit2; |
pfb_pos += rlen; |
} |
+ error = FT_ERR( Array_Too_Large ); |
if ( pfb_pos + 2 > pfb_len + 2 ) |
goto Exit2; |
pfb_data[pfb_pos++] = 0x80; |
@@ -1690,6 +1724,13 @@ |
aface ); |
Exit2: |
+ if ( error == FT_ERR( Array_Too_Large ) ) |
+ FT_TRACE2(( " Abort due to too-short buffer to store" |
+ " all POST fragments\n" )); |
+ else if ( error == FT_ERR( Invalid_Offset ) ) |
+ FT_TRACE2(( " Abort due to invalid offset in a POST fragment\n" )); |
+ if ( error ) |
+ error = FT_ERR( Cannot_Open_Resource ); |
FT_FREE( pfb_data ); |
Exit: |
@@ -1789,9 +1830,10 @@ |
if ( error ) |
return error; |
+ /* POST resources must be sorted to concatenate properly */ |
error = FT_Raccess_Get_DataOffsets( library, stream, |
map_offset, rdara_pos, |
- TTAG_POST, |
+ TTAG_POST, TRUE, |
&data_offsets, &count ); |
if ( !error ) |
{ |
@@ -1804,9 +1846,11 @@ |
return error; |
} |
+ /* sfnt resources should not be sorted to preserve the face order by |
+ QuickDraw API */ |
error = FT_Raccess_Get_DataOffsets( library, stream, |
map_offset, rdara_pos, |
- TTAG_sfnt, |
+ TTAG_sfnt, FALSE, |
&data_offsets, &count ); |
if ( !error ) |
{ |
@@ -2034,8 +2078,7 @@ |
FT_Module* limit; |
- /* test for valid `library' delayed to */ |
- /* FT_Stream_New() */ |
+ /* test for valid `library' delayed to `FT_Stream_New' */ |
if ( ( !aface && face_index >= 0 ) || !args ) |
return FT_THROW( Invalid_Argument ); |
@@ -2069,7 +2112,7 @@ |
params = args->params; |
} |
- error = open_face( driver, stream, face_index, |
+ error = open_face( driver, &stream, external_stream, face_index, |
num_params, params, &face ); |
if ( !error ) |
goto Success; |
@@ -2105,7 +2148,7 @@ |
params = args->params; |
} |
- error = open_face( driver, stream, face_index, |
+ error = open_face( driver, &stream, external_stream, face_index, |
num_params, params, &face ); |
if ( !error ) |
goto Success; |
@@ -2174,10 +2217,6 @@ |
Success: |
FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" )); |
- /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ |
- if ( external_stream ) |
- face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; |
- |
/* add the face object to its driver's list */ |
if ( FT_NEW( node ) ) |
goto Fail; |
@@ -2286,7 +2325,7 @@ |
FT_Open_Args open; |
- /* test for valid `face' delayed to FT_Attach_Stream() */ |
+ /* test for valid `face' delayed to `FT_Attach_Stream' */ |
if ( !filepathname ) |
return FT_THROW( Invalid_Argument ); |
@@ -2312,7 +2351,7 @@ |
FT_Driver_Class clazz; |
- /* test for valid `parameters' delayed to FT_Stream_New() */ |
+ /* test for valid `parameters' delayed to `FT_Stream_New' */ |
if ( !face ) |
return FT_THROW( Invalid_Face_Handle ); |
@@ -2348,6 +2387,9 @@ |
FT_EXPORT_DEF( FT_Error ) |
FT_Reference_Face( FT_Face face ) |
{ |
+ if ( !face ) |
+ return FT_THROW( Invalid_Face_Handle ); |
+ |
face->internal->refcount++; |
return FT_Err_Ok; |
@@ -2414,7 +2456,7 @@ |
return FT_THROW( Invalid_Face_Handle ); |
if ( !asize ) |
- return FT_THROW( Invalid_Size_Handle ); |
+ return FT_THROW( Invalid_Argument ); |
if ( !face->driver ) |
return FT_THROW( Invalid_Driver_Handle ); |
@@ -2923,6 +2965,8 @@ |
FT_Size_RequestRec req; |
+ /* check of `face' delayed to `FT_Request_Size' */ |
+ |
if ( !char_width ) |
char_width = char_height; |
else if ( !char_height ) |
@@ -2961,6 +3005,8 @@ |
FT_Size_RequestRec req; |
+ /* check of `face' delayed to `FT_Request_Size' */ |
+ |
if ( pixel_width == 0 ) |
pixel_width = pixel_height; |
else if ( pixel_height == 0 ) |
@@ -3111,15 +3157,6 @@ |
{ |
if ( cur[0]->encoding == encoding ) |
{ |
-#ifdef FT_MAX_CHARMAP_CACHEABLE |
- if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE ) |
- { |
- FT_ERROR(( "FT_Select_Charmap: requested charmap is found (%d), " |
- "but in too late position to cache\n", |
- cur - face->charmaps )); |
- continue; |
- } |
-#endif |
face->charmap = cur[0]; |
return 0; |
} |
@@ -3143,8 +3180,9 @@ |
return FT_THROW( Invalid_Face_Handle ); |
cur = face->charmaps; |
- if ( !cur ) |
+ if ( !cur || !charmap ) |
return FT_THROW( Invalid_CharMap_Handle ); |
+ |
if ( FT_Get_CMap_Format( charmap ) == 14 ) |
return FT_THROW( Invalid_Argument ); |
@@ -3154,19 +3192,11 @@ |
{ |
if ( cur[0] == charmap ) |
{ |
-#ifdef FT_MAX_CHARMAP_CACHEABLE |
- if ( cur - face->charmaps > FT_MAX_CHARMAP_CACHEABLE ) |
- { |
- FT_ERROR(( "FT_Set_Charmap: requested charmap is found (%d), " |
- "but in too late position to cache\n", |
- cur - face->charmaps )); |
- continue; |
- } |
-#endif |
face->charmap = cur[0]; |
- return 0; |
+ return FT_Err_Ok; |
} |
} |
+ |
return FT_THROW( Invalid_Argument ); |
} |
@@ -3188,15 +3218,6 @@ |
FT_ASSERT( i < charmap->face->num_charmaps ); |
-#ifdef FT_MAX_CHARMAP_CACHEABLE |
- if ( i > FT_MAX_CHARMAP_CACHEABLE ) |
- { |
- FT_ERROR(( "FT_Get_Charmap_Index: requested charmap is found (%d), " |
- "but in too late position to cache\n", |
- i )); |
- return -i; |
- } |
-#endif |
return i; |
} |
@@ -3349,6 +3370,7 @@ |
FT_UInt gindex = 0; |
+ /* only do something if we have a charmap, and we have glyphs at all */ |
if ( face && face->charmap && face->num_glyphs ) |
{ |
gindex = FT_Get_Char_Index( face, 0 ); |
@@ -3380,8 +3402,10 @@ |
FT_CMap cmap = FT_CMAP( face->charmap ); |
- do { |
+ do |
+ { |
gindex = cmap->clazz->char_next( cmap, &code ); |
+ |
} while ( gindex >= (FT_UInt)face->num_glyphs ); |
result = ( gindex == 0 ) ? 0 : code; |
@@ -3404,8 +3428,9 @@ |
FT_UInt result = 0; |
- if ( face && face->charmap && |
- face->charmap->encoding == FT_ENCODING_UNICODE ) |
+ if ( face && |
+ face->charmap && |
+ face->charmap->encoding == FT_ENCODING_UNICODE ) |
{ |
FT_CharMap charmap = find_variant_selector_charmap( face ); |
FT_CMap ucmap = FT_CMAP( face->charmap ); |
@@ -3583,7 +3608,9 @@ |
FT_UInt result = 0; |
- if ( face && FT_HAS_GLYPH_NAMES( face ) ) |
+ if ( face && |
+ FT_HAS_GLYPH_NAMES( face ) && |
+ glyph_name ) |
{ |
FT_Service_GlyphDict service; |
@@ -3608,27 +3635,28 @@ |
FT_Pointer buffer, |
FT_UInt buffer_max ) |
{ |
- FT_Error error = FT_ERR( Invalid_Argument ); |
+ FT_Error error; |
+ FT_Service_GlyphDict service; |
- /* clean up buffer */ |
- if ( buffer && buffer_max > 0 ) |
- ((FT_Byte*)buffer)[0] = 0; |
+ if ( !face ) |
+ return FT_THROW( Invalid_Face_Handle ); |
- if ( face && |
- (FT_Long)glyph_index < face->num_glyphs && |
- FT_HAS_GLYPH_NAMES( face ) ) |
- { |
- FT_Service_GlyphDict service; |
+ if ( !buffer || buffer_max == 0 ) |
+ return FT_THROW( Invalid_Argument ); |
+ /* clean up buffer */ |
+ ((FT_Byte*)buffer)[0] = '\0'; |
- FT_FACE_LOOKUP_SERVICE( face, |
- service, |
- GLYPH_DICT ); |
+ if ( (FT_Long)glyph_index > face->num_glyphs || |
+ !FT_HAS_GLYPH_NAMES( face ) ) |
+ return FT_THROW( Invalid_Argument ); |
- if ( service && service->get_name ) |
- error = service->get_name( face, glyph_index, buffer, buffer_max ); |
- } |
+ FT_FACE_LOOKUP_SERVICE( face, service, GLYPH_DICT ); |
+ if ( service && service->get_name ) |
+ error = service->get_name( face, glyph_index, buffer, buffer_max ); |
+ else |
+ error = FT_THROW( Invalid_Argument ); |
return error; |
} |
@@ -3669,7 +3697,7 @@ |
FT_Get_Sfnt_Table( FT_Face face, |
FT_Sfnt_Tag tag ) |
{ |
- void* table = 0; |
+ void* table = NULL; |
FT_Service_SFNT_Table service; |
@@ -3719,6 +3747,8 @@ |
FT_ULong offset; |
+ /* test for valid `length' delayed to `service->table_info' */ |
+ |
if ( !face || !FT_IS_SFNT( face ) ) |
return FT_THROW( Invalid_Face_Handle ); |
@@ -3786,12 +3816,12 @@ |
FT_Face face; |
- if ( size == NULL ) |
- return FT_THROW( Invalid_Argument ); |
+ if ( !size ) |
+ return FT_THROW( Invalid_Size_Handle ); |
face = size->face; |
- if ( face == NULL || face->driver == NULL ) |
- return FT_THROW( Invalid_Argument ); |
+ if ( !face || !face->driver ) |
+ return FT_THROW( Invalid_Face_Handle ); |
/* we don't need anything more complex than that; all size objects */ |
/* are already listed by the face */ |
@@ -3933,11 +3963,17 @@ |
static void |
ft_remove_renderer( FT_Module module ) |
{ |
- FT_Library library = module->library; |
- FT_Memory memory = library->memory; |
+ FT_Library library; |
+ FT_Memory memory; |
FT_ListNode node; |
+ library = module->library; |
+ if ( !library ) |
+ return; |
+ |
+ memory = library->memory; |
+ |
node = FT_List_Find( &library->renderers, module ); |
if ( node ) |
{ |
@@ -3964,7 +4000,7 @@ |
FT_Get_Renderer( FT_Library library, |
FT_Glyph_Format format ) |
{ |
- /* test for valid `library' delayed to FT_Lookup_Renderer() */ |
+ /* test for valid `library' delayed to `FT_Lookup_Renderer' */ |
return FT_Lookup_Renderer( library, format, 0 ); |
} |
@@ -3981,12 +4017,26 @@ |
FT_ListNode node; |
FT_Error error = FT_Err_Ok; |
+ FT_Renderer_SetModeFunc set_mode; |
+ |
if ( !library ) |
- return FT_THROW( Invalid_Library_Handle ); |
+ { |
+ error = FT_THROW( Invalid_Library_Handle ); |
+ goto Exit; |
+ } |
if ( !renderer ) |
- return FT_THROW( Invalid_Argument ); |
+ { |
+ error = FT_THROW( Invalid_Argument ); |
+ goto Exit; |
+ } |
+ |
+ if ( num_params > 0 && !parameters ) |
+ { |
+ error = FT_THROW( Invalid_Argument ); |
+ goto Exit; |
+ } |
node = FT_List_Find( &library->renderers, renderer ); |
if ( !node ) |
@@ -4000,18 +4050,14 @@ |
if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE ) |
library->cur_renderer = renderer; |
- if ( num_params > 0 ) |
- { |
- FT_Renderer_SetModeFunc set_mode = renderer->clazz->set_mode; |
- |
+ set_mode = renderer->clazz->set_mode; |
- for ( ; num_params > 0; num_params-- ) |
- { |
- error = set_mode( renderer, parameters->tag, parameters->data ); |
- if ( error ) |
- break; |
- parameters++; |
- } |
+ for ( ; num_params > 0; num_params-- ) |
+ { |
+ error = set_mode( renderer, parameters->tag, parameters->data ); |
+ if ( error ) |
+ break; |
+ parameters++; |
} |
Exit: |
@@ -4070,7 +4116,11 @@ |
/* if we changed the current renderer for the glyph image format */ |
/* we need to select it as the next current one */ |
if ( !error && update && renderer ) |
- FT_Set_Renderer( library, renderer, 0, 0 ); |
+ { |
+ error = FT_Set_Renderer( library, renderer, 0, 0 ); |
+ if ( error ) |
+ break; |
+ } |
} |
} |
@@ -4080,6 +4130,7 @@ |
#define FT_COMPONENT trace_bitmap |
/* we convert to a single bitmap format for computing the checksum */ |
+ if ( !error ) |
{ |
FT_Bitmap bitmap; |
FT_Error err; |
@@ -4087,6 +4138,7 @@ |
FT_Bitmap_New( &bitmap ); |
+ /* this also converts the bitmap flow to `down' (i.e., pitch > 0) */ |
err = FT_Bitmap_Convert( library, &slot->bitmap, &bitmap, 1 ); |
if ( !err ) |
{ |
@@ -4118,6 +4170,7 @@ |
return error; |
} |
+ |
/* documentation is in freetype.h */ |
FT_EXPORT_DEF( FT_Error ) |
@@ -4126,6 +4179,7 @@ |
{ |
FT_Library library; |
+ |
if ( !slot || !slot->face ) |
return FT_THROW( Invalid_Argument ); |
@@ -4326,7 +4380,7 @@ |
FT_Get_Module( FT_Library library, |
const char* module_name ) |
{ |
- FT_Module result = 0; |
+ FT_Module result = NULL; |
FT_Module* cur; |
FT_Module* limit; |
@@ -4451,7 +4505,7 @@ |
} |
- FT_Error |
+ static FT_Error |
ft_property_do( FT_Library library, |
const FT_String* module_name, |
const FT_String* property_name, |
@@ -4460,7 +4514,8 @@ |
{ |
FT_Module* cur; |
FT_Module* limit; |
- FT_Module_Interface interface1; |
+ FT_Module_Interface interface; |
+ |
FT_Service_Properties service; |
#ifdef FT_DEBUG_LEVEL_ERROR |
@@ -4502,16 +4557,16 @@ |
} |
/* search property service */ |
- interface1 = cur[0]->clazz->get_interface( cur[0], |
+ interface = cur[0]->clazz->get_interface( cur[0], |
FT_SERVICE_ID_PROPERTIES ); |
- if ( !interface1 ) |
+ if ( !interface ) |
{ |
FT_ERROR(( "%s: module `%s' doesn't support properties\n", |
func_name, module_name )); |
return FT_THROW( Unimplemented_Feature ); |
} |
- service = (FT_Service_Properties)interface1; |
+ service = (FT_Service_Properties)interface; |
if ( set ) |
missing_func = (FT_Bool)( !service->set_property ); |
@@ -4580,6 +4635,9 @@ |
FT_EXPORT_DEF( FT_Error ) |
FT_Reference_Library( FT_Library library ) |
{ |
+ if ( !library ) |
+ return FT_THROW( Invalid_Library_Handle ); |
+ |
library->refcount++; |
return FT_Err_Ok; |
@@ -4596,7 +4654,7 @@ |
FT_Error error; |
- if ( !memory ) |
+ if ( !memory || !alibrary ) |
return FT_THROW( Invalid_Argument ); |
#ifdef FT_DEBUG_LEVEL_ERROR |
@@ -4858,6 +4916,8 @@ |
*p_arg1 = subg->arg1; |
*p_arg2 = subg->arg2; |
*p_transform = subg->transform; |
+ |
+ error = FT_Err_Ok; |
} |
return error; |