ref: 5a829394f6029c534e8e5823d54ebb038adcf01e
parent: 7893501c3ead6a8c2e401d8e7de52796937679b9
author: Werner Lemberg <[email protected]>
date: Tue Jun 19 00:53:30 EDT 2007
* src/winfonts/winfnt.c (fnt_face_get_dll_font): Return error FNT_Err_Invalid_File_Format if file format was recognized but the file doesn't contain any FNT(NE) or RT_FONT(PE) resources. Add verbose debug logs to make it easier to debug failing load attempts. (FNT_Face_Init): A single FNT font can't contain more than 1 face, so return an error if requested face index is > 0. Do not do further attempt to load fonts if a previous attempt has failed but returned error FNT_Err_Invalid_File_Format, i.e., the file format has been recognized but no fonts found in the file.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-06-19 Dmitry Timoshkov <[email protected]>
+
+ * src/winfonts/winfnt.c (fnt_face_get_dll_font): Return error
+ FNT_Err_Invalid_File_Format if file format was recognized but
+ the file doesn't contain any FNT(NE) or RT_FONT(PE) resources.
+ Add verbose debug logs to make it easier to debug failing load
+ attempts.
+ (FNT_Face_Init): A single FNT font can't contain more than 1 face,
+ so return an error if requested face index is > 0.
+ Do not do further attempt to load fonts if a previous attempt has
+ failed but returned error FNT_Err_Invalid_File_Format, i.e., the
+ file format has been recognized but no fonts found in the file.
+
2007-07-19 suzuki toshiya <[email protected]>
* src/base/ftmac.c: Apply patches proposed by Sean McBride.
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -343,7 +343,7 @@
if ( !font_count || !font_offset )
{
FT_TRACE2(( "this file doesn't contain any FNT resources!\n" ));
- error = FNT_Err_Unknown_File_Format;
+ error = FNT_Err_Invalid_File_Format;
goto Exit;
}
@@ -413,6 +413,7 @@
pe32_header.size_of_optional_header != 0xe0 /* FIXME */ ||
pe32_header.magic32 != 0x10b )
{
+ FT_TRACE2(( "this file has an invalid PE header\n" ));
error = FNT_Err_Invalid_File_Format;
goto Exit;
}
@@ -435,6 +436,7 @@
goto Found_rsrc_section;
}
+ FT_TRACE2(( "this file doesn't contain any resources\n" ));
error = FNT_Err_Invalid_File_Format;
goto Exit;
@@ -553,6 +555,13 @@
}
}
+ if ( !face->root.num_faces )
+ {
+ FT_TRACE2(( "this file doesn't contain any RT_FONT resources\n" ));
+ error = FNT_Err_Invalid_File_Format;
+ goto Exit;
+ }
+
if ( face_index >= face->root.num_faces )
{
error = FNT_Err_Bad_Argument;
@@ -681,12 +690,18 @@
/* try to load font from a DLL */
error = fnt_face_get_dll_font( face, face_index );
- if ( error )
+ if ( error == FNT_Err_Unknown_File_Format )
{
/* this didn't work; try to load a single FNT font */
FNT_Font font;
+ if ( face_index > 0 )
+ {
+ error = FNT_Err_Bad_Argument;
+ goto Exit;
+ }
+
if ( FT_NEW( face->font ) )
goto Exit;
@@ -697,9 +712,10 @@
font->fnt_size = stream->size;
error = fnt_font_load( font, stream );
- if ( error )
- goto Fail;
}
+
+ if ( error )
+ goto Fail;
/* we now need to fill the root FT_Face fields */
/* with relevant information */