Given an FT_Error, is there a macro/function to return the corresponding error message string?
The answer is No, as far as I know.
You should create your own macro or function, using macros defined in fterrors.h. For example, the following code will work:
#include <ft2build.h>
#include FT_FREETYPE_H
const char* getErrorMessage(FT_Error err)
{
#undef FTERRORS_H_
#define FT_ERRORDEF( e, v, s ) case e: return s;
#define FT_ERROR_START_LIST switch (err) {
#define FT_ERROR_END_LIST }
#include FT_ERRORS_H
return "(Unknown error)";
}
Read fterrors.h (found in /usr/local/include/freetype2/ in my environment) for more detail and another example.
In case anyone else stumbles upon this question, FT_Error_String
was introduced in FreeType2 version 2.10.1 to retrieve the error string of an FT_Error code.
FT_Error error = ...
if (error != 0)
{
puts(FT_Error_String(error), stderr);
}
Important: You must define FT_CONFIG_OPTION_ERROR_STRINGS
when compiling FreeType otherwise the function will return NULL
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With