* `FT_Open_Face' tries `open_face_PS_from_sfnt_stream' when a sfnt container is found but not OpenType.

This commit is contained in:
Suzuki, Toshiya (鈴木俊哉) 2008-10-05 02:38:57 +00:00
parent 21bd516592
commit 2d3e0af942
4 changed files with 48 additions and 4 deletions

View File

@ -1,3 +1,17 @@
2008-10-05 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
* src/sfnt/sfobjs.c (sfnt_open_font): Allow 'typ1' version
tag in the beginning of sfnt container.
* src/sfnt/ttload.c (check_table_dir): Return
`SFNT_Err_Table_Missing' when sfnt table directory structure
is correct but essential tables for TrueType fonts (`head',
`bhed' or `SING') are missing. Other errors are returned
by SFNT_Err_Unknown_File_Format.
* src/base/ftobjs.c (FT_Open_Face): When TrueType driver returns
`FT_Err_Table_Missing', try `open_face_PS_from_sfnt_stream'.
It is enabled only when old mac font support is configured.
2008-10-04 suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
* include/freetype/tttags.h: Add TTAG_CID, TTAG_FOND, TTAG_LWFN,

View File

@ -1951,6 +1951,28 @@
if ( !error )
goto Success;
#ifdef FT_CONFIG_OPTION_MAC_FONTS
if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
FT_ERROR_BASE( error ) == FT_Err_Table_Missing )
{
/* TrueType but essential tables are missing */
if ( FT_Stream_Seek( stream, 0 ) )
break;
error = open_face_PS_from_sfnt_stream( library,
stream,
face_index,
num_params,
params,
aface );
if ( !error )
{
FT_Stream_Free( stream, external_stream );
return error;
}
}
#endif
if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format )
goto Fail3;
}

View File

@ -367,6 +367,7 @@
tag != TTAG_ttcf &&
tag != TTAG_OTTO &&
tag != TTAG_true &&
tag != TTAG_typ1 &&
tag != 0x00020000UL )
return SFNT_Err_Unknown_File_Format;

View File

@ -141,6 +141,13 @@
/* - look for a `head' table, check its size, and parse it to check */
/* whether its `magic' field is correctly set */
/* */
/* - errors (except of errors returned by stream handling) */
/* */
/* SFNT_Err_Unknown_File_Format: no table is defined in directory, */
/* it's not sfnt-wrapped data. */
/* SFNT_Err_Table_Missing: table directory is valid, but essential */
/* tables (head/bhed/SING) are missing. */
/* */
static FT_Error
check_table_dir( SFNT_Header sfnt,
FT_Stream stream )
@ -213,7 +220,7 @@
if ( table.Length < 0x36 )
{
FT_TRACE2(( "check_table_dir: `head' table too small\n" ));
error = SFNT_Err_Unknown_File_Format;
error = SFNT_Err_Table_Missing;
goto Exit;
}
@ -225,7 +232,7 @@
{
FT_TRACE2(( "check_table_dir:"
" no magic number found in `head' table\n"));
error = SFNT_Err_Unknown_File_Format;
error = SFNT_Err_Table_Missing;
goto Exit;
}
@ -261,7 +268,7 @@
#else
FT_TRACE2(( " neither `head' nor `sing' table found\n" ));
#endif
error = SFNT_Err_Unknown_File_Format;
error = SFNT_Err_Table_Missing;
}
Exit:
@ -341,7 +348,7 @@
error = check_table_dir( &sfnt, stream );
if ( error )
{
FT_TRACE2(( "tt_face_load_font_dir: invalid table directory!\n" ));
FT_TRACE2(( "tt_face_load_font_dir: invalid table directory for TrueType!\n" ));
goto Exit;
}