[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] FT_* error messages
From: |
Stefano Sabatini |
Subject: |
Re: [ft] FT_* error messages |
Date: |
Sat, 10 Jan 2009 22:33:11 +0100 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
On date Saturday 2009-01-10 21:03:57 +0100, Werner LEMBERG wrote:
>
> > fterrid.h contains a list of error messages defines [...]
>
> fterrid.h is from FreeType 1; this is no longer supported.
>
> > and FT_* functions return such error messages, but doesn't seem to
> > be a way to convert these error codes in corresponding strings to be
> > delivered to the user rather than the error code itself.
>
> FreeType 2 has such a mechanism; look into fterrors.h.
Yes, it's quite weird but works fine anyway, follows an usage example
for the archive:
---------------------------------------8<---------------------------------
#include <stdio.h>
#include <string.h>
#include <ft2build.h>
#include FT_FREETYPE_H
/* build error strings table */
#define FT_ERROR_START_LIST {
#define FT_ERRORDEF( e, v, s ) { e, s },
#define FT_ERROR_END_LIST { 0, 0 } };
#undef __FTERRORS_H__
const struct
{
int code;
const char* msg;
} ft_errors[] =
#include FT_ERRORS_H
int main(int argc, char** argv)
{
FT_Library library;
FT_Face face;
FT_Error error;
const char* face_filename;
if (argc != 2) {
fprintf (stderr, "usage: %s <face-filename>\n", argv[0]);
exit(1);
}
face_filename = argv[1];
/* initialize library */
if ((error = FT_Init_FreeType(&library))) {
fprintf(stderr, "Impossible to init the FT library: %s\n",
ft_errors[error].msg);
exit(1);
}
/* create font face object */
if ((error = FT_New_Face(library, face_filename, 0, &face))) {
fprintf(stderr, "Impossible to load face file '%s': %s\n",
face_filename, ft_errors[error].msg);
exit(1);
}
exit(0);
}
---------------------------------------8<---------------------------------
Thanks, regards.