mirror of
https://github.com/wez/wezterm.git
synced 2024-12-04 17:45:23 +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:
parent
ba44548d46
commit
4fd574cc7f
4
deps/freetype/build.rs
vendored
4
deps/freetype/build.rs
vendored
@ -148,6 +148,10 @@ fn freetype() {
|
|||||||
build_dir.join("freetype2/include/freetype/config/ftoption.h"),
|
build_dir.join("freetype2/include/freetype/config/ftoption.h"),
|
||||||
fs::read_to_string("freetype2/include/freetype/config/ftoption.h")
|
fs::read_to_string("freetype2/include/freetype/config/ftoption.h")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
.replace(
|
||||||
|
"/* #define FT_CONFIG_OPTION_ERROR_STRINGS */",
|
||||||
|
"#define FT_CONFIG_OPTION_ERROR_STRINGS",
|
||||||
|
)
|
||||||
.replace(
|
.replace(
|
||||||
"/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */",
|
"/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */",
|
||||||
"#define FT_CONFIG_OPTION_SYSTEM_ZLIB",
|
"#define FT_CONFIG_OPTION_SYSTEM_ZLIB",
|
||||||
|
@ -16,7 +16,20 @@ fn ft_result<T>(err: FT_Error, t: T) -> anyhow::Result<T> {
|
|||||||
if succeeded(err) {
|
if succeeded(err) {
|
||||||
Ok(t)
|
Ok(t)
|
||||||
} else {
|
} else {
|
||||||
|
unsafe {
|
||||||
|
let reason = FT_Error_String(err);
|
||||||
|
if reason.is_null() {
|
||||||
Err(anyhow!("FreeType error {:?} 0x{:x}", err, err))
|
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()
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user