Using ftxerr18
==============

21. 1. 1998
Erwin Dieterich


If you don't like error messages containing error codes like this:

    test> ftlint 24 furiosot.ttf
    furiosot.ttf: Could not find or open file.
    Error code = 0x0087.

and prefer something more informative, like this:

    test> ftlint 24 furiosot.ttf
    furiosot.ttf: Could not find or open file.
    FreeType error message: OS/2 table missing.

then read  on.  This  information could be  helpful to you.   If you
don't care, you can read on anyway.

The core  engine of  FreeType has defined  about 50  different error
codes.   Nearly  all  FreeType  functions  are  able  to  return  an
intelligible error code in case  something goes wrong.  If you can't
memorize  the error  codes,  you  can look  them  up in  apiref.txt.
However, if you are writing  a program that is intended for "normal"
users (e.g.   a font lister) you  should give those  users more than
just  an integer or  hex number.   Ftxerr18 (located  in lib/extend)
offers the  possibility to  translate a FreeType  error code  into a
string  describing the error  with one  function call.   Ftxerr18 is
fully internationalized  on Unix computers.  So  if your environment
variables are set accordingly,  ftxerr18 can return error strings in
your language  (assuming it is  supported).  See i18n.txt on  how to
use  national language  support  (NLS), on  the  languages that  are
supported  now, and  on how  to disable  NLS.  IF  NLS  is disabled,
ftxerr18 contains no operating system specific components.

Ftxerr18 offers only one function:

  char*  TT_ErrToString18( int  error )

It returns a pointer to a string describing the error that occurred.
A simple example on how to use ftxerr18, extending the code given in
apiref.txt on TT_Open_Face():

  error = TT_Open_Face( engine, "/var/fonts/wingding.ttf", &face );
  if ( error )
  {
    fprintf( stderr, "Could not open face.\n" );
    fprintf( stderr, "Reason: %s\n", TT_ErrToString18( error ) );
  }

Note that  in this  example no  NLS has been  used for  the strings.
With NLS the code would be written as:

  error = TT_Open_Face( engine, "/var/fonts/wingding.ttf", &face );
  if ( error )
  {
    fprintf( stderr, gettext ("Could not open face.\n" ) );
    fprintf( stderr, gettext( "Reason: %s\n" ),
             TT_ErrToString18( error ) );
  }

See i18n.txt for more information on NLS.

If  you  have  any   questions  or  comments  regarding  this  short
introduction to an even shorter function, feel free to email me at

    Erwin.Dieterich.ED@Bayer-AG.de


--- END ---
