From 86c0f904983b9cffe45636de8263cafe97cf9bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Suzuki=2C=20Toshiya=20=28=E9=88=B4=E6=9C=A8=E4=BF=8A?= =?UTF-8?q?=E5=93=89=29?= Date: Tue, 20 Nov 2007 14:00:17 +0000 Subject: [PATCH] * src/base/{ftobjs.c, ftrfork.c}: recovery of Carbon-free legacy MacOS font support in freetype-2.3.4 --- ChangeLog | 33 +++++++++++++++++++++++++++++++++ src/base/ftobjs.c | 8 ++++++-- src/base/ftrfork.c | 12 +++++++++++- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index a438cc7ac..c804a804c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2007-11-20 suzuki toshiya + + Fix to use MacOS legacy font support by Masatake Yamato, + on Mac OS X. It is not working since 2.3.5. In FT_Open_New(), + if FT_New_Stream() cannot mmap() specified file and cannot + seek to head of specified file, it returns NULL stream + and FT_Open_New() returns the error immediately. On MacOS, + most legacy MacOS font falls into such scenario because + their data forks are zero-sized and cannot seek. To proceed + to guessing of resource fork fonts, the functions for legacy + MacOS font must lay by NULL stream returned by FT_New_Stream(). + + * src/base/ftobjs.c (IsMacBinary): Returns an error + FT_Err_Invalid_Stream_Operation immediately when NULL stream + is passed. + + (FT_Open_Face): Even when FT_New_Stream() returns an error, + proceed to fallback. Originally, legacy MacOS font is tested + in the cases of FT_Err_Invalid_Stream_Operation (occurs when + data fork is empty) or FT_Err_Unknown_File_Format (occurs when + AppleSingle header or .dfont header is combined). + Now the case of FT_Err_Cannot_Open_Stream is included. + + * src/base/ftrfork.c (FT_Raccess_Guess): When passed stream + is NULL, skipping FT_Stream_Seek() to the head of stream + and proceed to unit testing of raccess_guess_XXX(). + FT_Stream_Seek() for NULL stream causes Bus error on Mac OS X. + + (raccess_guess_apple_double): Returns FT_Err_Cannot_Open_Stream + immediately if passed stream is NULL. + + (raccess_guess_apple_single): Ditto. + 2007-11-16 suzuki toshiya Fix for Carbon incompatibilities since Mac OS X 10.5, diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index eaf3075a6..210861b82 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -1527,6 +1527,9 @@ FT_Long dlen, offset; + if ( NULL == stream ) + return FT_Err_Invalid_Stream_Operation; + error = FT_Stream_Seek( stream, 0 ); if ( error ) goto Exit; @@ -1714,7 +1717,7 @@ /* create input stream */ error = FT_Stream_New( library, args, &stream ); if ( error ) - goto Exit; + goto Fail3; memory = library->memory; @@ -1786,7 +1789,8 @@ /* If we are on the mac, and we get an FT_Err_Invalid_Stream_Operation */ /* it may be because we have an empty data fork, so we need to check */ /* the resource fork. */ - if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format && + if ( FT_ERROR_BASE( error ) != FT_Err_Cannot_Open_Stream && + FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format && FT_ERROR_BASE( error ) != FT_Err_Invalid_Stream_Operation ) goto Fail2; diff --git a/src/base/ftrfork.c b/src/base/ftrfork.c index a4f726d93..120c2f803 100644 --- a/src/base/ftrfork.c +++ b/src/base/ftrfork.c @@ -339,7 +339,11 @@ for ( i = 0; i < FT_RACCESS_N_RULES; i++ ) { new_names[i] = NULL; - errors[i] = FT_Stream_Seek( stream, 0 ); + if ( NULL != stream ) + errors[i] = FT_Stream_Seek( stream, 0 ); + else + errors[i] = FT_Err_Ok; + if ( errors[i] ) continue ; @@ -362,6 +366,9 @@ *result_file_name = NULL; + if ( NULL == stream ) + return FT_Err_Cannot_Open_Stream; + return raccess_guess_apple_generic( library, stream, base_file_name, magic, result_offset ); } @@ -378,6 +385,9 @@ *result_file_name = NULL; + if ( NULL == stream ) + return FT_Err_Cannot_Open_Stream; + return raccess_guess_apple_generic( library, stream, base_file_name, magic, result_offset ); }