1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 13:21:38 +03:00

freetype: enable FT_Error_String

By default, freetype doesn't include error strings and FT_Error_String
will always return NULL.  Turn on the compile time option that makes
this function useful!
This commit is contained in:
Wez Furlong 2020-11-25 15:05:18 -08:00
parent ba44548d46
commit 4fd574cc7f
2 changed files with 18 additions and 1 deletions

View File

@ -148,6 +148,10 @@ fn freetype() {
build_dir.join("freetype2/include/freetype/config/ftoption.h"),
fs::read_to_string("freetype2/include/freetype/config/ftoption.h")
.unwrap()
.replace(
"/* #define FT_CONFIG_OPTION_ERROR_STRINGS */",
"#define FT_CONFIG_OPTION_ERROR_STRINGS",
)
.replace(
"/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */",
"#define FT_CONFIG_OPTION_SYSTEM_ZLIB",

View File

@ -16,7 +16,20 @@ fn ft_result<T>(err: FT_Error, t: T) -> anyhow::Result<T> {
if succeeded(err) {
Ok(t)
} else {
Err(anyhow!("FreeType error {:?} 0x{:x}", err, err))
unsafe {
let reason = FT_Error_String(err);
if reason.is_null() {
Err(anyhow!("FreeType error {:?} 0x{:x}", err, err))
} else {
let reason = std::ffi::CStr::from_ptr(reason);
Err(anyhow!(
"FreeType error {:?} 0x{:x}: {}",
err,
err,
reason.to_string_lossy()
))
}
}
}
}