]> git.donarmstrong.com Git - lilypond.git/commitdiff
improve freetype error reporting.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 23 Jan 2007 01:29:28 +0000 (02:29 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 23 Jan 2007 01:29:28 +0000 (02:29 +0100)
lily/freetype-error.cc [new file with mode: 0644]
lily/include/freetype.hh
lily/open-type-font.cc

diff --git a/lily/freetype-error.cc b/lily/freetype-error.cc
new file mode 100644 (file)
index 0000000..6836711
--- /dev/null
@@ -0,0 +1,42 @@
+/* 
+  freetype-error.cc -- implement freetype error messages
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2007 Han-Wen Nienhuys <hanwen@lilypond.org>
+  
+*/
+
+#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 <freetype/fterrors.h>
+
+  ;
+
+
+#include <string>
+
+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 "<unknown error>"; 
+}
+  
index 2297d6c1d8bf716f046371715215613d6fd33980..1b6dad26e8962ff795b4b47758a7da701a11fe35 100644 (file)
@@ -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 */
 
index 8b1229fe90917bc3f508fb6f20ad1b8372f16b67..d4ed2cfee8d6b25f88d0923813a4cbd76caaa0b6 100644 (file)
@@ -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;
 }