wuff-capi
C++ API for the wuff pure-Rust WOFF2 decoder, compatible with the decoding API of the woff2 C++ library.
Note: only the decoding API (woff2/decode.h and woff2/output.h) is
provided. The encoding API (woff2/encode.h) is not yet implemented.
What this crate provides
extern "C"symbols exported from Rust:wuff_woff2_compute_final_size— reads thetotalSfntSizefield of a WOFF2 header (equivalent towoff2::ComputeWOFF2FinalSize)wuff_woff2_decode— decompresses a WOFF2 font into a newly-allocated bufferwuff_woff2_free— frees a buffer returned bywuff_woff2_decode
- C++ headers (in
include/woff2) that provide a drop-in replacement for the C++ woff2 library's decoding API as header-only wrappers around the C symbols above.
Usage (from Rust)
Add wuff-capi as a dependency of the crate whose build script compiles the
C/C++ code that consumes the woff2 API. This crate sets links = "wuff", and
its build script exports the location of its headers, which is available in
dependent build scripts as the DEP_WUFF_INCLUDE_DIR environment variable:
// build.rs of a dependent crate
let woff2_include_dir = var.unwrap;
new
.cpp
.include
// ...
The Rust symbols are linked automatically as part of the normal Rust build.