* src/base/{ftobjs.c, ftrfork.c}: recovery of Carbon-free legacy MacOS font support in freetype-2.3.4

This commit is contained in:
Suzuki, Toshiya (鈴木俊哉) 2007-11-20 14:00:17 +00:00
parent a547068835
commit 86c0f90498
3 changed files with 50 additions and 3 deletions

View File

@ -1,3 +1,36 @@
2007-11-20 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
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 <mpsuzuki@hiroshima-u.ac.jp>
Fix for Carbon incompatibilities since Mac OS X 10.5,

View File

@ -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;

View File

@ -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 );
}