[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ft-devel] Throw SFNT_Err_Table_Missing and catch FT_Err_Table_Missing?
From: |
mpsuzuki |
Subject: |
[ft-devel] Throw SFNT_Err_Table_Missing and catch FT_Err_Table_Missing? |
Date: |
Sat, 4 Oct 2008 16:36:10 +0900 |
Dear Werner,
Attached patch is the last piece for the first step to
support sfnt-wrapped CID-keyed font (by this patch,
non-suitcased sfnt-wrapped CID-keyed font can be loaded).
To check the stream is a sfnt container, including valid
table directory, but essential TrueType tables (head, bhed
and SING), I modified src/sfnt/ttload.c:check_table_dir()
to return SFNT_Err_Missing_Table in such case. Other errors
are returned by SFNT_Err_Unknown_File_Format, as original
implementation.
The error is catched by FT_Open_Face(), but my patch
compares it with FT_Err_XXX (not SFNT_Err_XXX). Same macro
should be used between the thrower and the catcher?
Regards,
mpsuzuki
Index: ChangeLog
===================================================================
RCS file: /sources/freetype/freetype2/ChangeLog,v
retrieving revision 1.1817
diff -u -r1.1817 ChangeLog
--- ChangeLog 4 Oct 2008 07:11:57 -0000 1.1817
+++ ChangeLog 4 Oct 2008 07:19:52 -0000
@@ -1,5 +1,19 @@
2008-10-04 suzuki toshiya <address@hidden>
+ * src/sfnt/sfobjs.c (sfnt_open_font): Allow 'typ1' version
+ tag in the 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 <address@hidden>
+
* src/base/ftobjs.c (ft_lookup_PS_in_sfnt): Replaced by...
(ft_lookup_PS_in_sfnt_stream): This.
(open_face_PS_from_sfnt_stream): New function. It checks
Index: src/base/ftobjs.c
===================================================================
RCS file: /sources/freetype/freetype2/src/base/ftobjs.c,v
retrieving revision 1.302
diff -u -r1.302 ftobjs.c
--- src/base/ftobjs.c 4 Oct 2008 07:11:58 -0000 1.302
+++ src/base/ftobjs.c 4 Oct 2008 07:19:52 -0000
@@ -1949,6 +1949,28 @@
if ( !error )
goto Success;
+#ifdef FT_CONFIG_OPTION_MAC_FONTS
+ if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
+ 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;
}
Index: src/sfnt/sfobjs.c
===================================================================
RCS file: /sources/freetype/freetype2/src/sfnt/sfobjs.c,v
retrieving revision 1.135
diff -u -r1.135 sfobjs.c
--- src/sfnt/sfobjs.c 1 Oct 2008 22:46:26 -0000 1.135
+++ src/sfnt/sfobjs.c 4 Oct 2008 07:19:52 -0000
@@ -367,6 +367,7 @@
tag != TTAG_ttcf &&
tag != TTAG_OTTO &&
tag != TTAG_true &&
+ tag != FT_MAKE_TAG( 't', 'y', 'p', '1' ) &&
tag != 0x00020000UL )
return SFNT_Err_Unknown_File_Format;
Index: src/sfnt/ttload.c
===================================================================
RCS file: /sources/freetype/freetype2/src/sfnt/ttload.c,v
retrieving revision 1.132
diff -u -r1.132 ttload.c
--- src/sfnt/ttload.c 4 Aug 2008 05:45:41 -0000 1.132
+++ src/sfnt/ttload.c 4 Oct 2008 07:19:53 -0000
@@ -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;
}
- [ft-devel] Throw SFNT_Err_Table_Missing and catch FT_Err_Table_Missing?,
mpsuzuki <=