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'.
This commit is contained in:
Werner Lemberg 2011-11-26 13:38:26 +01:00
parent e01406bb91
commit 930e9bf8f4
10 changed files with 77 additions and 21 deletions

View File

@ -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> 2011-11-25 Werner Lemberg <wl@gnu.org>
[bdf] Add more error messages. [bdf] Add more error messages.

View File

@ -4,7 +4,7 @@
/* */ /* */
/* FreeType error codes (specification). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -54,6 +54,8 @@
"broken offset within table" ) "broken offset within table" )
FT_ERRORDEF_( Array_Too_Large, 0x0A, \ FT_ERRORDEF_( Array_Too_Large, 0x0A, \
"array allocation size too large" ) "array allocation size too large" )
FT_ERRORDEF_( Missing_Module, 0x0B, \
"missing module" )
/* glyph/character errors */ /* glyph/character errors */

View File

@ -1,6 +1,6 @@
# modules.cfg # modules.cfg
# #
# Copyright 2005, 2006, 2007, 2009, 2010 by # Copyright 2005-2007, 2009-2011 by
# David Turner, Robert Wilhelm, and Werner Lemberg. # David Turner, Robert Wilhelm, and Werner Lemberg.
# #
# This file is part of the FreeType project, and may only be used, modified, # 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. # PostScript Type 42 font driver.
# #
# This driver needs the `truetype' module. # This driver needs the `truetype' and `psaux' modules.
FONT_MODULES += type42 FONT_MODULES += type42
# Windows FONT/FNT font driver. See optional extension ftwinfnt.c below # Windows FONT/FNT font driver. See optional extension ftwinfnt.c below

View File

@ -494,7 +494,11 @@
sfnt = (SFNT_Service)FT_Get_Module_Interface( sfnt = (SFNT_Service)FT_Get_Module_Interface(
library, "sfnt" ); library, "sfnt" );
if ( !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 ); FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS );
@ -512,7 +516,8 @@
if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */ if ( face->format_tag != TTAG_OTTO ) /* `OTTO'; OpenType/CFF font */
{ {
FT_TRACE2(( "[not a valid OpenType/CFF font]\n" )); 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 */ /* if we are performing a simple font format check, exit immediately */
@ -604,7 +609,8 @@
" cannot open CFF & CEF fonts\n" " cannot open CFF & CEF fonts\n"
" " " "
" without the `PSNames' module\n" )); " without the `PSNames' module\n" ));
goto Bad_Format; error = CFF_Err_Missing_Module;
goto Exit;
} }
#ifdef FT_DEBUG_LEVEL_TRACE #ifdef FT_DEBUG_LEVEL_TRACE
@ -1014,10 +1020,6 @@
Exit: Exit:
return error; return error;
Bad_Format:
error = CFF_Err_Unknown_File_Format;
goto Exit;
} }

View File

@ -4,7 +4,7 @@
/* */ /* */
/* CID objects manager (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -299,6 +299,13 @@
psaux = (PSAux_Service)FT_Get_Module_Interface( psaux = (PSAux_Service)FT_Get_Module_Interface(
FT_FACE_LIBRARY( face ), "psaux" ); 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; face->psaux = psaux;
} }

View File

@ -452,7 +452,10 @@
{ {
sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" );
if ( !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->sfnt = sfnt;
face->goto_table = sfnt->goto_table; face->goto_table = sfnt->goto_table;

View File

@ -494,9 +494,14 @@
library = ttface->driver->root.library; 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 ) 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 */ /* create input stream from resource */
if ( FT_STREAM_SEEK( 0 ) ) if ( FT_STREAM_SEEK( 0 ) )

View File

@ -4,8 +4,7 @@
/* */ /* */
/* AFM support for Type 1 fonts (body). */ /* AFM support for Type 1 fonts (body). */
/* */ /* */
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, */ /* Copyright 1996-2011 by */
/* 2010 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -252,7 +251,7 @@
fi->Descender = t1_font->font_bbox.yMin; fi->Descender = t1_font->font_bbox.yMin;
psaux = (PSAux_Service)( (T1_Face)t1_face )->psaux; 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, error = psaux->afm_parser_funcs->init( &parser,
stream->memory, stream->memory,

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Type 1 objects manager (body). */ /* 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. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* 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 ), face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" ); "psaux" );
psaux = (PSAux_Service)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 ), face->pshinter = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"pshinter" ); "pshinter" );
@ -484,7 +490,7 @@
FT_Face root = &face->root; FT_Face root = &face->root;
if ( psnames && psaux ) if ( psnames )
{ {
FT_CharMapRec charmap; FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes; T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Type 42 objects manager (body). */ /* Type 42 objects manager (body). */
/* */ /* */
/* Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 */ /* Copyright 2002-2009, 2011 */
/* by Roberto Alameda. */ /* by Roberto Alameda. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* 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 ), face->psaux = FT_Get_Module_Interface( FT_FACE_LIBRARY( face ),
"psaux" ); "psaux" );
psaux = (PSAux_Service)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 */ /* open the tokenizer, this will also check the font format */
error = T42_Open_Face( face ); error = T42_Open_Face( face );
@ -321,7 +327,7 @@
root->face_flags |= FT_FACE_FLAG_VERTICAL; root->face_flags |= FT_FACE_FLAG_VERTICAL;
{ {
if ( psnames && psaux ) if ( psnames )
{ {
FT_CharMapRec charmap; FT_CharMapRec charmap;
T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes; T1_CMap_Classes cmap_classes = psaux->t1_cmap_classes;
@ -465,6 +471,12 @@
ttmodule = FT_Get_Module( FT_MODULE(driver)->library, "truetype" ); 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; driver->ttclazz = (FT_Driver_Class)ttmodule->clazz;
return T42_Err_Ok; return T42_Err_Ok;