Add new error code FT_Err_Missing_Module. Previously, FreeType misleadingly returned FT_Err_Unknown_File_Format if a module was missing (or a test was missing completely). * include/freetype/fterrdef.h (FT_Err_Missing_Module): Define. * src/cff/cffobjs.c (cff_face_init), src/cid/cidobjs.c (cid_face_init), src/sfnt/sfobjs.c (sfnt_init_face), src/truetype/ttobjs.c (tt_face_init), src/type1/t1objs.c (T1_Face_Init), src/type42/t42objs.c (T42_Face_Init, T42_Driver_Init): Updated. * src/type1/t1afm.c (T1_Read_Metrics), src/type/t1objs.c (T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Remove now redundant test for `psaux'.
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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
diff --git a/ChangeLog b/ChangeLog
index 51d4c74..7e78351 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2011-11-26 Werner Lemberg <wl@gnu.org>
+
+ Add new error code FT_Err_Missing_Module.
+
+ Previously, FreeType misleadingly returned
+ FT_Err_Unknown_File_Format if a module was missing (or a test was
+ missing completely).
+
+ * include/freetype/fterrdef.h (FT_Err_Missing_Module): Define.
+
+ * src/cff/cffobjs.c (cff_face_init), src/cid/cidobjs.c
+ (cid_face_init), src/sfnt/sfobjs.c (sfnt_init_face),
+ src/truetype/ttobjs.c (tt_face_init), src/type1/t1objs.c
+ (T1_Face_Init), src/type42/t42objs.c (T42_Face_Init,
+ T42_Driver_Init): Updated.
+
+ * src/type1/t1afm.c (T1_Read_Metrics), src/type/t1objs.c
+ (T1_Face_Init), src/type42/t42objs.c (T42_Face_Init): Remove now
+ redundant test for `psaux'.
+
2011-11-25 Werner Lemberg <wl@gnu.org>
[bdf] Add more error messages.
diff --git a/include/freetype/fterrdef.h b/include/freetype/fterrdef.h
index d4e7287..fb4b53b 100644
--- a/include/freetype/fterrdef.h
+++ b/include/freetype/fterrdef.h
@@ -4,7 +4,7 @@
/* */
/* FreeType error codes (specification). */
/* */
-/* Copyright 2002, 2004, 2006, 2007, 2010 by */
+/* Copyright 2002, 2004, 2006, 2007, 2010-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -54,6 +54,8 @@
"broken offset within table" )
FT_ERRORDEF_( Array_Too_Large, 0x0A, \
"array allocation size too large" )
+ FT_ERRORDEF_( Missing_Module, 0x0B, \
+ "missing module" )
/* glyph/character errors */
diff --git a/modules.cfg b/modules.cfg
index 8d5b6b5..a85378e 100644
--- a/modules.cfg
+++ b/modules.cfg
@@ -1,6 +1,6 @@
# modules.cfg
#
-# Copyright 2005, 2006, 2007, 2009, 2010 by
+# Copyright 2005-2007, 2009-2011 by
# David Turner, Robert Wilhelm, and Werner Lemberg.
#
# This file is part of the FreeType project, and may only be used, modified,
@@ -54,7 +54,7 @@ FONT_MODULES += pfr
# PostScript Type 42 font driver.
#
-# This driver needs the `truetype' module.
+# This driver needs the `truetype' and `psaux' modules.
FONT_MODULES += type42
# Windows FONT/FNT font driver. See optional extension ftwinfnt.c below
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 15707a2..feb5845 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -494,7 +494,11 @@
sfnt = (SFNT_Service)FT_Get_Module_Interface(
library, "sfnt" );
if ( !sfnt )
- goto Bad_Format;
+ {
+ FT_ERROR(( "cff_face_init: cannot access `sfnt' module\n" ));
+ error = CFF_Err_Missing_Module;
+ goto Exit;
+ }
FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
@@ -512,7 +516,8 @@
if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */
{
FT_TRACE2(( "[not a valid OpenType/CFF font]\n" ));
- goto Bad_Format;
+ error = CFF_Err_Unknown_File_Format;
+ goto Exit;
}
/* if we are performing a simple font format check, exit immediately */
@@ -604,7 +609,8 @@
" cannot open CFF & CEF fonts\n"
" "
" without the `PSNames' module\n" ));
- goto Bad_Format;
+ error = CFF_Err_Missing_Module;
+ goto Exit;
}
#ifdef FT_DEBUG_LEVEL_TRACE
@@ -1014,10 +1020,6 @@
Exit:
return error;
-
- Bad_Format:
- error = CFF_Err_Unknown_File_Format;
- goto Exit;
}
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index eb82168..17c851f 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -4,7 +4,7 @@
/* */
/* CID objects manager (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010 by */
+/* Copyright 1996-2006, 2008, 2010-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -299,6 +299,13 @@
psaux = (PSAux_Service)FT_Get_Module_Interface(
FT_FACE_LIBRARY( face ), "psaux" );
+ if ( !psaux )
+ {
+ FT_ERROR(( "cid_face_init: cannot access `psaux' module\n" ));
+ error = CID_Err_Missing_Module;
+ goto Exit;
+ }
+
face->psaux = psaux;
}
diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c
index 44471f6..c86c34e 100644
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -452,7 +452,10 @@
{
sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
- return SFNT_Err_Invalid_File_Format;
+ {
+ FT_ERROR(( "sfnt_init_face: cannot access `sfnt' module\n" ));
+ return SFNT_Err_Missing_Module;
+ }
face->sfnt = sfnt;
face->goto_table = sfnt->goto_table;
diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c
index d77c3c4..f36b46f 100644
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -494,9 +494,14 @@
library = ttface->driver->root.library;
- sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
+
+ sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
if ( !sfnt )
- goto Bad_Format;
+ {
+ FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" ));
+ error = TT_Err_Missing_Module;
+ goto Exit;
+ }
/* create input stream from resource */
if ( FT_STREAM_SEEK( 0 ) )
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
index 780ab33..1fff15d 100644
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -4,8 +4,7 @@
/* */
/* AFM support for Type 1 fonts (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */
-/* 2010 by */
+/* Copyright 1996-2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -252,7 +251,7 @@
fi->Descender = t1_font->font_bbox.yMin;
psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux;
- if ( psaux && psaux->afm_parser_funcs )
+ if ( psaux->afm_parser_funcs )
{
error = psaux->afm_parser_funcs->init( &parser,
stream->memory,
diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c
index 5863210..5c8a7bc 100644
--- a/src/type1/t1objs.c
+++ b/src/type1/t1objs.c
@@ -4,7 +4,7 @@
/* */
/* Type 1 objects manager (body). */
/* */
-/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 by */
+/* Copyright 1996-2009, 2011 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -313,6 +313,12 @@
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
+ if ( !psaux )
+ {
+ FT_ERROR(( "T1_Face_Init: cannot access `psaux' module\n" ));
+ error = T1_Err_Missing_Module;
+ goto Exit;
+ }
face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"pshinter" );
@@ -484,7 +490,7 @@
FT_Face root = &face->root;
- if ( psnames && psaux )
+ if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index a5e0ee5..7cf8801 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -4,7 +4,7 @@
/* */
/* Type 42 objects manager (body). */
/* */
-/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */
+/* Copyright 2002-2009, 2011 */
/* by Roberto Alameda. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -179,6 +179,12 @@
face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" );
psaux = (PSAux_Service)face->psaux;
+ if ( !psaux )
+ {
+ FT_ERROR(( "T42_Face_Init: cannot access `psaux' module\n" ));
+ error = T42_Err_Missing_Module;
+ goto Exit;
+ }
/* open the tokenizer, this will also check the font format */
error = T42_Open_Face( face );
@@ -321,7 +327,7 @@
root->face_flags |= FT_FACE_FLAG_VERTICAL;
{
- if ( psnames && psaux )
+ if ( psnames )
{
FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
@@ -465,6 +471,12 @@
ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" );
+ if ( !ttmodule )
+ {
+ FT_ERROR(( "T42_Driver_Init: cannot access `truetype' module\n" ));
+ return T42_Err_Missing_Module;
+ }
+
driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
return T42_Err_Ok;