From 209910ea2fdac61374a41537456f16eb1df25a21 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 23 Jan 2007 02:29:28 +0100 Subject: [PATCH] improve freetype error reporting. --- lily/freetype-error.cc | 42 ++++++++++++++++++++++++++++++++++++++++ lily/include/freetype.hh | 2 ++ lily/open-type-font.cc | 6 ++++-- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 lily/freetype-error.cc diff --git a/lily/freetype-error.cc b/lily/freetype-error.cc new file mode 100644 index 0000000000..683671146c --- /dev/null +++ b/lily/freetype-error.cc @@ -0,0 +1,42 @@ +/* + freetype-error.cc -- implement freetype error messages + + source file of the GNU LilyPond music typesetter + + (c) 2007 Han-Wen Nienhuys + +*/ + +#include "freetype.hh" + +#undef __FTERRORS_H__ +#define FT_ERRORDEF( e, v, s ) { e, s }, +#define FT_ERROR_START_LIST { +#define FT_ERROR_END_LIST { 0, 0 } }; + +const struct Freetype_error_message +{ + int err_code; + const char* err_msg; +} ft_errors[] = + +#include + + ; + + +#include + +string +freetype_error_string (int code) +{ + for (Freetype_error_message const *p = ft_errors; + p->err_msg; p ++) + { + if (p->err_code == code) + return p->err_msg; + } + + return ""; +} + diff --git a/lily/include/freetype.hh b/lily/include/freetype.hh index 2297d6c1d8..1b6dad26e8 100644 --- a/lily/include/freetype.hh +++ b/lily/include/freetype.hh @@ -19,5 +19,7 @@ extern FT_Library freetype2_library; FT_Face open_ft_face (string str); +string freetype_error_string (int code); + #endif /* FREETYPE_HH */ diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 8b1229fe90..d4ed2cfee8 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -97,8 +97,10 @@ open_ft_face (string str) if (error_code == FT_Err_Unknown_File_Format) error (_f ("unsupported font format: %s", str.c_str ())); else if (error_code) - error (_f ("unknown error: %d reading font file: %s", error_code, - str.c_str ())); + error (_f ("error reading font file %s: %s", + str.c_str (), + freetype_error_string (error_code).c_str () + )); return face; } -- 2.39.5