[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ft-devel] [PATCH] POSIX resource fork accessor in 2.3.8 is broken since
From: |
mpsuzuki |
Subject: |
[ft-devel] [PATCH] POSIX resource fork accessor in 2.3.8 is broken since CVS 2008-10-04 |
Date: |
Sat, 17 Jan 2009 02:59:33 +0900 |
Hi all,
When I added a preliminary support for sfnt-wrapped PostScript
Type1 & CID-keyed font on 2008-10-04, I had broken
Mac_Read_sfnt_Resource() in src/base/ftobjs.c. So,
freetype-2.3.8 on non-MacOS platforms cannot load suitcase fonts
at present. I will fix CVS soon, but if you want separated patch,
please apply attached patch. This bug is filed at:
https://savannah.nongnu.org/bugs/?25347
Regards,
mpsuzuki
--
Before all, Mac_Read_sfnt_Resource() tries to open PS Type1
or CID-keyed font in temporal sfnt stream, by calling
open_face_PS_from_sfnt_stream(), like this:
----------------------------------------------------------------
static FT_Error
Mac_Read_sfnt_Resource( FT_Library library,
FT_Stream stream,
FT_Long *offsets,
FT_Long resource_cnt,
FT_Long face_index,
FT_Face *aface )
{
...
flag_offset = offsets[face_index];
error = FT_Stream_Seek( stream, flag_offset );
if ( error )
goto Exit;
if ( FT_READ_LONG( rlen ) )
goto Exit;
if ( rlen == -1 )
return FT_Err_Cannot_Open_Resource;
error = open_face_PS_from_sfnt_stream( library,
stream,
face_index,
0, NULL,
aface );
----------------------------------------------------------------
If failed, whole of sfnt stream is copied to memory buffer, and
the buffer is passed to open_face_from_buffer() (and TrueType
face would be opened), like this.
----------------------------------------------------------------
if ( !error )
goto Exit;
if ( FT_ALLOC( sfnt_data, (FT_Long)rlen ) )
return error;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, rlen );
if ( error )
goto Exit;
is_cff = rlen > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
error = open_face_from_buffer( library,
sfnt_data,
rlen,
face_index_in_resource,
is_cff ? "cff" : "truetype",
aface );
----------------------------------------------------------------
But, this copying of sfnt stream to memory buffer is not
exact. In some case (e.g. PS Type1 nor CID-keyed font is
not found), open_face_PS_from_sfnt_stream() returns without
restoring the position of the sfnt stream, like this:
----------------------------------------------------------------
FT_LOCAL_DEF( FT_Error )
open_face_PS_from_sfnt_stream( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Int num_params,
FT_Parameter *params,
FT_Face *aface )
{
...
error = ft_lookup_PS_in_sfnt_stream( stream,
face_index,
&offset,
&length,
&is_sfnt_cid );
if ( error )
return error;
----------------------------------------------------------------
Thus, the copying of sfnt stream to memory buffer by
Mac_Read_sfnt_Resource() can make wrong image due to
unexpected position of sfnt stream.
The fix would be one of followings.
Fix 1) Improve open_face_PS_from_sfnt_stream() to restore
the position of sfnt stream always.
Fix 2) Improve Mac_Read_sfnt_Resource() to seek the sfnt
stream to correct position by itself, even if it is shifted
by open_face_PS_from_sfnt_stream().
Index: src/base/ftobjs.c
===================================================================
RCS file: /sources/freetype/freetype2/src/base/ftobjs.c,v
retrieving revision 1.318
diff -u -r1.318 ftobjs.c
--- src/base/ftobjs.c 13 Jan 2009 17:42:00 -0000 1.318
+++ src/base/ftobjs.c 16 Jan 2009 17:00:15 -0000
@@ -1417,7 +1417,7 @@
&length,
&is_sfnt_cid );
if ( error )
- return error;
+ goto Exit;
if ( FT_Stream_Seek( stream, pos + offset ) )
goto Exit;
@@ -1605,6 +1605,10 @@
if ( !error )
goto Exit;
+ /* rewind sfnt stream before open_face_PS_from_sfnt_stream() */
+ if ( FT_Stream_Seek( stream, flag_offset + 4 ) )
+ goto Exit;
+
if ( FT_ALLOC( sfnt_data, (FT_Long)rlen ) )
return error;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, rlen );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [ft-devel] [PATCH] POSIX resource fork accessor in 2.3.8 is broken since CVS 2008-10-04,
mpsuzuki <=