* 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
diff --git a/ChangeLog b/ChangeLog
index 357b11f..15197b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2007-06-19 Dmitry Timoshkov <dmitry@codeweavers.com>
+
+ * 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 <mpsuzuki@hiroshima-u.ac.jp>
* src/base/ftmac.c: Apply patches proposed by Sean McBride.
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index 259b3ac..4aa9744 100644
--- 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,10 +712,11 @@
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 */
{